From: snickersun Date: Fri, 28 Aug 2020 12:18:36 +0000 (+0800) Subject: release V508 X-Git-Url: http://git.snicker.com.cn/sitemap.xml?a=commitdiff_plain;h=2360ad1ca097c59dc04f9fce4f5345aaafa5d23e;p=protocol_srv.git release V508 发现网络即使通过心跳重发机制,也无法解决长时间 socket假链接的情况。因此添加15分钟(3次心跳)链接服务器无反馈后 自主断开网络的机制。 --- diff --git a/app/release/ICSer_V507_2008281155_release.apk b/app/release/ICSer_V508_2008282016_release.apk similarity index 78% rename from app/release/ICSer_V507_2008281155_release.apk rename to app/release/ICSer_V508_2008282016_release.apk index 6ea4569a..f1c71f90 100644 Binary files a/app/release/ICSer_V507_2008281155_release.apk and b/app/release/ICSer_V508_2008282016_release.apk differ diff --git a/app/release/output.json b/app/release/output.json index 4e481961..a55727f9 100644 --- a/app/release/output.json +++ b/app/release/output.json @@ -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 diff --git a/app/src/main/java/com/enqualcomm/support/bean/Runtime.java b/app/src/main/java/com/enqualcomm/support/bean/Runtime.java index feb4951f..99088f0b 100644 --- a/app/src/main/java/com/enqualcomm/support/bean/Runtime.java +++ b/app/src/main/java/com/enqualcomm/support/bean/Runtime.java @@ -23,7 +23,7 @@ public class Runtime { public int anti_test_cycle=30; public int SignalStrength; - + public long lastLoginSuccessTime=0; public TemperatureInfo tempInfo=new TemperatureInfo(); public boolean BindingStatus=false; private String battery="000"; diff --git a/app/src/main/java/com/enqualcomm/support/service/KeepAlive.java b/app/src/main/java/com/enqualcomm/support/service/KeepAlive.java index f11fb3f7..a4840f41 100644 --- a/app/src/main/java/com/enqualcomm/support/service/KeepAlive.java +++ b/app/src/main/java/com/enqualcomm/support/service/KeepAlive.java @@ -110,18 +110,25 @@ public class KeepAlive extends AbstractConnectionService { //更新系统的IMEI boolean ret=DeviceInfoUtil.updateImei(mRuntime); ICLogger.i("Update IMEI "+ret); - if (is_login_send_success) { + //只有曾经login成功过,且上一次成功时间超过15分钟,才会自主断开网络。 + long currenttime=System.currentTimeMillis(); + ICLogger.i("只有曾经login或者心跳发送成功过,且上一次成功时间超过15分钟,才会自主断开网络! last longin time "+ + mRuntime.lastLoginSuccessTime+" ms from last login time "+(currenttime-mRuntime.lastLoginSuccessTime)); + if ((mRuntime.lastLoginSuccessTime>0) && ((currenttime- mRuntime.lastLoginSuccessTime) > 15 * 60 * 1000)) { + ICLogger.i("超时自主断开网络!"); + CoreService.getInstance().disconnect_server(); + }else { + if (is_login_send_success) { connection.send(protocolAPIHelper.genStringMessage("heartbeat", protocolAPIHelper.getHeartbeatMSG(mRuntime))); Observable.timer(1000L, TimeUnit.MILLISECONDS).subscribe(new Action1() { - public void call(Long param1Long) { - connection.send(protocolAPIHelper.genStringMessage("binding", protocolAPIHelper.getBindingMSG())); - - } + public void call(Long param1Long) { + connection.send(protocolAPIHelper.genStringMessage("binding", protocolAPIHelper.getBindingMSG())); + } }); + } else { + connection.send(protocolAPIHelper.genStringMessage("heartbeat", protocolAPIHelper.getLoginMSG(mRuntime))); + } } - else - connection.send(protocolAPIHelper.genStringMessage("heartbeat", protocolAPIHelper.getLoginMSG(mRuntime))); - } } @@ -313,7 +320,7 @@ public class KeepAlive extends AbstractConnectionService { paramRuntime.setServerProtocolConnected(true); // isConnected = true; is_heartBeat_send_success=true; - + paramRuntime.lastLoginSuccessTime=System.currentTimeMillis(); // LauncherCtrl.getInstance(this.mContext).setStatusBarIcon("server_connected", STATUS_BAR_STATE_SERVER_CONNECTED_ON); // Deliver.triggerSendThread(); //链接上就尝试清除 buffer中的数据 @@ -325,7 +332,7 @@ public class KeepAlive extends AbstractConnectionService { } }else if (paramStringMessage.cmd().equals("login")) { //广播服务器连接成功的消息 - // paramRuntime.getContextProxy().sendBroadcastServerConnectionChanged(true); + paramRuntime.getContextProxy().sendBroadcastServerConnectionChanged(true); //登录包收到就停止重链接服务器 CoreService.getInstance().stopConnectionRetryTimer(); is_login_send_success=true; @@ -333,6 +340,8 @@ public class KeepAlive extends AbstractConnectionService { //心跳开始发送的时候,先重置response检测标志 is_heartBeat_send_success=false; + + paramRuntime.lastLoginSuccessTime=System.currentTimeMillis(); //发送心跳包 Observable.timer(3500L, TimeUnit.MILLISECONDS).subscribe(new Action1() { public void call(Long param1Long) { diff --git a/app/version_code.properties b/app/version_code.properties index 6871fe49..1f14a362 100644 --- a/app/version_code.properties +++ b/app/version_code.properties @@ -1,2 +1,2 @@ -#Fri Aug 28 11:55:33 CST 2020 -VERSION_CODE=507 +#Fri Aug 28 20:16:02 CST 2020 +VERSION_CODE=508