修改定位移动检测的逻辑
authorTrillGates <williamtrillgates@gmail.com>
Mon, 8 Nov 2021 08:57:43 +0000 (16:57 +0800)
committerTrillGates <williamtrillgates@gmail.com>
Mon, 8 Nov 2021 08:57:43 +0000 (16:57 +0800)
app/src/main/java/com/enqualcomm/support/CoreService.java
app/src/main/java/com/enqualcomm/support/LocationClient.java

index 2a5f715..b76b283 100644 (file)
@@ -23,6 +23,8 @@ import android.os.PowerManager;
 import android.support.annotation.Nullable;
 import android.text.TextUtils;
 import android.util.Log;
+import android.view.View;
+import android.widget.TextView;
 import android.widget.Toast;
 
 import com.enqualcomm.support.adapter.LBSHelper;
index 294d532..b339825 100644 (file)
@@ -893,11 +893,49 @@ public class LocationClient {
 
     }
 
+    private String lastMCC = "";
+    private String lastMnc = "";
+    private long lastLAC = 0l;
+    private long lastCID = 0l;
+
+    private boolean checkLBS() {
+        //获取LBS上一次的数据,与当前的数据进行对比即可
+        //只要有一个是变化的,那么我们就认为是变化了
+        ICLocation locationInstance = runtime.getLocationInstance();
+        String mcc = locationInstance.getMCC();
+        ICLogger.d("mcc==> " + mcc);
+        String mnc = locationInstance.getMNC();
+        ICLogger.d("mnc==> " + mnc);
+        long lac = locationInstance.getLAC();
+        ICLogger.d("lac==> " + lac);
+        long gsmStationCID = locationInstance.getGSMStationCID();
+        ICLogger.d("gsmStationCID==> " + gsmStationCID);
+        //判断跟上一次的是否一样,如果一样的话就没有变化
+        //如果变了,那么就返回true
+        ICLogger.d("last ==> lastMCC " + lastMCC + " lastMnc ==> " +
+                lastMnc + " lastLAC ==> " + lastLAC + " lastCID " + lastCID);
+        boolean result = false;
+        if (!lastMCC.equals(mcc) || !lastMnc.equals(mnc) || lastCID != gsmStationCID || lastLAC != lac) {
+            result = true;
+        }
+        //更新值
+        lastMnc = mnc;
+        lastMCC = mcc;
+        lastLAC = lac;
+        lastCID = gsmStationCID;
+        return result;
+    }
+
     /***
      *noMove and timeout return true
      * else return false
      */
     private boolean checkNoMoveTimeout() {
+        //如果LBS变化了,我们就认为位置改变了
+        if (checkLBS()) {
+            ICLogger.d("ON LBS CHANGE...");
+            return false;
+        }
         noMove = (runtime.getTotalStepCount() - runtime.getLastStepCount() <= 0);
         runtime.updateFZDDevStatusMoving(!noMove); //设置当前运动状态
         ICLogger.i("checkNoMoveTimeout last_noMove " + last_noMove + " noMove " + noMove + " lastStepCount " + runtime.getLastStepCount() + " StepCount " + runtime.getTotalStepCount());