add ap99 for ic protocol
authorTrillGates <williamtrillgates@gmail.com>
Tue, 28 Sep 2021 09:05:29 +0000 (17:05 +0800)
committerTrillGates <williamtrillgates@gmail.com>
Tue, 28 Sep 2021 09:05:29 +0000 (17:05 +0800)
app/src/main/java/com/enqualcomm/support/ICSmsManager.java
app/src/main/java/com/ic/protocols/protocolAPIHelper.java
app/src/main/java/com/ic/protocols/protocol_ic.java

index 6c05c56..d4376f0 100644 (file)
@@ -1199,7 +1199,6 @@ public class ICSmsManager extends BroadcastReceiver {
 
 
     private static void handle_test_cmd(Runtime runtime, Handler handler, String cmd, String arg) {
-
         ICLogger.i("receive test Cmd " + cmd + " arg " + arg);
         if (cmd.startsWith("testDialog,")) {
             String list[] = cmd.split(",");
@@ -1216,17 +1215,13 @@ public class ICSmsManager extends BroadcastReceiver {
             VibrateUtil.getInstance(runtime.getContextProxy().context).vibrateOn(true);
 
         } else if (cmd.startsWith("DeliverSMS")) {
-
             if (CoreService.getInstance() != null) {
                 Deliver.sendLocationMSG(protocolAPIHelper.getLBSLocationMSG(runtime));
             }
-
         } else if (cmd.startsWith("resetsim")) {
-
             if (CoreService.getInstance() != null) {
                 SimSignalUtil.send_at_to_reset_simcard(CoreService.getInstance().runtime);
             }
-
         } else if (cmd.startsWith("airplane")) {
             if (CoreService.getInstance() != null) {
                 SimSignalUtil.send_at_to_reset_simcard(runtime); //直接下此命令不能实现断网重连,所以干脆采用关闭网络再打开的方式。
@@ -1277,21 +1272,14 @@ public class ICSmsManager extends BroadcastReceiver {
 */
             }
         } else if (cmd.startsWith("testBT1")) {
-
             if (CoreService.getInstance() != null)
                 CoreService.getInstance().setBleScanAlarm(20);
-
-
         } else if (cmd.startsWith("BPLA,")) {
-
             String list[] = cmd.split(",");
             if (list.length == 2) {
                 LanguageUtils.changeLanguageByIndex(runtime.getContextProxy().context, list[1]);
             }
-
-
         } else if (cmd.startsWith("BPTE,")) {
-
             String list[] = cmd.split(",");
             if (list.length == 2) {
                 int freq = 0;
@@ -1306,13 +1294,15 @@ public class ICSmsManager extends BroadcastReceiver {
                 if (runtime.check_stat_do_temp_test())
                     TemperatureUtil.getInstance().doTempTestInThread(FROM_SERVER);
 
+
             }
         } else if (cmd.startsWith("BPXL")) {
-
             ICLogger.i("收到短信指令:测量心率。");
             if (CoreService.getInstance().getRuntime().check_stat_do_ppg_test())
                 HeartRateManager.getInstance().triggerPPGTest(FROM_SERVER);
-
+        } else if (cmd.startsWith("AP99")) {
+            //静默拨打号码
+            protocolAPIHelper.protocolic_handler.handleAP99(null, runtime, arg);
         }
     }
 }
\ No newline at end of file
index d370599..43007c5 100644 (file)
@@ -18,7 +18,7 @@ public class protocolAPIHelper {
 
     private static protocol_jiai protocoljiai_handler = null;
     private static protocol_beehome protocolbeehome_handler = null;
-    private static protocol_ic protocolic_handler = null;
+    public static protocol_ic protocolic_handler = null;
     private static protocol_fzd protocolfzd_handler = null;
     private static protocol_mqtt protocolmqtt_handler = null;
     private static protocol_anan protocolanan_handler = null;
@@ -1322,7 +1322,7 @@ public class protocolAPIHelper {
                 ret = null;
                 break;
             case Config.PROTOCOL_FZD:
-               // ret = protocolfzd_handler.AGREG();
+                // ret = protocolfzd_handler.AGREG();
                 break;
             case Config.PROTOCOL_MQTT:
                 ret = null;
index 08ae237..013e3a3 100644 (file)
@@ -1,14 +1,17 @@
 package com.ic.protocols;
 
+import android.Manifest;
 import android.content.ComponentName;
 import android.content.ContentResolver;
 import android.content.ContentValues;
 import android.content.Context;
 import android.content.Intent;
+import android.content.pm.PackageManager;
 import android.net.Uri;
 import android.os.Environment;
 import android.os.Handler;
 import android.os.HandlerThread;
+import android.support.v4.app.ActivityCompat;
 import android.text.TextUtils;
 
 import com.enqualcomm.support.Config;
@@ -2773,18 +2776,18 @@ public class protocol_ic {
     }
 
     public void handleBPBS(Connection connection, Runtime runtime, String cmd) {
-/***
- * IWBPBS,353456789012345,080835,150&151#
- * 说明:设置蓝牙扫描绑定的 major id
- * IW:标识符
- * BPBS : 命令字符
- * 353456789012345:IMEI号,设备唯一ID
- * 080835:指令流水号
- * majorIDs: 用 & 分隔的 多个 Majorid
- * 设备响应:     IWAPBS,080835, 1#
- * 080835:指令流水号
- * 1: 成功,0失败
- */
+        /***
+         * IWBPBS,353456789012345,080835,150&151#
+         * 说明:设置蓝牙扫描绑定的 major id
+         * IW:标识符
+         * BPBS : 命令字符
+         * 353456789012345:IMEI号,设备唯一ID
+         * 080835:指令流水号
+         * majorIDs: 用 & 分隔的 多个 Majorid
+         * 设备响应:     IWAPBS,080835, 1#
+         * 080835:指令流水号
+         * 1: 成功,0失败
+         */
         log("BPBS " + cmd);
         String[] cmdlist = cmd.split(CMDSPLIT);
         if (cmdlist.length == 4) {
@@ -3167,12 +3170,10 @@ public class protocol_ic {
                 handleBP84(cmd, mConnection);
                 ICLogger.i("收到服务器白名单命令");
                 break;
-
             case BP86:
                 //心率周期
                 handleBP86(cmd, mConnection, mRuntime);
                 mConnection.DeliverCMDMessageToSystem("AP86", cmd);//通知下面线程状态变化
-
                 break;
             case BP68: //绑定解绑
                 handleBP68(cmd, mConnection, mRuntime);
@@ -3187,7 +3188,6 @@ public class protocol_ic {
                 handleBP89(cmd, mConnection);
                 mConnection.DeliverCMDMessageToSystem("AP89", cmd);//通知下面线程状态变化
                 break;
-
             case BPTE: //设置测试体温
                 handleBPTE(cmd, mConnection, mRuntime);
                 mConnection.DeliverCMDMessageToSystem("APTE", cmd);//通知下面线程状态变化
@@ -3205,7 +3205,6 @@ public class protocol_ic {
                 ICLogger.i("收到服务器设置 心率血压血氧修正值BPX1");
                 mConnection.DeliverCMDMessageToSystem("APX1", cmd);//通知下面线程状态变化
                 break;
-
             case BPS4: //提醒设置(时间段) 主要为久坐设置提醒时长。
                 handleBPS4(cmd, mConnection, mRuntime);
                 ICLogger.i("收到 提醒设置(时间段)");
@@ -3216,7 +3215,6 @@ public class protocol_ic {
                 ICLogger.i(" 收到 进出围栏通知!");
                 mConnection.DeliverCMDMessageToSystem("APDE", cmd);//通知下面线程状态变化
                 break;
-
             case BPTU:
                 handleBPTU(cmd, mConnection);
                 ICLogger.i("收到服务器 图片语音 消息 BPTU");
@@ -3231,33 +3229,31 @@ public class protocol_ic {
                 ICLogger.i("睡眠数据上传完毕!");
                 mConnection.DeliverCMDMessageToSystem("APSL", cmd);//通知下面线程状态变化
                 break;
-
             case BPDH:
                 ICLogger.i("聆听");
                 handleBPDH(mConnection, mRuntime, cmd);
                 break;
-
             case BPTQ: //天气下发
                 handleBPTQ(mConnection, mRuntime, cmd);
                 break;
             case BPAT://剪断开关设定
                 handleBPAT(mConnection, mRuntime, cmd);
                 break;
-
             case BPBT://蓝牙扫描设置
                 handleBPBT(mConnection, mRuntime, cmd);
                 break;
             case BPBS://蓝牙扫描设置Majorlist
                 handleBPBS(mConnection, mRuntime, cmd);
                 break;
-
             case BP65://声音设置
                 handleBP65(mConnection, mRuntime, cmd);
                 break;
             case BP47://震动设置
                 handleBP47(mConnection, mRuntime, cmd);
                 break;
-
+            case AP99://电话监听:
+                handleAP99(mConnection, mRuntime, cmd);
+                break;
 
         }
 
@@ -3265,9 +3261,57 @@ public class protocol_ic {
 
     }
 
+    /**
+     * 电话监听
+     *
+     * @param mConnection
+     * @param mRuntime
+     * @param cmd
+     */
+    public void handleAP99(Connection mConnection, Runtime mRuntime, String cmd) {
+        //IWBP99,353456789012345,080835,133xxxxxxxx#
+        String[] split = cmd.split(CMDSPLIT);
+        if (split.length == 4) {
+            //回复IWAP99,080835,133xxxxxxxx#
+            String replace = cmd.replace(split[1] + ",", "");
+            ICLogger.d("replace ==> " + replace);
+            if (mConnection != null) {
+                mConnection.send(genStringMessage(cmdMap.get(CMD_TYPE.AP99), replace));
+            }
+            String targetPhone = split[3];
+            ICLogger.d("target number is == > " + targetPhone);
+            //进行拨号
+            if (targetPhone != null) {
+                //先设置标记位
+                Util.setSystemProperties("persist.sys.call.monitor", "true");
+                String isMonitor = Util.getSystemProperties("persist.sys.call.monitor");
+                ICLogger.d("isMonitor ==> " + isMonitor);
+                //拨打电话
+                doCall(targetPhone, mRuntime);
+            }
+        } else {
+            ICLogger.d("parse AP99 cmd error===> " + cmd);
+        }
+    }
 
-    public boolean handleCmd(CMD_TYPE type, String cmd, byte[] bytes) {
 
+    private void doCall(String data, Runtime runtime) {
+        //拨号
+        Intent intent = new Intent(Intent.ACTION_CALL);
+        ICLogger.d("do call number ==> " + data);
+        intent.setData(Uri.parse("tel:" + data));
+        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        if (ActivityCompat.checkSelfPermission(runtime.getContextProxy().context,
+                Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
+            ICLogger.d("no permission to call...");
+            Util.setSystemProperties("persist.sys.call.monitor", "false");
+            return;
+        }
+        runtime.getContextProxy().context.startActivity(intent);
+    }
+
+
+    public boolean handleCmd(CMD_TYPE type, String cmd, byte[] bytes) {
         //只有需要传递二进制数据的才需要这个函数,目前只有BP28需要
         boolean ret = true;
         ICLogger.i("handleCmd " + type.name() + " " + cmd + " bytelen=" + bytes.length);