瀏覽代碼

Initial commit

xunchuanzhi 1 年之前
當前提交
890155de23
共有 48 個文件被更改,包括 2220 次插入0 次删除
  1. 13 0
      .gitignore
  2. 3 0
      .idea/.gitignore
  3. 6 0
      .idea/compiler.xml
  4. 4 0
      .idea/encodings.xml
  5. 21 0
      .idea/gradle.xml
  6. 25 0
      .idea/jarRepositories.xml
  7. 14 0
      .idea/misc.xml
  8. 12 0
      .idea/runConfigurations.xml
  9. 6 0
      .idea/vcs.xml
  10. 1 0
      app/.gitignore
  11. 28 0
      app/build.gradle
  12. 21 0
      app/proguard-rules.pro
  13. 26 0
      app/src/androidTest/java/com/wdkl/aidlclient/ExampleInstrumentedTest.java
  14. 24 0
      app/src/main/AndroidManifest.xml
  15. 89 0
      app/src/main/aidl/com/wdkl/app/ncs/siptext/IMyAidlInterface.aidl
  16. 10 0
      app/src/main/aidl/com/wdkl/app/ncs/siptext/IPersonChangeListener.aidl
  17. 551 0
      app/src/main/java/com/wdkl/Util/NetHelper.java
  18. 234 0
      app/src/main/java/com/wdkl/Util/QSPermissionUtil.java
  19. 36 0
      app/src/main/java/com/wdkl/Util/Util.java
  20. 411 0
      app/src/main/java/com/wdkl/aidlclient/MainActivity.java
  21. 9 0
      app/src/main/java/com/wdkl/app/MessageEvent.java
  22. 34 0
      app/src/main/res/drawable-v24/ic_launcher_foreground.xml
  23. 170 0
      app/src/main/res/drawable/ic_launcher_background.xml
  24. 26 0
      app/src/main/res/layout/activity_main.xml
  25. 94 0
      app/src/main/res/layout/activity_sip_test.xml
  26. 5 0
      app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
  27. 5 0
      app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
  28. 二進制
      app/src/main/res/mipmap-hdpi/ic_launcher.png
  29. 二進制
      app/src/main/res/mipmap-hdpi/ic_launcher_round.png
  30. 二進制
      app/src/main/res/mipmap-mdpi/ic_launcher.png
  31. 二進制
      app/src/main/res/mipmap-mdpi/ic_launcher_round.png
  32. 二進制
      app/src/main/res/mipmap-xhdpi/ic_launcher.png
  33. 二進制
      app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
  34. 二進制
      app/src/main/res/mipmap-xxhdpi/ic_launcher.png
  35. 二進制
      app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
  36. 二進制
      app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
  37. 二進制
      app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
  38. 6 0
      app/src/main/res/values/colors.xml
  39. 3 0
      app/src/main/res/values/strings.xml
  40. 11 0
      app/src/main/res/values/styles.xml
  41. 17 0
      app/src/test/java/com/wdkl/aidlclient/ExampleUnitTest.java
  42. 27 0
      build.gradle
  43. 15 0
      gradle.properties
  44. 二進制
      gradle/wrapper/gradle-wrapper.jar
  45. 6 0
      gradle/wrapper/gradle-wrapper.properties
  46. 172 0
      gradlew
  47. 84 0
      gradlew.bat
  48. 1 0
      settings.gradle

+ 13 - 0
.gitignore

@@ -0,0 +1,13 @@
+*.iml
+.gradle
+/local.properties
+/.idea/caches
+/.idea/libraries
+/.idea/modules.xml
+/.idea/workspace.xml
+/.idea/navEditor.xml
+/.idea/assetWizardSettings.xml
+.DS_Store
+/build
+/captures
+.externalNativeBuild

+ 3 - 0
.idea/.gitignore

@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml

+ 6 - 0
.idea/compiler.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="CompilerConfiguration">
+    <bytecodeTargetLevel target="1.8" />
+  </component>
+</project>

+ 4 - 0
.idea/encodings.xml

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Encoding" addBOMForNewFiles="with NO BOM" />
+</project>

+ 21 - 0
.idea/gradle.xml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="GradleMigrationSettings" migrationVersion="1" />
+  <component name="GradleSettings">
+    <option name="linkedExternalProjectsSettings">
+      <GradleProjectSettings>
+        <option name="testRunner" value="PLATFORM" />
+        <option name="distributionType" value="DEFAULT_WRAPPED" />
+        <option name="externalProjectPath" value="$PROJECT_DIR$" />
+        <option name="modules">
+          <set>
+            <option value="$PROJECT_DIR$" />
+            <option value="$PROJECT_DIR$/app" />
+          </set>
+        </option>
+        <option name="resolveModulePerSourceSet" value="false" />
+        <option name="useQualifiedModuleNames" value="true" />
+      </GradleProjectSettings>
+    </option>
+  </component>
+</project>

+ 25 - 0
.idea/jarRepositories.xml

@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="RemoteRepositoriesConfiguration">
+    <remote-repository>
+      <option name="id" value="central" />
+      <option name="name" value="Maven Central repository" />
+      <option name="url" value="https://repo1.maven.org/maven2" />
+    </remote-repository>
+    <remote-repository>
+      <option name="id" value="jboss.community" />
+      <option name="name" value="JBoss Community repository" />
+      <option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
+    </remote-repository>
+    <remote-repository>
+      <option name="id" value="BintrayJCenter" />
+      <option name="name" value="BintrayJCenter" />
+      <option name="url" value="https://jcenter.bintray.com/" />
+    </remote-repository>
+    <remote-repository>
+      <option name="id" value="Google" />
+      <option name="name" value="Google" />
+      <option name="url" value="https://dl.google.com/dl/android/maven2/" />
+    </remote-repository>
+  </component>
+</project>

+ 14 - 0
.idea/misc.xml

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="CMakeSettings">
+    <configurations>
+      <configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" />
+    </configurations>
+  </component>
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
+    <output url="file://$PROJECT_DIR$/build/classes" />
+  </component>
+  <component name="ProjectType">
+    <option name="id" value="Android" />
+  </component>
+</project>

+ 12 - 0
.idea/runConfigurations.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="RunConfigurationProducerService">
+    <option name="ignoredProducers">
+      <set>
+        <option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
+        <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
+        <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
+      </set>
+    </option>
+  </component>
+</project>

+ 6 - 0
.idea/vcs.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="$PROJECT_DIR$" vcs="Git" />
+  </component>
+</project>

+ 1 - 0
app/.gitignore

@@ -0,0 +1 @@
+/build

+ 28 - 0
app/build.gradle

@@ -0,0 +1,28 @@
+apply plugin: 'com.android.application'
+
+android {
+    compileSdkVersion 28
+    defaultConfig {
+        applicationId "com.example.aidlclient"
+        minSdkVersion 18
+        targetSdkVersion 28
+        versionCode 1
+        versionName "1.0"
+        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+    }
+    buildTypes {
+        release {
+            minifyEnabled false
+            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+        }
+    }
+}
+
+dependencies {
+    implementation fileTree(dir: 'libs', include: ['*.jar'])
+    implementation 'com.android.support:appcompat-v7:28.0.0'
+    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
+    testImplementation 'junit:junit:4.12'
+    androidTestImplementation 'com.android.support.test:runner:1.0.2'
+    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
+}

+ 21 - 0
app/proguard-rules.pro

@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile

+ 26 - 0
app/src/androidTest/java/com/wdkl/aidlclient/ExampleInstrumentedTest.java

@@ -0,0 +1,26 @@
+package com.wdkl.aidlclient;
+
+import android.content.Context;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+    @Test
+    public void useAppContext() {
+        // Context of the app under test.
+        Context appContext = InstrumentationRegistry.getTargetContext();
+
+        assertEquals("com.example.aidlclient", appContext.getPackageName());
+    }
+}

+ 24 - 0
app/src/main/AndroidManifest.xml

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.wdkl.aidlclient">
+    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
+    <uses-permission android:name="android.permission.GET_PACKAGE_SIZE" />
+<!--    <uses-permission android:name="com.example.aidlclient.ipc.aidl.ACCESS_PERSON_SERVICE" />-->
+
+    <application
+        android:allowBackup="true"
+        android:icon="@mipmap/ic_launcher"
+        android:label="@string/app_name"
+        android:roundIcon="@mipmap/ic_launcher_round"
+        android:supportsRtl="true"
+        android:theme="@style/AppTheme">
+        <activity android:name="com.wdkl.aidlclient.MainActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+    </application>
+
+</manifest>

+ 89 - 0
app/src/main/aidl/com/wdkl/app/ncs/siptext/IMyAidlInterface.aidl

@@ -0,0 +1,89 @@
+// IMyAidlInterface.aidl
+package com.wdkl.app.ncs.siptext;
+
+// Declare any non-default types here with import statements
+import com.wdkl.app.ncs.siptext.IPersonChangeListener;
+interface IMyAidlInterface {
+     /**
+     *  设置sip账户名称
+     */
+    void setSipAccount (String username,String url);
+
+     /**
+     *  设置sip呼叫振铃的时间秒
+     */
+     void setBellsTime (int time);
+
+     /**
+     *  呼叫
+     */
+     void setCalling(String username ,String info);
+
+     /**
+     *  来电
+     */
+     String getCalling();
+
+     /**
+      *  状态
+      */
+      String getSIP();
+
+     /**
+     *  接听
+     */
+     void setAcceptWithParams();
+
+     /**
+     *  挂断
+     */
+     void setCallTerminate();
+
+     /**
+     *  设置录音文件地址
+     */
+     void setCallAddress(String address);
+
+     /**
+     * 设置关闭录音
+     *
+     */
+     void setMicEnabled(boolean isMicEnabled);
+
+
+//     /**
+//     *  设置通话静音
+//     */
+//     void setCallTerminate();
+
+
+//     /**
+//     *  切换免提与听筒
+//     *  1 是免提 2是听筒
+//     */
+//     void setCallTerminate(int type);
+
+
+
+     /**
+     *  sip状态
+     */
+//     String  onCallStateChanged(String type);
+    void registerListener(IPersonChangeListener listener);
+    void unregisterListener(IPersonChangeListener listener);
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}

+ 10 - 0
app/src/main/aidl/com/wdkl/app/ncs/siptext/IPersonChangeListener.aidl

@@ -0,0 +1,10 @@
+// IPersonChangeListener.aidl
+package com.wdkl.app.ncs.siptext;
+
+// Declare any non-default types here with import statements
+
+interface IPersonChangeListener {
+
+  void onPersonDataChanged(String  type);
+
+}

+ 551 - 0
app/src/main/java/com/wdkl/Util/NetHelper.java

@@ -0,0 +1,551 @@
+package com.wdkl.Util;
+
+import android.annotation.SuppressLint;
+import android.bluetooth.BluetoothAdapter;
+import android.content.Context;
+import android.net.ConnectivityManager;
+import android.net.wifi.WifiInfo;
+import android.net.wifi.WifiManager;
+import android.os.Build;
+import android.text.TextUtils;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.Inet4Address;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Timer;
+import java.util.TimerTask;
+
+
+public class NetHelper {
+    private WifiManager wifiManager;
+    private ConnectivityManager connManager;
+    private static NetHelper sInstance = null;
+
+    private static Timer timerNetStatus = null;
+    private static final int SCHEDULE_TIME = 30000;
+    public static boolean NetConn = false;
+
+    /**
+     * 以太网是否ping成功
+     */
+    public static final String ETHERNETSTATUS = "ethernetStatus";
+
+    public NetHelper() {
+    }
+
+    public static NetHelper getInstance() {
+        if (sInstance == null) {
+            synchronized (NetHelper.class) {
+                if (sInstance == null) {
+                    sInstance = new NetHelper();
+                }
+            }
+        }
+        return sInstance;
+    }
+
+    public void init(Context context) {
+        wifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
+        connManager = (ConnectivityManager) context.getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
+    }
+
+    public static void startNetCheck() {
+        if (timerNetStatus != null) {
+            timerNetStatus.purge();
+        }
+        timerNetStatus = new Timer();
+        timerNetStatus.schedule(new TimerTask() {
+            @Override
+            public void run() {
+                NetConn = ping(getLocalElement(3), 2, null);
+
+//                EventBus.getDefault().post(new MessageEvent(ETHERNETSTATUS, EVENT_INTERNETPING));//循环检测SIP,以太网ping状态
+            }
+        }, 10, SCHEDULE_TIME);
+    }
+
+    /**
+     * ping 网络
+     *
+     * @param host
+     * @param pingCount
+     * @param stringBuffer
+     * @return
+     */
+    public static boolean ping(String host, int pingCount, StringBuffer stringBuffer) {
+        String line = null;
+        Process process = null;
+        BufferedReader successReader = null;
+        String command = "ping -c " + pingCount + " " + host;
+        boolean isSuccess = false;
+        try {
+            process = Runtime.getRuntime().exec(command);
+            if (process == null) {
+                append(stringBuffer, "ping fail:process is null.");
+                return false;
+            }
+            successReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
+            while ((line = successReader.readLine()) != null) {
+                append(stringBuffer, line);
+            }
+            int status = process.waitFor();
+            if (status == 0) {
+                append(stringBuffer, "exec cmd success:" + command);
+                isSuccess = true;
+            } else {
+                append(stringBuffer, "exec cmd fail.");
+                isSuccess = false;
+            }
+            append(stringBuffer, "exec finished.");
+        } catch (IOException e) {
+        } catch (InterruptedException e) {
+        } finally {
+            if (process != null) {
+                process.destroy();
+            }
+            if (successReader != null) {
+                try {
+                    successReader.close();
+                } catch (IOException e) {
+                }
+            }
+        }
+
+        return isSuccess;
+    }
+
+    private static void append(StringBuffer stringBuffer, String text) {
+        if (stringBuffer != null) {
+            stringBuffer.append(text + "\n");
+        }
+    }
+
+    /**
+     * 获取网关  Waderson
+     * <p>
+     * 1 WIFI情况下获取网关 2 有线网络下的DHCP模式连接 3 有线网络其他连接方式:比如静态ip、pppoe拨号、ipoe拨号等
+     */
+    public static String getLocalElement(int type) {
+        String e = "";
+        if (1 == type) {
+            //e = getLocalElementByWifi();
+        } else if (2 == type) {
+            e = getLocalElementByDhcp();
+        } else if (3 == type) {
+            e = getLocalElementByIp();
+        }
+        if (!TextUtils.isEmpty(e) && e.length() >= 11 && e.length() <= 15) {
+            return e;
+        } else {
+            return "192.168.101.1";
+        }
+    }
+
+
+    /**
+     * 有线网络下的DHCP模式连接
+     */
+    public static String getLocalElementByDhcp() {
+        BufferedReader bufferedReader = null;
+        String str2 = "";
+        String str3 = "getprop dhcp.eth0.gateway";
+        Process exec;
+        BufferedReader bufferedReader2 = null;
+        try {
+            exec = Runtime.getRuntime().exec(str3);
+            try {
+                bufferedReader2 = new BufferedReader(new InputStreamReader(exec.getInputStream()));
+            } catch (Throwable th3) {
+                if (bufferedReader != null) {
+                    bufferedReader.close();
+                }
+                if (exec != null) {
+                    exec.exitValue();
+                }
+            }
+            try {
+                str3 = bufferedReader2.readLine();
+                if (str3 != null) {
+                    TextUtils.isEmpty(str3);
+                }
+                try {
+                    bufferedReader2.close();
+                } catch (IOException iOException222) {
+                    iOException222.printStackTrace();
+                }
+                if (exec != null) {
+                    try {
+                        exec.exitValue();
+                    } catch (Exception e5) {
+                    }
+                }
+            } catch (IOException e6) {
+                str3 = str2;
+                if (bufferedReader2 != null) {
+                    bufferedReader2.close();
+                }
+                if (exec != null) {
+                    exec.exitValue();
+                }
+                return str3;
+            }
+        } catch (IOException e62) {
+            bufferedReader2 = null;
+            exec = null;
+            str3 = str2;
+            if (bufferedReader2 != null) {
+                try {
+                    bufferedReader2.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            if (exec != null) {
+                exec.exitValue();
+            }
+            return str3;
+        } catch (Throwable th4) {
+            exec = null;
+            if (bufferedReader != null) {
+                try {
+                    bufferedReader.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            if (exec != null) {
+                exec.exitValue();
+            }
+        }
+        return str3;
+    }
+
+    /**
+     * 有线网络其他连接方式:比如静态ip、pppoe拨号、ipoe拨号等
+     */
+    public static String getLocalElementByIp() {
+        BufferedReader bufferedReader = null;
+        String result = "";
+        String str2 = "";
+        String str3 = "ip route list table 0";
+        Process exec;
+        BufferedReader bufferedReader2 = null;
+        try {
+            exec = Runtime.getRuntime().exec(str3);
+            try {
+                bufferedReader2 = new BufferedReader(new InputStreamReader(exec.getInputStream()));
+            } catch (Throwable th3) {
+                if (bufferedReader != null) {
+                    bufferedReader.close();
+                }
+                if (exec != null) {
+                    exec.exitValue();
+                }
+            }
+            try {
+                str2 = bufferedReader2.readLine();
+                if (str2 != null) {
+                    str2 = str2.trim();
+                    String[] strings = str2.split("\\s+");
+                    if (strings.length > 3) {
+                        result = strings[2];
+                    }
+                }
+                try {
+                    bufferedReader2.close();
+                } catch (IOException iOException222) {
+                    iOException222.printStackTrace();
+                }
+                if (exec != null) {
+                    try {
+                        exec.exitValue();
+                    } catch (Exception e5) {
+                    }
+                }
+            } catch (IOException e6) {
+                if (bufferedReader2 != null) {
+                    bufferedReader2.close();
+                }
+                if (exec != null) {
+                    exec.exitValue();
+                }
+                return result;
+            }
+        } catch (IOException e62) {
+            bufferedReader2 = null;
+            exec = null;
+            if (bufferedReader2 != null) {
+                try {
+                    bufferedReader2.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            if (exec != null) {
+                exec.exitValue();
+            }
+            return result;
+        } catch (Throwable th4) {
+            exec = null;
+            if (bufferedReader != null) {
+                try {
+                    bufferedReader.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            if (exec != null) {
+                exec.exitValue();
+            }
+        }
+        return result;
+    }
+
+    /**
+     * 得到MAC
+     *
+     * @return String
+     */
+    public String getMacAddress() {
+
+        if(Build.VERSION.SDK_INT <= Build.VERSION_CODES.O || Build.MODEL.equals("rk3368")){//小于安卓8 走这里
+            String mac = "";
+            try {
+                mac = getLocalMacAddressFromIp();
+                if (TextUtils.isEmpty(mac)) {
+                    mac = getNetworkMac();
+                }
+                if (TextUtils.isEmpty(mac)) {
+                    mac = tryGetWifiMac();
+                }
+            } catch (Exception e) {
+            }
+            return mac;
+        }else {//大于安卓8走这里
+            List<NetworkInterface> interfaces = null;
+            try {
+                interfaces = Collections.list(NetworkInterface.getNetworkInterfaces());
+                for (NetworkInterface networkInterface : interfaces) {
+                    if (networkInterface != null && TextUtils.isEmpty(networkInterface.getName()) == false) {
+                        if ("wlan0".equalsIgnoreCase(networkInterface.getName())) {
+                            byte[] macBytes = networkInterface.getHardwareAddress();
+                            if (macBytes != null && macBytes.length > 0) {
+                                StringBuilder str = new StringBuilder();
+                                for (byte b : macBytes) {
+                                    str.append(String.format("%02X:", b));
+                                }
+                                if (str.length() > 0) {
+                                    str.deleteCharAt(str.length() - 1);
+                                }
+                                return str.toString();
+                            }
+                        }
+                    }
+                }
+            } catch (SocketException e) {
+                e.printStackTrace();
+            }
+            return "unknown";
+
+        }
+    }
+
+    /**
+     * 兼容安卓5-10 获取Mac地址
+     * @return
+     */
+    public String getMacAddress2() {
+        List<NetworkInterface> interfaces = null;
+        try {
+            interfaces = Collections.list(NetworkInterface.getNetworkInterfaces());
+            for (NetworkInterface networkInterface : interfaces) {
+                if (networkInterface != null && TextUtils.isEmpty(networkInterface.getName()) == false) {
+                    if ("wlan0".equalsIgnoreCase(networkInterface.getName())) {
+                        byte[] macBytes = networkInterface.getHardwareAddress();
+                        if (macBytes != null && macBytes.length > 0) {
+                            StringBuilder str = new StringBuilder();
+                            for (byte b : macBytes) {
+                                str.append(String.format("%02X:", b));
+                            }
+                            if (str.length() > 0) {
+                                str.deleteCharAt(str.length() - 1);
+                            }
+                            return str.toString();
+                        }
+                    }
+                }
+            }
+        } catch (SocketException e) {
+            e.printStackTrace();
+        }
+        return "unknown";
+    }
+
+
+    /**
+     * 通过WiFiManager获取mac地址
+     * 这个方法Android 7.0是获取不到的,返回的是null,其实是返回“02:00:00:00:00:00”
+     *
+     * @return
+     */
+    public String tryGetWifiMac() {
+        String mac;
+        WifiInfo wi = wifiManager.getConnectionInfo();
+        if (wi == null || wi.getMacAddress() == null) {
+            mac = null;
+        }
+        if ("02:00:00:00:00:00".equals(wi.getMacAddress().trim())) {
+            mac = null;
+        } else {
+            mac = wi.getMacAddress().trim();
+        }
+        return mac;
+    }
+
+    /**
+     * 通过网络接口获取
+     *
+     * @return
+     */
+    public static String getNetworkMac() {
+        try {
+            List<NetworkInterface> all = Collections.list(NetworkInterface.getNetworkInterfaces());
+            for (NetworkInterface nif : all) {
+                // if (!nif.getName().equalsIgnoreCase("wlan0") && !nif.getName().equalsIgnoreCase("eth0") && !nif.getName().equalsIgnoreCase("eth1"))
+                if (!nif.getName().equalsIgnoreCase("eth0") && !nif.getName().equalsIgnoreCase("eth1") && !nif.getName().equalsIgnoreCase("eth2"))
+                    continue;
+                byte[] macBytes = nif.getHardwareAddress();
+                if (macBytes == null) {
+                    return null;
+                }
+                StringBuilder res1 = new StringBuilder();
+                for (byte b : macBytes) {
+                    res1.append(String.format("%02X:", b));
+                }
+                if (res1.length() > 0) {
+                    res1.deleteCharAt(res1.length() - 1);
+                }
+                return res1.toString();
+            }
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+        return null;
+    }
+
+
+    /**
+     * 根据IP地址获取MAC地址
+     *
+     * @return
+     */
+    @SuppressLint("NewApi")
+    public static String getLocalMacAddressFromIp() {
+        String strMacAddr = null;
+        try {
+            // 获得IpD地址
+            InetAddress ip = getLocalInetAddress();
+            byte[] b = NetworkInterface.getByInetAddress(ip)
+                    .getHardwareAddress();
+            StringBuffer buffer = new StringBuffer();
+            for (int i = 0; i < b.length; i++) {
+                if (i != 0) {
+                    buffer.append(':');
+                }
+                String str = Integer.toHexString(b[i] & 0xFF);
+                buffer.append(str.length() == 1 ? 0 + str : str);
+            }
+            strMacAddr = buffer.toString().toUpperCase();
+
+        } catch (Exception e) {
+
+        }
+
+        return strMacAddr;
+    }
+
+    /**
+     * 获取移动设备本地IP
+     *
+     * @return
+     */
+    public static InetAddress getLocalInetAddress() {
+        InetAddress ip = null;
+        try {
+            // 列举
+            Enumeration<NetworkInterface> en_netInterface = NetworkInterface
+                    .getNetworkInterfaces();
+            while (en_netInterface.hasMoreElements()) {// 是否还有元素
+                NetworkInterface ni = (NetworkInterface) en_netInterface
+                        .nextElement();// 得到下一个元素
+                Enumeration<InetAddress> en_ip = ni.getInetAddresses();// 得到一个ip地址的列举
+                while (en_ip.hasMoreElements()) {
+                    ip = en_ip.nextElement();
+                    if (!ip.isLoopbackAddress()
+                            && ip.getHostAddress().indexOf(":") == -1)
+                        break;
+                    else
+                        ip = null;
+                }
+
+                if (ip != null) {
+                    break;
+                }
+            }
+        } catch (SocketException e) {
+
+            e.printStackTrace();
+        }
+        return ip;
+    }
+
+    //获取本地ip地址
+    public String getLocalIP() {
+        try {
+            for (Enumeration<NetworkInterface> enNetI = NetworkInterface.getNetworkInterfaces(); enNetI.hasMoreElements(); ) {
+                NetworkInterface netI = enNetI.nextElement();
+                for (Enumeration<InetAddress> enumIpAddr = netI.getInetAddresses(); enumIpAddr.hasMoreElements(); ) {
+                    InetAddress inetAddress = enumIpAddr.nextElement();
+                    if (inetAddress instanceof Inet4Address && !inetAddress.isLoopbackAddress()) {
+                        return inetAddress.getHostAddress();
+                    }
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    public static boolean isBTConnected() {
+        BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter();
+        if (btAdapter != null) {
+            return btAdapter.getState() == BluetoothAdapter.STATE_ON;
+        }
+
+        return false;
+    }
+
+    public int getNetworkType() {
+        if (connManager != null && connManager.getActiveNetworkInfo() != null) {
+            return connManager.getActiveNetworkInfo().getType();
+        }
+
+        return -1;
+    }
+
+    public boolean networkAvailable() {
+        if (connManager != null && connManager.getActiveNetworkInfo() != null) {
+            return connManager.getActiveNetworkInfo().isConnected();
+        }
+
+        return false;
+    }
+}

+ 234 - 0
app/src/main/java/com/wdkl/Util/QSPermissionUtil.java

@@ -0,0 +1,234 @@
+package com.wdkl.Util;
+
+
+import android.Manifest;
+import android.annotation.TargetApi;
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Fragment;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.net.Uri;
+import android.os.Build;
+import android.os.Bundle;
+import android.os.Process;
+import android.support.annotation.NonNull;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.Window;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+
+
+public class QSPermissionUtil {
+    public final static String[] SDCARD = new String[]{Manifest.permission.RECORD_AUDIO, Manifest.permission.WRITE_EXTERNAL_STORAGE};
+    public final static String[] CAMERA_AUDIO = new String[]{Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO};
+    public final static String[] CAMERA = new String[]{Manifest.permission.GET_PACKAGE_SIZE};
+
+    public final static String[] LOCATION = new String[]{Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION};
+    public final static String[] BLE = LOCATION;
+
+    /**
+     * 动态申请权限
+     */
+    public static void requestPermission(Activity activity, PermissionListener permissionListener, String... permissions) {
+        requestPermission(activity, 775, permissionListener, permissions);
+    }
+
+    public static void requestPermission(Activity activity, int requestCode, PermissionListener permissionListener, String... permissions) {
+        if (Build.VERSION.SDK_INT < 23) {
+            if (permissionListener != null)
+                permissionListener.onPermissionSucceed(requestCode, Arrays.asList(permissions));
+        } else {
+            try {
+                //利用Fragment申请权限,不用开发者处理onRequestPermissionsResult了
+                PermissionFragment permissionFragment = new PermissionFragment();
+                permissionFragment.setPermission(permissionListener, requestCode, permissions);
+                activity.getFragmentManager().beginTransaction().add(Window.ID_ANDROID_CONTENT, permissionFragment).commit();
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    /**
+     * 动态申请权限,被拒一次后申请前增加提示框
+     */
+    public static void requestRationalePermission(Activity activity, PermissionListener permissionListener, String... permissions) {
+        requestRationalePermission(activity, 775, permissionListener, permissions);
+    }
+
+    public static void requestRationalePermission(final Activity activity, final int requestCode, final PermissionListener permissionListener, final String... permissions) {
+        if (Build.VERSION.SDK_INT < 23) {
+            permissionListener.onPermissionSucceed(requestCode, Arrays.asList(permissions));
+        } else {
+            if (isRationalePermission(activity, permissions)) {
+                new AlertDialog.Builder(activity)
+                        .setTitle("权限已被拒绝")
+                        .setMessage("您已经拒绝过我们申请授权,请您同意授权,否则功能无法正常使用!")
+                        .setPositiveButton("同意", new DialogInterface.OnClickListener() {
+                            @Override
+                            public void onClick(DialogInterface dialog, int which) {
+                                requestPermission(activity, requestCode, permissionListener, permissions);
+                            }
+                        })
+                        .setNegativeButton("取消", null)
+                        .show();
+            } else {
+                requestPermission(activity, requestCode, permissionListener, permissions);
+            }
+        }
+    }
+
+    /**
+     * 显示手动设置权限对话框
+     */
+    public static void showSettingDialog(final Activity activity) {
+        new AlertDialog.Builder(activity)
+                .setTitle("权限申请失败")
+                .setMessage("我们需要的一些权限被您拒绝或者系统发生错误申请失败,请您到设置页面手动授权,否则功能无法正常使用!")
+                .setPositiveButton("去设置", new DialogInterface.OnClickListener() {
+                    @Override
+                    public void onClick(DialogInterface dialog, int which) {
+                        Intent intent = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS");
+                        Uri uri = Uri.fromParts("package", activity.getPackageName(), (String) null);
+                        intent.setData(uri);
+                        activity.startActivityForResult(intent, 755);
+                    }
+                })
+                .setNegativeButton("取消", null)
+                .show();
+    }
+
+    /**
+     * 是否有权限
+     */
+    public static boolean hasPermission(Context context, String... permissions) {
+        if (Build.VERSION.SDK_INT < 23) {
+            return true;
+        } else {
+            for (String permission : permissions) {
+                boolean hasPermission = context.checkPermission
+                        (permission, Process.myPid(), Process.myUid()) == PackageManager.PERMISSION_GRANTED;
+                if (!hasPermission) {
+                    return false;
+                }
+            }
+            return true;
+        }
+    }
+
+    /**
+     * 是否被拒绝了一次了
+     */
+    public static boolean isRationalePermission(Activity activity, String... permissions) {
+        if (Build.VERSION.SDK_INT < 23) {
+            return false;
+        } else {
+            for (String permission : permissions) {
+                //有一个被拒了一次返回
+                if (activity.shouldShowRequestPermissionRationale(permission)) {
+                    return true;
+                }
+            }
+            return false;
+        }
+    }
+
+    /**
+     * 是否永远拒绝了
+     * 需要在被拒绝后调用
+     */
+    public static boolean isAlwaysDeniedPermission(Activity activity, String... permissions) {
+        return isAlwaysDeniedPermission(activity, Arrays.asList(permissions));
+    }
+
+    /**
+     * 是否永远拒绝了
+     * 需要在被拒绝后调用
+     */
+    public static boolean isAlwaysDeniedPermission(Activity activity, List<String> permissions) {
+        if (Build.VERSION.SDK_INT < 23) {
+            return false;
+        } else {
+            for (String permission : permissions) {
+                //有一个被永远拒了返回
+                //shouldShowRequestPermissionRationale只有拒绝了之后返回true
+                if (!activity.shouldShowRequestPermissionRationale(permission)) {
+                    return true;
+                }
+            }
+            return false;
+        }
+    }
+
+
+    @TargetApi(Build.VERSION_CODES.M)
+    public static class PermissionFragment extends Fragment {
+
+        private PermissionListener permissionListener;
+        private int requestCode;
+        private String[] permissions;
+
+
+        public void setPermission(PermissionListener permissionListener, int requestCode, String... permissions) {
+            this.permissionListener = permissionListener;
+            this.requestCode = requestCode;
+            this.permissions = permissions;
+        }
+
+        @Override
+        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+            return new View(container.getContext());
+        }
+
+        @Override
+        public void onActivityCreated(Bundle savedInstanceState) {
+            super.onActivityCreated(savedInstanceState);
+            try {
+                requestPermissions(permissions, requestCode);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+
+        //申请权限回调
+        @Override
+        public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
+            super.onRequestPermissionsResult(requestCode, permissions, grantResults);
+            if (permissionListener != null) {
+
+                List<String> grantedList = new ArrayList<>();
+                List<String> deniedList = new ArrayList<>();
+
+                for (int i = 0; i < permissions.length; ++i) {
+                    if (grantResults[i] == 0) {
+                        grantedList.add(permissions[i]);
+                    } else {
+                        deniedList.add(permissions[i]);
+                    }
+                }
+
+                if (deniedList.isEmpty()) {
+                    permissionListener.onPermissionSucceed(requestCode, grantedList);
+                } else {
+                    permissionListener.onPermissionFailed(requestCode, deniedList);
+                }
+            }
+            getActivity().getFragmentManager().beginTransaction().remove(this).commit();
+        }
+
+    }
+
+    public interface PermissionListener {
+        void onPermissionSucceed(int requestCode, List<String> grantedList);
+
+        void onPermissionFailed(int requestCode, List<String> deniedList);
+    }
+}

+ 36 - 0
app/src/main/java/com/wdkl/Util/Util.java

@@ -0,0 +1,36 @@
+package com.wdkl.Util;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+public class Util {
+    private static final String SP_NAME = "SP_PREF";
+    private static final String KEY_SP_SIP_ACCOUNT = "KEY_SP_SIP_ACCOUNT";
+
+    public static String getTimeFilename(){
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HHmmss");
+        Date date = new Date();
+        return dateFormat.format(date);
+    }
+
+    private static SharedPreferences getSP(Context context) {
+        return context.getSharedPreferences(SP_NAME, Context.MODE_PRIVATE);
+    }
+
+    private static SharedPreferences.Editor getEditor(Context context) {
+        return getSP(context).edit();
+    }
+
+    public static String getSipAccount(Context context) {
+        return getSP(context).getString(KEY_SP_SIP_ACCOUNT, "7550000506003011802202");
+    }
+
+    public static void setSipAccount(Context context, String value) {
+        getEditor(context).putString(KEY_SP_SIP_ACCOUNT, value).apply();
+    }
+
+
+}

+ 411 - 0
app/src/main/java/com/wdkl/aidlclient/MainActivity.java

@@ -0,0 +1,411 @@
+package com.wdkl.aidlclient;
+
+import android.app.ActivityManager;
+import android.app.PendingIntent;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.ServiceInfo;
+import android.media.AudioManager;
+import android.os.Build;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.provider.Settings;
+import android.support.v4.app.FragmentActivity;
+import android.support.v7.app.AppCompatActivity;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.wdkl.Util.QSPermissionUtil;
+import com.wdkl.app.ncs.siptext.IMyAidlInterface;
+import com.wdkl.app.ncs.siptext.IPersonChangeListener;
+
+import java.util.List;
+
+
+public class MainActivity extends AppCompatActivity {
+
+    private IMyAidlInterface iMyAidlInterface;
+    private IBinder mService = null;
+    private Boolean mHasBind = false;
+    TextView sip_test_id;
+    Button   sip_test_call,toggle_speaker,terminate_call,sip_test_zc;
+    LinearLayout call_main;
+    RelativeLayout call_view;
+    TextView call_view_id;
+    String username;
+    String myname ="";
+    String shuju = "{\"id\": 2161,\"customer_id\": 737}";
+
+    private AudioManager audioManager;
+
+
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_sip_test);
+//        checkPermissionRequest(this);
+        checkPermissionRequest();
+        audioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
+        try {
+            if (iMyAidlInterface!=null){
+                myname = iMyAidlInterface.getSIP()!= null ? iMyAidlInterface.getSIP() : "";
+                if (myname!=""){
+                    //获取sip服务接口
+                    Intent intent = new Intent();
+                    intent.setAction("com.wdkl.app.ncs.siptext.service.WdklSipService");
+                    intent.setPackage("com.wdkl.app.ncs.siptext");
+                    mHasBind =bindService(intent, connection, BIND_AUTO_CREATE);
+                }else {
+                    //服务重新连接
+                    connectService(getBaseContext());
+                }
+            }else {
+                //服务重新连接
+                connectService(getBaseContext());
+            }
+        } catch (RemoteException e) {
+            e.printStackTrace();
+        }
+        sip_test_id = (TextView)findViewById(R.id.sip_test_id);
+        Button sip_test_call = (Button)findViewById(R.id.sip_test_call);
+        sip_test_id = (TextView)findViewById(R.id.sip_test_id);
+        call_view_id = (TextView)findViewById(R.id.call_view_id);
+        call_main = (LinearLayout)findViewById(R.id.call_main);
+        call_view = (RelativeLayout)findViewById(R.id.call_view);
+        call_view.setVisibility(View.GONE);
+        toggle_speaker = (Button)findViewById(R.id.toggle_speaker);
+        terminate_call = (Button)findViewById(R.id.terminate_call);
+        sip_test_zc = (Button)findViewById(R.id.sip_test_zc);
+
+
+        sip_test_call.setOnClickListener(new View.OnClickListener() {
+
+            @Override
+            public void onClick(View v) {
+                EditText callout_sipno = (EditText)findViewById(R.id.callout_sipno);
+                String sipno = callout_sipno.getText().toString().trim();
+                //进行sip通讯时判断服务是否启动
+                try {
+                    if (iMyAidlInterface!=null){
+                         myname = iMyAidlInterface.getSIP()!= null ? iMyAidlInterface.getSIP() : "";
+                        if (myname!=""){
+ //                        if (isAppRunning(getBaseContext())){
+                        String sip_on=sipno;
+                        if (!sip_on.equals("")){
+                            iMyAidlInterface.setCalling(sip_on,shuju);
+                        }else {
+                            Toast.makeText(getBaseContext(), "账号不能为空",Toast.LENGTH_SHORT).show();
+                        }
+//                      String sip_on="10002@192.168.1.130";
+                            //呼叫
+
+                        }else {
+                            //服务重新连接
+                            connectService(getBaseContext());
+                        }
+
+
+                    }else {
+                        //服务重新连接
+                        connectService(getBaseContext());
+                    }
+                } catch (RemoteException e) {
+                    e.printStackTrace();
+                }
+            }
+        });
+
+        sip_test_zc.setOnClickListener(new View.OnClickListener() {
+
+            @Override
+            public void onClick(View v) {
+                EditText callout_sipno = (EditText)findViewById(R.id.callout_sipno);
+                String sipno = callout_sipno.getText().toString().trim();
+                //进行sip通讯时判断服务是否启动
+                try {
+                    if (iMyAidlInterface!=null){
+                        myname = iMyAidlInterface.getSIP()!= null ? iMyAidlInterface.getSIP() : "";
+                        if (myname!=""){
+                            String sip_on=sipno;
+                            //呼叫
+//                            iMyAidlInterface.setCalling(sip_on);
+                            iMyAidlInterface.setSipAccount(sip_on,"");
+                            myname = iMyAidlInterface.getSIP()!= null ? iMyAidlInterface.getSIP() : "";
+                            sip_test_id.setText("本设备sip:"+myname);
+                        }else {
+                            //服务重新连接
+                            connectService(getBaseContext());
+                        }
+
+
+                    }else {
+                        //服务重新连接
+                        connectService(getBaseContext());
+                    }
+                } catch (RemoteException e) {
+                    e.printStackTrace();
+                }
+            }
+        });
+        toggle_speaker.setOnClickListener(new View.OnClickListener() {
+
+            @Override
+            public void onClick(View v) {
+                speakerOn();
+            }
+        });
+        terminate_call.setOnClickListener(new View.OnClickListener() {
+
+            @Override
+            public void onClick(View v) {
+                if (iMyAidlInterface!=null){
+                    //挂断
+                    try {
+                        call_main.setVisibility(View.VISIBLE);
+                        call_view.setVisibility(View.GONE);
+                        iMyAidlInterface.setCallTerminate();
+                    } catch (RemoteException e) {
+                        e.printStackTrace();
+                    }
+                }else {
+                    //服务重新连接
+                    connectService(getBaseContext());
+                }
+
+            }
+        });
+    }
+
+    private ServiceConnection connection = new ServiceConnection() {
+
+
+        @Override
+        public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
+            try {
+                mService=iBinder;
+                //给binder设置一个死亡代理
+                iBinder.linkToDeath(mDeathRecipient, 0);
+                iMyAidlInterface=IMyAidlInterface.Stub.asInterface(iBinder);
+                registerListener();
+                //注册sip账号以及域名(必填,url不输入为本设备ip)
+//                iMyAidlInterface.setSipAccount("10001","");
+                //设置铃声
+                iMyAidlInterface.setBellsTime(3);
+                //此处是你注册的账号与域名,
+                myname = iMyAidlInterface.getSIP()!= null ? iMyAidlInterface.getSIP() : "";
+                sip_test_id.setText("本设备sip:"+myname);
+            } catch (RemoteException e) {
+                e.printStackTrace();
+            }
+
+        }
+
+        @Override
+        public void onServiceDisconnected(ComponentName componentName) {
+            iMyAidlInterface=null;
+            unbindService(connection);
+        }
+    };
+
+    private IPersonChangeListener.Stub mPersonChangeListener = new IPersonChangeListener.Stub() {
+        @Override
+        public void onPersonDataChanged(String type) throws RemoteException {
+          //服务端传过来的sip状态
+            Log.d("sipCall", ">>>>>>>>>>>> call state: " + type + ", " );
+          if (type.equals("IncomingReceived")||type.equals("IncomingEarlyMedia")){
+              //来电接口
+              iMyAidlInterface.setAcceptWithParams();
+              //来电人员信息
+               username=iMyAidlInterface.getCalling();
+              runOnUiThread(new Runnable() {
+                  @Override
+                  public void run() {
+                      call_view_id.setText(username);
+                      call_view.setVisibility(View.VISIBLE);
+                      call_main.setVisibility(View.GONE);
+                  }
+              });
+
+          }else  if (type.equals("Connected")){
+              runOnUiThread(new Runnable() {
+                  @Override
+                  public void run() {
+
+                      call_view.setVisibility(View.VISIBLE);
+                      call_main.setVisibility(View.GONE);
+                  }
+              });
+
+
+          }else  if (type.equals("End")){
+              //挂断
+              runOnUiThread(new Runnable() {
+                  @Override
+                  public void run() {
+                      call_main.setVisibility(View.VISIBLE);
+                      call_view.setVisibility(View.GONE);
+                  }
+              });
+
+          }
+
+        }
+    };
+    private void registerListener() {
+        if (iMyAidlInterface != null) {
+            try {
+                sip_test_id.setText("本设备的sip:");
+                iMyAidlInterface.registerListener(mPersonChangeListener);
+            } catch (RemoteException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    private void unregisterListener() {
+        if (iMyAidlInterface != null && iMyAidlInterface.asBinder().isBinderAlive()) {
+            try {
+                iMyAidlInterface.unregisterListener(mPersonChangeListener);
+            } catch (RemoteException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    private IBinder.DeathRecipient mDeathRecipient = new IBinder.DeathRecipient() {
+        @Override
+        public void binderDied() {
+            // 子线程
+            // 监听 binder died
+            Log.d("sipCall", "binder died, thread = " + Thread.currentThread().getName());
+            // 移除死亡通知
+            if (mService != null) {
+                mService.unlinkToDeath(this, 0);
+            }
+            mService = null;
+            // 重新连接
+            connectService(getBaseContext());
+        }
+    };
+
+
+
+    private void connectService(Context context) {
+        String packageName = "com.wdkl.app.ncs.siptext"; // 目标应用的包名
+        String serviceClassName = "com.wdkl.app.ncs.siptext.service.WdklSipService"; // 目标服务的类名
+
+        Intent serviceIntent = new Intent();
+        serviceIntent.setComponent(new ComponentName(packageName, serviceClassName));
+        // 启动服务
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+            // Android 8.0 及以上版本需要使用 startForegroundService() 方法启动服务
+            context.startForegroundService(serviceIntent);
+        } else {
+            // Android 7.0 及以下版本可以直接使用 startService() 方法启动服务
+            context.startService(serviceIntent);
+        }
+
+        Intent intent = new Intent();
+        intent.setAction("com.wdkl.app.ncs.siptext.service.WdklSipService");
+        intent.setPackage("com.wdkl.app.ncs.siptext");
+        mHasBind =bindService(intent, connection, BIND_AUTO_CREATE);
+
+    }
+    private void speakerOn(){
+//        Log.i(TAG,">>>>>>>>>>>>>>"+audioManager.isSpeakerphoneOn());
+        //5.0以上
+//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+//            //设置mode
+//            audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
+//        } else {
+//            //设置mode
+//            audioManager.setMode(AudioManager.MODE_IN_CALL);
+//        }
+        audioManager.setMode(AudioManager.MODE_IN_CALL);
+        //设置音量,解决有些机型切换后没声音或者声音突然变大的问题
+        audioManager.setStreamVolume(
+                AudioManager.STREAM_MUSIC,
+                audioManager.getStreamVolume(AudioManager.STREAM_MUSIC),
+                AudioManager.FX_KEY_CLICK
+        );
+        audioManager.setSpeakerphoneOn(true);
+    }
+//    private boolean isAppRunning(Context context, String packageName) {
+//        ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
+//        List<ActivityManager.RunningAppProcessInfo> processInfoList = activityManager.getRunningAppProcesses();
+//
+//        if (processInfoList != null) {
+//            for (ActivityManager.RunningAppProcessInfo processInfo : processInfoList) {
+//                if (processInfo.processName.equals(packageName)) {
+//                    return true;
+//                }
+//            }
+//        }
+//
+//        return false;
+//    }
+
+
+    private boolean isAppRunning(Context context) {
+        boolean isServiceRunning = false;
+        ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
+        List<ActivityManager.RunningServiceInfo> runningServices = activityManager.getRunningServices(Integer.MAX_VALUE);
+
+            for (ActivityManager.RunningServiceInfo serviceInfo : runningServices) {
+                if (serviceInfo.service.getClassName().equals("com.wdkl.app.ncs.siptext.service.WdklSipService")) {
+                    // 这里找到了目标服务
+                    isServiceRunning = true;
+                    return true;
+                }
+            }
+
+
+        return isServiceRunning;
+    }
+    public void checkPermissionRequest() {
+        QSPermissionUtil.requestPermission(this, new QSPermissionUtil.PermissionListener() {
+            @Override
+            public void onPermissionSucceed(int requestCode, List<String> grantedList) {
+
+            }
+
+            @Override
+            public void onPermissionFailed(int requestCode, List<String> deniedList) {
+                if (QSPermissionUtil.isAlwaysDeniedPermission(MainActivity.this, deniedList)) {
+                    QSPermissionUtil.showSettingDialog(MainActivity.this);
+                }
+            }
+        }, QSPermissionUtil.CAMERA);
+    }
+    @Override
+    protected void onStop() {
+        super.onStop();
+        unregisterListener();
+        iMyAidlInterface=null;
+        if (mHasBind) {
+            unbindService(connection);
+        }
+    }
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+        unregisterListener();
+        iMyAidlInterface=null;
+        if (mHasBind) {
+            unbindService(connection);
+        }
+    }
+}

+ 9 - 0
app/src/main/java/com/wdkl/app/MessageEvent.java

@@ -0,0 +1,9 @@
+package com.wdkl.app;
+
+public class MessageEvent {
+    public String message;
+
+    public MessageEvent(String message) {
+        this.message = message;
+    }
+}

文件差異過大導致無法顯示
+ 34 - 0
app/src/main/res/drawable-v24/ic_launcher_foreground.xml


+ 170 - 0
app/src/main/res/drawable/ic_launcher_background.xml

@@ -0,0 +1,170 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="108dp"
+    android:height="108dp"
+    android:viewportWidth="108"
+    android:viewportHeight="108">
+    <path
+        android:fillColor="#008577"
+        android:pathData="M0,0h108v108h-108z" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M9,0L9,108"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M19,0L19,108"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M29,0L29,108"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M39,0L39,108"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M49,0L49,108"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M59,0L59,108"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M69,0L69,108"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M79,0L79,108"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M89,0L89,108"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M99,0L99,108"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,9L108,9"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,19L108,19"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,29L108,29"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,39L108,39"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,49L108,49"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,59L108,59"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,69L108,69"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,79L108,79"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,89L108,89"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,99L108,99"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M19,29L89,29"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M19,39L89,39"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M19,49L89,49"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M19,59L89,59"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M19,69L89,69"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M19,79L89,79"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M29,19L29,89"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M39,19L39,89"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M49,19L49,89"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M59,19L59,89"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M69,19L69,89"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M79,19L79,89"
+        android:strokeWidth="0.8"
+        android:strokeColor="#33FFFFFF" />
+</vector>

+ 26 - 0
app/src/main/res/layout/activity_main.xml

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context=".MainActivity"
+    android:orientation="vertical">
+
+    <TextView
+        android:id="@+id/text1"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="Hello World!"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
+
+    <Button
+        android:id="@+id/button1"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:text="SEND"/>
+
+</LinearLayout>

+ 94 - 0
app/src/main/res/layout/activity_sip_test.xml

@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="utf-8"?>
+    <RelativeLayout
+        xmlns:android="http://schemas.android.com/apk/res/android"
+        xmlns:tools="http://schemas.android.com/tools"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+         >
+
+        <LinearLayout
+            android:id="@+id/call_main"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:orientation="vertical"
+
+            android:padding="16dp">
+
+            <TextView
+                android:id="@+id/sip_test_id"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_margin="16dp"/>
+
+            <EditText
+                android:id="@+id/callout_sipno"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:hint="test call out sip no"
+                android:layout_margin="16dp"
+                tools:ignore="MissingConstraints" />
+
+            <Button
+                android:id="@+id/sip_test_back"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="BACK"
+                android:layout_margin="16dp"
+                android:visibility="gone"
+                tools:ignore="MissingConstraints" />
+
+            <Button
+                android:id="@+id/sip_test_call"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="呼叫"
+                android:layout_margin="16dp"
+                tools:ignore="MissingConstraints" />
+            <Button
+                android:id="@+id/sip_test_zc"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="注册"
+                android:layout_margin="16dp"
+                tools:ignore="MissingConstraints" />
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_centerVertical="true"
+                android:gravity="center"
+                android:text="注册账号只需要在输入框输入账号即可,默认域名为本设备ip"
+                />
+        </LinearLayout>
+    <RelativeLayout
+        android:id="@+id/call_view"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        >
+        <TextView
+            android:id="@+id/call_view_id"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_centerVertical="true"
+            android:layout_margin="16dp"
+            android:gravity="center"
+            android:text="来电信息"
+            />
+        <Button
+            android:id="@+id/toggle_speaker"
+            android:text="切换外放"
+            android:layout_marginBottom="30dp"
+            android:layout_centerHorizontal="true"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"/>
+
+        <Button
+            android:id="@+id/terminate_call"
+            android:text="挂断"
+            android:layout_alignParentBottom="true"
+            android:layout_centerHorizontal="true"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content" />
+    </RelativeLayout>
+
+
+    </RelativeLayout>

+ 5 - 0
app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
+    <background android:drawable="@drawable/ic_launcher_background" />
+    <foreground android:drawable="@drawable/ic_launcher_foreground" />
+</adaptive-icon>

+ 5 - 0
app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
+    <background android:drawable="@drawable/ic_launcher_background" />
+    <foreground android:drawable="@drawable/ic_launcher_foreground" />
+</adaptive-icon>

二進制
app/src/main/res/mipmap-hdpi/ic_launcher.png


二進制
app/src/main/res/mipmap-hdpi/ic_launcher_round.png


二進制
app/src/main/res/mipmap-mdpi/ic_launcher.png


二進制
app/src/main/res/mipmap-mdpi/ic_launcher_round.png


二進制
app/src/main/res/mipmap-xhdpi/ic_launcher.png


二進制
app/src/main/res/mipmap-xhdpi/ic_launcher_round.png


二進制
app/src/main/res/mipmap-xxhdpi/ic_launcher.png


二進制
app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png


二進制
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png


二進制
app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png


+ 6 - 0
app/src/main/res/values/colors.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <color name="colorPrimary">#008577</color>
+    <color name="colorPrimaryDark">#00574B</color>
+    <color name="colorAccent">#D81B60</color>
+</resources>

+ 3 - 0
app/src/main/res/values/strings.xml

@@ -0,0 +1,3 @@
+<resources>
+    <string name="app_name">AIDL Client</string>
+</resources>

+ 11 - 0
app/src/main/res/values/styles.xml

@@ -0,0 +1,11 @@
+<resources>
+
+    <!-- Base application theme. -->
+    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
+        <!-- Customize your theme here. -->
+        <item name="colorPrimary">@color/colorPrimary</item>
+        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
+        <item name="colorAccent">@color/colorAccent</item>
+    </style>
+
+</resources>

+ 17 - 0
app/src/test/java/com/wdkl/aidlclient/ExampleUnitTest.java

@@ -0,0 +1,17 @@
+package com.wdkl.aidlclient;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
+ */
+public class ExampleUnitTest {
+    @Test
+    public void addition_isCorrect() {
+        assertEquals(4, 2 + 2);
+    }
+}

+ 27 - 0
build.gradle

@@ -0,0 +1,27 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+buildscript {
+    repositories {
+        google()
+        jcenter()
+        
+    }
+    dependencies {
+        classpath 'com.android.tools.build:gradle:3.4.0'
+        
+        // NOTE: Do not place your application dependencies here; they belong
+        // in the individual module build.gradle files
+    }
+}
+
+allprojects {
+    repositories {
+        google()
+        jcenter()
+        
+    }
+}
+
+task clean(type: Delete) {
+    delete rootProject.buildDir
+}

+ 15 - 0
gradle.properties

@@ -0,0 +1,15 @@
+# Project-wide Gradle settings.
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+org.gradle.jvmargs=-Xmx1536m
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
+
+

二進制
gradle/wrapper/gradle-wrapper.jar


+ 6 - 0
gradle/wrapper/gradle-wrapper.properties

@@ -0,0 +1,6 @@
+#Fri Apr 19 22:20:07 CST 2019
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip

+ 172 - 0
gradlew

@@ -0,0 +1,172 @@
+#!/usr/bin/env sh
+
+##############################################################################
+##
+##  Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+        PRG="$link"
+    else
+        PRG=`dirname "$PRG"`"/$link"
+    fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+    echo "$*"
+}
+
+die () {
+    echo
+    echo "$*"
+    echo
+    exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+  CYGWIN* )
+    cygwin=true
+    ;;
+  Darwin* )
+    darwin=true
+    ;;
+  MINGW* )
+    msys=true
+    ;;
+  NONSTOP* )
+    nonstop=true
+    ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+        # IBM's JDK on AIX uses strange locations for the executables
+        JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+        JAVACMD="$JAVA_HOME/bin/java"
+    fi
+    if [ ! -x "$JAVACMD" ] ; then
+        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+    fi
+else
+    JAVACMD="java"
+    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+    MAX_FD_LIMIT=`ulimit -H -n`
+    if [ $? -eq 0 ] ; then
+        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+            MAX_FD="$MAX_FD_LIMIT"
+        fi
+        ulimit -n $MAX_FD
+        if [ $? -ne 0 ] ; then
+            warn "Could not set maximum file descriptor limit: $MAX_FD"
+        fi
+    else
+        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+    fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+    JAVACMD=`cygpath --unix "$JAVACMD"`
+
+    # We build the pattern for arguments to be converted via cygpath
+    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+    SEP=""
+    for dir in $ROOTDIRSRAW ; do
+        ROOTDIRS="$ROOTDIRS$SEP$dir"
+        SEP="|"
+    done
+    OURCYGPATTERN="(^($ROOTDIRS))"
+    # Add a user-defined pattern to the cygpath arguments
+    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+    fi
+    # Now convert the arguments - kludge to limit ourselves to /bin/sh
+    i=0
+    for arg in "$@" ; do
+        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
+
+        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
+            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+        else
+            eval `echo args$i`="\"$arg\""
+        fi
+        i=$((i+1))
+    done
+    case $i in
+        (0) set -- ;;
+        (1) set -- "$args0" ;;
+        (2) set -- "$args0" "$args1" ;;
+        (3) set -- "$args0" "$args1" "$args2" ;;
+        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+    esac
+fi
+
+# Escape application args
+save () {
+    for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+    echo " "
+}
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+  cd "$(dirname "$0")"
+fi
+
+exec "$JAVACMD" "$@"

+ 84 - 0
gradlew.bat

@@ -0,0 +1,84 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem  Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega

+ 1 - 0
settings.gradle

@@ -0,0 +1 @@
+include ':app'