add sos receive page.
authorTrillGates <williamtrillgates@gmail.com>
Mon, 6 Sep 2021 07:40:00 +0000 (15:40 +0800)
committerTrillGates <williamtrillgates@gmail.com>
Mon, 6 Sep 2021 07:40:00 +0000 (15:40 +0800)
app/src/main/java/com/ic/protocolSrv/service/Deliver.java
app/src/main/java/com/ic/protocolSrv/utils/ProcessReceiver.java
app/src/main/java/com/ic/protocols/protocol_fzd.java
app/src/main/java/com/ic/view/SOSRecView.java [new file with mode: 0644]
app/src/main/res/layout/sos_receive_layout.xml [new file with mode: 0644]
app/src/main/res/mipmap-mdpi/sos_receive_icon.png [new file with mode: 0644]
local.properties

index e8dec33..e1ef690 100644 (file)
@@ -631,7 +631,6 @@ public class Deliver extends AbstractConnectionService {
                 ICLogger.d("send find device action...");
                 context.sendBroadcast(intent);
             }, 500);
-
             return true;
         } else if ("takephoto".equals(paramStringMessage.cmd())) {
 
@@ -671,6 +670,9 @@ public class Deliver extends AbstractConnectionService {
                     CoreService.getInstance().getConnection().DeliverCMDMessageToSystem("SentVoicePacket", "");
             }, recordtime * 1000);
             return true;
+        } else if ("sosReceive".equals(paramStringMessage.cmd())) {
+            //显示一个弹窗,然后只有按钮才可以退出
+            ICLogger.d("sosReceive ... show page...");
         }
         return false;
     }
index 854fe21..d30537f 100644 (file)
@@ -468,7 +468,6 @@ public class ProcessReceiver extends BroadcastReceiver {
                     this.screenOn(paramContext);
                 }
             } else if (paramIntent.hasExtra("findDev")) {
-
                 ICLogger.d("hasExtra(findDev)");
                 String findDevTxt = paramIntent.getStringExtra("findDev");
                 SharePreferenceUtil.getPrefBoolean(paramContext, "key_is_resume", false);
index 0f74e2e..518a281 100644 (file)
@@ -440,6 +440,7 @@ public class protocol_fzd {
         profile,//情景模式
         SOSON,//w100SOS 报警开关
         IP,//配置服务器地址
+        SOSREC,//服务器响应S0S消息
     }
 
     public static HashMap<CMD_TYPE, String> cmdMap = null;
@@ -1361,33 +1362,33 @@ public class protocol_fzd {
 
     public void handleHrtstart(Connection connection, Runtime runtime, String cmd, String data) {
         //[IC*334588000000156*len*hrtstart,x]
-            //  x 为上传间隔时间,单位秒,连续上传时最小时间不小于 300 秒,最大不超过 65535.
+        //  x 为上传间隔时间,单位秒,连续上传时最小时间不小于 300 秒,最大不超过 65535.
         //  实例:[IC*334588000000156*len*hrtstart,300]
         //终端会每隔 300 秒检测一次心率
         //
         //x 为 1 则代表终端心率单次上传,上传完后自动关闭。x 为 0 则代表终端心率上传关闭。
 
-        int testcycle=0;
-        try{
-            testcycle=Integer.parseInt(data);
-        }catch (Exception e){
+        int testcycle = 0;
+        try {
+            testcycle = Integer.parseInt(data);
+        } catch (Exception e) {
             ICLogger.e(e.getMessage());
-            testcycle=0;
+            testcycle = 0;
             ICLogger.i("Hrtstart format error!");
             return;
         }
         connection.send(hrtstart());
 
-        if(testcycle>=0 && testcycle<65535) {
-            ICLogger.i("收到服务器指令:设置心率周期 " + testcycle + "秒 相当于 "+testcycle/60 +"分钟" );
+        if (testcycle >= 0 && testcycle < 65535) {
+            ICLogger.i("收到服务器指令:设置心率周期 " + testcycle + "秒 相当于 " + testcycle / 60 + "分钟");
             try {
                 //发送重置PPGCycle的广播,会在CoreServer里面执行
-                CoreService.getInstance().setHeartRateDetectAlarm(testcycle/60);
+                CoreService.getInstance().setHeartRateDetectAlarm(testcycle / 60);
             } catch (Exception e) {
                 ICLogger.e(e.getMessage(), e);
             }
-        }else{
-            ICLogger.i("收到服务器指令:设置心率周期超限[0~65535] " + testcycle + "秒 相当于 "+testcycle/60 +"分钟" );
+        } else {
+            ICLogger.i("收到服务器指令:设置心率周期超限[0~65535] " + testcycle + "秒 相当于 " + testcycle / 60 + "分钟");
         }
 
     }
@@ -1406,21 +1407,21 @@ public class protocol_fzd {
         //    实例:[IC*334588000000156*0002*IP]
         //    说明:设置服务器地址和端口
 
-        String[] cmdlist=data.split(CMD_SPLIT);
-        if(cmdlist.length==2) {
+        String[] cmdlist = data.split(CMD_SPLIT);
+        if (cmdlist.length == 2) {
             connection.send(IP());
 
-                try {
-                    String ip = cmdlist[0];
-                    int port = Integer.valueOf(cmdlist[1].replace("#", ""));
-                    Config.setCustomServer(runtime.getContextProxy().context, true, ip, port);
-                    Config.loadServerSettings(runtime);
-                    CoreService.getInstance().disconnect_server();
-                    CoreService.getInstance().ReConnectToServer();
-                }catch (Exception e){
-                    ICLogger.e(e.getMessage(),e);
-                }
-        }else{
+            try {
+                String ip = cmdlist[0];
+                int port = Integer.valueOf(cmdlist[1].replace("#", ""));
+                Config.setCustomServer(runtime.getContextProxy().context, true, ip, port);
+                Config.loadServerSettings(runtime);
+                CoreService.getInstance().disconnect_server();
+                CoreService.getInstance().ReConnectToServer();
+            } catch (Exception e) {
+                ICLogger.e(e.getMessage(), e);
+            }
+        } else {
             ICLogger.i("IP format error!");
         }
 
@@ -1738,7 +1739,7 @@ public class protocol_fzd {
             case hrtstart:
                 ICLogger.i("收到服务器心率检测命令");
                 Config.testType = HeartRateOxygenTestType.JUST_HEART_RATE;
-                handleHrtstart(mConnection,mRuntime,cmd,data);
+                handleHrtstart(mConnection, mRuntime, cmd, data);
                 break;
             case bldstart:
                 handleBldstart(mConnection);
@@ -1929,12 +1930,16 @@ public class protocol_fzd {
                 break;
             case SOSON:
                 ICLogger.d("收到服务器设置的SOS开发消息..");
-                handleSOSON(cmd,data,mRuntime,mConnection);
+                handleSOSON(cmd, data, mRuntime, mConnection);
                 break;
             case IP:
                 //设置服务器IP
-                ICLogger.d("设置服务器 IP 为 "+data);
-                handleIP(mConnection, mRuntime, cmd,data);
+                ICLogger.d("设置服务器IP为 " + data);
+                handleIP(mConnection, mRuntime, cmd, data);
+                break;
+            case SOSREC:
+                ICLogger.d("服务器收到SOS消息...");
+                mConnection.DeliverCMDMessageToSystem("sosReceive", cmd);
                 break;
         }
         return ret;
@@ -2144,14 +2149,16 @@ public class protocol_fzd {
     private static final String BOOT_OFF_ACTION_OFF = "0";
     private static final String BOOT_OFF_ACTION_ON = "1";
     private static final long ONE_DAY = 86400000L;
+
     public static StringMessage SOSON() {
         return genFZDCMD(cmdMap.get(CMD_TYPE.SOSON));
     }
 
-    private void handleSOSON(String cmd, String data, Runtime mRuntime,Connection connection) {
+    private void handleSOSON(String cmd, String data, Runtime mRuntime, Connection connection) {
         connection.send(SOSON());
         handleSettings(CMD_TYPE.SOSON, data, mRuntime);
     }
+
     /**
      * 设置开关机时间
      * <p>
diff --git a/app/src/main/java/com/ic/view/SOSRecView.java b/app/src/main/java/com/ic/view/SOSRecView.java
new file mode 100644 (file)
index 0000000..e558fab
--- /dev/null
@@ -0,0 +1,53 @@
+package com.ic.view;
+
+import android.content.Context;
+import android.view.Gravity;
+import android.view.View;
+import android.view.WindowManager;
+
+import com.ic.protocolSrv.ICApplication;
+import com.ic.protocolSrv.R;
+import com.ic.protocolSrv.utils.ICLogger;
+
+public class SOSRecView {
+
+    private WindowManager windowManager;
+
+    private static SOSRecView sInstance;
+    private boolean isShow;
+    private View view;
+
+    public static SOSRecView getInstance() {
+        if (sInstance == null) {
+            sInstance = new SOSRecView();
+        }
+        return sInstance;
+    }
+
+    public void showMsgDialog() {
+        ICLogger.d("showMsgDialog..." + isShow);
+        if (isShow) {
+            return;
+        }
+        isShow = true;
+        Context context = ICApplication.sContext;
+        windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
+        //设置属性
+        WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
+        layoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
+        //这个是针对S123的屏幕,如果要适配其他,可以动态获取屏幕宽度,高度,再以百分比的形式计算即可。
+        layoutParams.height = WindowManager.LayoutParams.MATCH_PARENT;
+        layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
+        layoutParams.packageName = context.getPackageName();
+        layoutParams.gravity = Gravity.CENTER;
+        //加载布局
+        view = View.inflate(context, R.layout.find_device_layout, null);
+        windowManager.addView(view, layoutParams);
+    }
+
+    public void dismiss() {
+        windowManager.removeView(view);
+        sInstance = null;
+        windowManager = null;
+    }
+}
diff --git a/app/src/main/res/layout/sos_receive_layout.xml b/app/src/main/res/layout/sos_receive_layout.xml
new file mode 100644 (file)
index 0000000..0f26037
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@android:color/black">
+
+    <ImageView
+        android:id="@+id/w100_press_btn"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:src="@mipmap/sos_receive_icon"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
+
+
+</android.support.constraint.ConstraintLayout>
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-mdpi/sos_receive_icon.png b/app/src/main/res/mipmap-mdpi/sos_receive_icon.png
new file mode 100644 (file)
index 0000000..b6b6bf6
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/sos_receive_icon.png differ
index 7a80275..7420f9e 100644 (file)
@@ -4,5 +4,5 @@
 # Location of the SDK. This is only used by Gradle.\r
 # For customization when using a Version Control System, please read the\r
 # header note.\r
-#Fri Sep 03 11:56:39 CST 2021\r
-sdk.dir=C\:\\Users\\incar\\AppData\\Local\\Android\\Sdk\r
+#Mon Sep 06 15:08:10 CST 2021\r
+sdk.dir=E\:\\Android\\Sdk\r