release V688
authorsnickersun <scy@incartech.cn>
Wed, 4 Nov 2020 11:24:59 +0000 (19:24 +0800)
committersnickersun <scy@incartech.cn>
Wed, 4 Nov 2020 11:24:59 +0000 (19:24 +0800)
1、移动检测 添加 区分心跳时的纯蓝牙扫描和定位时的蓝牙扫描
2、修改APBR上传格式,添加时间。
3、mqtt STATE_NONE时恢复 onMqttDisconnected调用,之前的修改造成了出错后不能恢复。

app/release/ICSer_V688_2011041727_release.apk [moved from app/release/ICSer_V687_2011032007_release.apk with 78% similarity]
app/release/output.json
app/src/main/java/com/enqualcomm/support/CoreService.java
app/src/main/java/com/enqualcomm/support/LocationClient.java
app/src/main/java/com/enqualcomm/support/bean/Runtime.java
app/src/main/java/com/enqualcomm/support/utils/TimeUtil.java
app/src/main/java/com/ic/protocols/protocol_ic.java
app/src/main/java/com/ic/protocols/protocol_mqtt_client.java
app/version_code.properties

similarity index 78%
rename from app/release/ICSer_V687_2011032007_release.apk
rename to app/release/ICSer_V688_2011041727_release.apk
index 689cbb7..1e3bbb3 100644 (file)
Binary files a/app/release/ICSer_V687_2011032007_release.apk and b/app/release/ICSer_V688_2011041727_release.apk differ
index 9d3efb6..5296347 100644 (file)
@@ -1 +1 @@
-[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":687,"versionName":"2011032007","enabled":true,"outputFile":"ICSer_V687_2011032007_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V687_2011032007_release.apk","properties":{}}]
\ No newline at end of file
+[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":688,"versionName":"2011041727","enabled":true,"outputFile":"ICSer_V688_2011041727_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V688_2011041727_release.apk","properties":{}}]
\ No newline at end of file
index 54033fd..6763ff4 100644 (file)
@@ -471,6 +471,8 @@ public class CoreService extends Service {
         }\r
         this.runtime.setSaveStepCount(j);\r
         this.runtime.setTotalStepCount(i);\r
+        runtime.setLastStepCountForBT(runtime.getTotalStepCount());\r
+        runtime.setLastStepCount(runtime.getTotalStepCount());\r
     }\r
     public void saveStepCount(){\r
         int i = runtime.getTotalStepCount();\r
index 8a839ed..c9aadbc 100644 (file)
@@ -2,6 +2,7 @@ package com.enqualcomm.support;
 \r
 import android.content.BroadcastReceiver;\r
 import android.content.Context;\r
+import android.content.IClipboard;\r
 import android.content.Intent;\r
 import android.content.IntentFilter;\r
 import android.os.Handler;\r
@@ -250,7 +251,8 @@ public class LocationClient {
         runtime.bleInfo.last_is_in_area=runtime.bleInfo.is_in_area;\r
         //扫描结束就清掉scanBLEOnly,保证下次不会被误操作。\r
         scanBLEOnly=false;\r
-        }else{ //Config.BLEScanProtocol==0\r
+        }else{\r
+          //Config.BLEScanProtocol == 1\r
           if (btNewScanResult!=null && btNewScanResult.size() > 0) {\r
             StringBuilder sb = new StringBuilder();\r
             sb.append("found bt mac ").append(btNewScanResult.size());\r
@@ -444,14 +446,15 @@ public class LocationClient {
               public void call(Object param1Object) { waitAndSendLocation(); }\r
             });\r
           }else if (msg.what == msgWhat_StartLocationProcess) {\r
-            if (runtime.bleInfo.btMacList.size() > 0) {\r
+            if (Config.BLEScanProtocol == 0 &&  runtime.bleInfo.btMacList.size() > 0) {\r
               if(scanBLEOnly && btHelper.isBtscanning()){\r
                 //如果正在进行独立蓝牙扫描,则强制切换为正常扫描。\r
                 scanBLEOnly=false;\r
               }else {\r
                 //有蓝牙搜索要求则 先进行蓝牙扫描\r
-                if (needLocationForBT())\r
+                if (needLocation()) {\r
                   btHelper.scanBLE();\r
+                }\r
               }\r
             } else {\r
               //没有蓝牙搜索要求,就正常定位\r
@@ -463,8 +466,10 @@ public class LocationClient {
                 //有蓝牙搜索要求则 先进行蓝牙扫描\r
                 if (!btHelper.isBtscanning()) {\r
                   scanBLEOnly = true;\r
-                  if (needLocationForBT())\r
+                  if (needLocationForBT()) {\r
+                    ICLogger.i("msgWhat_StartBLEProcess");\r
                     btHelper.scanBLE();\r
+                  }\r
                 } else {\r
                   ICLogger.i("BT Scanning skip ScanBLE only!");\r
                 }\r
@@ -472,10 +477,12 @@ public class LocationClient {
             }else{\r
               //有蓝牙搜索要求则 先进行蓝牙扫描\r
               if (!btHelper.isBtscanning()) {\r
-                if (needLocationForBT())\r
+                if (needLocationForBT()) {\r
+                  ICLogger.i("msgWhat_StartBLEProcess2");\r
                   btHelper.scanBLE();\r
+                }\r
               } else {\r
-                ICLogger.i("BT Scanning skip ScanBLE only!");\r
+                ICLogger.i("BT Scanning skip ScanBLE only2!");\r
               }\r
             }\r
           }else if (msg.what == msgWhat_StartSOSLocationProcess){\r
@@ -485,25 +492,25 @@ public class LocationClient {
               //更新lbs信息\r
               CellInfoUtil.getCellInfo(runtime.getContextProxy().getTelephonyManager(),runtime);\r
 \r
-              if (runtime.bleInfo.btMacList.size() > 0) {\r
-                if(scanBLEOnly && btHelper.isBtscanning())\r
-                {\r
-                  //如果正在进行独立蓝牙扫描,则强制切换为正常扫描。\r
-                  scanBLEOnly = false;\r
-                }else {\r
-                  //有蓝牙搜索要求则 先进行蓝牙扫描\r
+                if (Config.BLEScanProtocol==0 && runtime.bleInfo.btMacList.size() > 0) {\r
                   startSOSLocation = true;//启动SOS定位,为了快速响应,只要wifi定位即可。\r
-                  forceLocation = 1;\r
-                  if (needLocationForBT())\r
-                    btHelper.scanBLE();\r
+                  if (scanBLEOnly && btHelper.isBtscanning()) {\r
+                    //如果正在进行独立蓝牙扫描,则强制切换为正常扫描。\r
+                    scanBLEOnly = false;\r
+                  } else {\r
+                    //SOS location 有蓝牙搜索要求则 先进行蓝牙扫描\r
+                      forceLocation = 1;\r
+                    if(!btHelper.isBtscanning())\r
+                      btHelper.scanBLE();\r
+                  }\r
+                } else {\r
+                  Util.mSleep(1000);\r
+                  StringMessage waningmsg = protocolAPIHelper.getWarningMSG(runtime);\r
+                  DeliverMessage(waningmsg);\r
                 }\r
-              } else {\r
-                Util.mSleep(1000);\r
-                StringMessage waningmsg=protocolAPIHelper.getWarningMSG(runtime);\r
-                DeliverMessage(waningmsg);\r
-              }\r
             }\r
 \r
+\r
 //\r
 //            startSOSLocation=true;//启动SOS定位,为了快速响应,只要wifi定位即可。\r
 //            forceLocation=1;\r
@@ -824,7 +831,33 @@ public void updateCellInfo() {
   private static boolean last_noMove=false;\r
   private static final int MaxNoMoveTimeout=3*60*1000; //3分钟\r
   private static long first_NoMove_timestamp=0;\r
+  private static long first_NoMove_timestampForBT=0;\r
+  private static boolean last_noMoveForBT=false;\r
+\r
+  /***\r
+   *noMove and timeout return true\r
+   * else return false\r
+   */\r
+  private boolean checkNoMoveTimeoutForBT(){\r
+    noMove=runtime.getLastStepCountForBT() == runtime.getTotalStepCount();\r
+    runtime.updateFZDDevStatusMoving(!noMove); //设置当前运动状态\r
+    ICLogger.i("BT checkNoMoveTimeout last_noMoveForBT "+last_noMoveForBT+" noMove "+noMove+ " lastStepCountForBT "+runtime.getLastStepCountForBT()+" StepCount "+runtime.getTotalStepCount());\r
+    if (last_noMoveForBT==false&& noMove==true){\r
+      first_NoMove_timestampForBT=System.currentTimeMillis();\r
+    }else if (noMove==false){\r
+      first_NoMove_timestampForBT=0;\r
+    }\r
+    last_noMoveForBT=noMove;\r
+    //属于 判断是否 不动的状态超时\r
+    if (noMove==true&& first_NoMove_timestampForBT>0.01  && System.currentTimeMillis()-first_NoMove_timestampForBT > MaxNoMoveTimeout){\r
+      ICLogger.i("BT checkNoMoveTimeout true ");\r
+      return true;\r
+    }else{\r
+      ICLogger.i("BT checkNoMoveTimeout false");\r
+      return false;\r
+    }\r
 \r
+  }\r
 \r
   /***\r
    *noMove and timeout return true\r
@@ -833,7 +866,7 @@ public void updateCellInfo() {
   private boolean checkNoMoveTimeout(){\r
     noMove=runtime.getLastStepCount() == runtime.getTotalStepCount();\r
     runtime.updateFZDDevStatusMoving(!noMove); //设置当前运动状态\r
-    ICLogger.i(" checkNoMoveTimeout last_noMove "+last_noMove+" noMove "+noMove);\r
+    ICLogger.i("checkNoMoveTimeout last_noMove "+last_noMove+" noMove "+noMove+ " lastStepCount "+runtime.getLastStepCount()+" StepCount "+runtime.getTotalStepCount());\r
     if (last_noMove==false&& noMove==true){\r
       first_NoMove_timestamp=System.currentTimeMillis();\r
     }else if (noMove==false){\r
@@ -854,7 +887,7 @@ public void updateCellInfo() {
   private boolean needLocationForBT(){\r
     updateStepCount();//update StepCount,保证每次定位前,计步数据是最新的。防止丢数据。\r
     //如果没有动,且超时。则跳过定位\r
-    NoMoveTimeout=checkNoMoveTimeout();\r
+    NoMoveTimeout=checkNoMoveTimeoutForBT();\r
     ICLogger.i("BT NoMoveTimeout "+NoMoveTimeout+", forceLocation="+forceLocation+", Config.forceMoveCheck="+Config.forceMoveCheck+", skipMoveCheck="+skipMoveCheck);\r
 \r
     // 不强制定位 且 (WorkingMod 不是紧急模式 或者 强制进行移动检测),且 没有移动过\r
@@ -865,6 +898,26 @@ public void updateCellInfo() {
 \r
       return false;\r
     }\r
+    //以目前逻辑,每次检测必然跟随蓝牙扫描,因此可以在此直接更新上一次的计步次数,配合下次的运动检测\r
+    runtime.setLastStepCountForBT(runtime.getTotalStepCount());\r
+    return true;\r
+  }\r
+\r
+  private boolean needLocation(){\r
+    updateStepCount();//update StepCount,保证每次定位前,计步数据是最新的。防止丢数据。\r
+    //如果没有动,且超时。则跳过定位\r
+    NoMoveTimeout=checkNoMoveTimeout();\r
+    ICLogger.i(" NoMoveTimeout "+NoMoveTimeout+", forceLocation="+forceLocation+", Config.forceMoveCheck="+Config.forceMoveCheck+", skipMoveCheck="+skipMoveCheck);\r
+\r
+    // 不强制定位 且 (WorkingMod 不是紧急模式 或者 强制进行移动检测),且 没有移动过\r
+    if ( ( forceLocation != 1 ) &&\r
+            (Config.forceMoveCheck==true)  &&\r
+            (NoMoveTimeout) && (skipMoveCheck ==false  )){\r
+      ICLogger.i("No Move ,skip BT location2!");\r
+\r
+      return false;\r
+    }\r
+    //只做正常定位前是否运动的判断,给定位前蓝牙扫描专用的。和 NeedlocationFotBT 还不同。\r
     return true;\r
   }\r
    public void startLocationProcess(int mod){\r
@@ -900,8 +953,7 @@ public void updateCellInfo() {
     forceLocation=0;\r
     isLocating=true;\r
 \r
-\r
-\r
+     //如果不动且超时,则意味着要进行定位,更新计步,配合下一次运动检查。\r
     runtime.setLastStepCount(runtime.getTotalStepCount());\r
     updateCellInfo();\r
     if(!Config.disableWiFiScan)   startWifiScan();\r
index d3c27c0..dbce6d9 100644 (file)
@@ -550,6 +550,7 @@ public class Runtime {
     return dnsUtil;\r
   }\r
   private int lastStepCount=0;\r
+  private int lastStepCountForBT=0;\r
   private long timestamp;\r
   \r
   public int totalStepCount;\r
@@ -577,6 +578,13 @@ public class Runtime {
   public void setLastStepCount(int st){\r
     lastStepCount=st;\r
   }\r
+  public int getLastStepCountForBT(){\r
+        return lastStepCountForBT;\r
+  }\r
+  public void setLastStepCountForBT(int st){\r
+        lastStepCountForBT=st;\r
+    }\r
+\r
   public String IMEI() { return this.imei; }\r
   \r
   public String IMEI_CID() { return this.imei_cid; }\r
index d5be643..11d0da7 100644 (file)
@@ -33,8 +33,9 @@ public class TimeUtil {
   \r
   public static String getSystemTime2(long paramLong) { return (new SimpleDateFormat("yyyyMMdd;HHmmss")).format(new Date(paramLong)); }\r
   \r
+  public static String getSystemTimeyyyyMMddHHmmss() { return getSystemTime3(System.currentTimeMillis()); }\r
   public static String getSystemTime3() { return getSystemTime3(System.currentTimeMillis()); }\r
-  \r
+\r
   public static String getSystemTime3(long paramLong) { return (new SimpleDateFormat("yyyyMMddHHmmss")).format(new Date(paramLong)); }\r
   \r
   public static String getSystemTime4() { return getSystemTime4(System.currentTimeMillis()); }\r
index 1c58bc3..6296d98 100644 (file)
@@ -2243,7 +2243,7 @@ public class protocol_ic {
     public static StringMessage APSL(String date,int deepsleep,int lightsleep,int score){\r
 /***\r
  * 示例:\r
- * IWAPSL,202008003,240,120,90#\r
+ * IWAPSL,20200803,240,120,90#\r
  * 说明:睡眠计算时间 当日21:00至 次日 9:00, 睡眠时间记录为当日时间。如2020-8-3的睡眠时间段为 2020-8-3 21:00 ~ 2020-8-4 09:00\r
  * IW:标识符\r
  * APSL:命令字\r
@@ -2663,6 +2663,11 @@ public class protocol_ic {
      * @return\r
      */\r
     public static StringMessage APBR(Runtime runtime) {\r
+        /**\r
+         * #IWAPBR,353456789012345,080835,1#\r
+         *\r
+         * #IWBPBR#\r
+         */\r
         if (runtime.bleInfo.btScanResult.size() > 0) {\r
             StringBuffer sb=new StringBuffer();\r
             sb.append(runtime.bleInfo.btScanResult.size());\r
@@ -2670,6 +2675,7 @@ public class protocol_ic {
                 sb.append(CMDSPLIT).append(it);\r
             }\r
             return genStringMessage("APBR", new StringBuffer(CMDHEADER).append(cmdMap.get(CMD_TYPE.APBR))\r
+                    .append(CMDSPLIT).append(TimeUtil.getSystemTimeyyyyMMddHHmmss())\r
                     .append(CMDSPLIT).append(sb.toString())\r
                     .append(CMDEND).toString());\r
 \r
index e5b61e3..fcbc851 100644 (file)
@@ -60,8 +60,8 @@ public class protocol_mqtt_client {
 \r
         switch (msg.arg1) {\r
             case MQTTConnectionConstants.STATE_NONE:\r
-//                if (mqttCallbackInterface!= null)\r
-//                    mqttCallbackInterface.onMqttDisconnected();\r
+                if (mqttCallbackInterface!= null)\r
+                    mqttCallbackInterface.onMqttDisconnected();\r
                 break;\r
             case MQTTConnectionConstants.STATE_CONNECTING:\r
                 break;\r
index 0be0e94..7594c8c 100644 (file)
@@ -1,2 +1,2 @@
-#Tue Nov 03 20:07:50 CST 2020\r
-VERSION_CODE=687\r
+#Wed Nov 04 17:27:07 CST 2020\r
+VERSION_CODE=688\r