From: TrillGates Date: Tue, 28 Dec 2021 12:17:19 +0000 (+0800) Subject: 监听微聊起来的广播,并且去请求数据 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=dbf53f1b291d8dde2024485a01e2d21599dc9763;p=icsupport.git 监听微聊起来的广播,并且去请求数据 --- diff --git a/app/release/ICSer_V942_2112222059_release.apk b/app/release/ICSer_V943_2112282014_release.apk similarity index 77% rename from app/release/ICSer_V942_2112222059_release.apk rename to app/release/ICSer_V943_2112282014_release.apk index 21d481e5..a98526a8 100644 Binary files a/app/release/ICSer_V942_2112222059_release.apk and b/app/release/ICSer_V943_2112282014_release.apk differ diff --git a/app/release/output.json b/app/release/output.json index 9f9fef83..8fd67078 100644 --- a/app/release/output.json +++ b/app/release/output.json @@ -1 +1 @@ -[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":942,"versionName":"2112222059","enabled":true,"outputFile":"ICSer_V942_2112222059_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V942_2112222059_release.apk","properties":{}}] \ No newline at end of file +[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":943,"versionName":"2112282014","enabled":true,"outputFile":"ICSer_V943_2112282014_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V943_2112282014_release.apk","properties":{}}] \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 3a2d053b..263ac4f7 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -110,7 +110,8 @@ - @@ -184,6 +185,7 @@ + diff --git a/app/src/main/java/com/enqualcomm/support/Config.java b/app/src/main/java/com/enqualcomm/support/Config.java index eb928d70..182960fd 100644 --- a/app/src/main/java/com/enqualcomm/support/Config.java +++ b/app/src/main/java/com/enqualcomm/support/Config.java @@ -963,7 +963,8 @@ public class Config { enableDataRoaming = true; Config.GpsForceMoveCheck = false; //即爱对gps不进行运动检测,此变量专门为了给其他协议进行强制运动检测用的。 - } else if (Config.custom_name.equals("l005")) { + } else if (Config.custom_name.equals("l005") || + Config.custom_name.equals("PT460")) { ConfigAlarm(Runtime.AlarmType.ALARM_CUTOFF, true); ConfigAlarm(Runtime.AlarmType.ALARM_ILLEGAL_CUTOFF, true); ConfigAlarm(Runtime.AlarmType.ALARM_LOCK_WATCH, true); diff --git a/app/src/main/java/com/enqualcomm/support/CoreService.java b/app/src/main/java/com/enqualcomm/support/CoreService.java index 2f8da328..7c717ee5 100644 --- a/app/src/main/java/com/enqualcomm/support/CoreService.java +++ b/app/src/main/java/com/enqualcomm/support/CoreService.java @@ -1600,15 +1600,6 @@ public class CoreService extends Service { public void stopConnectionRetryTimer() { if (mTimer_retry_connect != null) { mTimer_retry_connect.shutdownNow(); -// while(!mTimer_retry_connect.isTerminated()) -// { -// ICLogger.i("Wait for thread pool terminated"); -// try { -// Thread.sleep(500); -// } catch (InterruptedException e) { -// e.printStackTrace(); -// } -// } mTimer_retry_connect.purge(); mTimer_retry_connect = null; } diff --git a/app/src/main/java/com/enqualcomm/support/utils/ProcessReceiver.java b/app/src/main/java/com/enqualcomm/support/utils/ProcessReceiver.java index 2d0e1676..85010d78 100644 --- a/app/src/main/java/com/enqualcomm/support/utils/ProcessReceiver.java +++ b/app/src/main/java/com/enqualcomm/support/utils/ProcessReceiver.java @@ -69,21 +69,23 @@ public class ProcessReceiver extends BroadcastReceiver { private float y2 = 0.0F; - private static ProcessReceiver processReceiver=null; + private static ProcessReceiver processReceiver = null; + public ProcessReceiver() { if (mHandler == null) { HandlerThread handlerThread = new HandlerThread("ic:process-receiver-handler-thread"); handlerThread.start(); mHandler = new Handler(handlerThread.getLooper()); } - if (processReceiver == null){ + if (processReceiver == null) { processReceiver = this; } } - public static ProcessReceiver getInstance(){ + public static ProcessReceiver getInstance() { return processReceiver; } + private static Handler mHandler = null; @@ -297,29 +299,33 @@ public class ProcessReceiver extends BroadcastReceiver { } @Override - public void onReceive(Context paramContext, Intent paramIntent) { + public void onReceive(Context context, Intent intent) { boolean isSilence; Contact contact; - String str = paramIntent.getAction(); + String action = intent.getAction(); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("action=="); - stringBuilder.append(str); + stringBuilder.append(action); ICLogger.i(stringBuilder.toString()); if (CoreService.getInstance() == null) { - ICLogger.i("CoreService is null skip deal with this message! " + str); - paramContext.startService(new Intent(paramContext, CoreService.class));// protocol service + ICLogger.i("CoreService is null skip deal with this message! " + action); + context.startService(new Intent(context, CoreService.class));// protocol service return; } - if (RESUME_ACTION.equals(str)) { - SharePreferenceUtil.setPrefBoolean(paramContext, "key_is_resume", paramIntent.getBooleanExtra("is_resume", false)); + if ("com.ic.action.ON_WE_TALK_CREATE".equals(action)) { + ICLogger.d("微聊打开,请求一下微聊的消息."); + //这个是微聊起来的时候,调用一下获取消息 + protocolAPIHelper.requestWeTalkMsg(); + } else if (RESUME_ACTION.equals(action)) { + SharePreferenceUtil.setPrefBoolean(context, "key_is_resume", intent.getBooleanExtra("is_resume", false)); return; - } else if (ACTION_MESSAGE_SENT.equals(str)) { + } else if (ACTION_MESSAGE_SENT.equals(action)) { - String msgType = paramIntent.getStringExtra(KEY_MESSAGE_TYPE); - String msgFrom = paramIntent.getStringExtra(KEY_MESSAGE_FROM); - String msgUrl = paramIntent.getStringExtra(KEY_MESSAGE_URL); + String msgType = intent.getStringExtra(KEY_MESSAGE_TYPE); + String msgFrom = intent.getStringExtra(KEY_MESSAGE_FROM); + String msgUrl = intent.getStringExtra(KEY_MESSAGE_URL); ICLogger.i("receive msg to send type=" + msgType + ", msg from = " + msgFrom + ", msgUrl" + msgUrl); if (msgFrom == null) msgFrom = "123"; /** @@ -328,19 +334,19 @@ public class ProcessReceiver extends BroadcastReceiver { */ if (msgType.equals("voice")) { //创建voiceConent并添加到数据 - final VoiceContent voiceContent = VoiceContent.placeHolderOut(CONTACT_CATEGORY_GROUP, msgFrom,"0000", msgUrl, 1, 3); + final VoiceContent voiceContent = VoiceContent.placeHolderOut(CONTACT_CATEGORY_GROUP, msgFrom, "0000", msgUrl, 1, 3); // 把voiceContent拆解成1024的分包 - Util.parseToVoicePacketSent(voiceContent,1024); + Util.parseToVoicePacketSent(voiceContent, 1024); //trigger 分包发送 if (CoreService.getInstance().getConnection() != null) CoreService.getInstance().getConnection().DeliverCMDMessageToSystem("SentVoicePacket", ""); } else if (msgType.equals("pic")) { //创建voiceConent并添加到数据 - final VoiceContent voiceContent = VoiceContent.placeHolderOut(CONTACT_CATEGORY_GROUP, msgFrom,"0000", msgUrl, 2, 3); + final VoiceContent voiceContent = VoiceContent.placeHolderOut(CONTACT_CATEGORY_GROUP, msgFrom, "0000", msgUrl, 2, 3); // 把voiceContent拆解成1024的分包 - Util.parseToVoicePacketSent(voiceContent,1024); + Util.parseToVoicePacketSent(voiceContent, 1024); //trigger 分包发送 if (CoreService.getInstance().getConnection() != null) { @@ -358,11 +364,11 @@ public class ProcessReceiver extends BroadcastReceiver { CoreService.getInstance().getConnection().DeliverCMDMessageToSystem("SentVoicePacket", ""); } } - } else if (ACTION_SHUTDOWN.equals(str)) { - playshutdownsound(paramContext); + } else if (ACTION_SHUTDOWN.equals(action)) { + playshutdownsound(context); Util.shutdown(); return; - } else if (ACTION_PLAYTIME.equals(str)) { + } else if (ACTION_PLAYTIME.equals(action)) { LedUtil.setBlueLedOn(true); mHandler.postDelayed(new Runnable() { @Override @@ -371,27 +377,27 @@ public class ProcessReceiver extends BroadcastReceiver { } }, 2000L); return; - } else if (ACTION_REMOTE_CAMERA.equals(str)) { - if (paramIntent.hasExtra("remote_number")) { + } else if (ACTION_REMOTE_CAMERA.equals(action)) { + if (intent.hasExtra("remote_number")) { //接收拍照命令,执行拍照 - String str1 = paramIntent.getStringExtra("remote_number"); + String str1 = intent.getStringExtra("remote_number"); mHandler.post(new Runnable() { @Override public void run() { - (new CameraUtil(paramContext)).getPicture(str1); + (new CameraUtil(context)).getPicture(str1); } }); } else { //接收到拍照完毕命令,发送照片 - String msgFrom = paramIntent.getStringExtra("number"); - String msgUrl = paramIntent.getStringExtra("filepath"); + String msgFrom = intent.getStringExtra("number"); + String msgUrl = intent.getStringExtra("filepath"); ICLogger.i("receive taken photo to send " + msgUrl); //创建voiceConent并添加到数据 - final VoiceContent voiceContent = VoiceContent.placeHolderOut(CONTACT_CATEGORY_GROUP, msgFrom,"0000", msgUrl, 2, 2); + final VoiceContent voiceContent = VoiceContent.placeHolderOut(CONTACT_CATEGORY_GROUP, msgFrom, "0000", msgUrl, 2, 2); // 把voiceContent拆解成1024的分包 - Util.parseToVoicePacketSent(voiceContent,1024); + Util.parseToVoicePacketSent(voiceContent, 1024); //trigger 分包发送 if (CoreService.getInstance().getConnection() != null) { @@ -415,94 +421,94 @@ public class ProcessReceiver extends BroadcastReceiver { return; - } else if (DIALOG_ACTION.equals(str)) { - if (paramIntent.hasExtra("contact")) { - contact = (Contact) paramIntent.getParcelableExtra("contact"); - SharePreferenceUtil.getPrefBoolean(paramContext, "key_is_resume", false); - isSilence = SharePreferenceUtil.getPrefBoolean(paramContext, "KEY_ISSILENCE", false); + } else if (DIALOG_ACTION.equals(action)) { + if (intent.hasExtra("contact")) { + contact = (Contact) intent.getParcelableExtra("contact"); + SharePreferenceUtil.getPrefBoolean(context, "key_is_resume", false); + isSilence = SharePreferenceUtil.getPrefBoolean(context, "KEY_ISSILENCE", false); if (contact != null && !isSilence) { - if (!DeviceInfoUtil.isTopActivity(paramContext)) { - this.initMyDialog(paramContext, contact, 1, "", false); + if (!DeviceInfoUtil.isTopActivity(context)) { + this.initMyDialog(context, contact, 1, "", false); } //屏幕量了 - if (!Util.isScreenON(paramContext)) { - this.screenOn(paramContext); - VibrateUtil.getInstance(paramContext).vibrateOn(true); - this.playNotificationVoice(paramContext); + if (!Util.isScreenON(context)) { + this.screenOn(context); + VibrateUtil.getInstance(context).vibrateOn(true); + this.playNotificationVoice(context); } } - } else if (paramIntent.hasExtra("talkTextMsg")) { - contact = (Contact) paramIntent.getParcelableExtra("talkTextMsg"); - SharePreferenceUtil.getPrefBoolean(paramContext, "key_is_resume", false); - isSilence = SharePreferenceUtil.getPrefBoolean(paramContext, "KEY_ISSILENCE", false); + } else if (intent.hasExtra("talkTextMsg")) { + contact = (Contact) intent.getParcelableExtra("talkTextMsg"); + SharePreferenceUtil.getPrefBoolean(context, "key_is_resume", false); + isSilence = SharePreferenceUtil.getPrefBoolean(context, "KEY_ISSILENCE", false); if (contact != null && !isSilence) { - if (!DeviceInfoUtil.isTopActivity(paramContext)) { - this.initMyDialog(paramContext, contact, 1, "", false); + if (!DeviceInfoUtil.isTopActivity(context)) { + this.initMyDialog(context, contact, 1, "", false); } //屏幕量了 - if (!Util.isScreenON(paramContext)) { - this.screenOn(paramContext); - VibrateUtil.getInstance(paramContext).vibrateOn(true); - this.playNotificationVoice(paramContext); + if (!Util.isScreenON(context)) { + this.screenOn(context); + VibrateUtil.getInstance(context).vibrateOn(true); + this.playNotificationVoice(context); } } - } else if (paramIntent.hasExtra("sms")) { - String sms = paramIntent.getStringExtra("sms"); - SharePreferenceUtil.getPrefBoolean(paramContext, "key_is_resume", false); - isSilence = SharePreferenceUtil.getPrefBoolean(paramContext, "KEY_ISSILENCE", false); + } else if (intent.hasExtra("sms")) { + String sms = intent.getStringExtra("sms"); + SharePreferenceUtil.getPrefBoolean(context, "key_is_resume", false); + isSilence = SharePreferenceUtil.getPrefBoolean(context, "KEY_ISSILENCE", false); if (sms != null && !isSilence) { //if (!DeviceInfoUtil.isTopActivity(paramContext)) { - this.initMyDialog(paramContext, null, 3, sms, false); - this.playNotificationVoice(paramContext); - VibrateUtil.getInstance(paramContext).vibrateOn(true); + this.initMyDialog(context, null, 3, sms, false); + this.playNotificationVoice(context); + VibrateUtil.getInstance(context).vibrateOn(true); //} - this.screenOn(paramContext); + this.screenOn(context); } - } else if (paramIntent.hasExtra("pushtxt")) { - String sms = paramIntent.getStringExtra("pushtxt"); + } else if (intent.hasExtra("pushtxt")) { + String sms = intent.getStringExtra("pushtxt"); boolean needreply = false; - if (paramIntent.hasExtra("needreply")) { - needreply = paramIntent.getBooleanExtra("needreply", false); + if (intent.hasExtra("needreply")) { + needreply = intent.getBooleanExtra("needreply", false); } - SharePreferenceUtil.getPrefBoolean(paramContext, "key_is_resume", false); - isSilence = SharePreferenceUtil.getPrefBoolean(paramContext, "KEY_ISSILENCE", false); + SharePreferenceUtil.getPrefBoolean(context, "key_is_resume", false); + isSilence = SharePreferenceUtil.getPrefBoolean(context, "KEY_ISSILENCE", false); if (sms != null && !isSilence) { - if (!DeviceInfoUtil.isTopActivity(paramContext)) { - this.initMyDialog(paramContext, null, 4, sms, needreply); - this.playNotificationVoice(paramContext); - VibrateUtil.getInstance(paramContext).vibrateOn(true); + if (!DeviceInfoUtil.isTopActivity(context)) { + this.initMyDialog(context, null, 4, sms, needreply); + this.playNotificationVoice(context); + VibrateUtil.getInstance(context).vibrateOn(true); } - this.screenOn(paramContext); + this.screenOn(context); } - } else if (paramIntent.hasExtra("findDev")) { - String finddevtxt = paramIntent.getStringExtra("findDev"); - SharePreferenceUtil.getPrefBoolean(paramContext, "key_is_resume", false); - isSilence = SharePreferenceUtil.getPrefBoolean(paramContext, "KEY_ISSILENCE", false); + } else if (intent.hasExtra("findDev")) { + String finddevtxt = intent.getStringExtra("findDev"); + SharePreferenceUtil.getPrefBoolean(context, "key_is_resume", false); + isSilence = SharePreferenceUtil.getPrefBoolean(context, "KEY_ISSILENCE", false); if (finddevtxt != null && !isSilence) { - this.initMyDialog(paramContext, null, 5, finddevtxt, false); - this.playFindDevVoice(paramContext); - VibrateUtil.getInstance(paramContext).vibrateOn(true); + this.initMyDialog(context, null, 5, finddevtxt, false); + this.playFindDevVoice(context); + VibrateUtil.getInstance(context).vibrateOn(true); - this.screenOn(paramContext); + this.screenOn(context); } - } else if (paramIntent.hasExtra("takephoto")) { - String takephoto = paramIntent.getStringExtra("takephoto"); - SharePreferenceUtil.getPrefBoolean(paramContext, "key_is_resume", false); - isSilence = SharePreferenceUtil.getPrefBoolean(paramContext, "KEY_ISSILENCE", false); + } else if (intent.hasExtra("takephoto")) { + String takephoto = intent.getStringExtra("takephoto"); + SharePreferenceUtil.getPrefBoolean(context, "key_is_resume", false); + isSilence = SharePreferenceUtil.getPrefBoolean(context, "KEY_ISSILENCE", false); if (takephoto != null && !isSilence) { - this.initMyDialog(paramContext, null, 6, takephoto, false); - this.playNotificationVoice(paramContext); - VibrateUtil.getInstance(paramContext).vibrateOn(true); + this.initMyDialog(context, null, 6, takephoto, false); + this.playNotificationVoice(context); + VibrateUtil.getInstance(context).vibrateOn(true); - this.screenOn(paramContext); + this.screenOn(context); } } - } else if (ACTION_SET_SIT_RANGE.equals(str)) { - if (paramIntent.hasExtra(Constants.KEY_SIT_RANGE)) { - int sitrange = paramIntent.getIntExtra(Constants.KEY_SIT_RANGE, 0); - Config.setKeepSitRangeInMinutes(paramContext, sitrange); + } else if (ACTION_SET_SIT_RANGE.equals(action)) { + if (intent.hasExtra(Constants.KEY_SIT_RANGE)) { + int sitrange = intent.getIntExtra(Constants.KEY_SIT_RANGE, 0); + Config.setKeepSitRangeInMinutes(context, sitrange); ICLogger.i("set KeepSitRange int " + sitrange + " minutes!"); ICLogger.i("则重置 lastCheckSitTime 以及 lastSitCheckStepCount"); Runtime.lastSitCheckStepCount = CoreService.getInstance().getRuntime().getTotalStepCount(); @@ -534,7 +540,7 @@ public class ProcessReceiver extends BroadcastReceiver { } - public void showWarningText(Context context,String txt){ + public void showWarningText(Context context, String txt) { initMyDialog(context, null, 5, txt, false); playFindDevVoice(context); VibrateUtil.getInstance(context).vibrateOn(true); diff --git a/app/src/main/java/com/ic/protocols/protocolAPIHelper.java b/app/src/main/java/com/ic/protocols/protocolAPIHelper.java index b32dd9f8..17010744 100644 --- a/app/src/main/java/com/ic/protocols/protocolAPIHelper.java +++ b/app/src/main/java/com/ic/protocols/protocolAPIHelper.java @@ -166,6 +166,16 @@ public class protocolAPIHelper { return true; } + public static boolean requestWeTalkMsg() { + if (is_protocol_not_Initialled()) return false; + switch (Config.protocol_no) { + case Config.PROTOCOL_BEEHOME: + protocolbeehome_handler.doAP05(); + break; + } + return true; + } + /* 返回true 表示 cmd 全部解析成功 返回false表示 cmd至少有一条解析失败,失败的数据归入buffer,下一次识别接着使用 diff --git a/app/src/main/java/com/ic/protocols/protocol_beehome.java b/app/src/main/java/com/ic/protocols/protocol_beehome.java index 7be9394d..71baff52 100644 --- a/app/src/main/java/com/ic/protocols/protocol_beehome.java +++ b/app/src/main/java/com/ic/protocols/protocol_beehome.java @@ -48,6 +48,7 @@ import java.util.List; import static com.enqualcomm.support.Constants.ACTION_ALARM_ALARM_CHANGE; import static com.enqualcomm.support.Constants.FROM_SERVER; import static com.enqualcomm.support.LocationClient.LOCATION_MODE; +import static com.ic.protocols.protocol_beehome.CMD_TYPE.AP05; import static com.ic.protocols.protocol_beehome.CMD_TYPE.AP32; import static java.lang.Math.abs; @@ -90,6 +91,13 @@ public class protocol_beehome { .toString())); } + public void doAP05() { + ICLogger.d("doAP05..."); + String ap05Msg = AP05(true); + StringMessage stringMessage = genStringMessage(cmdStrMap.get(AP05), ap05Msg); + mConnection.send(stringMessage); + } + public enum CMD_TYPE { /*终端发起*/ AP00,//登录包 @@ -1190,23 +1198,18 @@ public class protocol_beehome { // AP05命令L02服务器不适用 - // public static String AP05(boolean recvFlag){ - // - //// IWAP05,1# - // return new StringBuffer(CMDHEADER).append(cmdMap.get(CMD_TYPE.AP05)) - // .append(CMDSPLIT).append(recvFlag?1:0) - // .append(CMDEND).toString(); - // - // } - // - // - // public void handleBP05(String cmd){ - //// IWBP05,6# - // String[] cmdlist=cmd.split(CMDSPLIT); - // if (cmdlist.length>1){ - // ICLogger.i(" 服务器有 " +cmdlist[1]+" 条语音未接收!"); - // } - // } + public static String AP05(boolean recFlat) { + return new StringBuffer(CMDHEADER).append(cmdMap.get(CMD_TYPE.AP05)) + .append(CMDSPLIT).append(recFlat ? 1 : 0) + .append(CMDEND).toString(); + } + + public void handleBP05(String cmd) { + String[] cmdList = cmd.split(CMDSPLIT); + if (cmdList.length > 1) { + ICLogger.i(" 服务器有 " + cmdList[1] + " 条语音未接收!"); + } + } public static byte[] AP07(String packetTime, int count, int index, int dataLen, byte[] amrData) { @@ -2269,7 +2272,7 @@ public class protocol_beehome { private void handleBPTQ(String cmd) { //对指令进行切割 String[] split = cmd.split(CMDSPLIT); - if (split.length == 24) { + if (split.length == 23) { //先拿到城市数据 String cityName = split[split.length - 1]; for (int j = 1; j < split.length; j += 7) { @@ -2468,14 +2471,12 @@ public class protocol_beehome { } } - public void handleBPSQ(String cmd, Connection connection, Runtime runtime) { //IWBPSQ,353456789012345,080835,1,60# //说明: // 080835为序列号,1,是传感器类型(1是心率,2是血压,3是体温,4是血氧),60为间隔时间,单位为秒 String[] list = cmd.split(CMDSPLIT); if (list.length >= 5) { - String imei = list[1]; String index = list[2]; String typestr = list[3].trim(); @@ -2865,6 +2866,10 @@ public class protocol_beehome { ICLogger.d("接收到二维码的图片."); handleBP87(cmd, mRuntime); break; + case BP05: + ICLogger.d("收到服务器BP05"); + handleBP05(cmd); + break; } return ret; } diff --git a/app/version_code.properties b/app/version_code.properties index ce05b5a4..88c499d4 100644 --- a/app/version_code.properties +++ b/app/version_code.properties @@ -1,2 +1,2 @@ -#Wed Dec 22 20:59:27 CST 2021 -VERSION_CODE=942 +#Tue Dec 28 20:14:43 CST 2021 +VERSION_CODE=943