From: snickersun Date: Thu, 15 Oct 2020 12:05:44 +0000 (+0800) Subject: release V659 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=0f7154a4a0efdb443efd2235c97f2ae4d00e6edd;p=protocol_srv.git release V659 蓝牙扫描单次6秒,如果未扫到重试2次,所以扫描次数最少1次,最多3次。 充电检测函数修改, persist.sys.disableWiFiLocation=true 屏蔽wifi定位 确保每次扫描都有结果后再进行定位报警 --- diff --git a/app/release/ICSer_V657_2010142343_release.apk b/app/release/ICSer_V659_2010151957_release.apk similarity index 78% rename from app/release/ICSer_V657_2010142343_release.apk rename to app/release/ICSer_V659_2010151957_release.apk index b1911534..d90e8dc5 100644 Binary files a/app/release/ICSer_V657_2010142343_release.apk and b/app/release/ICSer_V659_2010151957_release.apk differ diff --git a/app/release/output.json b/app/release/output.json index fc5d7199..3647a2c7 100644 --- a/app/release/output.json +++ b/app/release/output.json @@ -1 +1 @@ -[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":657,"versionName":"2010142343","enabled":true,"outputFile":"ICSer_V657_2010142343_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V657_2010142343_release.apk","properties":{}}] \ No newline at end of file +[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":659,"versionName":"2010151957","enabled":true,"outputFile":"ICSer_V659_2010151957_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V659_2010151957_release.apk","properties":{}}] \ No newline at end of file diff --git a/app/src/main/java/com/enqualcomm/support/Config.java b/app/src/main/java/com/enqualcomm/support/Config.java index 4867d9e8..ff64e09b 100644 --- a/app/src/main/java/com/enqualcomm/support/Config.java +++ b/app/src/main/java/com/enqualcomm/support/Config.java @@ -55,8 +55,9 @@ public class Config { public static boolean noTempSensor=false; public static boolean noPPGSensor=false; public static boolean needBroadcastAntiAlarm=true; + public static boolean disableWiFiScan=false; static { - + disableWiFiScan=Util.getSystemProperties("persist.sys.disableWiFiLocation","false").equals("true"); } private static String make() { diff --git a/app/src/main/java/com/enqualcomm/support/CoreService.java b/app/src/main/java/com/enqualcomm/support/CoreService.java index 149edffc..65863d09 100644 --- a/app/src/main/java/com/enqualcomm/support/CoreService.java +++ b/app/src/main/java/com/enqualcomm/support/CoreService.java @@ -686,8 +686,6 @@ public class CoreService extends Service { Config.ConfigAlarm(Runtime.AlarmType.ALARM_CUTOFF,true); Config.ConfigAlarm(Runtime.AlarmType.ALARM_ILLEGAL_CUTOFF,true); Config.ConfigAlarm(Runtime.AlarmType.ALARM_LOCK_WATCH,true); - Config.setNeedAntiOff(runtime.getContextProxy().context,true); - Config.setNeedCutOff(runtime.getContextProxy().context,true); if (Config.getConfigInitFlag(this)==0) { Config.setLocationMode(this, CUSTOM_MOD8_GPS); // Config.setLocationMode(this, CUSTOM_MOD8_WIFI); @@ -722,7 +720,7 @@ public class CoreService extends Service { } Config.dumpAlarmConfig(); - //初始化剪断,脱腕报警开关(这个开关是界面提示显示用的,上面的Config.ConfigAlarm 是上报服务器消息的开关) + //A9专用变量 初始化剪断,脱腕报警开关(这个开关是界面提示显示用的,上面的Config.ConfigAlarm 是上报服务器消息的开关) runtime.setNeddReportCutoff(Config.getNeedCutOff(this)); runtime.setNeedAntioff(Config.getNeedAntiOff(this)); @@ -1469,6 +1467,7 @@ public class CoreService extends Service { public void onDestroy() { super.onDestroy(); + saveStepCount(); this.connectionServiceChain.processDetach(this.connection, this.runtime); this.invokeHandlerServiceChain.processDetach(this.connection, this.runtime); diff --git a/app/src/main/java/com/enqualcomm/support/LocationClient.java b/app/src/main/java/com/enqualcomm/support/LocationClient.java index 9eb2fb63..41b2194a 100644 --- a/app/src/main/java/com/enqualcomm/support/LocationClient.java +++ b/app/src/main/java/com/enqualcomm/support/LocationClient.java @@ -118,6 +118,12 @@ public class LocationClient { int preNetworkTypeNomber; private boolean scanBLEOnly=false; + //如果未扫到,重试扫描的次数。 + private int maxBLEScanTime=2; + private int ScanBLERetryCount=maxBLEScanTime; + + + private static LocationClient gLocationCline=null; // private BroadcastReceiver screenOnReceiver = new BroadcastReceiver() { // public void onReceive(Context param1Context, Intent param1Intent) { @@ -149,17 +155,32 @@ public class LocationClient { break; } } - runtime.bleInfo.is_in_area = in_area; + if(in_area == false && ScanBLERetryCount-- > 0){ + //如果没有扫描到,且扫描次数没有超限,则重新扫描一次。注意要delay 5秒 + try{ + Thread.sleep(5000); + }catch ( Exception e){} + //Do retry Scan + ICLogger.i("BT BLE not found retry Scan "+ ScanBLERetryCount); + btHelper.scanBLE(); + return ; + }else { + runtime.bleInfo.is_in_area = in_area; + ScanBLERetryCount=maxBLEScanTime; + } + }catch(Exception e){//如果出错,原来的状态不要变。防止误报,最多延迟一个周期报。 e.printStackTrace(); ICLogger.i(e.getMessage()); } } else { runtime.bleInfo.is_in_area = false; + ScanBLERetryCount=maxBLEScanTime; } ICLogger.i("Bt Dev Is in Area " + runtime.bleInfo.is_in_area); if(scanBLEOnly==true){ + //只扫描蓝牙,不做定位 if (runtime.bleInfo.is_in_area == false ) { runtime.updateFZDDevStatusEscape(true); ICLogger.i("BT 不在区域内"); @@ -167,14 +188,10 @@ public class LocationClient { //只有上一次在区域内,这次出区域才需要报警 ICLogger.i("BT 不在区域内,且上次在区域内,报警!"); //如果需要报警定位,则强制进行sos定位,不能通过triggerSOS,因为函数中调用了BLEScan会造成循环调用 - if (donotScanWiFi){ + StringMessage AL_CMD = protocolAPIHelper.getWarningMSG(runtime); DeliverMessage(AL_CMD); - }else { - startSOSLocation = true;//启动SOS定位,为了快速响应,只要wifi定位即可。 - forceLocation = 1; - startLocationProcess(ICLocation.NORMAL_MOD); - } + } }else{ @@ -182,32 +199,26 @@ public class LocationClient { runtime.updateFZDDevStatusEscape(false); } }else { + //定位前的蓝牙扫描 if (runtime.bleInfo.is_in_area == false) { ICLogger.i("BT 不在区域内,开启定位流程"); runtime.updateFZDDevStatusEscape(true); if ( runtime.bleInfo.last_is_in_area==true) { //只有上一次在区域内,这次出区域才需要报警 ICLogger.i("BT 不在区域内,且上次在区域内,报警!"); - if (donotScanWiFi){ + StringMessage AL_CMD = protocolAPIHelper.getWarningMSG(runtime); DeliverMessage(AL_CMD); startSOSLocation=false; - }else { - //如果需要报警定位,则强制进行sos定位,不能通过triggerSOS,因为函数中调用了BLEScan会造成循环调用 - startSOSLocation = true;//启动SOS定位,为了快速响应,只要wifi定位即可。 - forceLocation = 1; - startLocationProcess(ICLocation.NORMAL_MOD); - } + }else { if (startSOSLocation) { - if (donotScanWiFi) { + StringMessage AL_CMD = protocolAPIHelper.getWarningMSG(runtime); DeliverMessage(AL_CMD); startSOSLocation=false; - } else { - startLocationProcess(ICLocation.NORMAL_MOD); - } + } else { startLocationProcess(runtime.getLocationInstance().getWorkingMod()); } @@ -308,29 +319,38 @@ public class LocationClient { mhandler.sendEmptyMessage(msgWhat_StartBLEProcess); } - private static boolean donotScanWiFi=true; public void triggerSOSLocationProcess(){ - if (donotScanWiFi){ - updateCellInfo(); - if (runtime.bleInfo.btMacList.size() > 0) { - //有蓝牙搜索要求则 先进行蓝牙扫描 - startSOSLocation=true;//启动SOS定位,为了快速响应,只要wifi定位即可。 - forceLocation=1; - if (needLocationForBT()) - btHelper.scanBLE(); - } else { - try{ - Thread.sleep(1000); - }catch (Exception e){} - StringMessage waningmsg=protocolAPIHelper.getWarningMSG(runtime); - DeliverMessage(waningmsg); - } - }else { - mhandler.sendEmptyMessage(msgWhat_StartSOSLocationProcess); - } + (new Thread(new Runnable() { + public void run() { + + if (runtime !=null) { + //更新lbs信息 + CellInfoUtil.getCellInfo(runtime.getContextProxy().getTelephonyManager(),runtime); + + if (runtime.bleInfo.btMacList.size() > 0) { + //有蓝牙搜索要求则 先进行蓝牙扫描 + startSOSLocation=true;//启动SOS定位,为了快速响应,只要wifi定位即可。 + forceLocation=1; + if (needLocationForBT()) + btHelper.scanBLE(); + } else { + try{ + Thread.sleep(1000); + }catch (Exception e){} + StringMessage waningmsg=protocolAPIHelper.getWarningMSG(runtime); + DeliverMessage(waningmsg); + } + } + + } + })).start(); + + +// mhandler.sendEmptyMessage(msgWhat_StartSOSLocationProcess); + } private static int checktimes=0; @@ -801,7 +821,7 @@ public void updateCellInfo() { if ( ( forceLocation != 1 ) && (Config.forceMoveCheck==true) && (NoMoveTimeout) && (skipMoveCheck ==false )){ - ICLogger.i("No Move ,skip location!"); + ICLogger.i("No Move ,skip BT location!"); return false; } return true; @@ -843,7 +863,7 @@ public void updateCellInfo() { runtime.setLastStepCount(runtime.getTotalStepCount()); updateCellInfo(); - startWifiScan(); + if(!Config.disableWiFiScan) startWifiScan(); switch(mod){ case ICLocation.CUSTOM_MOD: case ICLocation.CUSTOM_MOD8_GPS: diff --git a/app/src/main/java/com/enqualcomm/support/adapter/BTHelper.java b/app/src/main/java/com/enqualcomm/support/adapter/BTHelper.java index 61e9078b..af923d78 100644 --- a/app/src/main/java/com/enqualcomm/support/adapter/BTHelper.java +++ b/app/src/main/java/com/enqualcomm/support/adapter/BTHelper.java @@ -23,7 +23,7 @@ public class BTHelper { private Context mContext=null; private BTScanCallback mCallback=null; private static BTHelper mBThelper=null; - + private int BLETimeoutForOneScan=6; private static boolean btscanning=false; private boolean enabledBeforScan=false; BTHelper(){ @@ -218,7 +218,7 @@ public class BTHelper { if (mCallback != null) mCallback.OnScanFinished(mPairedDevicesArray, mNewDevicesArray); } - }, 5000); + }, BLETimeoutForOneScan*1000); }else{ ICLogger.i("BT Scanning skip Scan!"); } diff --git a/app/src/main/java/com/enqualcomm/support/utils/BatteryUtil.java b/app/src/main/java/com/enqualcomm/support/utils/BatteryUtil.java index f3ca3958..18ef3123 100644 --- a/app/src/main/java/com/enqualcomm/support/utils/BatteryUtil.java +++ b/app/src/main/java/com/enqualcomm/support/utils/BatteryUtil.java @@ -261,10 +261,12 @@ public class BatteryUtil { // 是否在充电 int status = batteryStatus.getIntExtra(EXTRA_STATUS, -1); - boolean isCharging = status == BATTERY_STATUS_CHARGING ;//|| status == BatteryManager.BATTERY_STATUS_FULL; - - return isCharging; + boolean isCharging = (status == BATTERY_STATUS_CHARGING) ;//|| status == BatteryManager.BATTERY_STATUS_FULL; + boolean isCharging2 = batteryStatus.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1) != 0; + ICLogger.d("isCharging = " +isCharging+" isCharging2 "+ isCharging2 ); + return isCharging2; } + public void unregisterBroadReceiver() { (this.mRuntime.getContextProxy()).context.unregisterReceiver(this.batteryChangedReceiver); } } diff --git a/app/version_code.properties b/app/version_code.properties index ca27c458..f1ccb936 100644 --- a/app/version_code.properties +++ b/app/version_code.properties @@ -1,2 +1,2 @@ -#Wed Oct 14 23:43:00 CST 2020 -VERSION_CODE=657 +#Thu Oct 15 19:57:42 CST 2020 +VERSION_CODE=659