فهرست منبع

增加后台控制设备重启和打开网络调试功能

weizhengliang 1 سال پیش
والد
کامیت
d33dbb8942

+ 8 - 0
android_host/src/main/h10_wke_1h/java/com/wdkl/ncs/android/component/nursehome/activity/NurseHomeActivity.kt

@@ -2148,6 +2148,14 @@ class NurseHomeActivity  : BaseActivity<NurseHomeActivityPresenter, ActivityNurs
                                 AppUpdateHelper.restartApp(activity)
                             }
                         }
+                    } else if (tcpModel.action == TcpAction.DeviceAction.OPEN_DEBUG) {
+                        //打开调试
+                        if (AppUtil.openNetworkDebug()) {
+                            showMessage("enable debug")
+                        }
+                    } else if (tcpModel.action == TcpAction.DeviceAction.REBOOT) {
+                        //设备重启
+                        AppUpdateHelper.reboot(activity)
                     }
                 } else if (tcpModel.type == TcpType.DATA) {
                     if (tcpModel.action == TcpAction.DataAction.INTERACTION) {

+ 1 - 32
android_host/src/main/h10_wke_1h/java/com/wdkl/ncs/android/component/nursehome/fragment/SystemSettingsFragment.kt

@@ -272,7 +272,7 @@ class SystemSettingsFragment:BaseFragment<SystemSettingsPresenter,FragmentSystem
 
             if (clickTimes > 9) {
                 if (Build.BOARD.equals("k37mv1_64_bsp") || Build.MODEL.equals("KT10-3F")) {
-                    openNetwrokDebug()
+                    AppUtil.openNetworkDebug()
                 } else {
                     showMessage("do not support debug")
                 }
@@ -293,37 +293,6 @@ class SystemSettingsFragment:BaseFragment<SystemSettingsPresenter,FragmentSystem
         tv_device_ip.setText(NetHelper.getInstance().localIP)
     }
 
-    //开启网络调试
-    private fun openNetwrokDebug() {
-        val commands = arrayListOf(
-            "/system/bin/sh",
-            "setprop service.adb.tcp.port 5555",
-            "stop adbd",
-            "start adbd"
-        )
-        try {
-            RunAsRoot(commands)
-            showMessage("start Debug")
-        } catch (e: IOException) {
-            e.printStackTrace()
-        }
-    }
-
-    private fun RunAsRoot(cmds: ArrayList<String>) {
-        val p = Runtime.getRuntime().exec("su")
-        val os = DataOutputStream(p.outputStream)
-        for (tmpCmd in cmds) {
-            os.writeBytes(
-                """
-            $tmpCmd
-            
-            """.trimIndent()
-            )
-        }
-        os.writeBytes("exit\n")
-        os.flush()
-    }
-
     /**
      *绑定事件
      */

+ 25 - 0
android_host/src/main/h10_wke_1h/java/com/wdkl/ncs/android/component/nursehome/util/AppUtil.java

@@ -5,6 +5,8 @@ import android.content.Context;
 import android.text.TextUtils;
 import android.util.Log;
 
+import com.wdkl.ncs.android.middleware.common.Constants;
+
 import java.io.DataOutputStream;
 import java.io.IOException;
 import java.util.Calendar;
@@ -93,4 +95,27 @@ public class AppUtil {
         alarmManager.setTimeZone(timeZone);
         alarmManager.setTime(timeMills);
     }
+
+    //开启网络调试
+    public static boolean openNetworkDebug() {
+        try {
+            Process process = Runtime.getRuntime().exec("su");
+            if (null == process) {
+                return false;
+            }
+            DataOutputStream os = new DataOutputStream(process.getOutputStream());
+            os.writeBytes("setprop service.adb.tcp.port 5555\n");
+            os.writeBytes("stop adbd\n");
+            os.writeBytes("start adbd\n");
+            os.writeBytes("exit\n");
+            os.flush();
+            Constants.Companion.setDEBUG(true);
+
+            return true;
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+
+        return false;
+    }
 }

+ 8 - 0
android_host/src/main/h10_z3128_1h/java/com/wdkl/ncs/android/component/nursehome/activity/NurseHomeActivity.kt

@@ -1699,6 +1699,14 @@ class NurseHomeActivity  : BaseActivity<NurseHomeActivityPresenter, ActivityNurs
                                 AppUpdateHelper.restartApp(activity)
                             }
                         }
+                    } else if (tcpModel.action == TcpAction.DeviceAction.OPEN_DEBUG) {
+                        //打开调试
+                        if (AppUtil.openNetworkDebug()) {
+                            showMessage("enable debug")
+                        }
+                    } else if (tcpModel.action == TcpAction.DeviceAction.REBOOT) {
+                        //设备重启
+                        AppUpdateHelper.reboot(activity)
                     }
                 } else if (tcpModel.type == TcpType.DATA) {
                     if (tcpModel.action == TcpAction.DataAction.INTERACTION) {

+ 1 - 33
android_host/src/main/h10_z3128_1h/java/com/wdkl/ncs/android/component/nursehome/fragment/SystemSettingsFragment.kt

@@ -266,7 +266,7 @@ class SystemSettingsFragment:BaseFragment<SystemSettingsPresenter,FragmentSystem
             }
 
             if (clickTimes > 9) {
-                openNetwrokDebug()
+                AppUtil.openNetworkDebug()
                 clickTimes = 1
             }
             clickTime = time
@@ -283,38 +283,6 @@ class SystemSettingsFragment:BaseFragment<SystemSettingsPresenter,FragmentSystem
         spinner_call_stay_time.setSelection(originTime)
     }
 
-    //开启网络调试
-    private fun openNetwrokDebug() {
-        val commands = arrayListOf(
-            "/system/bin/sh",
-            "setprop service.adb.tcp.port 5555",
-            "stop adbd",
-            "start adbd"
-        )
-        try {
-            RunAsRoot(commands)
-            showMessage("start Debug")
-        } catch (e: IOException) {
-            e.printStackTrace()
-        }
-    }
-
-    private fun RunAsRoot(cmds: ArrayList<String>) {
-        val p = Runtime.getRuntime().exec("su")
-        val os = DataOutputStream(p.outputStream)
-        for (tmpCmd in cmds) {
-            os.writeBytes(
-                """
-            $tmpCmd
-            
-            """.trimIndent()
-            )
-        }
-        os.writeBytes("exit\n")
-        os.flush()
-    }
-
-
     /**
      *绑定事件
      */

+ 25 - 0
android_host/src/main/h10_z3128_1h/java/com/wdkl/ncs/android/component/nursehome/util/AppUtil.java

@@ -5,6 +5,8 @@ import android.content.Context;
 import android.text.TextUtils;
 import android.util.Log;
 
+import com.wdkl.ncs.android.middleware.common.Constants;
+
 import java.io.DataOutputStream;
 import java.io.IOException;
 import java.io.PrintWriter;
@@ -112,4 +114,27 @@ public class AppUtil {
         }
     }
 
+    //开启网络调试
+    public static boolean openNetworkDebug() {
+        try {
+            Process process = Runtime.getRuntime().exec("su");
+            if (null == process) {
+                return false;
+            }
+            DataOutputStream os = new DataOutputStream(process.getOutputStream());
+            os.writeBytes("setprop service.adb.tcp.port 5555\n");
+            os.writeBytes("stop adbd\n");
+            os.writeBytes("start adbd\n");
+            os.writeBytes("exit\n");
+            os.flush();
+            Constants.Companion.setDEBUG(true);
+
+            return true;
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+
+        return false;
+    }
+
 }

+ 270 - 9
middleware/src/main/code/com/wdkl/ncs/android/middleware/tcp/enums/TcpAction.java

@@ -14,6 +14,7 @@ public interface TcpAction {
     String getDescription();
 
     enum CallbackAction implements TcpAction {
+        ACK("反馈"),
         SUCCESS("同步"),
         FAILED("失败"),
         NO_MATCH("没有匹配");
@@ -88,7 +89,7 @@ public interface TcpAction {
         HANDOFF("挂断"),
         CANCEL("取消"),
         PCALLING("已经通话中"),
-        VOICE_OFF("通话被接听"),
+        VOICE_OFF("通话被其他设备处理"),
         RS485CALL("485界面发起呼叫"),
         RS485CANCEL("485界面呼叫取消"),
         RS485CANCEL_BY_DOOR("485门口机取消房间内的呼叫"),
@@ -104,6 +105,7 @@ public interface TcpAction {
         GAINED("呼叫被应答"),
         HCALL("手柄呼叫"),
         HRESPONSE("响应手柄"),
+        HRESPONSED("响应过手柄了"),
         NO_MATCH("没有匹配");
 
 
@@ -145,6 +147,7 @@ public interface TcpAction {
         CANCEL("取消"),
         SUCCESS("呼叫成功"),
         FAILED("呼叫失败"),
+        VIDEO_OFF("视频被其他设备处理"),
         NO_MATCH("没有匹配");
 
         private final String description;
@@ -174,8 +177,9 @@ public interface TcpAction {
 
 
     enum SOSAction implements TcpAction {
-        CALL("紧急呼叫"),
-        CANCEL("取消"),
+        CALL("紧急呼叫"),   //1
+        CANCEL("取消"),   //1
+        CANCELED("已取消"),    //1
         TRANSFER("转接"),
         ALARM_TEST("测试报警"),
         ALARM_INTRUSION("侵入报警"),
@@ -192,12 +196,16 @@ public interface TcpAction {
         ALARM_WATER_OVERFLOW("浸水报警"),
         ALARM_LOW_VOLTAGE("低电压报警"),
         ALARM_TEMPERATURE("温度报警"),
-        ALARM_FALL("跌报警"),
+        ALARM_FALL("跌报警"),
         ALARM_VITAL("体征报警"),
         AlARM_BUTTON("紧急按钮"),
-        ALARM_FALL_RADAR("跌报警"),
+        ALARM_FALL_RADAR("跌报警"),
         ALARM_INFUSION_RADAR("输液报警"),
-        ROOM_CALL("房间紧急呼叫"),
+        ROOM_CALL("房间紧急呼叫"),    //1
+        OTHER_CALL("其他紧急呼叫"),   //1
+        RECEIVED("客户端收到确认"),
+        // 当设备在科室级时用这个PART_USER_CALL,比如:用户手环
+        PART_USER_CALL("用户紧急呼叫"),   //
         NO_MATCH("没有匹配");
 
         private final String description;
@@ -321,7 +329,9 @@ public interface TcpAction {
     }
 
     enum DeviceAction implements TcpAction {
-        RESTART("重启"),
+        RESTART("重启APP"),
+        REBOOT("重启机器"),
+        OPEN_DEBUG("打开网络调试"),
         CONNECT("连接"),
         APP_UPDATE("APP更新"),
         DEVICE_REFRESH("设备刷新"),
@@ -329,6 +339,8 @@ public interface TcpAction {
         DEVICE_CHANGE("设备更换"),
         USER_CHANGE("用户绑定"),
         SERVER_CHANGE("设备ip地址更换"),
+        S485_POWER_RESET("485控制版复位电路"),
+        S485_POWER_RESET_SUCCESS("485控制版复位电路成功"),
         NO_MATCH("没有匹配");
 
         private final String description;
@@ -357,13 +369,14 @@ public interface TcpAction {
 
     enum EventAction implements TcpAction {
         KEY_CLICK("按键事件"),
-        RESPONSE("已响应"),
+        RESPONSE("响应"),
+        RESPONSED("已响应"),
         RECEIVED("接收端收到确认"),
         CANCEL("取消"),
         CANCEL_CONFIRM("接收端确认收到取消"),
+        NO_TARGET("没有目标设备"),
         COMPLETED("完成"),
         NO_MATCH("没有匹配");
-
         private final String description;
         EventAction(String description){
             this.description = description;
@@ -396,6 +409,8 @@ public interface TcpAction {
         SOS_CANCEL("取消"),
         NURSING("护理"),
         NURSING_END("护理结束"),
+        SHOW("显示"),
+        CLEAR("清除"),
         NO_MATCH("没有匹配");
 
         private final String description;
@@ -427,6 +442,7 @@ public interface TcpAction {
     enum DataAction implements TcpAction {
         REFRESH("刷新数据"),
         INTERACTION("刷新交互列表"),
+        REMIND("提醒消息"),
         NO_MATCH("没有匹配");
 
         private final String description;
@@ -456,6 +472,8 @@ public interface TcpAction {
     enum BroadcastAction implements TcpAction {
         START("开始"),
         STOP("停止"),
+        SHOUT_START("喊话开始"),
+        SHOUT_STOP("喊话结束"),
         NO_MATCH("没有匹配");
 
         private final String description;
@@ -578,4 +596,247 @@ public interface TcpAction {
             return userOptionEnum == null ? NO_MATCH :userOptionEnum;
         }
     }
+
+    /**
+     * 433相关action
+      */
+    enum S433Action implements TcpAction {
+        CALL("呼叫"),
+        SOS_CALL("紧急呼叫"),
+        CANCEL("取消"),
+        SYNC_TIME("同步时间"),
+        DATA("同步数据"),
+        EXIST("调试"),
+        ACK("返回"),
+        NO_MATCH("没有匹配");
+
+        private final String description;
+        S433Action(String description){
+            this.description = description;
+        }
+        public String getDescription() {
+            return description;
+        }
+
+        public String getName(){
+            return this.name();
+        }
+
+        private final static Map<String , S433Action> ENUM_MAP = new HashMap<String, S433Action>();
+        static {
+            for(S433Action v : values()) {
+                ENUM_MAP.put(v.toString() , v);
+            }
+        }
+        public static S433Action fromString(String v) {
+            S433Action userOptionEnum = ENUM_MAP.get(v);
+            return userOptionEnum == null ? NO_MATCH :userOptionEnum;
+        }
+    }
+
+    enum SignInAction implements TcpAction{
+        SIGN_IN("发起签到"),
+        SIGN_IN_SUCCESS("签到成功"),
+        SIGN_IN_FAILED("签到失败"),
+        NO_MATCH("没有匹配");
+
+        private final String description;
+        SignInAction(String description){
+            this.description = description;
+        }
+        public String getDescription() {
+            return description;
+        }
+
+        public String getName(){
+            return this.name();
+        }
+
+        private final static Map<String , SignInAction> ENUM_MAP = new HashMap<String, SignInAction>();
+        static {
+            for(SignInAction v : values()) {
+                ENUM_MAP.put(v.toString() , v);
+            }
+        }
+        public static SignInAction fromString(String v) {
+            SignInAction signInAction = ENUM_MAP.get(v);
+            return signInAction == null ? NO_MATCH :signInAction;
+        }
+    }
+
+
+    enum PositionAction implements TcpAction{
+        POSITION_START("定位开始"),
+        POSITION_END("结束定位"),
+        NO_MATCH("没有匹配");
+
+        private final String description;
+        PositionAction(String description){
+            this.description = description;
+        }
+        public String getDescription() {
+            return description;
+        }
+
+        public String getName(){
+            return this.name();
+        }
+
+        private final static Map<String , PositionAction> ENUM_MAP = new HashMap<String, PositionAction>();
+        static {
+            for(PositionAction v : values()) {
+                ENUM_MAP.put(v.toString() , v);
+            }
+        }
+        public static PositionAction fromString(String v) {
+            PositionAction positionAction = ENUM_MAP.get(v);
+            return positionAction == null ? NO_MATCH : positionAction;
+        }
+    }
+
+    enum BlueCodeAction implements TcpAction{
+        CALL("呼叫"),
+        SUCCESS("成功"),
+        RESPONSE("响应"),
+        RESPONDED("已响应"),
+        NO_MATCH("没有匹配");
+
+        private final String description;
+        BlueCodeAction(String description){
+            this.description = description;
+        }
+        public String getDescription() {
+            return description;
+        }
+        public String getName(){
+            return this.name();
+        }
+
+        private final static Map<String , BlueCodeAction> ENUM_MAP = new HashMap<String, BlueCodeAction>();
+        static {
+            for(BlueCodeAction v : values()) {
+                ENUM_MAP.put(v.toString() , v);
+            }
+        }
+        public static BlueCodeAction fromString(String v) {
+            return ENUM_MAP.get(v);
+        }
+    }
+
+
+    enum CountdownAction implements TcpAction {
+        START("倒计时开始"),
+        END("倒计时结束"),
+        CANCEL("倒计时取消"),
+        NO_MATCH("没有匹配");
+
+        private final String description;
+        CountdownAction(String description){
+            this.description = description;
+        }
+        public String getDescription() {
+            return description;
+        }
+
+        public String getName(){
+            return this.name();
+        }
+
+        private final static Map<String , CountdownAction> ENUM_MAP = new HashMap<String, CountdownAction>();
+        static {
+            for(CountdownAction v : values()) {
+                ENUM_MAP.put(v.toString() , v);
+            }
+        }
+        public static CountdownAction fromString(String v) {
+            return ENUM_MAP.get(v);
+        }
+    }
+
+
+    enum RoomCheckAction implements TcpAction {
+        START("巡房开始"),
+        END("巡房结束"),
+        NO_MATCH("没有匹配");
+
+        private final String description;
+        RoomCheckAction(String description){
+            this.description = description;
+        }
+        public String getDescription() {
+            return description;
+        }
+
+        public String getName(){
+            return this.name();
+        }
+
+        private final static Map<String , RoomCheckAction> ENUM_MAP = new HashMap<String, RoomCheckAction>();
+        static {
+            for(RoomCheckAction v : values()) {
+                ENUM_MAP.put(v.toString() , v);
+            }
+        }
+        public static RoomCheckAction fromString(String v) {
+            return ENUM_MAP.get(v);
+        }
+    }
+
+
+    enum ScreenTipAction implements TcpAction {
+        START("提示语开始"),
+        QUIT("提示语退出"),
+        NO_MATCH("没有匹配");
+
+        private final String description;
+        ScreenTipAction(String description){
+            this.description = description;
+        }
+        public String getDescription() {
+            return description;
+        }
+
+        public String getName(){
+            return this.name();
+        }
+
+        private final static Map<String , ScreenTipAction> ENUM_MAP = new HashMap<String, ScreenTipAction>();
+        static {
+            for(ScreenTipAction v : values()) {
+                ENUM_MAP.put(v.toString() , v);
+            }
+        }
+        public static ScreenTipAction fromString(String v) {
+            return ENUM_MAP.get(v);
+        }
+    }
+
+    enum AuthAction implements TcpAction {
+        LOGIN("登录"),
+        LOGOUT("退出"),
+        NO_MATCH("没有匹配");
+
+        private final String description;
+        AuthAction(String description){
+            this.description = description;
+        }
+        public String getDescription() {
+            return description;
+        }
+
+        public String getName(){
+            return this.name();
+        }
+
+        private final static Map<String , AuthAction> ENUM_MAP = new HashMap<String, AuthAction>();
+        static {
+            for(AuthAction v : values()) {
+                ENUM_MAP.put(v.toString() , v);
+            }
+        }
+        public static AuthAction fromString(String v) {
+            return ENUM_MAP.get(v);
+        }
+    }
+
 }