浏览代码

修复分机与手机之间通话无法建立,tcp出现两个实例

wuyunfeng 3 年之前
父节点
当前提交
f9f8edc465
共有 29 个文件被更改,包括 510 次插入110 次删除
  1. 1 1
      WebRTC/src/main/java/com/wdkl/core/socket/IEvent.java
  2. 3 1
      WebRTC/src/main/java/com/wdkl/core/socket/MyWebSocket.java
  3. 6 2
      WebRTC/src/main/java/com/wdkl/core/socket/SocketManager.java
  4. 5 0
      WebRTC/src/main/java/com/wdkl/core/voip/VoipReceiver.java
  5. 139 0
      app/keystore_wuyuqing_3128/keytool-importkeypair
  6. 1 0
      app/keystore_wuyuqing_3128/password.txt
  7. 二进制
      app/keystore_wuyuqing_3128/platform.pk8
  8. 24 0
      app/keystore_wuyuqing_3128/platform.x509.pem
  9. 二进制
      app/keystore_wuyuqing_3128/rk3128.jks
  10. 7 0
      app/keystore_wuyuqing_3128/rk3128_generate_key.sh
  11. 139 0
      app/keystore_wuyuqing_3128/rk3128_signapk/keytool-importkeypair
  12. 二进制
      app/keystore_wuyuqing_3128/rk3128_signapk/platform.pk8
  13. 24 0
      app/keystore_wuyuqing_3128/rk3128_signapk/platform.x509.pem
  14. 二进制
      app/keystore_wuyuqing_3128/rk3128_signapk/rk3128.jks
  15. 7 0
      app/keystore_wuyuqing_3128/rk3128_signapk/rk3128_generate_key.sh
  16. 二进制
      app/keystore_wuyuqing_3128/rk3128_signapk/signapk.jar
  17. 二进制
      app/keystore_wuyuqing_3128/signapk.jar
  18. 2 2
      build.gradle
  19. 0 0
      gradle/wrapper/gradle-wrapper.jar
  20. 2 3
      gradle/wrapper/gradle-wrapper.properties
  21. 32 18
      home/src/main/code/com/wdkl/ncs/android/component/home/activity/WatchHome2Activity.kt
  22. 46 34
      home/src/main/code/com/wdkl/ncs/android/component/home/activity/WebRTCVoipAudioActivity.kt
  23. 5 0
      home/src/main/code/com/wdkl/ncs/android/component/home/activity/WebRTCVoipAudioRingingActivity.kt
  24. 39 29
      home/src/main/code/com/wdkl/ncs/android/component/home/service/WdKeepAliveService.kt
  25. 4 1
      home/src/main/code/com/wdkl/ncs/android/component/home/util/TcpCallbackImpl.java
  26. 2 0
      middleware/src/main/code/com/wdkl/ncs/android/middleware/common/Constants.kt
  27. 8 8
      middleware/src/main/code/com/wdkl/ncs/android/middleware/tcp/TcpClient.java
  28. 6 4
      middleware/src/main/code/com/wdkl/ncs/android/middleware/tcp/TcpClientHandler.java
  29. 8 7
      rtc-chat/src/main/java/com/wdkl/skywebrtc/SkyEngineKit.java

+ 1 - 1
WebRTC/src/main/java/com/wdkl/core/socket/IEvent.java

@@ -24,7 +24,7 @@ public interface IEvent {
 
 
     void onNewPeer(String myId);
     void onNewPeer(String myId);
 
 
-    void onReject(String userId, int type);
+    void onReject(String userId, int type,String room);
 
 
     // onOffer
     // onOffer
     void onOffer(String userId, String sdp);
     void onOffer(String userId, String sdp);

+ 3 - 1
WebRTC/src/main/java/com/wdkl/core/socket/MyWebSocket.java

@@ -32,6 +32,7 @@ public class MyWebSocket extends WebSocketClient {
     private boolean connectFlag = false;
     private boolean connectFlag = false;
 
 
 
 
+
     public MyWebSocket(URI serverUri, IEvent event) {
     public MyWebSocket(URI serverUri, IEvent event) {
         super(serverUri);
         super(serverUri);
         this.iEvent = event;
         this.iEvent = event;
@@ -216,7 +217,8 @@ public class MyWebSocket extends WebSocketClient {
         if (data != null) {
         if (data != null) {
             String fromID = (String) data.get("fromID");
             String fromID = (String) data.get("fromID");
             int rejectType = Integer.parseInt(String.valueOf(data.get("refuseType")));
             int rejectType = Integer.parseInt(String.valueOf(data.get("refuseType")));
-            this.iEvent.onReject(fromID, rejectType);
+            String room = (String) data.get("room");
+            this.iEvent.onReject(fromID, rejectType,room);
         }
         }
     }
     }
 
 

+ 6 - 2
WebRTC/src/main/java/com/wdkl/core/socket/SocketManager.java

@@ -19,6 +19,7 @@ import java.lang.ref.WeakReference;
 import java.net.URI;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URISyntaxException;
 import java.security.SecureRandom;
 import java.security.SecureRandom;
+import java.util.Arrays;
 import java.util.List;
 import java.util.List;
 
 
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLContext;
@@ -283,11 +284,14 @@ public class SocketManager implements IEvent {
     }
     }
 
 
     @Override
     @Override
-    public void onReject(String userId, int type) {
+    public void onReject(String userId, int type,String room) {
         handler.post(() -> {
         handler.post(() -> {
             CallSession currentSession = SkyEngineKit.Instance().getCurrentSession();
             CallSession currentSession = SkyEngineKit.Instance().getCurrentSession();
+            Log.i(TAG,"current RoomId:"+currentSession.getRoomId()+",reject:"+room);
             if (currentSession != null) {
             if (currentSession != null) {
-                currentSession.onRefuse(userId, type);
+                if((myId.equals(userId)||currentSession.getRoomId().equals(room)&&myId.equals(userId))) {
+                    currentSession.onRefuse(userId, type);
+                }
             }
             }
         });
         });
 
 

+ 5 - 0
WebRTC/src/main/java/com/wdkl/core/voip/VoipReceiver.java

@@ -15,11 +15,15 @@ import com.blankj.utilcode.util.LogUtils;
 import com.wdkl.core.base.BaseActivity;
 import com.wdkl.core.base.BaseActivity;
 import com.wdkl.core.socket.SocketManager;
 import com.wdkl.core.socket.SocketManager;
 import com.wdkl.core.util.ActivityStackManager;
 import com.wdkl.core.util.ActivityStackManager;
+import com.wdkl.ncs.android.component.nursehome.common.Constants;
+import com.wdkl.ncs.android.middleware.utils.MessageEvent;
 import com.wdkl.permission.Permissions;
 import com.wdkl.permission.Permissions;
 import com.wdkl.skywebrtc.SkyEngineKit;
 import com.wdkl.skywebrtc.SkyEngineKit;
 import com.wdkl.webrtc.R;
 import com.wdkl.webrtc.R;
 import com.tapadoo.alerter.Alerter;
 import com.tapadoo.alerter.Alerter;
 
 
+import org.greenrobot.eventbus.EventBus;
+
 import java.util.ArrayList;
 import java.util.ArrayList;
 
 
 /**
 /**
@@ -194,6 +198,7 @@ public class VoipReceiver extends BroadcastReceiver {
         if (b) {
         if (b) {
             //App.getInstance().setOtherUserId(inviteId);
             //App.getInstance().setOtherUserId(inviteId);
             LogUtils.dTag(TAG, "onHasPermission list.size() = " + list.size());
             LogUtils.dTag(TAG, "onHasPermission list.size() = " + list.size());
+            EventBus.getDefault().post(new MessageEvent(Constants.INCOME_CALL_READY,Constants.INCOME_CALL_READY));
             if (list.size() == 1) {
             if (list.size() == 1) {
                 //以视频电话拨打,切换到音频或重走这里,结束掉上一个,防止对方挂断后,下边还有一个通话界面
                 //以视频电话拨打,切换到音频或重走这里,结束掉上一个,防止对方挂断后,下边还有一个通话界面
 //                if (context instanceof CallSingleActivity) {
 //                if (context instanceof CallSingleActivity) {

+ 139 - 0
app/keystore_wuyuqing_3128/keytool-importkeypair

@@ -0,0 +1,139 @@
+#! /bin/bash
+#
+# This file is part of keytool-importkeypair.
+#
+# keytool-importkeypair is free software: you can redistribute it
+# and/or modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# keytool-importkeypair is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with keytool-importkeypair.  If not, see
+# <http://www.gnu.org/licenses/>.
+#
+
+DEFAULT_KEYSTORE=$HOME/.keystore
+keystore=$DEFAULT_KEYSTORE
+pk8=""
+cert=""
+alias=""
+passphrase=""
+tmpdir=""
+
+scriptname=`basename $0`
+
+usage() {
+cat << EOF
+usage: ${scriptname} [-k keystore] [-p storepass]
+-pk8 pk8 -cert cert -alias key_alias
+
+This script is used to import a key/certificate pair
+into a Java keystore.
+
+If a keystore is not specified then the key pair is imported into
+~/.keystore in the user's home directory.
+
+The passphrase can also be read from stdin.
+EOF
+}
+
+cleanup() {
+if [ ! -z "${tmpdir}" -a -d ${tmpdir} ]; then
+   rm -fr ${tmpdir}
+fi
+}
+
+while [ $# -gt 0 ]; do
+        case $1
+        in
+                -p | --passphrase | -passphrase)
+                        passphrase=$2
+                        shift 2
+        ;;
+                -h | --help)
+                        usage
+                        exit 0
+        ;;
+                -k | -keystore | --keystore)
+                        keystore=$2
+                        shift 2
+        ;;
+                -pk8 | --pk8 | -key | --key)
+                        pk8=$2
+                        shift 2
+        ;;
+                -cert | --cert | -pem | --pem)
+                        cert=$2
+                        shift 2
+        ;;
+                -a | -alias | --alias)
+                        alias=$2
+                        shift 2
+        ;;
+                *)
+                        echo "${scriptname}: Unknown option $1, exiting" 1>&2
+                        usage
+                        exit 1
+        ;;
+        esac
+done
+
+if [ -z "${pk8}" -o -z "${cert}" -o -z "${alias}" ]; then
+   echo "${scriptname}: Missing option, exiting..." 1>&2
+   usage
+   exit 1
+fi
+
+
+for f in "${pk8}" "${cert}"; do
+    if [ ! -f "$f" ]; then
+       echo "${scriptname}: Can't find file $f, exiting..." 1>&2
+       exit 1
+    fi
+done
+
+if [ ! -f "${keystore}" ]; then
+   storedir=`dirname "${keystore}"`
+   if [ ! -d "${storedir}" -o ! -w "${storedir}" ]; then
+      echo "${scriptname}: Can't access ${storedir}, exiting..." 1>&2
+      exit 1
+   fi
+fi
+
+# Create temp directory ofr key and pkcs12 bundle
+tmpdir=`mktemp -q -d "/tmp/${scriptname}.XXXX"`
+
+if [ $? -ne 0 ]; then
+   echo "${scriptname}: Can't create temp directory, exiting..." 1>&2
+   exit 1
+fi
+
+key="${tmpdir}/key"
+p12="${tmpdir}/p12"
+
+if [ -z "${passphrase}" ]; then
+   # Request a passphrase
+  read -p "Enter a passphrase: " -s passphrase
+  echo ""
+fi
+
+# Convert PK8 to PEM KEY
+openssl pkcs8 -inform DER -nocrypt -in "${pk8}" -out "${key}"
+
+# Bundle CERT and KEY
+openssl pkcs12 -export -in "${cert}" -inkey "${key}" -out "${p12}" -password pass:"${passphrase}" -name "${alias}"
+
+# Print cert
+echo -n "Importing \"${alias}\" with "
+openssl x509 -noout -fingerprint -in "${cert}"
+
+# Import P12 in Keystore
+keytool -importkeystore -deststorepass "${passphrase}" -destkeystore "${keystore}" -srckeystore "${p12}" -srcstoretype PKCS12 -srcstorepass "${passphrase}" 
+
+# Cleanup
+cleanup

+ 1 - 0
app/keystore_wuyuqing_3128/password.txt

@@ -0,0 +1 @@
+111111

二进制
app/keystore_wuyuqing_3128/platform.pk8


+ 24 - 0
app/keystore_wuyuqing_3128/platform.x509.pem

@@ -0,0 +1,24 @@
+-----BEGIN CERTIFICATE-----
+MIID+zCCAuOgAwIBAgIJAP8GQTI8+VUSMA0GCSqGSIb3DQEBCwUAMIGUMQswCQYD
+VQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4g
+VmlldzEQMA4GA1UECgwHQW5kcm9pZDEQMA4GA1UECwwHQW5kcm9pZDEQMA4GA1UE
+AwwHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTAe
+Fw0xNDEyMjMwNjQzNDFaFw00MjA1MTAwNjQzNDFaMIGUMQswCQYDVQQGEwJVUzET
+MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G
+A1UECgwHQW5kcm9pZDEQMA4GA1UECwwHQW5kcm9pZDEQMA4GA1UEAwwHQW5kcm9p
+ZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTCCASAwDQYJKoZI
+hvcNAQEBBQADggENADCCAQgCggEBAKHY8Fl4XZzpJvgHoezYjhmKPvdq9DGYVc/X
+9NQO5oUlYIA/Ci5rzvljz13KbNve/KxuEu9HN8SzsLg9EBhghOko8JxEg7I8W6uP
+VOoRngNCMvXzjf6av77vxPqphlgq++Y4MIC+fiOxLd+gpYq0p6W7RWxEgrzLHnWi
+CX0dRmWDs+ey2t4f1WKzGoRQQS0Tn21CViThrVEe+zNwANnhErUcvoQB2m4/PQot
+uij7LZNccHJvUOUf5/4wIZd8JOgO3VLwzFO/HhrqUjafCvkpKTjW8oQmHLUz5m40
+ljETGEjqQ6AuAwmaeFT+Bwj1DUaYg+m7AzalJ2aAtHVX0FftRUkCAQOjUDBOMB0G
+A1UdDgQWBBQi+LgbyFfWSoWCbQ+NVDF4ZKTPCjAfBgNVHSMEGDAWgBQi+LgbyFfW
+SoWCbQ+NVDF4ZKTPCjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQBH
+1kIQlSBjXRMuQdaDLytr8ZaJXIN1HApg2QA8azYQXOS/B16gwm6tBfh1dL86LL/7
+w09oM9LZv8WwtQyFNjM97vvQvkaOGW/ubhrKOk3+8HTHkEx4n7H6tYGOLdpmWepD
+fBSEFuLwq6yqG6wZFdd7IKO+sPlCxqUpqg40YAb4WOwzDbiuJnswDftP3wIaaJPh
+li6OIjRKyd3Sgw1MtffHOy+WSwqHLkGNgH6GAgvZlvhPA/yim+rjnE9oKV5G6Pyg
+QK7kJJjS/LdeqxE7M7pNRYPhcLT7qhE7MiuBuyqwAMTTBoU8u3lTdOZwNErbRT5t
+SXkgVMffkfN7wBNqpSSY
+-----END CERTIFICATE-----

二进制
app/keystore_wuyuqing_3128/rk3128.jks


+ 7 - 0
app/keystore_wuyuqing_3128/rk3128_generate_key.sh

@@ -0,0 +1,7 @@
+#!/bin/sh
+# 转换系统签名命令
+./keytool-importkeypair -k rk3128.jks -p 111111 -pk8 platform.pk8 -cert platform.x509.pem -alias rk3128
+# rk3128.jks : 签名文件
+# 111111 : 签名文件密码
+# platform.pk8、platform.x509.pem : 系统签名文件
+# rk3128 : 签名文件别名

+ 139 - 0
app/keystore_wuyuqing_3128/rk3128_signapk/keytool-importkeypair

@@ -0,0 +1,139 @@
+#! /bin/bash
+#
+# This file is part of keytool-importkeypair.
+#
+# keytool-importkeypair is free software: you can redistribute it
+# and/or modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# keytool-importkeypair is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with keytool-importkeypair.  If not, see
+# <http://www.gnu.org/licenses/>.
+#
+
+DEFAULT_KEYSTORE=$HOME/.keystore
+keystore=$DEFAULT_KEYSTORE
+pk8=""
+cert=""
+alias=""
+passphrase=""
+tmpdir=""
+
+scriptname=`basename $0`
+
+usage() {
+cat << EOF
+usage: ${scriptname} [-k keystore] [-p storepass]
+-pk8 pk8 -cert cert -alias key_alias
+
+This script is used to import a key/certificate pair
+into a Java keystore.
+
+If a keystore is not specified then the key pair is imported into
+~/.keystore in the user's home directory.
+
+The passphrase can also be read from stdin.
+EOF
+}
+
+cleanup() {
+if [ ! -z "${tmpdir}" -a -d ${tmpdir} ]; then
+   rm -fr ${tmpdir}
+fi
+}
+
+while [ $# -gt 0 ]; do
+        case $1
+        in
+                -p | --passphrase | -passphrase)
+                        passphrase=$2
+                        shift 2
+        ;;
+                -h | --help)
+                        usage
+                        exit 0
+        ;;
+                -k | -keystore | --keystore)
+                        keystore=$2
+                        shift 2
+        ;;
+                -pk8 | --pk8 | -key | --key)
+                        pk8=$2
+                        shift 2
+        ;;
+                -cert | --cert | -pem | --pem)
+                        cert=$2
+                        shift 2
+        ;;
+                -a | -alias | --alias)
+                        alias=$2
+                        shift 2
+        ;;
+                *)
+                        echo "${scriptname}: Unknown option $1, exiting" 1>&2
+                        usage
+                        exit 1
+        ;;
+        esac
+done
+
+if [ -z "${pk8}" -o -z "${cert}" -o -z "${alias}" ]; then
+   echo "${scriptname}: Missing option, exiting..." 1>&2
+   usage
+   exit 1
+fi
+
+
+for f in "${pk8}" "${cert}"; do
+    if [ ! -f "$f" ]; then
+       echo "${scriptname}: Can't find file $f, exiting..." 1>&2
+       exit 1
+    fi
+done
+
+if [ ! -f "${keystore}" ]; then
+   storedir=`dirname "${keystore}"`
+   if [ ! -d "${storedir}" -o ! -w "${storedir}" ]; then
+      echo "${scriptname}: Can't access ${storedir}, exiting..." 1>&2
+      exit 1
+   fi
+fi
+
+# Create temp directory ofr key and pkcs12 bundle
+tmpdir=`mktemp -q -d "/tmp/${scriptname}.XXXX"`
+
+if [ $? -ne 0 ]; then
+   echo "${scriptname}: Can't create temp directory, exiting..." 1>&2
+   exit 1
+fi
+
+key="${tmpdir}/key"
+p12="${tmpdir}/p12"
+
+if [ -z "${passphrase}" ]; then
+   # Request a passphrase
+  read -p "Enter a passphrase: " -s passphrase
+  echo ""
+fi
+
+# Convert PK8 to PEM KEY
+openssl pkcs8 -inform DER -nocrypt -in "${pk8}" -out "${key}"
+
+# Bundle CERT and KEY
+openssl pkcs12 -export -in "${cert}" -inkey "${key}" -out "${p12}" -password pass:"${passphrase}" -name "${alias}"
+
+# Print cert
+echo -n "Importing \"${alias}\" with "
+openssl x509 -noout -fingerprint -in "${cert}"
+
+# Import P12 in Keystore
+keytool -importkeystore -deststorepass "${passphrase}" -destkeystore "${keystore}" -srckeystore "${p12}" -srcstoretype PKCS12 -srcstorepass "${passphrase}" 
+
+# Cleanup
+cleanup

二进制
app/keystore_wuyuqing_3128/rk3128_signapk/platform.pk8


+ 24 - 0
app/keystore_wuyuqing_3128/rk3128_signapk/platform.x509.pem

@@ -0,0 +1,24 @@
+-----BEGIN CERTIFICATE-----
+MIID+zCCAuOgAwIBAgIJAP8GQTI8+VUSMA0GCSqGSIb3DQEBCwUAMIGUMQswCQYD
+VQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4g
+VmlldzEQMA4GA1UECgwHQW5kcm9pZDEQMA4GA1UECwwHQW5kcm9pZDEQMA4GA1UE
+AwwHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTAe
+Fw0xNDEyMjMwNjQzNDFaFw00MjA1MTAwNjQzNDFaMIGUMQswCQYDVQQGEwJVUzET
+MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G
+A1UECgwHQW5kcm9pZDEQMA4GA1UECwwHQW5kcm9pZDEQMA4GA1UEAwwHQW5kcm9p
+ZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTCCASAwDQYJKoZI
+hvcNAQEBBQADggENADCCAQgCggEBAKHY8Fl4XZzpJvgHoezYjhmKPvdq9DGYVc/X
+9NQO5oUlYIA/Ci5rzvljz13KbNve/KxuEu9HN8SzsLg9EBhghOko8JxEg7I8W6uP
+VOoRngNCMvXzjf6av77vxPqphlgq++Y4MIC+fiOxLd+gpYq0p6W7RWxEgrzLHnWi
+CX0dRmWDs+ey2t4f1WKzGoRQQS0Tn21CViThrVEe+zNwANnhErUcvoQB2m4/PQot
+uij7LZNccHJvUOUf5/4wIZd8JOgO3VLwzFO/HhrqUjafCvkpKTjW8oQmHLUz5m40
+ljETGEjqQ6AuAwmaeFT+Bwj1DUaYg+m7AzalJ2aAtHVX0FftRUkCAQOjUDBOMB0G
+A1UdDgQWBBQi+LgbyFfWSoWCbQ+NVDF4ZKTPCjAfBgNVHSMEGDAWgBQi+LgbyFfW
+SoWCbQ+NVDF4ZKTPCjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQBH
+1kIQlSBjXRMuQdaDLytr8ZaJXIN1HApg2QA8azYQXOS/B16gwm6tBfh1dL86LL/7
+w09oM9LZv8WwtQyFNjM97vvQvkaOGW/ubhrKOk3+8HTHkEx4n7H6tYGOLdpmWepD
+fBSEFuLwq6yqG6wZFdd7IKO+sPlCxqUpqg40YAb4WOwzDbiuJnswDftP3wIaaJPh
+li6OIjRKyd3Sgw1MtffHOy+WSwqHLkGNgH6GAgvZlvhPA/yim+rjnE9oKV5G6Pyg
+QK7kJJjS/LdeqxE7M7pNRYPhcLT7qhE7MiuBuyqwAMTTBoU8u3lTdOZwNErbRT5t
+SXkgVMffkfN7wBNqpSSY
+-----END CERTIFICATE-----

二进制
app/keystore_wuyuqing_3128/rk3128_signapk/rk3128.jks


+ 7 - 0
app/keystore_wuyuqing_3128/rk3128_signapk/rk3128_generate_key.sh

@@ -0,0 +1,7 @@
+#!/bin/sh
+# 转换系统签名命令
+./keytool-importkeypair -k rk3128.jks -p 111111 -pk8 platform.pk8 -cert platform.x509.pem -alias rk3128
+# rk3128.jks : 签名文件
+# 111111 : 签名文件密码
+# platform.pk8、platform.x509.pem : 系统签名文件
+# rk3128 : 签名文件别名

二进制
app/keystore_wuyuqing_3128/rk3128_signapk/signapk.jar


二进制
app/keystore_wuyuqing_3128/signapk.jar


+ 2 - 2
build.gradle

@@ -47,12 +47,12 @@ buildscript {
     /**
     /**
      * APP版本码
      * APP版本码
      */
      */
-    ext.app_version_code = 68
+    ext.app_version_code = 69
 
 
     /**
     /**
      * APP版本号
      * APP版本号
      */
      */
-    ext.app_version = "1.1.50"
+    ext.app_version = "1.1.51"
 
 
     /**
     /**
      * 项目依赖库
      * 项目依赖库

+ 0 - 0
gradle/wrapper/gradle-wrapper.jar


+ 2 - 3
gradle/wrapper/gradle-wrapper.properties

@@ -1,7 +1,6 @@
-
-#Mon Mar 08 20:44:19 CST 2021
+#Fri Jan 22 17:49:32 CST 2021
 distributionBase=GRADLE_USER_HOME
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
 distributionPath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
 zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip

+ 32 - 18
home/src/main/code/com/wdkl/ncs/android/component/home/activity/WatchHome2Activity.kt

@@ -270,28 +270,35 @@ class WatchHome2Activity : BaseActivity<WatchHomeActivityPresenter, WatchActivit
             return
             return
         }
         }
 
 
-        if (Strings.isNullOrEmpty(data.ethIp)){
-            Thread(Runnable {
-                //连接TCP
-                if (TcpClient.getInstance().channel==null || !TcpClient.getInstance().channel.isActive) {
+//        if (Strings.isNullOrEmpty(data.ethIp)){
+//            Thread(Runnable {
+//                //连接TCP
+//                if (TcpClient.getInstance().channel==null || !TcpClient.getInstance().channel.isActive) {
+//                    TcpClient.getInstance().init(Constants.tcpServer, Constants.tcpPort, Constants.heartBeat,iTcpCallBack)
+//                }
+//                while (!(TcpClient.getInstance().channel==null || !TcpClient.getInstance().channel.isActive)) {
+//                    presenter.getDeviceVO(Constants.imei)
+//                    Thread.sleep(1000)
+//                }
+//            }).start()
+//            showMessage("获取设备数据中,请稍候")
+//            return
+//        } else {
+//            Thread(Runnable {
+//                //连接TCP
+//                if (TcpClient.getInstance().channel==null || !TcpClient.getInstance().channel.isActive) {
+//                    TcpClient.getInstance().init(Constants.tcpServer, Constants.tcpPort, Constants.heartBeat,iTcpCallBack)
+//                }
+//            }).start()
+//        }
+
+        if(!Strings.isNullOrEmpty(data.ethIp)&&!Strings.isNullOrEmpty(Constants.tcpServer)){
+            Thread(Runnable { //连接TCP
                     TcpClient.getInstance().init(Constants.tcpServer, Constants.tcpPort, Constants.heartBeat,iTcpCallBack)
                     TcpClient.getInstance().init(Constants.tcpServer, Constants.tcpPort, Constants.heartBeat,iTcpCallBack)
-                }
-                while (!(TcpClient.getInstance().channel==null || !TcpClient.getInstance().channel.isActive)) {
-                    presenter.getDeviceVO(Constants.imei)
-                    Thread.sleep(1000)
-                }
-            }).start()
-            showMessage("获取设备数据中,请稍候")
-            return
-        } else {
-            Thread(Runnable {
-                //连接TCP
-                if (TcpClient.getInstance().channel==null || !TcpClient.getInstance().channel.isActive) {
-                    TcpClient.getInstance().init(Constants.tcpServer, Constants.tcpPort, Constants.heartBeat,iTcpCallBack)
-                }
             }).start()
             }).start()
         }
         }
 
 
+
         loadingDialog.dismiss()
         loadingDialog.dismiss()
         watch_activity_register_layout.visibility = View.GONE
         watch_activity_register_layout.visibility = View.GONE
         watch_activity_home_linyout.visibility = View.VISIBLE
         watch_activity_home_linyout.visibility = View.VISIBLE
@@ -314,6 +321,13 @@ class WatchHome2Activity : BaseActivity<WatchHomeActivityPresenter, WatchActivit
         Constants.userName = data.memberName
         Constants.userName = data.memberName
         Constants.userRoleName = data.roleName
         Constants.userRoleName = data.roleName
 
 
+        if(!Strings.isNullOrEmpty(Constants.sipId)){ //拿到SIP账号后登陆webrtc
+            SocketManager.getInstance().unConnect()
+            AppTool.Time.delay(300, {
+                SocketManager.getInstance().connect(Urls.WS, Constants.sipId, 0)
+            })
+        }
+
         presenter.getAppVersion(Constants.partId, 7)
         presenter.getAppVersion(Constants.partId, 7)
 
 
         //保活守护进程
         //保活守护进程

+ 46 - 34
home/src/main/code/com/wdkl/ncs/android/component/home/activity/WebRTCVoipAudioActivity.kt

@@ -130,41 +130,26 @@ class WebRTCVoipAudioActivity : Activity(), View.OnClickListener, CallSessionCal
 
 
     fun createCallout(){
     fun createCallout(){
         Handler().postDelayed({
         Handler().postDelayed({
-            if (gEngineKit?.currentSession?.state != EnumType.CallState.Connected){
-                //showMessage("连接失败")
-                gEngineKit?.endCall()
-                val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
-                val voiceUtilTcpModel = VoiceUtil.voiceHandoff(Constants.deviceId, tcpModel.toId, interactionVO.id)
-                TcpClient.getInstance().sendMsg(voiceUtilTcpModel.toJson())
-                finish()
-            }
+//            Log.i(TAG,"session state:"+gEngineKit?.currentSession?.state+",userState:"+SocketManager.getInstance().userState)
+//            if (gEngineKit?.currentSession?.state != EnumType.CallState.Connected){
+//                //showMessage("连接失败")
+//
+//                gEngineKit?.endCall()
+//                val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
+//                val voiceUtilTcpModel = VoiceUtil.voiceHandoff(Constants.deviceId, tcpModel.toId, interactionVO.id)
+//                TcpClient.getInstance().sendMsg(voiceUtilTcpModel.toJson())
+//                finish()
+//            }
             call_duration_tv.base = SystemClock.elapsedRealtime()
             call_duration_tv.base = SystemClock.elapsedRealtime()
             call_duration_tv.start()
             call_duration_tv.start()
         }, 2900)
         }, 2900)
 
 
         val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
         val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
         if ((interactionVO.fromClerkId!=null && interactionVO.fromClerkId>=0) && interactionVO.fromDeviceId!=Constants.deviceId){
         if ((interactionVO.fromClerkId!=null && interactionVO.fromClerkId>=0) && interactionVO.fromDeviceId!=Constants.deviceId){
-            Handler().postDelayed({
-                val session = gEngineKit?.currentSession
-                if (session != null) {
-                    session.setSessionCallback(this)
-                    Log.d(TAG, "session = " + session + "; session.getState() = " + session.state)
-                    if (session.state == EnumType.CallState.Incoming || session.state == EnumType.CallState.Connected || session.state == EnumType.CallState.Connecting){
-                        session.joinHome(session.roomId)
-                        setAudioDeviceOut(session)
-                    } else {
-                        showMessage("对方忙线中")
-                        AppTool.Time.delay(800) {
-                            finish()
-                        }
-                    }
-                } else {
-                    showMessage("对方已挂断")
-                    AppTool.Time.delay(800) {
-                        finish()
-                    }
-                }
-            },1000)
+//            Handler().postDelayed({
+//
+//            },1000)
+            //等待准备接听事件分发后,加入房间
         } else {
         } else {
             if (createEnabled) {
             if (createEnabled) {
                 var room = UUID.randomUUID().toString() + System.currentTimeMillis()
                 var room = UUID.randomUUID().toString() + System.currentTimeMillis()
@@ -180,9 +165,7 @@ class WebRTCVoipAudioActivity : Activity(), View.OnClickListener, CallSessionCal
                 } else {
                 } else {
                     session.setSessionCallback(this)
                     session.setSessionCallback(this)
                     Log.d(TAG + "_peer", " 呼出状态: myId = ${session?.mMyId} , targetId = ${session?.mTargetId}, roomId = ${session?.roomId}, state = ${session?.state}, outCallResult = $outCallResult")
                     Log.d(TAG + "_peer", " 呼出状态: myId = ${session?.mMyId} , targetId = ${session?.mTargetId}, roomId = ${session?.roomId}, state = ${session?.state}, outCallResult = $outCallResult")
-                    if (outCallResult!!) {
-                        setAudioDeviceOut(session)
-                    } else if (session.state == EnumType.CallState.Connected || session.state == EnumType.CallState.Connecting) {
+                    if (outCallResult!!||session.state == EnumType.CallState.Connected || session.state == EnumType.CallState.Connecting) {
                         setAudioDeviceOut(session)
                         setAudioDeviceOut(session)
                     } else {
                     } else {
                         if (session.state != EnumType.CallState.Idle) {
                         if (session.state != EnumType.CallState.Idle) {
@@ -190,7 +173,7 @@ class WebRTCVoipAudioActivity : Activity(), View.OnClickListener, CallSessionCal
                         } else {
                         } else {
                             showMessage("通话失败,请重试")
                             showMessage("通话失败,请重试")
                         }
                         }
-                        AppTool.Time.delay(300) {
+                        AppTool.Time.delay(800) {
                             finish()
                             finish()
                         }
                         }
                     }
                     }
@@ -352,6 +335,28 @@ class WebRTCVoipAudioActivity : Activity(), View.OnClickListener, CallSessionCal
                     finish()
                     finish()
                 }
                 }
             }
             }
+        }else if(messageEvent.tag==Constants.INCOME_CALL_READY){ //已准备好接听电话,加入房间
+
+            val session = gEngineKit?.currentSession
+            if (session != null) {
+                session.setSessionCallback(this)
+                Log.d(TAG, "session = " + session + "; session.getState() = " + session.state)
+                if (session.state == EnumType.CallState.Incoming || session.state == EnumType.CallState.Connected || session.state == EnumType.CallState.Connecting){
+                    session.joinHome(session.roomId)
+                    setAudioDeviceOut(session)
+                } else {
+                    showMessage("对方忙线中")
+                    AppTool.Time.delay(800) {
+                        finish()
+                    }
+                }
+            } else {
+                showMessage("对方已挂断")
+                AppTool.Time.delay(800) {
+                    finish()
+                }
+            }
+
         }
         }
     }
     }
 
 
@@ -378,9 +383,16 @@ class WebRTCVoipAudioActivity : Activity(), View.OnClickListener, CallSessionCal
     }
     }
 
 
     override fun finish() {
     override fun finish() {
-        if (gEngineKit?.currentSession?.state != EnumType.CallState.Idle){
+        Log.i("_sfinish","gEngineKit?.currentSession?.state="+gEngineKit?.currentSession?.state)
+
+        val session = gEngineKit?.getCurrentSession()
+
+        Log.e("结束通话",""+session?.roomId)
+        if (session != null) {
+            session?.setCallState(EnumType.CallState.Idle)
             gEngineKit?.endCall()
             gEngineKit?.endCall()
         }
         }
+
         super.finish()
         super.finish()
     }
     }
 
 

+ 5 - 0
home/src/main/code/com/wdkl/ncs/android/component/home/activity/WebRTCVoipAudioRingingActivity.kt

@@ -16,6 +16,7 @@ import android.util.Log
 import android.view.KeyEvent
 import android.view.KeyEvent
 import android.view.View
 import android.view.View
 import com.google.gson.Gson
 import com.google.gson.Gson
+import com.wdkl.core.util.ActivityStackManager
 import com.wdkl.core.voip.AsyncPlayer
 import com.wdkl.core.voip.AsyncPlayer
 import com.wdkl.ncs.android.component.home.R
 import com.wdkl.ncs.android.component.home.R
 import com.wdkl.ncs.android.component.home.broadcast.MyMediaButtonReceiver
 import com.wdkl.ncs.android.component.home.broadcast.MyMediaButtonReceiver
@@ -157,6 +158,8 @@ class WebRTCVoipAudioRingingActivity : Activity(), View.OnClickListener {
         intent.putExtra("targetId", targetId)
         intent.putExtra("targetId", targetId)
         intent.putExtra("TcpModel", tcpModel)
         intent.putExtra("TcpModel", tcpModel)
         intent.putExtra(WebRTCVoipAudioActivity().ACTION, WebRTCVoipAudioActivity().CALLING)
         intent.putExtra(WebRTCVoipAudioActivity().ACTION, WebRTCVoipAudioActivity().CALLING)
+        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
+        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
         startActivity(intent)
         startActivity(intent)
         finish()
         finish()
     }
     }
@@ -214,6 +217,7 @@ class WebRTCVoipAudioRingingActivity : Activity(), View.OnClickListener {
             Log.i(TAG,"收到tcp"+tcpModel!!.action)
             Log.i(TAG,"收到tcp"+tcpModel!!.action)
             if (tcpModel.action === TcpAction.VoiceAction.CANCEL || tcpModel.action === TcpAction.VoiceAction.HANDOFF) {
             if (tcpModel.action === TcpAction.VoiceAction.CANCEL || tcpModel.action === TcpAction.VoiceAction.HANDOFF) {
 
 
+
                 val curInteractionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
                 val curInteractionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
                 if (curInteractionVO.id==interactionVO.id) {
                 if (curInteractionVO.id==interactionVO.id) {
                     //对方取消;
                     //对方取消;
@@ -224,6 +228,7 @@ class WebRTCVoipAudioRingingActivity : Activity(), View.OnClickListener {
 //                asyncPlayer.stop()
 //                asyncPlayer.stop()
                     finish()
                     finish()
                 }
                 }
+
             }
             }
         } else if (messageEvent.tag == Constants.EVENT_BLUETOOTH_ACCEPT_CALL){
         } else if (messageEvent.tag == Constants.EVENT_BLUETOOTH_ACCEPT_CALL){
             answerCall()
             answerCall()

+ 39 - 29
home/src/main/code/com/wdkl/ncs/android/component/home/service/WdKeepAliveService.kt

@@ -1,5 +1,6 @@
 package com.wdkl.ncs.android.component.home.service
 package com.wdkl.ncs.android.component.home.service
 
 
+import android.app.Activity
 import android.app.ActivityManager
 import android.app.ActivityManager
 import android.content.ComponentName
 import android.content.ComponentName
 import android.content.Context
 import android.content.Context
@@ -7,18 +8,22 @@ import android.content.Intent
 import android.os.Handler
 import android.os.Handler
 import android.os.IBinder
 import android.os.IBinder
 import android.os.Messenger
 import android.os.Messenger
+import android.text.TextUtils
 import android.util.Log
 import android.util.Log
+import com.alibaba.fastjson.JSON
 import com.google.common.base.Strings
 import com.google.common.base.Strings
 import com.google.gson.FieldNamingPolicy
 import com.google.gson.FieldNamingPolicy
 import com.google.gson.Gson
 import com.google.gson.Gson
 import com.google.gson.GsonBuilder
 import com.google.gson.GsonBuilder
 import com.wdkl.core.consts.Urls
 import com.wdkl.core.consts.Urls
 import com.wdkl.core.socket.SocketManager
 import com.wdkl.core.socket.SocketManager
+import com.wdkl.core.util.ActivityStackManager
 import com.wdkl.ncs.android.component.home.BuildConfig
 import com.wdkl.ncs.android.component.home.BuildConfig
 import com.wdkl.ncs.android.component.home.activity.*
 import com.wdkl.ncs.android.component.home.activity.*
 import com.wdkl.ncs.android.component.home.settingconfig.SettingConfig
 import com.wdkl.ncs.android.component.home.settingconfig.SettingConfig
 import com.wdkl.ncs.android.component.home.util.*
 import com.wdkl.ncs.android.component.home.util.*
 import com.wdkl.ncs.android.component.nursehome.common.Constants
 import com.wdkl.ncs.android.component.nursehome.common.Constants
+import com.wdkl.ncs.android.lib.utils.AppTool
 import com.wdkl.ncs.android.lib.utils.getJsonString
 import com.wdkl.ncs.android.lib.utils.getJsonString
 import com.wdkl.ncs.android.middleware.api.ApiManager
 import com.wdkl.ncs.android.middleware.api.ApiManager
 import com.wdkl.ncs.android.middleware.model.dos.PartSettingDO
 import com.wdkl.ncs.android.middleware.model.dos.PartSettingDO
@@ -40,9 +45,10 @@ import java.util.concurrent.ConcurrentLinkedQueue
 
 
 class WdKeepAliveService : AbsWorkService() {
 class WdKeepAliveService : AbsWorkService() {
     val TAG = "WdKeepAliveService"
     val TAG = "WdKeepAliveService"
+
     companion object instance {
     companion object instance {
-        var updateLastTime : Long = System.currentTimeMillis() / 1000
-        var sosQueue : ConcurrentLinkedQueue<TcpModel> = ConcurrentLinkedQueue<TcpModel>()
+        var updateLastTime: Long = System.currentTimeMillis() / 1000
+        var sosQueue: ConcurrentLinkedQueue<TcpModel> = ConcurrentLinkedQueue<TcpModel>()
 
 
         var mNewEventListActive = false
         var mNewEventListActive = false
     }
     }
@@ -91,21 +97,21 @@ class WdKeepAliveService : AbsWorkService() {
 
 
     @Subscribe(threadMode = ThreadMode.MAIN)
     @Subscribe(threadMode = ThreadMode.MAIN)
     fun onMoonEvent(messageEvent: MessageEvent) {
     fun onMoonEvent(messageEvent: MessageEvent) {
-        when(messageEvent.tag){
+        when (messageEvent.tag) {
             //拨出成功 || 有来电
             //拨出成功 || 有来电
-            1->{
+            1 -> {
                 Util.wakeUpAndUnlock(this)
                 Util.wakeUpAndUnlock(this)
 
 
                 SpeechUtil.getInstance().stopSpeak()
                 SpeechUtil.getInstance().stopSpeak()
 
 
                 val tcpModel = messageEvent.getMessage() as TcpModel
                 val tcpModel = messageEvent.getMessage() as TcpModel
-                if (tcpModel.type == TcpType.VOICE){
+                if (tcpModel.type == TcpType.VOICE) {
 //                var gson = GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create()
 //                var gson = GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create()
                     val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
                     val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
                     val intent = Intent()
                     val intent = Intent()
 
 
-                    if (tcpModel.action == TcpAction.VoiceAction.SUCCESS){  //拨出成功
-                        Log.i(TAG,"拨出成功 ${interactionVO.fromMemberName} ${interactionVO.id}")
+                    if (tcpModel.action == TcpAction.VoiceAction.SUCCESS) {  //拨出成功
+                        Log.i(TAG, "拨出成功 ${interactionVO.fromMemberName} ${interactionVO.id}")
                         DeviceChannel.calling = true;
                         DeviceChannel.calling = true;
                         intent.setClass(this, WebRTCVoipAudioActivity::class.java)
                         intent.setClass(this, WebRTCVoipAudioActivity::class.java)
                         intent.putExtra("targetId", interactionVO?.toSipId)
                         intent.putExtra("targetId", interactionVO?.toSipId)
@@ -113,8 +119,9 @@ class WdKeepAliveService : AbsWorkService() {
                         intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
                         intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
                         intent.putExtra(WebRTCVoipAudioActivity().ACTION, WebRTCVoipAudioActivity().CALL)
                         intent.putExtra(WebRTCVoipAudioActivity().ACTION, WebRTCVoipAudioActivity().CALL)
                         startActivity(intent)
                         startActivity(intent)
-                    } else if (tcpModel.action == TcpAction.VoiceAction.CALL){  //有来电
+                    } else if (tcpModel.action == TcpAction.VoiceAction.CALL) {  //有来电
                         DeviceChannel.calling = true;
                         DeviceChannel.calling = true;
+                        Log.i(TAG, "来电:" + JSON.toJSONString(interactionVO))
                         intent.setClass(this, WebRTCVoipAudioRingingActivity::class.java)
                         intent.setClass(this, WebRTCVoipAudioRingingActivity::class.java)
                         intent.putExtra("targetId", interactionVO?.fromSipId)
                         intent.putExtra("targetId", interactionVO?.fromSipId)
                         intent.putExtra("TcpModel", tcpModel)
                         intent.putExtra("TcpModel", tcpModel)
@@ -124,7 +131,7 @@ class WdKeepAliveService : AbsWorkService() {
                 }
                 }
             }
             }
             //事件与语音留言通道
             //事件与语音留言通道
-            3->{
+            3 -> {
                 if (!mNewEventListActive) {
                 if (!mNewEventListActive) {
                     Thread(Runnable {
                     Thread(Runnable {
                         while (DeviceChannel.calling) {
                         while (DeviceChannel.calling) {
@@ -146,7 +153,7 @@ class WdKeepAliveService : AbsWorkService() {
                 }
                 }
             }
             }
             //SOS通道
             //SOS通道
-            999->{
+            999 -> {
                 if (!mNewEventListActive) {
                 if (!mNewEventListActive) {
                     while (DeviceChannel.calling) {
                     while (DeviceChannel.calling) {
                         Thread.sleep(400)
                         Thread.sleep(400)
@@ -167,12 +174,12 @@ class WdKeepAliveService : AbsWorkService() {
                     }
                     }
                 }
                 }
             }
             }
-            Constants.EVENT_SOS_POLL->{
+            Constants.EVENT_SOS_POLL -> {
                 val tcpModel = sosQueue.poll()
                 val tcpModel = sosQueue.poll()
                 openSos(tcpModel)
                 openSos(tcpModel)
             }
             }
             //用户切换
             //用户切换
-            Constants.EVENT_USER_CHANGE->{
+            Constants.EVENT_USER_CHANGE -> {
                 Thread(Runnable {
                 Thread(Runnable {
                     while (DeviceChannel.calling) {    //通话中不处理,一直等待至结束
                     while (DeviceChannel.calling) {    //通话中不处理,一直等待至结束
                         Thread.sleep(400)
                         Thread.sleep(400)
@@ -183,7 +190,7 @@ class WdKeepAliveService : AbsWorkService() {
                 }).start()
                 }).start()
             }
             }
             //设备切换
             //设备切换
-            Constants.EVENT_DEVICE_CHANGE->{
+            Constants.EVENT_DEVICE_CHANGE -> {
                 Thread(Runnable {
                 Thread(Runnable {
                     while (DeviceChannel.calling) {    //通话中不处理,一直等待至结束
                     while (DeviceChannel.calling) {    //通话中不处理,一直等待至结束
                         Thread.sleep(400)
                         Thread.sleep(400)
@@ -198,18 +205,18 @@ class WdKeepAliveService : AbsWorkService() {
                 }).start()
                 }).start()
             }
             }
             //系统设置
             //系统设置
-            Constants.EVENT_DEVICE_SETTING->{
+            Constants.EVENT_DEVICE_SETTING -> {
                 Thread(Runnable {
                 Thread(Runnable {
                     var jsonStr = ""
                     var jsonStr = ""
-                    val partSettingDO = ApiManager.API_WatchDeviceInfoAndTCPMailingAddress.getDeviceSettingData(""+Constants.partId).map {
+                    val partSettingDO = ApiManager.API_WatchDeviceInfoAndTCPMailingAddress.getDeviceSettingData("" + Constants.partId).map {
                         jsonStr = it.getJsonString()
                         jsonStr = it.getJsonString()
                         val gson = GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create()
                         val gson = GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create()
                         val partSettingDO = gson.fromJson(jsonStr, PartSettingDO::class.java)
                         val partSettingDO = gson.fromJson(jsonStr, PartSettingDO::class.java)
                         return@map partSettingDO
                         return@map partSettingDO
                     }.blockingSingle()
                     }.blockingSingle()
 
 
-                    Log.i(TAG,"收到系统设置 " +  jsonStr)
-                    if(partSettingDO != null&&partSettingDO.transferDuration !=null&&partSettingDO.transferDurationLeader != null){
+                    Log.i(TAG, "收到系统设置 " + jsonStr)
+                    if (partSettingDO != null && partSettingDO.transferDuration != null && partSettingDO.transferDurationLeader != null) {
                         if (Constants.userRoleName != null) {
                         if (Constants.userRoleName != null) {
                             if (!Constants.userRoleName!!.contains("护士组长") && Constants.userRoleName!!.contains("护士")) {
                             if (!Constants.userRoleName!!.contains("护士组长") && Constants.userRoleName!!.contains("护士")) {
                                 SettingConfig.setCountdownTime(application, partSettingDO.transferDuration)
                                 SettingConfig.setCountdownTime(application, partSettingDO.transferDuration)
@@ -221,7 +228,7 @@ class WdKeepAliveService : AbsWorkService() {
                 }).start()
                 }).start()
             }
             }
             //APP升级
             //APP升级
-            Constants.EVENT_APP_UPDATE->{
+            Constants.EVENT_APP_UPDATE -> {
                 Thread(Runnable {
                 Thread(Runnable {
                     while (DeviceChannel.calling) {    //通话中不处理,一直等待至结束
                     while (DeviceChannel.calling) {    //通话中不处理,一直等待至结束
                         Thread.sleep(400)
                         Thread.sleep(400)
@@ -231,7 +238,7 @@ class WdKeepAliveService : AbsWorkService() {
                     Util.wakeUpAndUnlock(this)
                     Util.wakeUpAndUnlock(this)
                     val tcpModel = messageEvent.getMessage() as TcpModel
                     val tcpModel = messageEvent.getMessage() as TcpModel
                     if (tcpModel.action == TcpAction.DeviceAction.APP_UPDATE) {
                     if (tcpModel.action == TcpAction.DeviceAction.APP_UPDATE) {
-                        if ((System.currentTimeMillis() / 1000) - updateLastTime > 10){   //大于10秒可继续升级
+                        if ((System.currentTimeMillis() / 1000) - updateLastTime > 10) {   //大于10秒可继续升级
                             updateLastTime = System.currentTimeMillis() / 1000
                             updateLastTime = System.currentTimeMillis() / 1000
                             val intent = Intent()
                             val intent = Intent()
                             intent.setClass(this, AppUpdateActivity::class.java)
                             intent.setClass(this, AppUpdateActivity::class.java)
@@ -242,7 +249,7 @@ class WdKeepAliveService : AbsWorkService() {
                 }).start()
                 }).start()
             }
             }
             //网络断开
             //网络断开
-            Constants.EVENT_TCP_BREAK->{
+            Constants.EVENT_TCP_BREAK -> {
                 Util.wakeUpAndUnlock(this@WdKeepAliveService)
                 Util.wakeUpAndUnlock(this@WdKeepAliveService)
                 Log.w(TAG, "EVENT TCP BREAK")
                 Log.w(TAG, "EVENT TCP BREAK")
                 reConnect()
                 reConnect()
@@ -250,8 +257,8 @@ class WdKeepAliveService : AbsWorkService() {
         }
         }
     }
     }
 
 
-    fun openSos(tcpModel: TcpModel?){
-        if (tcpModel!=null) {
+    fun openSos(tcpModel: TcpModel?) {
+        if (tcpModel != null) {
             while (DeviceChannel.calling) {    //通话中不处理,一直等待至结束
             while (DeviceChannel.calling) {    //通话中不处理,一直等待至结束
                 Thread.sleep(400)
                 Thread.sleep(400)
             }
             }
@@ -292,27 +299,30 @@ class WdKeepAliveService : AbsWorkService() {
                 }
                 }
             }
             }
             checkNetStateTimer!!.schedule(checkNetStateTimerTask, 8000, Constants.heartBeat * 1000L)
             checkNetStateTimer!!.schedule(checkNetStateTimerTask, 8000, Constants.heartBeat * 1000L)
+//            checkNetStateTimer!!.schedule(checkNetStateTimerTask, 8000, 5000)
         }
         }
     }
     }
 
 
-    fun reConnect(){
+    fun reConnect() {
         if (NetHelper.getInstance().getNetworkState(this@WdKeepAliveService) != NetHelper.NETWORK_NONE) {
         if (NetHelper.getInstance().getNetworkState(this@WdKeepAliveService) != NetHelper.NETWORK_NONE) {
+            if (!TextUtils.isEmpty(Constants.sipId) && !SocketManager.getInstance().userState.equals(1)) { //webrtc 断线重连
+                SocketManager.getInstance().connect(Urls.WS, Constants.sipId, 0)
+            }
+
             if (!TcpClientHandler.getConnected()) {
             if (!TcpClientHandler.getConnected()) {
                 Log.w(TAG, "断网唤醒CPU")
                 Log.w(TAG, "断网唤醒CPU")
-                val wakeLock = Util.wakeUpAndUnlock(this@WdKeepAliveService)
+//                val wakeLock = Util.wakeUpAndUnlock(this@WdKeepAliveService)
                 if (TcpClient.getInstance().retryTimes < 30) {
                 if (TcpClient.getInstance().retryTimes < 30) {
                     if (TcpClient.getInstance().channel == null || TcpClient.getInstance().bootstrap == null) {
                     if (TcpClient.getInstance().channel == null || TcpClient.getInstance().bootstrap == null) {
-                        TcpClient.getInstance().init(Constants.tcpServer, Constants.tcpPort, Constants.heartBeat, iTcpCallBack)
-                    } else {
-                        TcpClient.getInstance().doConnect(iTcpCallBack)
+                        TcpClient.getInstance().doConnect(iTcpCallBack)//   TcpClient.getInstance().init(Constants.tcpServer, Constants.tcpPort, Constants.heartBeat, iTcpCallBack)
                     }
                     }
                 } else {
                 } else {
                     AppUtils.restartApp()
                     AppUtils.restartApp()
                 }
                 }
             } else {
             } else {
                 TcpClient.getInstance().sendMsg("0")
                 TcpClient.getInstance().sendMsg("0")
-                if (SocketManager.getInstance().connectFlag){
-                    EventBus.getDefault().post(MessageEvent(TcpModel(),Constants.EVENT_RTC_STATE))
+                if (SocketManager.getInstance().connectFlag) {
+                    EventBus.getDefault().post(MessageEvent(TcpModel(), Constants.EVENT_RTC_STATE))
                 } else {
                 } else {
                     iTcpCallBack.connected()
                     iTcpCallBack.connected()
                 }
                 }

+ 4 - 1
home/src/main/code/com/wdkl/ncs/android/component/home/util/TcpCallbackImpl.java

@@ -1,5 +1,6 @@
 package com.wdkl.ncs.android.component.home.util;
 package com.wdkl.ncs.android.component.home.util;
 
 
+import com.google.common.base.Strings;
 import com.wdkl.core.consts.Urls;
 import com.wdkl.core.consts.Urls;
 import com.wdkl.core.socket.SocketManager;
 import com.wdkl.core.socket.SocketManager;
 import com.wdkl.ncs.android.component.nursehome.common.Constants;
 import com.wdkl.ncs.android.component.nursehome.common.Constants;
@@ -10,6 +11,8 @@ import org.greenrobot.eventbus.EventBus;
 public class TcpCallbackImpl implements ITcpCallBack {
 public class TcpCallbackImpl implements ITcpCallBack {
     @Override
     @Override
     public void connected() {
     public void connected() {
-        SocketManager.getInstance().connect(Urls.WS, Constants.Companion.getSipId(), 0);
+        if (!Strings.isNullOrEmpty(Constants.Companion.getSipId()) && SocketManager.getInstance().getUserState()!=1) {
+            SocketManager.getInstance().connect(Urls.WS, Constants.Companion.getSipId(), 0);
+        }
     }
     }
 }
 }

+ 2 - 0
middleware/src/main/code/com/wdkl/ncs/android/middleware/common/Constants.kt

@@ -20,6 +20,8 @@ class Constants {
         var heartBeat: Int = 29    //tcp心跳
         var heartBeat: Int = 29    //tcp心跳
         var ttsState: Int = 0
         var ttsState: Int = 0
 
 
+        const val INCOME_CALL_READY:Int=0x16
+
         var sosActive = false
         var sosActive = false
 
 
         const val SYSTEM_REGISTERED = "SYSTEM_REGISTERED"
         const val SYSTEM_REGISTERED = "SYSTEM_REGISTERED"

+ 8 - 8
middleware/src/main/code/com/wdkl/ncs/android/middleware/tcp/TcpClient.java

@@ -30,7 +30,7 @@ public class TcpClient {
     //数据处理
     //数据处理
     TcpClientHandler tcpClientHandler = new TcpClientHandler();
     TcpClientHandler tcpClientHandler = new TcpClientHandler();
     //重试间隔
     //重试间隔
-    private Integer retrySeconds = 3;
+    private Integer retrySeconds = 5;
     //重试计数
     //重试计数
     public Integer retryTimes = 1;
     public Integer retryTimes = 1;
 
 
@@ -68,7 +68,7 @@ public class TcpClient {
                         // LengthFieldPrepender是一个编码器,主要是在响应字节数据前面添加字节长度字段
                         // LengthFieldPrepender是一个编码器,主要是在响应字节数据前面添加字节长度字段
                         socketChannel.pipeline().addLast(new LengthFieldPrepender(2));
                         socketChannel.pipeline().addLast(new LengthFieldPrepender(2));
                         //心跳包应当小于服务器间隔
                         //心跳包应当小于服务器间隔
-                        socketChannel.pipeline().addLast(new IdleStateHandler(hbSeconds+1, hbSeconds, 0, TimeUnit.SECONDS));
+                        socketChannel.pipeline().addLast(new IdleStateHandler(hbSeconds*2, hbSeconds, 0, TimeUnit.SECONDS));
                         socketChannel.pipeline().addLast(new StringDecoder(CharsetUtil.UTF_8));
                         socketChannel.pipeline().addLast(new StringDecoder(CharsetUtil.UTF_8));
                         socketChannel.pipeline().addLast(new StringEncoder(CharsetUtil.UTF_8));
                         socketChannel.pipeline().addLast(new StringEncoder(CharsetUtil.UTF_8));
                         socketChannel.pipeline().addLast(tcpClientHandler);
                         socketChannel.pipeline().addLast(tcpClientHandler);
@@ -83,7 +83,6 @@ public class TcpClient {
             System.out.println("TcpClient connecting");
             System.out.println("TcpClient connecting");
             return;
             return;
         }
         }
-
         System.out.println("TcpClient connect start");
         System.out.println("TcpClient connect start");
         ChannelFuture future = bootstrap.connect().addListener(new ChannelFutureListener() {
         ChannelFuture future = bootstrap.connect().addListener(new ChannelFutureListener() {
             @Override
             @Override
@@ -104,18 +103,19 @@ public class TcpClient {
                         public void run() {
                         public void run() {
                             if (retryTimes > 30) {
                             if (retryTimes > 30) {
                                 System.out.println("TcpClient 重试" + (retryTimes - 1) + "次,结束");
                                 System.out.println("TcpClient 重试" + (retryTimes - 1) + "次,结束");
-
+                                retryTimes = 1;
                                 channelFuture.channel().eventLoop().schedule(new Runnable() {
                                 channelFuture.channel().eventLoop().schedule(new Runnable() {
                                     @Override
                                     @Override
                                     public void run() {
                                     public void run() {
-                                        retryTimes = 0;
-                                        System.out.println("TcpClient 1分钟后 重试连接");
-                                        init(Constants.Companion.getTcpServer(),Constants.Companion.getTcpPort(),Constants.Companion.getHeartBeat(),iTcpCallBack);
+                                        System.out.println("TcpClient 10分钟后 重试连接");
+//                                        init(Constants.Companion.getTcpServer(),Constants.Companion.getTcpPort(),Constants.Companion.getHeartBeat(),iTcpCallBack);
+                                        doConnect(iTcpCallBack);
                                     }
                                     }
                                 },60*10, TimeUnit.SECONDS);
                                 },60*10, TimeUnit.SECONDS);
                             } else {
                             } else {
                                 retryTimes++;
                                 retryTimes++;
-                                init(Constants.Companion.getTcpServer(),Constants.Companion.getTcpPort(),Constants.Companion.getHeartBeat(),iTcpCallBack);
+                                doConnect(iTcpCallBack);
+//                                init(Constants.Companion.getTcpServer(),Constants.Companion.getTcpPort(),Constants.Companion.getHeartBeat(),iTcpCallBack);
                             }
                             }
                         }
                         }
                     }, retrySeconds, TimeUnit.SECONDS);
                     }, retrySeconds, TimeUnit.SECONDS);

+ 6 - 4
middleware/src/main/code/com/wdkl/ncs/android/middleware/tcp/TcpClientHandler.java

@@ -67,7 +67,8 @@ public class TcpClientHandler extends SimpleChannelInboundHandler<String> {
         this.ctx = null;
         this.ctx = null;
         Log.i(TAG, "TcpClientHandler 失去连接");
         Log.i(TAG, "TcpClientHandler 失去连接");
         EventBus.getDefault().post(new MessageEvent("net off",Constants.EVENT_TCP_BREAK));
         EventBus.getDefault().post(new MessageEvent("net off",Constants.EVENT_TCP_BREAK));
-        reConnect(ctx);
+        TcpClient.getInstance().doConnect(null);
+//        reConnect(ctx);
     }
     }
 
 
     //读取String消息
     //读取String消息
@@ -94,10 +95,11 @@ public class TcpClientHandler extends SimpleChannelInboundHandler<String> {
         if (evt instanceof IdleStateEvent){
         if (evt instanceof IdleStateEvent){
             IdleStateEvent event = (IdleStateEvent)evt;
             IdleStateEvent event = (IdleStateEvent)evt;
             if (event.state()== IdleState.WRITER_IDLE){
             if (event.state()== IdleState.WRITER_IDLE){
-                TcpClient.getInstance().sendMsg("0");
+//                TcpClient.getInstance().sendMsg("0");
+                ctx.writeAndFlush("0");
             }else if (event.state() == IdleState.READER_IDLE){
             }else if (event.state() == IdleState.READER_IDLE){
                 Log.i(TAG,"TcpClientHandler ===> pong from server failed");
                 Log.i(TAG,"TcpClientHandler ===> pong from server failed");
-                EventBus.getDefault().post(new MessageEvent("net off",Constants.EVENT_TCP_BREAK));
+//                EventBus.getDefault().post(new MessageEvent("net off",Constants.EVENT_TCP_BREAK));
                 ctx.close();
                 ctx.close();
             }
             }
         }
         }
@@ -105,7 +107,7 @@ public class TcpClientHandler extends SimpleChannelInboundHandler<String> {
 
 
     @Override
     @Override
     public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
     public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
-        ctx.close();
+//        ctx.close();
         connected = false;
         connected = false;
         Log.i(TAG,"TcpClientHandler 失去连接,错误引起 " + cause.getMessage());
         Log.i(TAG,"TcpClientHandler 失去连接,错误引起 " + cause.getMessage());
     }
     }

+ 8 - 7
rtc-chat/src/main/java/com/wdkl/skywebrtc/SkyEngineKit.java

@@ -69,10 +69,10 @@ public class SkyEngineKit {
             return false;
             return false;
         }
         }
         // 忙线中
         // 忙线中
-        if (mCurrentCallSession != null && mCurrentCallSession.getState() != EnumType.CallState.Idle) {
-            Log.i(TAG, "startCall error,currentCallSession is exist");
-            return false;
-        }
+//        if (mCurrentCallSession != null && mCurrentCallSession.getState() != EnumType.CallState.Idle) {
+//            Log.i(TAG, "startCall error,currentCallSession is exist,mCurrentCallSession.getState()="+mCurrentCallSession.getState());
+//            return false;
+//        }
         isAudioOnly = audioOnly;
         isAudioOnly = audioOnly;
         isOutGoing = true;
         isOutGoing = true;
         // 初始化会话
         // 初始化会话
@@ -83,7 +83,7 @@ public class SkyEngineKit {
         // 创建房间
         // 创建房间
         mCurrentCallSession.createHome(room, 2);
         mCurrentCallSession.createHome(room, 2);
 
 
-        return true;
+        return !TextUtils.isEmpty(mCurrentCallSession.getRoomId());
     }
     }
 
 
     // 接听电话
     // 接听电话
@@ -94,9 +94,9 @@ public class SkyEngineKit {
             return false;
             return false;
         }
         }
         // 忙线中
         // 忙线中
-        if (mCurrentCallSession != null && mCurrentCallSession.getState() != EnumType.CallState.Idle) {
+        if (mCurrentCallSession != null && mCurrentCallSession.getState() != EnumType.CallState.Idle&&mCurrentCallSession.getState() != EnumType.CallState.Connecting) {
             // 发送->忙线中...
             // 发送->忙线中...
-            Log.i(TAG, "startInCall busy,currentCallSession is exist,start sendBusyRefuse!");
+            Log.i(TAG, "startInCall busy,currentCallSession is exist,start sendBusyRefuse!:"+mCurrentCallSession.getState());
             mCurrentCallSession.sendBusyRefuse(room, targetId);
             mCurrentCallSession.sendBusyRefuse(room, targetId);
             return false;
             return false;
         }
         }
@@ -132,6 +132,7 @@ public class SkyEngineKit {
                 }
                 }
             } else {
             } else {
                 if (mCurrentCallSession.getState() == EnumType.CallState.Outgoing) {
                 if (mCurrentCallSession.getState() == EnumType.CallState.Outgoing) {
+
                     mCurrentCallSession.sendCancel();
                     mCurrentCallSession.sendCancel();
 //                    if (!TextUtils.isEmpty(mCurrentCallSession.getRoomId())){
 //                    if (!TextUtils.isEmpty(mCurrentCallSession.getRoomId())){
 //                        mCurrentCallSession.leave();
 //                        mCurrentCallSession.leave();