release V508
authorsnickersun <scy@incartech.cn>
Fri, 28 Aug 2020 12:18:36 +0000 (20:18 +0800)
committersnickersun <scy@incartech.cn>
Fri, 28 Aug 2020 12:18:36 +0000 (20:18 +0800)
发现网络即使通过心跳重发机制,也无法解决长时间 socket假链接的情况。因此添加15分钟(3次心跳)链接服务器无反馈后 自主断开网络的机制。

app/release/ICSer_V508_2008282016_release.apk [moved from app/release/ICSer_V507_2008281155_release.apk with 78% similarity]
app/release/output.json
app/src/main/java/com/enqualcomm/support/bean/Runtime.java
app/src/main/java/com/enqualcomm/support/service/KeepAlive.java
app/version_code.properties

similarity index 78%
rename from app/release/ICSer_V507_2008281155_release.apk
rename to app/release/ICSer_V508_2008282016_release.apk
index 6ea4569..f1c71f9 100644 (file)
Binary files a/app/release/ICSer_V507_2008281155_release.apk and b/app/release/ICSer_V508_2008282016_release.apk differ
index 4e48196..a55727f 100644 (file)
@@ -1 +1 @@
-[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":507,"versionName":"2008281155","enabled":true,"outputFile":"ICSer_V507_2008281155_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V507_2008281155_release.apk","properties":{}}]
\ No newline at end of file
+[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":508,"versionName":"2008282016","enabled":true,"outputFile":"ICSer_V508_2008282016_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V508_2008282016_release.apk","properties":{}}]
\ No newline at end of file
index feb4951..99088f0 100644 (file)
@@ -23,7 +23,7 @@ public class Runtime {
     public int anti_test_cycle=30;\r
 \r
     public int SignalStrength;\r
-\r
+    public long lastLoginSuccessTime=0;\r
     public TemperatureInfo tempInfo=new TemperatureInfo();\r
   public boolean BindingStatus=false;\r
   private String battery="000";\r
index f11fb3f..a4840f4 100644 (file)
@@ -110,18 +110,25 @@ public class KeepAlive extends AbstractConnectionService {
           //更新系统的IMEI\r
           boolean ret=DeviceInfoUtil.updateImei(mRuntime);\r
           ICLogger.i("Update IMEI "+ret);\r
-          if (is_login_send_success) {\r
+          //只有曾经login成功过,且上一次成功时间超过15分钟,才会自主断开网络。\r
+          long currenttime=System.currentTimeMillis();\r
+          ICLogger.i("只有曾经login或者心跳发送成功过,且上一次成功时间超过15分钟,才会自主断开网络! last longin time "+\r
+                  mRuntime.lastLoginSuccessTime+" ms from last login time "+(currenttime-mRuntime.lastLoginSuccessTime));\r
+          if ((mRuntime.lastLoginSuccessTime>0) && ((currenttime- mRuntime.lastLoginSuccessTime) > 15 * 60 * 1000)) {\r
+            ICLogger.i("超时自主断开网络!");\r
+            CoreService.getInstance().disconnect_server();\r
+          }else {\r
+            if (is_login_send_success) {\r
               connection.send(protocolAPIHelper.genStringMessage("heartbeat", protocolAPIHelper.getHeartbeatMSG(mRuntime)));\r
               Observable.timer(1000L, TimeUnit.MILLISECONDS).subscribe(new Action1<Long>() {\r
-                  public void call(Long param1Long) {\r
-                      connection.send(protocolAPIHelper.genStringMessage("binding", protocolAPIHelper.getBindingMSG()));\r
-\r
-                  }\r
+                public void call(Long param1Long) {\r
+                  connection.send(protocolAPIHelper.genStringMessage("binding", protocolAPIHelper.getBindingMSG()));\r
+                }\r
               });\r
+            } else {\r
+              connection.send(protocolAPIHelper.genStringMessage("heartbeat", protocolAPIHelper.getLoginMSG(mRuntime)));\r
+            }\r
           }\r
-          else\r
-            connection.send(protocolAPIHelper.genStringMessage("heartbeat", protocolAPIHelper.getLoginMSG(mRuntime)));\r
-\r
         }\r
       }\r
 \r
@@ -313,7 +320,7 @@ public class KeepAlive extends AbstractConnectionService {
       paramRuntime.setServerProtocolConnected(true);\r
 //      isConnected = true;\r
       is_heartBeat_send_success=true;\r
-\r
+      paramRuntime.lastLoginSuccessTime=System.currentTimeMillis();\r
 //      LauncherCtrl.getInstance(this.mContext).setStatusBarIcon("server_connected", STATUS_BAR_STATE_SERVER_CONNECTED_ON);\r
 //      Deliver.triggerSendThread(); //链接上就尝试清除 buffer中的数据\r
 \r
@@ -325,7 +332,7 @@ public class KeepAlive extends AbstractConnectionService {
       }\r
     }else   if (paramStringMessage.cmd().equals("login")) {\r
       //广播服务器连接成功的消息\r
-     // paramRuntime.getContextProxy().sendBroadcastServerConnectionChanged(true);\r
+      paramRuntime.getContextProxy().sendBroadcastServerConnectionChanged(true);\r
       //登录包收到就停止重链接服务器\r
       CoreService.getInstance().stopConnectionRetryTimer();\r
       is_login_send_success=true;\r
@@ -333,6 +340,8 @@ public class KeepAlive extends AbstractConnectionService {
 \r
       //心跳开始发送的时候,先重置response检测标志\r
       is_heartBeat_send_success=false;\r
+\r
+      paramRuntime.lastLoginSuccessTime=System.currentTimeMillis();\r
       //发送心跳包\r
       Observable.timer(3500L, TimeUnit.MILLISECONDS).subscribe(new Action1<Long>() {\r
         public void call(Long param1Long) {\r
index 6871fe4..1f14a36 100644 (file)
@@ -1,2 +1,2 @@
-#Fri Aug 28 11:55:33 CST 2020\r
-VERSION_CODE=507\r
+#Fri Aug 28 20:16:02 CST 2020\r
+VERSION_CODE=508\r