From: TrillGates Date: Mon, 15 Nov 2021 11:54:48 +0000 (+0800) Subject: 修改了定位相关的逻辑,修改了SOS紧急定位模式 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=b1f5a4555f8665b092c133ee0b043cd0f79ccb2f;p=icsupport.git 修改了定位相关的逻辑,修改了SOS紧急定位模式 --- diff --git a/app/release/ICProtocol81_V939_2111151105_release.apk b/app/release/ICProtocol81_V943_2111151802_release.apk similarity index 78% rename from app/release/ICProtocol81_V939_2111151105_release.apk rename to app/release/ICProtocol81_V943_2111151802_release.apk index f072d92c..b2504efa 100644 Binary files a/app/release/ICProtocol81_V939_2111151105_release.apk and b/app/release/ICProtocol81_V943_2111151802_release.apk differ diff --git a/app/release/output.json b/app/release/output.json index daae44ee..668aaac8 100644 --- a/app/release/output.json +++ b/app/release/output.json @@ -1 +1 @@ -[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":939,"versionName":"2111151105","enabled":true,"outputFile":"ICProtocol81_V939_2111151105_release.apk","fullName":"release","baseName":"release"},"path":"ICProtocol81_V939_2111151105_release.apk","properties":{}}] \ No newline at end of file +[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":943,"versionName":"2111151802","enabled":true,"outputFile":"ICProtocol81_V943_2111151802_release.apk","fullName":"release","baseName":"release"},"path":"ICProtocol81_V943_2111151802_release.apk","properties":{}}] \ No newline at end of file diff --git a/app/src/main/java/com/ic/protocolSrv/CoreService.java b/app/src/main/java/com/ic/protocolSrv/CoreService.java index f6d4ea34..cf91cf99 100644 --- a/app/src/main/java/com/ic/protocolSrv/CoreService.java +++ b/app/src/main/java/com/ic/protocolSrv/CoreService.java @@ -308,14 +308,14 @@ public class CoreService extends Service { } } //add by TrillGates=====end - //去除SOS紧急定位 模式切换(客户需求) - //runtime.setAlarmType(Runtime.AlarmType.ALARM_SOS); + runtime.setAlarmType(Runtime.AlarmType.ALARM_SOS); //trigger AP10 报警定位 ICLogger.i("triggerSOSLocationProcess "); LocationClient.getInstance().triggerSOSLocationProcess(); //Deliver.sendLocationMSG(protocolAPIHelper.getWarningMSG(runtime)); //开启紧急定位模式,GPS 优先1分钟一次定位,持续5分钟 - runtime.getLocationInstance().setWorkingMod(EMERGNECY_MOD); + //去除SOS紧急定位 模式切换(客户需求) + //runtime.getLocationInstance().setWorkingMod(EMERGNECY_MOD); setLocationAlarm(runtime.getLocationInstance().getWorkingMod()); //SOS模式,心率测试1分钟一次,持续5分钟 if (needHRSTestOnSOS) { diff --git a/app/src/main/java/com/ic/protocolSrv/LocationClient.java b/app/src/main/java/com/ic/protocolSrv/LocationClient.java index 5b2a7401..f2371a24 100644 --- a/app/src/main/java/com/ic/protocolSrv/LocationClient.java +++ b/app/src/main/java/com/ic/protocolSrv/LocationClient.java @@ -412,13 +412,12 @@ public class LocationClient { public void startGpsLocate() { - boolean FactryModeOpening = DeviceInfoUtil.isFactoryTestTopActivity(runtime.getContextProxy().context); + boolean FactoryModeOpening = DeviceInfoUtil.isFactoryTestTopActivity(runtime.getContextProxy().context); boolean needReOpenGPS = runtime.getFactoryTestingStat(); - runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_OPEN); - //防止与工厂测试冲突 - if (FactryModeOpening == false || needReOpenGPS == true) { - if (needReOpenGPS == true) { + //防止与工厂测试冲突 + if (!FactoryModeOpening || needReOpenGPS) { + if (needReOpenGPS) { ICLogger.i("工厂模式关闭了GPS,需要重新关闭GPS以同步状态!"); //处理过后,要把状态设置为初始状态,防止每次都重启。 runtime.setFactoryTestingStat(false); @@ -428,19 +427,16 @@ public class LocationClient { ICLogger.i("开启GPS扫描!"); if (Config.LOG_TOFILE) ICLogger.logToFile("GPS", "开启GPS扫描!"); if (!nmeaListener.isListening()) { - runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_OPEN); //此处为了检测是否定位时可以正确识别状态,以防一直处于GPS定位成功状态 -// Single.just(null).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1() { -// public void call(Object param1Object) { -// nmeaListener.startListen(); -// } -// }); + //此处为了检测是否定位时可以正确识别状态,以防一直处于GPS定位成功状态 + runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_OPEN); nmeaListener.startListen(); - } else { ICLogger.i("GPS is still listening, skip open it!"); - runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_OPEN); //此处为了检测是否定位时可以正确识别状态,以防一直处于GPS定位成功状态 - if (Config.LOG_TOFILE) + //此处为了检测是否定位时可以正确识别状态,以防一直处于GPS定位成功状态 + runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_OPEN); + if (Config.LOG_TOFILE) { ICLogger.logToFile("GPS", "GPS is still listening, skip open it!"); + } } } else { ICLogger.i("工厂模式,skip 开启GPS扫描!"); @@ -583,19 +579,24 @@ public class LocationClient { gps_nosignal = false; checktimes++; int mode = runtime.getLocationInstance().getWorkingMod(); - if (runtime.getWifiInfo().length() > 0) wifi_ok = true; - if (runtime.getLocationInstance().getLocationStat() == ICLocation.LOCATION_STAT.LOCATION_FIXED) + ICLogger.d("runtime.getWifiInfo().length()==> " + runtime.getWifiInfo().length()); + if (runtime.getWifiInfo().length() > 0) { + wifi_ok = true; + } + ICLogger.d("runtime.getLocationInstance().getLocationStat() ==> " + + runtime.getLocationInstance().getLocationStat()); + if (runtime.getLocationInstance().getLocationStat() == ICLocation.LOCATION_STAT.LOCATION_FIXED) { gps_ok = true; - if (runtime.getLocationInstance().getLocationStat() == ICLocation.LOCATION_STAT.LOCATION_GPS_TIEMOUT) + } + if (runtime.getLocationInstance().getLocationStat() == ICLocation.LOCATION_STAT.LOCATION_GPS_TIEMOUT) { gps_nosignal = true; + } lbs_ok = ( runtime.getLocationInstance().isDataChanged() == false /*如果mcc,mnc等都没有赋过值 */ || (runtime.getLocationInstance().getMNC().equals("0") && runtime.getLocationInstance().getMCC().equals("0") && runtime.getLocationInstance().getGSMStationCID() == 0 && runtime.getLocationInstance().getLAC() == 0 ) ) ? false : true; - - // ICLogger.i("getMNC "+runtime.getLocationInstance().getMNC()+" getMCC "+runtime.getLocationInstance().getMCC()+" getGSMStationCID " + runtime.getLocationInstance().getGSMStationCID()+ " getLAC "+runtime.getLocationInstance().getLAC()+" changed "+runtime.getLocationInstance().isDataChanged()); ICLogger.i("waitAndSendLocation " + checktimes + ", lbs=" + lbs_ok + ", wifi=" + wifi_ok + ", gps=" + gps_ok + ", mode=" + mode); if (NoMoveAndNoGPSsignalSkipGpsFlag) { ICLogger.i("NoMove And NoGPSsignal SkipGpsLocation!"); @@ -607,15 +608,8 @@ public class LocationClient { case ICLocation.EMERGNECY_MOD: case ICLocation.REALTIME_MOD: { //GPS 优先的话多给些时间(10秒) - timeCost = System.currentTimeMillis() - startCheckTime; - - if ((checktimes > WiFiLocationTimeoutInSeconds) || ((startCheckTime != 0L) && (timeCost > WiFiLocationTimeoutInSeconds * 1000))) { - ICLogger.i("waitAndSendLocation WiFi TimeOut " + checktimes + " > " + WiFiLocationTimeoutInSeconds + " or timeCost " + timeCost + "> " + WiFiLocationTimeoutInSeconds * 1000 + "ms "); - wifi_timeout = true; - } - if ((checktimes > GPSLocationTimeoutInSeconds) || ((startCheckTime != 0L) && (timeCost > GPSLocationTimeoutInSeconds * 1000))) { - //有时timer计数不准,则根据实际时间计算 - ICLogger.i("waitAndSendLocation " + checktimes + "> " + GPSLocationTimeoutInSeconds + " or timeCost " + timeCost + "> " + GPSLocationTimeoutInSeconds * 1000 + "ms "); + if (checktimes > GPSLocationTimeoutInSeconds) { + ICLogger.i("waitAndSendLocation " + checktimes + " timeout"); timeout = true; } if (mNoMoveTimeout && (timeout || gps_nosignal)) { @@ -629,16 +623,17 @@ public class LocationClient { || (lbs_ok && (gps_ok || startSOSLocation) && wifi_ok) || (lbs_ok && gps_nosignal && wifi_ok) ) { - String locationtype = "LBS"; + String locationType = "LBS"; if (gps_ok) { - locationtype = "GPS"; + locationType = "GPS"; } else if (wifi_ok) { - locationtype = "WiFi"; + locationType = "WiFi"; } - runtime.getLocationInstance().setLocationType(locationtype); + runtime.getLocationInstance().setLocationType(locationType); runtime.getLocationInstance().setLocationTime(TimeUtil.getSystemTime3()); - ICLogger.i("waitAndSendLocation startSOSLocation " + startSOSLocation + " or startNomalLocation " + startNomalLocation); - + ICLogger.i("waitAndSendLocation startSOSLocation " + + startSOSLocation + " or startNomalLocation " + + startNomalLocation); if (startSOSLocation) { StringMessage AP10_CMD = protocolAPIHelper.getWarningMSG(runtime); DeliverMessage(AP10_CMD); @@ -648,10 +643,8 @@ public class LocationClient { if (startNomalLocation = true) { startNomalLocation = false; if (gps_ok) { -// if (!TextUtils.isEmpty(runtime.getWifiInfo())) { StringMessage AP01_CMD = protocolAPIHelper.getGPSLocationMSG(runtime); DeliverMessage(AP01_CMD); -// } } else { StringMessage AP02_CMD = protocolAPIHelper.getLBSLocationMSG(runtime); DeliverMessage(AP02_CMD); @@ -661,16 +654,17 @@ public class LocationClient { String msg = "Location Fixed Type " + runtime.getLocationInstance().getLocationType() + " at " + runtime.getLocationInstance().getLocationTime() + " timeout " + timeout; ICLogger.i(msg); if (responseUrl != null) { - if (locationtype.equals("GPS")) { + if (locationType.equals("GPS")) { responseUrl.replyCallBack(runtime.getLocationInstance().getLocation().latGPSStr + "," + runtime.getLocationInstance().getLocation().lonGPSStr); } else { - responseUrl.replyCallBack("Location Fixed Type " + locationtype); + responseUrl.replyCallBack("Location Fixed Type " + locationType); } } if (Config.LOG_TOFILE) { ICLogger.logToFile("GPS", msg); } - } else if ((timeout || gps_nosignal) && !lbs_ok && wifi_timeout) { + + } else if (timeout) { //timeout + noLBS +noGPS ICLogger.i("timeout no location "); stopCheckLocationResult(); @@ -962,6 +956,7 @@ public class LocationClient { public static void setSkipMoveCheck(boolean _skipMoveCheck) { + ICLogger.d("setSkipMoveCheck ==> " + _skipMoveCheck); skipMoveCheck = _skipMoveCheck; } @@ -1004,7 +999,6 @@ public class LocationClient { } - private String lastMCC = ""; private String lastMnc = ""; private long lastLAC = 0l; @@ -1071,6 +1065,8 @@ public class LocationClient { private boolean needLocationForBT() { updateStepCount();//update StepCount,保证每次定位前,计步数据是最新的。防止丢数据。 //如果没有动,且超时。则跳过定位 + ICLogger.d("skipMoveCheck ==> " + skipMoveCheck); + ICLogger.d("Config.forceGPSMoveCheck ==> " + Config.forceGPSMoveCheck); if (skipMoveCheck || Config.forceGPSMoveCheck) { mNoMoveTimeout = false; } else { @@ -1083,7 +1079,6 @@ public class LocationClient { if ((forceLocation != 1) && (mNoMoveTimeout) && (!skipMoveCheck)) { ICLogger.i("No Move ,skip BT location!"); - return false; } //以目前逻辑,每次检测必然跟随蓝牙扫描,因此可以在此直接更新上一次的计步次数,配合下次的运动检测 @@ -1094,6 +1089,8 @@ public class LocationClient { private boolean needLocation() { updateStepCount();//update StepCount,保证每次定位前,计步数据是最新的。防止丢数据。 //如果没有动,且超时。则跳过定位 + ICLogger.d("skipMoveCheck ==> " + skipMoveCheck); + ICLogger.d("Config.forceGPSMoveCheck ==> " + Config.forceGPSMoveCheck); if (skipMoveCheck || Config.forceGPSMoveCheck) { mNoMoveTimeout = false; } else { @@ -1118,6 +1115,8 @@ public class LocationClient { ICLogger.i("locating ,skip location!"); return; } + ICLogger.d("Config.forceGPSMoveCheck ==> " + Config.forceGPSMoveCheck); + ICLogger.d("skipMoveCheck ==> " + skipMoveCheck); //默认运动检测开启 if (skipMoveCheck || Config.forceGPSMoveCheck) { mNoMoveTimeout = false; @@ -1139,6 +1138,8 @@ public class LocationClient { return; } + ICLogger.d("mNoMoveTimeout ==> " + mNoMoveTimeout); + ICLogger.d("gpsTimeoutCountOnNoMove ==> " + gpsTimeoutCountOnNoMove); if (mNoMoveTimeout) { // 记录gps 无信号或者timeout的次数,超过5 就会停止使用gps定位,只要有一次 移动,或者设置为wifi定位,则清零。 if (gpsTimeoutCountOnNoMove >= MaxGpsTimeoutCountOnNoMove) { @@ -1162,12 +1163,14 @@ public class LocationClient { switch (mod) { case ICLocation.CUSTOM_MOD: case ICLocation.CUSTOM_MOD8_GPS: + ICLogger.d("NoMoveAndNoGPSsignalSkipGpsFlag ==> " + NoMoveAndNoGPSsignalSkipGpsFlag); if (!NoMoveAndNoGPSsignalSkipGpsFlag) { if (runtime.getLocationInstance().getLocation_cycle() <= 60) { nmeaListener.setNoStop(true); } else { nmeaListener.setNoStop(false); } + ICLogger.d("startGpsLocate..."); startGpsLocate(); } else { clearGPSlocateStat(); //如果wifi优先,则确保gps关闭,防止切换回来gps状态错误,尤其是不NoStop模式下的gps切换回来有此风险。 diff --git a/app/src/main/java/com/ic/protocolSrv/utils/CellInfoUtil.java b/app/src/main/java/com/ic/protocolSrv/utils/CellInfoUtil.java index cbdd4ddf..02efdc81 100644 --- a/app/src/main/java/com/ic/protocolSrv/utils/CellInfoUtil.java +++ b/app/src/main/java/com/ic/protocolSrv/utils/CellInfoUtil.java @@ -71,7 +71,6 @@ public class CellInfoUtil { } public static int getSignal(TelephonyManager tm, Runtime runtime) { - if (tm == null) return 5; try { diff --git a/app/src/main/java/com/ic/protocols/protocol_fzd.java b/app/src/main/java/com/ic/protocols/protocol_fzd.java index 0d4d0aa3..40b7c6c8 100644 --- a/app/src/main/java/com/ic/protocols/protocol_fzd.java +++ b/app/src/main/java/com/ic/protocols/protocol_fzd.java @@ -443,8 +443,7 @@ public class protocol_fzd { IP,//配置服务器地址 SOSREC,//服务器响应S0S消息 LOCATIONMODE,//设置工作模式 - BPMC,//专门控制skipmovecheck - APMC,// + SKIPMOVE,//专门控制skipmovecheck } public static HashMap cmdMap; @@ -525,8 +524,7 @@ public class protocol_fzd { cmdMap.put(CMD_TYPE.IP, "IP"); cmdMap.put(CMD_TYPE.SOSREC, "SOSREC"); cmdMap.put(CMD_TYPE.LOCATIONMODE, "LOCATIONMODE"); - cmdMap.put(CMD_TYPE.BPMC, "BPMC"); - cmdMap.put(CMD_TYPE.APMC, "APMC"); + cmdMap.put(CMD_TYPE.SKIPMOVE, "SKIPMOVE"); } private Connection mConnection = null; @@ -902,8 +900,8 @@ public class protocol_fzd { int data_buf_len = data_buf.length(); String header = genHeader(data_buf_len, CMD); if (doEncryption) { - String keyheader = keyheader(CMD, data_buf_len);//计算header md5值 - sb.append(CMD_HEADER).append(keyheader).append(header).append(CMD_SPLIT).append(data).append(CMD_END); + String keyHeader = keyheader(CMD, data_buf_len);//计算header md5值 + sb.append(CMD_HEADER).append(keyHeader).append(header).append(CMD_SPLIT).append(data).append(CMD_END); } else { sb.append(CMD_HEADER).append(header).append(CMD_SPLIT).append(data).append(CMD_END); } @@ -1971,16 +1969,16 @@ public class protocol_fzd { ICLogger.d("服务器收到SOS消息..."); mConnection.DeliverCMDMessageToSystem("sosReceive", cmd); break; - case BPMC: + case SKIPMOVE: ICLogger.d("收到服务器下发的修改skipmovecheck"); - handleBPMC(cmd); + handleSKIPMOVE(cmd); break; } return ret; } - private void handleBPMC(String cmd) { + private void handleSKIPMOVE(String cmd) { //指令,IMEI,流水,值:0,1,2。 //0表示关闭,1表示打开,2表示获取当前的状态,不做设置,只返回 //IWBPMC,353456789012345,080835,1# @@ -2003,7 +2001,7 @@ public class protocol_fzd { responseValue = LocationClient.getSkipMoveCheck(); } //返回结果 - StringMessage apmc = APMC(index, responseValue); + StringMessage apmc = SKIPMOVE(responseValue); ICLogger.d("apmc ==> " + apmc); mConnection.send(apmc); } else { @@ -2014,12 +2012,11 @@ public class protocol_fzd { /** * 回复内容 * - * @param index * @param responseValue * @return */ - private StringMessage APMC(String index, boolean responseValue) { - StringMessage stringMessage = genFZDCMD(cmdMap.get(CMD_TYPE.APMC), String.valueOf(responseValue)); + private StringMessage SKIPMOVE(boolean responseValue) { + StringMessage stringMessage = genFZDCMD(cmdMap.get(CMD_TYPE.SKIPMOVE), String.valueOf(responseValue)); ICLogger.d("stringMessage ==> " + stringMessage); return stringMessage; } diff --git a/app/version_code.properties b/app/version_code.properties index eb7aae61..e2d69da0 100644 --- a/app/version_code.properties +++ b/app/version_code.properties @@ -1,2 +1,2 @@ -#Mon Nov 15 11:05:04 CST 2021 -VERSION_CODE=939 +#Mon Nov 15 18:02:35 CST 2021 +VERSION_CODE=943 diff --git a/git b/git new file mode 100644 index 00000000..e69de29b