1、修复每次心跳两次的问题。
authorsnickersun <scy@incartech.cn>
Mon, 9 Mar 2020 09:37:10 +0000 (17:37 +0800)
committersnickersun <scy@incartech.cn>
Mon, 9 Mar 2020 09:37:10 +0000 (17:37 +0800)
2、修复GPS进入工厂测试后,不会再发送已经定位的信息造成的永不GPS定位问题。
3、GPS定位5秒后作为定位标准
4、release V372 版本

app/release/ICSer_V371_2003061530_release.apk [deleted file]
app/release/ICSer_V372_2003091732_release.apk [new file with mode: 0644]
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/NMEAListener.java
app/src/main/java/com/enqualcomm/support/service/Deliver.java
app/src/main/java/com/enqualcomm/support/service/KeepAlive.java
app/src/main/java/com/enqualcomm/support/utils/DeviceInfoUtil.java
app/version_code.properties

diff --git a/app/release/ICSer_V371_2003061530_release.apk b/app/release/ICSer_V371_2003061530_release.apk
deleted file mode 100644 (file)
index abf6b8d..0000000
Binary files a/app/release/ICSer_V371_2003061530_release.apk and /dev/null differ
diff --git a/app/release/ICSer_V372_2003091732_release.apk b/app/release/ICSer_V372_2003091732_release.apk
new file mode 100644 (file)
index 0000000..88f36ea
Binary files /dev/null and b/app/release/ICSer_V372_2003091732_release.apk differ
index 46e1e6d..0abe58b 100644 (file)
@@ -794,7 +794,6 @@ public class CoreService extends Service {
         //心跳指令默认设置为3分钟\r
         AlarmHelper.setRealTimeAlarm(runtime.getContextProxy().context,cycle, HEART_ALARM);\r
         sb.append(" setHeartAlarm  "+HEART_ALARM+", cycle "+cycle);\r
-\r
 //        locationClient.triggerLocationProcess();\r
         ICLogger.i(sb.toString());\r
         FileOutputUtil.fileOutput(runtime.getCacheDir(),"HeartAlarm",sb.toString());\r
@@ -876,7 +875,7 @@ public class CoreService extends Service {
                     public void run() {\r
                         ReConnectToServer();\r
                     }\r
-                }, 0, 20000); //每20秒重试一次\r
+                }, 0, 20000); //每次都是断网才需要重连,所以不需要delay,并且每20秒重试一次\r
             }\r
         }\r
     }\r
index fe6d375..059ce5f 100644 (file)
@@ -70,8 +70,6 @@ public class LocationClient {
 \r
   private static NettyConnection connection;\r
 \r
-\r
-  \r
   private static boolean isLocationCallBack = false;\r
 \r
   private static boolean linkOK = false;\r
@@ -236,7 +234,7 @@ public class LocationClient {
       timeout=false;\r
       //延时2秒执行发送“读取定位”消息\r
       if (mTimer==null) mTimer=new Timer();\r
-      mTimer.schedule(new MyTimerTask(), 0,1000L);\r
+      mTimer.schedule(new MyTimerTask(), 1000L,1000L);\r
   }\r
   class MyTimerTask extends TimerTask {\r
     public void run() {\r
index 8d8ff56..e8e98c1 100644 (file)
@@ -42,6 +42,11 @@ public class NMEAListener implements NmeaListener, LocationListener {
   int numberOfSatellites;\r
   Runtime runtime;\r
 \r
+  private static int MaxFixedTimes=5;\r
+\r
+  private static int locationFixedCount=0;\r
+\r
+\r
 \r
   public void setNoStop(boolean nostop){\r
     noStop=nostop;\r
@@ -117,7 +122,7 @@ public class NMEAListener implements NmeaListener, LocationListener {
             gpsMode = GPS_CURRENT_STATUS.GPS_FIXED;\r
 \r
 \r
-           delaystop();\r
+         //  delaystop();\r
 \r
           break;\r
         case  GpsStatus.GPS_EVENT_STARTED:\r
@@ -158,7 +163,8 @@ public class NMEAListener implements NmeaListener, LocationListener {
       //no start\r
       //do nothing\r
 \r
-      }else if (message.what==MSG_WHAT_GPS_FIXED){\r
+      }\r
+      else if (message.what==MSG_WHAT_GPS_FIXED){\r
         //fixed\r
          /*\r
         只有当前GPS已经定位,且location不为空才给 runtime赋值GPS坐标。\r
@@ -303,7 +309,8 @@ public class NMEAListener implements NmeaListener, LocationListener {
         只有当前GPS已经定位,且location不为空才给 runtime赋值GPS坐标。\r
         延迟三秒后才设置runtime的定位标志,以便稳定坐标值。\r
          */\r
-        if (location != null  && gpsMode == GPS_CURRENT_STATUS.GPS_FIXED ) {\r
+//      if (location != null  && gpsMode == GPS_CURRENT_STATUS.GPS_FIXED ) {\r
+        if (location != null  ) {\r
           longitude = location.getLongitude();\r
           latitude = location.getLatitude();\r
 \r
@@ -348,15 +355,21 @@ public class NMEAListener implements NmeaListener, LocationListener {
              strLatitude = df.format(latitude);\r
              strLongitude = df.format(longitude);\r
 \r
+            locationFixedCount++;\r
 \r
-            sb.append(", gps time "+TimeUtil.getLocalTime(gpsTime)+" lon " + strLongitude + "  lat " + strLatitude +" TimeToFirstFix "+status.getTimeToFirstFix());\r
-\r
+            sb.append(", gps time= "+TimeUtil.getLocalTime(gpsTime)+" ,lon= " + strLongitude + ", lat= " + strLatitude +" FixedCount="+locationFixedCount+", TimeToFirstFix="+status.getTimeToFirstFix());\r
             ICLogger.i( sb.toString());\r
-\r
             if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(this.runtime.getCacheDir(),"GPS",sb.toString());\r
             runtime.getLocationInstance().setLocation(latitude,longitude,speed,0,status.getMaxSatellites());\r
-            if (noStop){//如果是不停止gps,那么每次确认定位的数据都设置标志位,以便其他线程能及时更新数据\r
+            if (locationFixedCount > MaxFixedTimes ){\r
+               /*\r
+                只有当前GPS已经定位,且location不为空才给 runtime赋值GPS坐标。\r
+                延迟MaxFixedTimes秒后才设置runtime的定位标志,以便稳定坐标值。\r
+              */\r
               runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_FIXED);\r
+              if(!noStop){\r
+                stopListen();\r
+              }\r
             }\r
           }\r
 \r
@@ -385,6 +398,7 @@ public class NMEAListener implements NmeaListener, LocationListener {
       longitude = 0;\r
       latitude = 0;\r
       searchCout = 0;\r
+      locationFixedCount=0;\r
       gpsMode = GPS_CURRENT_STATUS.GPS_LISTENING;\r
       locationManager.addGpsStatusListener(statusListener);//监听搜星状态\r
 //    this.locationManager.addNmeaListener(this);\r
index c1343aa..e20ee01 100644 (file)
@@ -112,13 +112,13 @@ public class Deliver extends AbstractConnectionService {
     @Override\r
     public boolean handleMessage(Message message) {\r
 \r
-      switch (message.what){\r
-        case 1:\r
-          mSendMSGHandler.post(delaySendMSG);\r
-          break;\r
-        default:\r
-          break;\r
-      }\r
+//      switch (message.what){\r
+//        case 1:\r
+//          mSendMSGHandler.post(delaySendMSG);\r
+//          break;\r
+//        default:\r
+//          break;\r
+//      }\r
       return false;\r
     }\r
   });\r
@@ -141,7 +141,7 @@ public class Deliver extends AbstractConnectionService {
 //          }\r
 //        }\r
         if (getAndSendMsgFromQueue()==true){\r
-          mSendMSGHandler.postDelayed(delaySendMSG,5000);\r
+          mSendMSGHandler.postDelayed(delaySendMSG,5000L);\r
         }\r
 //        sendingMsg=false;\r
 //        ICLogger.i("exit delaySendMSG!");\r
@@ -179,8 +179,8 @@ public class Deliver extends AbstractConnectionService {
     return ret;\r
   }\r
   public static void triggerSendThread() {\r
-\r
-    mSendMSGHandler.sendEmptyMessage(1);\r
+    mSendMSGHandler.post(delaySendMSG);\r
+//    mSendMSGHandler.sendEmptyMessage(1);\r
   }\r
 \r
   public static boolean getAndSendMsgFromQueue(){\r
@@ -225,7 +225,7 @@ public class Deliver extends AbstractConnectionService {
           str = "no message!\n";\r
         }\r
         ICLogger.i("send cached cmd : \n"+str);\r
-        ICLogger.i("\n"+queue.size()+" in Queue!");\r
+        ICLogger.i("\n"+queue.size()+" left in Queue!");\r
       }finally {\r
         if(mLock!=null && mLock.isLocked())\r
           mLock.unlock();\r
@@ -289,7 +289,9 @@ public static void sendLocationMSG( String Msg){
         if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(mRuntime.getCacheDir(), "APILog", " queueFullskip  " + Msg);\r
 \r
       }\r
-      triggerSendThread();\r
+\r
+//      if(queue.size()>5) //测试queue 发送逻辑用\r
+        triggerSendThread();\r
 \r
     }else {\r
       if (checkNetwork()) {\r
index 7c7e1e3..7c7e39c 100644 (file)
@@ -111,7 +111,7 @@ public class KeepAlive extends AbstractConnectionService {
           public void run() {\r
             checkSrvResponse();\r
           }\r
-        }, 0, heartBeatRetryTimeout*1000); //每5秒重试一次\r
+        }, 3*1000, heartBeatRetryTimeout*1000); //delay 3秒先检查一次,然后每5秒重试一次\r
       }\r
     }\r
   }\r
index b4333fe..0d011ac 100644 (file)
@@ -194,7 +194,8 @@ public class DeviceInfoUtil {
             .append(DeviceInfoUtil.getVersionCode(runtime.getContextProxy().context))\r
             .append(SimSignalUtil.hasSimCard(runtime.getContextProxy().context)?" SIM ":" NoSIM ")\r
             .append(sim.getNetworkType()==SimSignalUtil.IS_2G?"2G":(sim.getNetworkType()==SimSignalUtil.IS_3G)?"3G":(sim.getNetworkType()==SimSignalUtil.IS_4G?"4G":"unknown"))\r
-            .append(" [").append(runtime.getSignalStrength()).append(",Mini:").append(SimSignalUtil.getMinSignalStrength(sim.getNetworkType())).append("]")\r
+            .append(" [").append(runtime.getSignalStrength()).append(",Mini:").append(SimSignalUtil.getMinSignalStrength(sim.getNetworkType())).append("] ")\r
+            .append(runtime.IMEI())\r
             .append("\n SocketConnection ").append(KeepAlive.isConnected).append(" , HBcycle ").append(runtime.getHeartBeatCycle())\r
             .append("\n ServerConnected is ").append(runtime.isServerProtocolConnected())\r
             .append(" \n Bat ").append(runtime.getBattery()).append(",").append(runtime.getBatteryVotage())\r
index 29f92bf..c0f4754 100644 (file)
@@ -1,2 +1,2 @@
-#Fri Mar 06 15:30:32 CST 2020\r
-VERSION_CODE=371\r
+#Mon Mar 09 17:32:36 CST 2020\r
+VERSION_CODE=372\r