xunchuanzhi 1 год назад
Сommit
a2db999b35
55 измененных файлов с 2783 добавлено и 0 удалено
  1. 15 0
      .gitignore
  2. 3 0
      .idea/.gitignore
  3. 6 0
      .idea/compiler.xml
  4. 23 0
      .idea/gradle.xml
  5. 55 0
      .idea/jarRepositories.xml
  6. 9 0
      .idea/misc.xml
  7. 1 0
      app/.gitignore
  8. 39 0
      app/build.gradle
  9. BIN
      app/libs/linphone-sdk-android-5.2.10.aar
  10. 21 0
      app/proguard-rules.pro
  11. 26 0
      app/src/androidTest/java/com/wdkl/app/ncs/siptext/ExampleInstrumentedTest.java
  12. 103 0
      app/src/main/AndroidManifest.xml
  13. 89 0
      app/src/main/aidl/com/wdkl/app/ncs/siptext/IMyAidlInterface.aidl
  14. 10 0
      app/src/main/aidl/com/wdkl/app/ncs/siptext/IPersonChangeListener.aidl
  15. 58 0
      app/src/main/java/com/wdkl/app/ncs/siptext/MainActivity.java
  16. 25 0
      app/src/main/java/com/wdkl/app/ncs/siptext/Util/Base64Util.java
  17. 551 0
      app/src/main/java/com/wdkl/app/ncs/siptext/Util/NetHelper.java
  18. 234 0
      app/src/main/java/com/wdkl/app/ncs/siptext/Util/QSPermissionUtil.java
  19. 54 0
      app/src/main/java/com/wdkl/app/ncs/siptext/Util/Util.java
  20. 209 0
      app/src/main/java/com/wdkl/app/ncs/siptext/activity/CallActivity.java
  21. 27 0
      app/src/main/java/com/wdkl/app/ncs/siptext/broadcast/WdBootReceiver.java
  22. 510 0
      app/src/main/java/com/wdkl/app/ncs/siptext/service/WdklSipService.java
  23. 30 0
      app/src/main/res/drawable-v24/ic_launcher_foreground.xml
  24. 170 0
      app/src/main/res/drawable/ic_launcher_background.xml
  25. 20 0
      app/src/main/res/layout/activity_main.xml
  26. 34 0
      app/src/main/res/layout/call.xml
  27. 5 0
      app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
  28. 5 0
      app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
  29. BIN
      app/src/main/res/mipmap-hdpi/ic_launcher.png
  30. BIN
      app/src/main/res/mipmap-hdpi/ic_launcher_round.png
  31. BIN
      app/src/main/res/mipmap-mdpi/ic_launcher.png
  32. BIN
      app/src/main/res/mipmap-mdpi/ic_launcher_round.png
  33. BIN
      app/src/main/res/mipmap-xhdpi/ic_launcher.png
  34. BIN
      app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
  35. BIN
      app/src/main/res/mipmap-xxhdpi/ic_launcher.png
  36. BIN
      app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
  37. BIN
      app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
  38. BIN
      app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
  39. BIN
      app/src/main/res/raw/incoming_call_ring.mp3
  40. 20 0
      app/src/main/res/raw/linphonerc_default
  41. 34 0
      app/src/main/res/raw/linphonerc_factory
  42. BIN
      app/src/main/res/raw/outgoing_call_ring.mp3
  43. BIN
      app/src/main/res/raw/wr_ringback.wav
  44. 16 0
      app/src/main/res/values-night/themes.xml
  45. 10 0
      app/src/main/res/values/colors.xml
  46. 3 0
      app/src/main/res/values/strings.xml
  47. 16 0
      app/src/main/res/values/themes.xml
  48. 17 0
      app/src/test/java/com/wdkl/app/ncs/siptext/ExampleUnitTest.java
  49. 52 0
      build.gradle
  50. 19 0
      gradle.properties
  51. BIN
      gradle/wrapper/gradle-wrapper.jar
  52. 6 0
      gradle/wrapper/gradle-wrapper.properties
  53. 172 0
      gradlew
  54. 84 0
      gradlew.bat
  55. 2 0
      settings.gradle

+ 15 - 0
.gitignore

@@ -0,0 +1,15 @@
+*.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
+.cxx
+local.properties

+ 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>

+ 23 - 0
.idea/gradle.xml

@@ -0,0 +1,23 @@
+<?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="disableWrapperSourceDistributionNotification" value="true" />
+        <option name="distributionType" value="DEFAULT_WRAPPED" />
+        <option name="externalProjectPath" value="$PROJECT_DIR$" />
+        <option name="gradleJvm" value="1.8" />
+        <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>

+ 55 - 0
.idea/jarRepositories.xml

@@ -0,0 +1,55 @@
+<?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>
+    <remote-repository>
+      <option name="id" value="MavenRepo" />
+      <option name="name" value="MavenRepo" />
+      <option name="url" value="https://repo.maven.apache.org/maven2/" />
+    </remote-repository>
+    <remote-repository>
+      <option name="id" value="maven" />
+      <option name="name" value="maven" />
+      <option name="url" value="http://maven.aliyun.com/nexus/content/repositories/google" />
+    </remote-repository>
+    <remote-repository>
+      <option name="id" value="maven5" />
+      <option name="name" value="maven5" />
+      <option name="url" value="https://linphone.org/maven_repository" />
+    </remote-repository>
+    <remote-repository>
+      <option name="id" value="maven4" />
+      <option name="name" value="maven4" />
+      <option name="url" value="https://jitpack.io" />
+    </remote-repository>
+    <remote-repository>
+      <option name="id" value="maven2" />
+      <option name="name" value="maven2" />
+      <option name="url" value="http://maven.aliyun.com/nexus/content/repositories/jcenter" />
+    </remote-repository>
+    <remote-repository>
+      <option name="id" value="maven3" />
+      <option name="name" value="maven3" />
+      <option name="url" value="http://maven.aliyun.com/nexus/content/groups/public/" />
+    </remote-repository>
+  </component>
+</project>

+ 9 - 0
.idea/misc.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <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>

+ 1 - 0
app/.gitignore

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

+ 39 - 0
app/build.gradle

@@ -0,0 +1,39 @@
+plugins {
+    id 'com.android.application'
+}
+
+android {
+    compileSdkVersion 30
+    buildToolsVersion "30.0.2"
+
+    defaultConfig {
+        applicationId "com.wdkl.app.ncs.siptext"
+        minSdkVersion 24
+        targetSdkVersion 30
+        versionCode 1
+        versionName "1.0"
+
+        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+    }
+
+    buildTypes {
+        release {
+            minifyEnabled false
+            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+        }
+    }
+    compileOptions {
+        sourceCompatibility JavaVersion.VERSION_1_8
+        targetCompatibility JavaVersion.VERSION_1_8
+    }
+}
+
+dependencies {
+
+    implementation 'androidx.appcompat:appcompat:1.3.0-alpha02'
+    implementation 'com.google.android.material:material:1.2.1'
+    testImplementation 'junit:junit:4.+'
+    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
+    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
+    compile files('libs/linphone-sdk-android-5.2.10.aar')
+}

BIN
app/libs/linphone-sdk-android-5.2.10.aar


+ 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/app/ncs/siptext/ExampleInstrumentedTest.java

@@ -0,0 +1,26 @@
+package com.wdkl.app.ncs.siptext;
+
+import android.content.Context;
+
+import androidx.test.platform.app.InstrumentationRegistry;
+import androidx.test.ext.junit.runners.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.getInstrumentation().getTargetContext();
+        assertEquals("com.wdkl.app.ncs.siptext", appContext.getPackageName());
+    }
+}

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

@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    package="com.wdkl.app.ncs.siptext">
+
+    <!-- Android8.0未知来源权限 -->
+    <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
+    <uses-permission android:name="android.permission.INSTALL_PACKAGES" />
+    <!-- silentUpdate -->
+    <uses-permission
+        android:name="android.permission."
+        tools:ignore="ProtectedPermissions" />
+    <uses-permission android:name="android.permission.USE_SIP" />
+    <uses-permission android:name="android.permission.VIBRATE" />
+    <uses-permission android:name="android.permission.RECORD_AUDIO" />
+    <uses-permission
+        android:name="android.permission.WRITE_SECURE_SETTINGS"
+        tools:ignore="ProtectedPermissions" />
+
+    <uses-feature
+        android:name="android.hardware.sip.voip"
+        android:required="true" />
+    <uses-feature
+        android:name="android.hardware.wifi"
+        android:required="true" />
+    <uses-feature
+        android:name="android.hardware.microphone"
+        android:required="true" />
+
+    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
+    <uses-permission android:name="android.permission.INTERNET" />
+    <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
+    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
+    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
+    <uses-permission android:name="android.permission.WAKE_LOCK" />
+    <uses-permission
+        android:name="android.permission.DEVICE_POWER"
+        tools:ignore="ProtectedPermissions" />
+    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
+    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
+
+    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
+    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
+    <uses-permission android:name="android.permission.READ_CONTACTS"/>
+    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
+    <uses-permission android:name="android.permission.BLUETOOTH"/>
+    <uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
+    <uses-permission android:name="android.permission.BROADCAST_STICKY"/>
+    <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
+    <uses-permission android:name= "android.manifest.permission.INTERNAL_SYSTEM_WINDOW"/>
+    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
+    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
+    <uses-permission android:name="android.permission.SYSTEM_OVERLAY_WINDOW" />
+<!--    <permission-->
+<!--        android:name="com.example.aidlclient.ipc.aidl.ACCESS_PERSON_SERVICE"-->
+<!--        android:protectionLevel="normal" />-->
+
+<!--    <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/Theme.Siptext" >
+
+        <activity android:name=".MainActivity"
+            android:label="@string/app_name"
+            >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.intent.category.LAUNCHER" />
+                        <data android:scheme="no_launcher" />
+            </intent-filter>
+        </activity>
+
+        <receiver
+            android:name=".broadcast.WdBootReceiver"
+            android:enabled="true"
+            android:exported="true">
+            <intent-filter android:priority="1000">
+                <action android:name="android.intent.action.BOOT_COMPLETED"/>
+            </intent-filter>
+        </receiver>
+        <service
+            android:name=".service.WdklSipService"
+            android:enabled="true"
+            android:exported="true">
+            <intent-filter>
+                <action android:name="com.wdkl.app.ncs.siptext.service.WdklSipService"/>
+            </intent-filter>
+        </service>
+        <activity android:name="com.wdkl.app.ncs.siptext.activity.CallActivity" />
+    </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);
+
+}

+ 58 - 0
app/src/main/java/com/wdkl/app/ncs/siptext/MainActivity.java

@@ -0,0 +1,58 @@
+package com.wdkl.app.ncs.siptext;
+
+import android.Manifest;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.os.Build;
+import android.os.Bundle;
+
+import com.wdkl.app.ncs.siptext.Util.QSPermissionUtil;
+import com.wdkl.app.ncs.siptext.service.WdklSipService;
+
+import java.util.List;
+
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.core.app.ActivityCompat;
+import androidx.core.content.ContextCompat;
+import androidx.core.util.Consumer;
+import androidx.fragment.app.FragmentActivity;
+
+
+public class MainActivity extends AppCompatActivity {
+
+    private IMyAidlInterface student;
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_main);
+        checkPermissionRequest(this);
+    }
+
+
+    public void checkPermissionRequest(FragmentActivity activity) {
+        QSPermissionUtil.requestPermission(this, new QSPermissionUtil.PermissionListener() {
+            @Override
+            public void onPermissionSucceed(int requestCode, List<String> grantedList) {
+
+                Intent serviceIntent = new Intent(activity, WdklSipService.class);
+                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+                    //android8.0以上通过startForegroundService启动service
+                    startForegroundService(serviceIntent);
+                } else {
+                    startService(serviceIntent);
+                }
+                finish();
+            }
+
+            @Override
+            public void onPermissionFailed(int requestCode, List<String> deniedList) {
+                if (QSPermissionUtil.isAlwaysDeniedPermission(MainActivity.this, deniedList)) {
+                    QSPermissionUtil.showSettingDialog(MainActivity.this);
+                }
+            }
+        }, QSPermissionUtil.SDCARD);
+    }
+
+
+
+}

+ 25 - 0
app/src/main/java/com/wdkl/app/ncs/siptext/Util/Base64Util.java

@@ -0,0 +1,25 @@
+package com.wdkl.app.ncs.siptext.Util;
+
+import android.util.Base64;
+
+import java.nio.charset.StandardCharsets;
+
+public class Base64Util {
+    //编码
+    public static String encodeBase64(String input) {
+        return Base64.encodeToString(input.getBytes(), Base64.NO_WRAP);
+    }
+
+
+    //解码
+    public static String decodeBase64(String input) {
+        if (input != null) {
+            byte[] data = Base64.decode(input, Base64.NO_WRAP);
+            return new String(data);
+        }else {
+            return "";
+        }
+    }
+
+
+}

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

@@ -0,0 +1,551 @@
+package com.wdkl.app.ncs.siptext.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/app/ncs/siptext/Util/QSPermissionUtil.java

@@ -0,0 +1,234 @@
+package com.wdkl.app.ncs.siptext.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.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;
+
+import androidx.annotation.NonNull;
+
+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.CAMERA};
+
+    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);
+    }
+}

+ 54 - 0
app/src/main/java/com/wdkl/app/ncs/siptext/Util/Util.java

@@ -0,0 +1,54 @@
+package com.wdkl.app.ncs.siptext.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";
+    private static final String KEY_SP_SIP_TIME = "KEY_SP_SIP_TIME";
+    private static final String KEY_SP_SIP_ADDRESS = "KEY_SP_SIP_ADDRESS";
+
+    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();
+    }
+
+    public static String getSipTime(Context context) {
+        return getSP(context).getString(KEY_SP_SIP_TIME, "0");
+    }
+
+    public static void setSipTime(Context context, String value) {
+        getEditor(context).putString(KEY_SP_SIP_TIME, value).apply();
+    }
+
+    public static String getSipAddress(Context context) {
+        return getSP(context).getString(KEY_SP_SIP_ADDRESS, "");
+    }
+
+    public static void setSipTimeAddress(Context context, String value) {
+        getEditor(context).putString(KEY_SP_SIP_ADDRESS, value).apply();
+    }
+
+
+}

+ 209 - 0
app/src/main/java/com/wdkl/app/ncs/siptext/activity/CallActivity.java

@@ -0,0 +1,209 @@
+package com.wdkl.app.ncs.siptext.activity;
+
+import android.annotation.TargetApi;
+import android.app.Activity;
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.content.res.Configuration;
+import android.media.AudioManager;
+import android.os.Bundle;
+
+import android.util.DisplayMetrics;
+import android.util.Log;
+import android.view.TextureView;
+import android.view.View;
+import android.widget.RelativeLayout;
+
+
+import com.wdkl.app.ncs.siptext.R;
+import com.wdkl.app.ncs.siptext.service.WdklSipService;
+
+import org.linphone.core.Call;
+import org.linphone.core.Core;
+import org.linphone.core.CoreListenerStub;
+import org.linphone.core.VideoDefinition;
+import org.linphone.mediastream.Version;
+
+import androidx.annotation.Nullable;
+
+public class CallActivity extends Activity {
+    private static final String TAG = "CallActivity";
+    // 远程视频
+    private TextureView mVideoView;
+    // 本地视频
+    private TextureView mCaptureView;
+
+    private CoreListenerStub mCoreListener;
+
+    private AudioManager audioManager;
+
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        setContentView(R.layout.call);
+
+        mVideoView = findViewById(R.id.videoSurface);
+        mCaptureView = findViewById(R.id.videoCaptureSurface);
+
+        Core core = WdklSipService.getCore();
+        // 配置核心视频层渲染
+        core.setNativeVideoWindowId(mVideoView);
+        core.setNativePreviewWindowId(mCaptureView);
+
+        audioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
+
+        // 配置通话状态结束监听
+        mCoreListener = new CoreListenerStub() {
+            @Override
+            public void onCallStateChanged(Core core, Call call, Call.State state, String message) {
+                try {
+                    if (state == Call.State.End || state == Call.State.Released) {
+                        //没有通话时则退出
+                        if (WdklSipService.getCore().getCallsNb() == 0) {
+                            finish();
+                        }
+                    }
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        };
+
+        findViewById(R.id.toggle_speaker).setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                speakerOn();
+            }
+        });
+
+        findViewById(R.id.terminate_call).setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                Core core = WdklSipService.getCore();
+                if (core.getCallsNb() > 0) {
+                    Call call = core.getCurrentCall();
+                    if (call == null) {
+                        call = core.getCalls()[0];
+                    }
+                    call.terminate();
+                }
+            }
+        });
+    }
+
+    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);
+        Log.i(TAG,">>>>>>>>>>>>>>"+audioManager.isSpeakerphoneOn());
+    }
+
+    @Override
+    protected void onStart() {
+        super.onStart();
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+
+        WdklSipService.getCore().addListener(mCoreListener);
+        resizePreview();
+    }
+
+    @Override
+    protected void onPause() {
+        WdklSipService.getCore().removeListener(mCoreListener);
+
+        super.onPause();
+    }
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+    }
+
+    @TargetApi(24)
+    @Override
+    public void onUserLeaveHint() {
+        // 判断设备是否支持画中画
+        boolean supportsPip =
+                getPackageManager()
+                        .hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE);
+        Log.i(TAG,"[Call] Is picture in picture supported: " + supportsPip);
+        if (supportsPip && Version.sdkAboveOrEqual(24)) {
+            enterPictureInPictureMode();
+        }
+    }
+
+    @Override
+    public void onPictureInPictureModeChanged(
+            boolean isInPictureInPictureMode, Configuration newConfig) {
+        if (isInPictureInPictureMode) {
+            // Currently nothing to do has we only display video
+            // But if we had controls or other UI elements we should hide them
+        } else {
+            // If we did hide something, let's make them visible again
+        }
+    }
+
+    private void resizePreview() {
+        Core core = WdklSipService.getCore();
+        if (core.getCallsNb() > 0) {
+            Call call = core.getCurrentCall();
+            if (call == null) {
+                call = core.getCalls()[0];
+            }
+            if (call == null) return;
+
+            DisplayMetrics metrics = new DisplayMetrics();
+            getWindowManager().getDefaultDisplay().getMetrics(metrics);
+            int screenHeight = metrics.heightPixels;
+            int maxHeight =
+                    screenHeight / 4; // 本地1/4高
+
+            VideoDefinition videoSize =
+                    call.getCurrentParams()
+                            .getSentVideoDefinition();
+            if (videoSize.getWidth() == 0 || videoSize.getHeight() == 0) {
+                Log.w(TAG,
+                        "[Video] 无法使用发送端视频定义, 使用默认");
+                videoSize = core.getPreferredVideoDefinition();
+            }
+            int width = videoSize.getWidth();
+            int height = videoSize.getHeight();
+
+            Log.d(TAG,"[Video] Video height is " + height + ", width is " + width);
+            width = width * maxHeight / height;
+            height = maxHeight;
+
+            if (mCaptureView == null) {
+                Log.e(TAG,"[Video] 本地视频流 is null !");
+                return;
+            }
+
+            RelativeLayout.LayoutParams newLp = new RelativeLayout.LayoutParams(width, height);
+            newLp.addRule(
+                    RelativeLayout.ALIGN_PARENT_BOTTOM,
+                    1); // Clears the rule, as there is no removeRule until API 17.
+            newLp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 1);
+            mCaptureView.setLayoutParams(newLp);
+            Log.d(TAG,"[Video] 远程视频 size set to " + width + "x" + height);
+        }
+    }
+}

+ 27 - 0
app/src/main/java/com/wdkl/app/ncs/siptext/broadcast/WdBootReceiver.java

@@ -0,0 +1,27 @@
+package com.wdkl.app.ncs.siptext.broadcast;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Build;
+import android.util.Log;
+
+import com.wdkl.app.ncs.siptext.service.WdklSipService;
+
+
+public class WdBootReceiver extends BroadcastReceiver {
+
+    @Override
+    public void onReceive(Context context, Intent intent) {
+        Log.i("sipcall", "开机广播");
+        if ("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) {
+            Intent serviceIntent = new Intent(context, WdklSipService.class);
+            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+                //android8.0以上通过startForegroundService启动service
+                context.startForegroundService(serviceIntent);
+            } else {
+                context.startService(serviceIntent);
+            }
+        }
+    }
+}

+ 510 - 0
app/src/main/java/com/wdkl/app/ncs/siptext/service/WdklSipService.java

@@ -0,0 +1,510 @@
+package com.wdkl.app.ncs.siptext.service;
+
+import android.app.Notification;
+import android.app.NotificationChannel;
+import android.app.NotificationManager;
+import android.app.Service;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.os.Build;
+import android.os.Environment;
+import android.os.Handler;
+import android.os.IBinder;
+import android.os.RemoteCallbackList;
+import android.os.RemoteException;
+import android.text.TextUtils;
+import android.util.Log;
+import android.widget.Toast;
+
+import com.wdkl.app.ncs.siptext.IMyAidlInterface;
+import com.wdkl.app.ncs.siptext.IPersonChangeListener;
+import com.wdkl.app.ncs.siptext.R;
+import com.wdkl.app.ncs.siptext.Util.Base64Util;
+import com.wdkl.app.ncs.siptext.Util.NetHelper;
+import com.wdkl.app.ncs.siptext.Util.Util;
+import com.wdkl.app.ncs.siptext.activity.CallActivity;
+
+import androidx.annotation.Nullable;
+
+import org.linphone.core.AccountCreator;
+import org.linphone.core.Address;
+import org.linphone.core.Call;
+import org.linphone.core.CallParams;
+import org.linphone.core.Core;
+import org.linphone.core.CoreListenerStub;
+import org.linphone.core.Factory;
+import org.linphone.core.LogCollectionState;
+import org.linphone.core.ProxyConfig;
+import org.linphone.core.TransportType;
+import org.linphone.core.Transports;
+import org.linphone.mediastream.Version;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Timer;
+import java.util.TimerTask;
+
+public class WdklSipService extends Service {
+    private static final String START_SIPPHONE_LOGS = " ==== Device information dump ====";
+
+    private static final String PREFER_PAYLOAD = "PUMU";
+    //单例化服务,以便全局调用
+    private static WdklSipService sInstance;
+
+    private NotificationManager notificationManager = null;
+    private String notificationId = "channelId0";
+    private String notificationName = "sip_service";
+
+    private Handler mHandler;
+    private Timer mTimer;
+
+    private Core mCore;
+    private CoreListenerStub mCoreListener;
+
+    private String state=null;
+
+    private String username="";
+
+    private String Adderss="";
+
+    public static boolean isReady() {
+        return sInstance != null;
+    }
+
+    public static WdklSipService getInstance() {
+        return sInstance;
+    }
+
+    public static Core getCore() {
+        return sInstance.mCore;
+    }
+
+    private RemoteCallbackList<IPersonChangeListener> mListenerList = new RemoteCallbackList<>();
+
+
+    @Nullable
+    @Override
+    public IBinder onBind(Intent intent) {
+//        绑定的包名
+//        int check = checkCallingOrSelfPermission("com.example.aidlclient.ipc.aidl.ACCESS_PERSON_SERVICE");
+//        if (check == PackageManager.PERMISSION_DENIED) {
+//            Log.d(">>>>>>>>>>>>>>", "没有权限");
+//            return null;
+//        }
+
+//        Log.d(">>>>>>>>>>>>>>", "有权限");
+        return mBinder;
+    }
+
+
+    // 包名验证
+    private boolean verifyPackage(int uid) {
+        String packageName = null;
+        String[] packages = getPackageManager().getPackagesForUid(uid);
+        if (packages != null && packages.length > 0) {
+            packageName = packages[0];
+        }
+        if (!"com.example.aidlclient".equals(packageName)) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public void onCreate() {
+        super.onCreate();
+        notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+            NotificationChannel channel = new NotificationChannel(
+                    notificationId,
+                    notificationName,
+                    NotificationManager.IMPORTANCE_HIGH
+            );
+            channel.enableVibration(true);
+            channel.enableLights(true);
+            channel.setBypassDnd(true);
+            channel.setShowBadge(true);
+            channel.setSound(null, null);
+            notificationManager.createNotificationChannel(channel);
+        }
+
+        //首次调用必须使用 Factory相关方法
+        //这里开户调试日志及设置路径
+        String basePath = getFilesDir().getAbsolutePath();
+        Factory.instance().setLogCollectionPath(basePath);
+        Factory.instance().enableLogCollection(LogCollectionState.Enabled);
+        Factory.instance().setDebugMode(false, getString(R.string.app_name));
+
+        //收集一些设备信息
+        Log.i(">>>>>>>>>>>>>>", START_SIPPHONE_LOGS);
+        dumpDeviceInformation();
+        dumpInstalledLinphoneInformation();
+
+        mHandler = new Handler();
+        //主监听器,根据事件调用界面
+        mCoreListener = new CoreListenerStub() {
+
+
+            @Override
+            public void onCallStateChanged(Core core, Call call, Call.State state, String message) {
+                Log.i("sipCall>>>>>>>>>>>>>>","state " + state.name() + " ,message " + message +
+                        ", remote address "+call.getRemoteAddressAsString() +
+                        ", remote user " + call.getRemoteAddress().getUsername() +
+                        ", remoe contact " + call.getRemoteContact()
+                );
+
+                if (call.getRemoteParams()!=null){
+                    String shuju= call.getRemoteParams().getCustomHeader("X-extraData");
+                    username =  Base64Util.decodeBase64(shuju);
+                    Log.d("sipCall", ">>>>>>>>>>>> call shuju:"+shuju);
+                }
+                onDataChange(state.name());
+                if (state == Call.State.IncomingReceived) {
+
+                } else if (state == Call.State.Connected) {
+                    //录音
+                    call.startRecording();
+
+
+                }
+            }
+        };
+
+        try {
+            //复制一些源资源
+            //默认配置只能在首次时安装一次
+            copyIfNotExist(R.raw.linphonerc_default, basePath + "/.wdkl_sip_rc");
+            //用户配置,每次复制
+            copyFromPackage(R.raw.linphonerc_factory, "wdkl_sip_rc");
+        } catch (IOException ioe) {
+            Log.e("sipCall>>>>>>>>>>>>>>",ioe.getMessage());
+        }
+
+        //创建SIP核心并加载监听器
+        mCore = Factory.instance()
+                .createCore(basePath + "/.wdkl_sip_rc", basePath + "/wdkl_sip_rc", this);
+        mCore.addListener(mCoreListener);
+        String time = Util.getSipTime(this);
+        mCore.setRing(time);
+        //SIP核心配置完成
+        configureCore();
+    }
+
+    @Override
+    public int onStartCommand(Intent intent, int flags, int startId) {
+        super.onStartCommand(intent, flags, startId);
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+            startForeground(11, getNotification()); //开前台服务
+        }
+        super.onStartCommand(intent, flags, startId);
+        //如果服务已经在运行,则返回
+        if (sInstance != null) {
+            return START_STICKY;
+        }
+
+        //一旦服务启动,则一直保持
+        sInstance = this;
+
+        //SIP核心在创建和配置完成后,开启
+        mCore.start();
+        //必须定时运行 SIP核心 iterate()
+        TimerTask lTask =
+                new TimerTask() {
+                    @Override
+                    public void run() {
+                        mHandler.post(
+                                new Runnable() {
+                                    @Override
+                                    public void run() {
+                                        if (mCore != null) {
+                                            mCore.iterate();
+                                        }
+                                    }
+                                });
+                    }
+                };
+        mTimer = new Timer("wdkl sip scheduler");
+        mTimer.schedule(lTask, 0, 20);
+
+        return START_STICKY;
+    }
+
+    @Override
+    public void onDestroy() {
+        mCore.removeListener(mCoreListener);
+        mTimer.cancel();
+        mCore.stop();
+        // A stopped Core can be started again
+        // To ensure resources are freed, we must ensure it will be garbage collected
+        mCore = null;
+        // Don't forget to free the singleton as well
+        sInstance = null;
+
+        super.onDestroy();
+    }
+
+    private Notification getNotification() {
+        Notification.Builder builder = new Notification.Builder(this)
+                .setSmallIcon(R.mipmap.ic_launcher)
+                .setContentTitle("sip service")
+                .setContentText("running...")
+                .setOnlyAlertOnce(true);
+
+        //设置Notification的ChannelID,否则不能正常显示
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+            builder.setChannelId(notificationId);
+        }
+
+        return builder.build();
+    }
+
+    @Override
+    public void onTaskRemoved(Intent rootIntent) {
+        // For this sample we will kill the Service at the same time we kill the app
+        stopSelf();
+
+        super.onTaskRemoved(rootIntent);
+    }
+
+    private void configureCore() {
+        // We will create a directory for user signed certificates if needed
+        String basePath = getFilesDir().getAbsolutePath();
+        String userCerts = basePath + "/user-certs";
+        File f = new File(userCerts);
+        if (!f.exists()) {
+            if (!f.mkdir()) {
+                Log.e("sipCall>>>>>>>>>>>>>>",userCerts + " can't be created.");
+            }
+        }
+        mCore.setUserCertificatesPath(userCerts);
+    }
+
+    private void dumpDeviceInformation() {
+        StringBuilder sb = new StringBuilder();
+        sb.append("DEVICE=").append(Build.DEVICE).append("\n");
+        sb.append("MODEL=").append(Build.MODEL).append("\n");
+        sb.append("MANUFACTURER=").append(Build.MANUFACTURER).append("\n");
+        sb.append("SDK=").append(Build.VERSION.SDK_INT).append("\n");
+        sb.append("Supported ABIs=");
+        for (String abi : Version.getCpuAbis()) {
+            sb.append(abi).append(", ");
+        }
+        sb.append("\n");
+        Log.i("sipCall>>>>>>>>>>>>>>",sb.toString());
+    }
+
+    private void dumpInstalledLinphoneInformation() {
+        PackageInfo info = null;
+        try {
+            info = getPackageManager().getPackageInfo(getPackageName(), 0);
+        } catch (PackageManager.NameNotFoundException nnfe) {
+            Log.e("sipCall>>>>>>>>>>>>>>",nnfe.getMessage());
+        }
+
+        if (info != null) {
+            Log.i(
+                    "sipCall>>>>>>>>>>>>>>",
+                    info.versionName + " (" + info.versionCode + ")");
+        } else {
+            Log.i("sipCall>>>>>>>>>>>>>>","[Service] sipphone version is unknown");
+        }
+    }
+
+    private void copyIfNotExist(int ressourceId, String target) throws IOException {
+        File lFileToCopy = new File(target);
+        if (!lFileToCopy.exists()) {
+            copyFromPackage(ressourceId, lFileToCopy.getName());
+        }
+    }
+
+
+    private void copyFromPackage(int ressourceId, String target) throws IOException {
+        FileOutputStream lOutputStream = openFileOutput(target, 0);
+        InputStream lInputStream = getResources().openRawResource(ressourceId);
+        int readByte;
+        byte[] buff = new byte[8048];
+        while ((readByte = lInputStream.read(buff)) != -1) {
+            lOutputStream.write(buff, 0, readByte);
+        }
+        lOutputStream.flush();
+        lOutputStream.close();
+        lInputStream.close();
+    }
+    private void onDataChange( String type ) {
+        try {
+            int count = mListenerList.beginBroadcast();
+            for (int i = 0; i < count; i++) {
+                try {
+                    mListenerList.getBroadcastItem(i).onPersonDataChanged(type);
+                } catch (RemoteException e) {
+                    e.printStackTrace();
+                }
+            }
+            mListenerList.finishBroadcast();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    private final IMyAidlInterface.Stub mBinder = new IMyAidlInterface.Stub() {
+
+        /**
+        * 设置sip账户名称
+        * */
+        @Override
+        public void setSipAccount(String username,String url) throws RemoteException {
+            Log.d("sipCall", ">>>>>>>>>>>> call state: 设置sip账户名称 " +username );
+            //无服务器时端口必须,固定5060,否则拨打IP时,也需加上端口号。如:sip:192.168.1.100:6666
+            Transports transports = Factory.instance().createTransports();
+            transports.setUdpPort(5060);
+            transports.setTcpPort(5060);
+            mCore.setTransports(transports);
+            //设置显示名称
+            AccountCreator accountCreator = mCore.createAccountCreator(null);
+            accountCreator.setUsername(username); //此处就当设置为房间床位号
+            if (url==null || url==""){
+                accountCreator.setDomain("");
+            }else {
+                accountCreator.setDomain(NetHelper.getInstance().getLocalIP());
+            }
+            accountCreator.setTransport(TransportType.Udp);
+            ProxyConfig cfg = accountCreator.createProxyConfig();
+            mCore.setDefaultProxyConfig(cfg);
+            mCore.setIncTimeout(60);
+        }
+
+
+
+        /**
+         *  设置sip呼叫振铃的时间秒
+         */
+        @Override
+        public void setBellsTime(int time) throws RemoteException {
+           Util.setSipTime(getBaseContext(),String.valueOf(time));
+           mCore.setRing(String.valueOf(time));
+        }
+
+        /**
+         *  呼叫
+         */
+        @Override
+        public void setCalling(String username, String info) throws RemoteException {
+            Log.d("sipCall", ">>>>>>>>>>>> call state: 呼叫"   +username );
+//            Address addressToCall = mCore.interpretUrl(username+"@"+NetHelper.getInstance().getLocalIP());
+            Address addressToCall = mCore.interpretUrl(username);
+            CallParams params = mCore.createCallParams(null);
+            Adderss =   Util.getSipAddress(getBaseContext());
+            //录音文件路径
+            if (Adderss.equals("")){
+                //录音文件路径
+                params.setRecordFile(Environment.getExternalStorageDirectory().getPath()+"/Download/"+ Util.getTimeFilename() +".wav");
+            }else {
+                params.setRecordFile(Adderss);
+            }
+            if(!TextUtils.isEmpty(info)){
+                params.addCustomHeader("X-extraData",Base64Util.encodeBase64(info));
+            }
+            if (addressToCall != null) {
+                mCore.inviteAddressWithParams(addressToCall, params);
+            }
+
+        }
+
+        /**
+         *  来电
+         */
+        @Override
+        public String getCalling() throws RemoteException {
+            Log.d("sipCall", ">>>>>>>>>>>> call state: 来电"  );
+            return username;
+
+        }
+
+        @Override
+        public String getSIP() throws RemoteException {
+            String myname = mCore.getIdentity();
+            return myname;
+        }
+
+        /**
+         *  接听
+         */
+        @Override
+        public void setAcceptWithParams() throws RemoteException {
+            Log.d("sipCall", ">>>>>>>>>>>> call state: 接听"  );
+            if (mCore != null && mCore.getCallsNb() > 0) {
+                Call call = mCore.getCurrentCall();
+                if (call == null) {
+                    call = mCore.getCalls()[0];
+                }
+                CallParams params = mCore.createCallParams(call);
+                params.setVideoEnabled(false);
+                Adderss =   Util.getSipAddress(getBaseContext());
+                //录音文件路径
+                if (Adderss.equals("")){
+                    //录音文件路径
+                    params.setRecordFile(Environment.getExternalStorageDirectory().getPath()+"/Download/"+ Util.getTimeFilename() +".wav");
+                }else {
+                    params.setRecordFile(Adderss);
+                }
+                call.acceptWithParams(params);
+            }
+        }
+        /**
+         *  挂断
+         */
+        @Override
+        public void setCallTerminate() throws RemoteException {
+            Log.d("sipCall", ">>>>>>>>>>>> call state: 挂断"  );
+            if (mCore.getCallsNb() > 0) {
+                Call call = mCore.getCurrentCall();
+                if (call == null) {
+                    call = mCore.getCalls()[0];
+                }
+                call.stopRecording();
+                call.terminate();
+            }
+        }
+
+        /**
+         *  设置录音文件地址
+         */
+        @Override
+        public void setCallAddress(String address) throws RemoteException {
+            Util.setSipTimeAddress(getBaseContext(),String.valueOf(address));
+        }
+
+
+
+        /**
+         * 设置关闭录音
+         *
+         */
+        @Override
+        public void setMicEnabled(boolean isMicEnabled) throws RemoteException {
+            if (isMicEnabled){
+                mCore.setMicEnabled(true);
+            }else {
+                mCore.setMicEnabled(false);
+            }
+        }
+
+        /**
+         *  sip状态
+         */
+        @Override
+        public void registerListener(IPersonChangeListener listener) throws RemoteException {
+            mListenerList.register(listener);
+        }
+
+        @Override
+        public void unregisterListener(IPersonChangeListener listener) throws RemoteException {
+            mListenerList.unregister(listener);
+        }
+
+    };
+}

Разница между файлами не показана из-за своего большого размера
+ 30 - 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:viewportHeight="108"
+    android:viewportWidth="108">
+    <path
+        android:fillColor="#3DDC84"
+        android:pathData="M0,0h108v108h-108z" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M9,0L9,108"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M19,0L19,108"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M29,0L29,108"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M39,0L39,108"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M49,0L49,108"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M59,0L59,108"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M69,0L69,108"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M79,0L79,108"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M89,0L89,108"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M99,0L99,108"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,9L108,9"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,19L108,19"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,29L108,29"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,39L108,39"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,49L108,49"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,59L108,59"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,69L108,69"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,79L108,79"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,89L108,89"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M0,99L108,99"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M19,29L89,29"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M19,39L89,39"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M19,49L89,49"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M19,59L89,59"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M19,69L89,69"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M19,79L89,79"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M29,19L29,89"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M39,19L39,89"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M49,19L49,89"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M59,19L59,89"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M69,19L69,89"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+    <path
+        android:fillColor="#00000000"
+        android:pathData="M79,19L79,89"
+        android:strokeColor="#33FFFFFF"
+        android:strokeWidth="0.8" />
+</vector>

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

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout 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"
+    android:gravity="center"
+    android:background="@android:color/transparent"
+    tools:context=".MainActivity">
+
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="请授权后启动sip服务"
+        android:textStyle="bold"
+        android:textSize="40sp"
+        />
+
+
+</LinearLayout>

+ 34 - 0
app/src/main/res/layout/call.xml

@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <TextureView
+        android:id="@+id/videoSurface"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent" />
+
+    <TextureView
+        android:id="@+id/videoCaptureSurface"
+        android:layout_width="300dp"
+        android:layout_height="200dp"
+        android:layout_alignParentRight="true"
+        android:layout_alignParentBottom="true" />
+
+    <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>

+ 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>

BIN
app/src/main/res/mipmap-hdpi/ic_launcher.png


BIN
app/src/main/res/mipmap-hdpi/ic_launcher_round.png


BIN
app/src/main/res/mipmap-mdpi/ic_launcher.png


BIN
app/src/main/res/mipmap-mdpi/ic_launcher_round.png


BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.png


BIN
app/src/main/res/mipmap-xhdpi/ic_launcher_round.png


BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.png


BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png


BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png


BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png


BIN
app/src/main/res/raw/incoming_call_ring.mp3


+ 20 - 0
app/src/main/res/raw/linphonerc_default

@@ -0,0 +1,20 @@
+[sip]
+contact="Linphone Android" <sip:allen@8.129.220.143>
+use_info=0
+use_ipv6=1
+keepalive_period=30000
+sip_port=-1
+sip_tcp_port=-1
+sip_tls_port=-1
+media_encryption=none
+
+[video]
+size=vga
+
+[app]
+tunnel=disabled
+push_notification=1
+
+[misc]
+max_calls=10
+history_max_size=100

+ 34 - 0
app/src/main/res/raw/linphonerc_factory

@@ -0,0 +1,34 @@
+
+#
+#This file shall not contain path referencing package name, in order to be portable when app is renamed.
+#Paths to resources must be set from LinphoneManager, after creating LinphoneCore.
+[net]
+mtu=1300
+#Because dynamic bitrate adaption can increase bitrate, we must allow "no limit"
+download_bw=0
+upload_bw=0
+force_ice_disablement=0
+
+[sip]
+guess_hostname=1
+register_only_when_network_is_up=1
+auto_net_state_mon=1
+auto_answer_replacing_calls=1
+ping_with_options=0
+use_cpim=1
+
+[video]
+displaytype=MSAndroidTextureDisplay
+
+[misc]
+enable_basic_to_client_group_chat_room_migration=0
+enable_simple_group_chat_message_state=0
+aggregate_imdn=1
+notify_each_friend_individually_when_presence_received=0
+
+[app]
+activation_code_length=4
+prefer_basic_chat_room=1
+
+[assistant]
+xmlrpc_url=https://subscribe.linphone.org:444/wizard.php

BIN
app/src/main/res/raw/outgoing_call_ring.mp3


BIN
app/src/main/res/raw/wr_ringback.wav


+ 16 - 0
app/src/main/res/values-night/themes.xml

@@ -0,0 +1,16 @@
+<resources xmlns:tools="http://schemas.android.com/tools">
+    <!-- Base application theme. -->
+    <style name="Theme.Siptext" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
+        <!-- Primary brand color. -->
+        <item name="colorPrimary">@color/purple_200</item>
+        <item name="colorPrimaryVariant">@color/purple_700</item>
+        <item name="colorOnPrimary">@color/black</item>
+        <!-- Secondary brand color. -->
+        <item name="colorSecondary">@color/teal_200</item>
+        <item name="colorSecondaryVariant">@color/teal_200</item>
+        <item name="colorOnSecondary">@color/black</item>
+        <!-- Status bar color. -->
+        <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
+        <!-- Customize your theme here. -->
+    </style>
+</resources>

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

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <color name="purple_200">#FFBB86FC</color>
+    <color name="purple_500">#FF6200EE</color>
+    <color name="purple_700">#FF3700B3</color>
+    <color name="teal_200">#FF03DAC5</color>
+    <color name="teal_700">#FF018786</color>
+    <color name="black">#FF000000</color>
+    <color name="white">#FFFFFFFF</color>
+</resources>

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

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

+ 16 - 0
app/src/main/res/values/themes.xml

@@ -0,0 +1,16 @@
+<resources xmlns:tools="http://schemas.android.com/tools">
+    <!-- Base application theme. -->
+    <style name="Theme.Siptext" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
+        <!-- Primary brand color. -->
+        <item name="colorPrimary">@color/purple_500</item>
+        <item name="colorPrimaryVariant">@color/purple_700</item>
+        <item name="colorOnPrimary">@color/white</item>
+        <!-- Secondary brand color. -->
+        <item name="colorSecondary">@color/teal_200</item>
+        <item name="colorSecondaryVariant">@color/teal_700</item>
+        <item name="colorOnSecondary">@color/black</item>
+        <!-- Status bar color. -->
+        <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
+        <!-- Customize your theme here. -->
+    </style>
+</resources>

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

@@ -0,0 +1,17 @@
+package com.wdkl.app.ncs.siptext;
+
+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);
+    }
+}

+ 52 - 0
build.gradle

@@ -0,0 +1,52 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+buildscript {
+    repositories {
+        maven { url 'http://maven.aliyun.com/nexus/content/repositories/google' }
+        maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter'}
+        maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
+        maven { url "https://jitpack.io" }
+        jcenter()
+        mavenCentral()
+        google()
+    }
+    dependencies {
+        repositories {
+            /**
+             * 依赖仓储
+             */
+            maven { url 'http://maven.aliyun.com/nexus/content/repositories/google' }
+            maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter'}
+            maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
+
+            //jcenter()
+            mavenCentral()
+            google()
+        }
+        classpath 'com.android.tools.build:gradle:4.2.1'
+
+        // NOTE: Do not place your application dependencies here; they belong
+        // in the individual module build.gradle files
+    }
+}
+
+allprojects {
+    repositories {
+        maven { url 'http://maven.aliyun.com/nexus/content/repositories/google' }
+        maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter'}
+        maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
+        maven { url "https://jitpack.io" }
+
+        maven {
+            // Replace snapshots by releases for releases !
+            url "https://linphone.org/maven_repository"
+        }
+        jcenter()
+        mavenCentral()
+        google()
+
+    }
+}
+
+task clean(type: Delete) {
+    delete rootProject.buildDir
+}

+ 19 - 0
gradle.properties

@@ -0,0 +1,19 @@
+# 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=-Xmx2048m -Dfile.encoding=UTF-8
+# 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
+# AndroidX package structure to make it clearer which packages are bundled with the
+# Android operating system, and which are packaged with your app"s APK
+# https://developer.android.com/topic/libraries/support-library/androidx-rn
+android.useAndroidX=true
+# Automatically convert third-party libraries to use AndroidX
+android.enableJetifier=true

BIN
gradle/wrapper/gradle-wrapper.jar


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

@@ -0,0 +1,6 @@
+#Mon Oct 30 16:45:19 CST 2023
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.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

+ 2 - 0
settings.gradle

@@ -0,0 +1,2 @@
+include ':app'
+rootProject.name = "siptext"