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(",");
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); //直接下此命令不能实现断网重连,所以干脆采用关闭网络再打开的方式。
*/
}
} 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;
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
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;
}
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) {
handleBP84(cmd, mConnection);
ICLogger.i("收到服务器白名单命令");
break;
-
case BP86:
//心率周期
handleBP86(cmd, mConnection, mRuntime);
mConnection.DeliverCMDMessageToSystem("AP86", cmd);//通知下面线程状态变化
-
break;
case BP68: //绑定解绑
handleBP68(cmd, mConnection, mRuntime);
handleBP89(cmd, mConnection);
mConnection.DeliverCMDMessageToSystem("AP89", cmd);//通知下面线程状态变化
break;
-
case BPTE: //设置测试体温
handleBPTE(cmd, mConnection, mRuntime);
mConnection.DeliverCMDMessageToSystem("APTE", cmd);//通知下面线程状态变化
ICLogger.i("收到服务器设置 心率血压血氧修正值BPX1");
mConnection.DeliverCMDMessageToSystem("APX1", cmd);//通知下面线程状态变化
break;
-
case BPS4: //提醒设置(时间段) 主要为久坐设置提醒时长。
handleBPS4(cmd, mConnection, mRuntime);
ICLogger.i("收到 提醒设置(时间段)");
ICLogger.i(" 收到 进出围栏通知!");
mConnection.DeliverCMDMessageToSystem("APDE", cmd);//通知下面线程状态变化
break;
-
case BPTU:
handleBPTU(cmd, mConnection);
ICLogger.i("收到服务器 图片语音 消息 BPTU");
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;
}
}
+ /**
+ * 电话监听
+ *
+ * @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);