From: snickersun Date: Mon, 9 Mar 2020 09:37:10 +0000 (+0800) Subject: 1、修复每次心跳两次的问题。 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=95ac1f2cd38dd54d48e5fa4d04b4b8cd68d08866;p=icsupport.git 1、修复每次心跳两次的问题。 2、修复GPS进入工厂测试后,不会再发送已经定位的信息造成的永不GPS定位问题。 3、GPS定位5秒后作为定位标准 4、release V372 版本 --- diff --git a/app/release/ICSer_V371_2003061530_release.apk b/app/release/ICSer_V371_2003061530_release.apk deleted file mode 100644 index abf6b8da..00000000 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 index 00000000..88f36ea8 Binary files /dev/null and b/app/release/ICSer_V372_2003091732_release.apk differ diff --git a/app/src/main/java/com/enqualcomm/support/CoreService.java b/app/src/main/java/com/enqualcomm/support/CoreService.java index 46e1e6d8..0abe58b4 100644 --- a/app/src/main/java/com/enqualcomm/support/CoreService.java +++ b/app/src/main/java/com/enqualcomm/support/CoreService.java @@ -794,7 +794,6 @@ public class CoreService extends Service { //心跳指令默认设置为3分钟 AlarmHelper.setRealTimeAlarm(runtime.getContextProxy().context,cycle, HEART_ALARM); sb.append(" setHeartAlarm "+HEART_ALARM+", cycle "+cycle); - // locationClient.triggerLocationProcess(); ICLogger.i(sb.toString()); FileOutputUtil.fileOutput(runtime.getCacheDir(),"HeartAlarm",sb.toString()); @@ -876,7 +875,7 @@ public class CoreService extends Service { public void run() { ReConnectToServer(); } - }, 0, 20000); //每20秒重试一次 + }, 0, 20000); //每次都是断网才需要重连,所以不需要delay,并且每20秒重试一次 } } } diff --git a/app/src/main/java/com/enqualcomm/support/LocationClient.java b/app/src/main/java/com/enqualcomm/support/LocationClient.java index fe6d375a..059ce5f6 100644 --- a/app/src/main/java/com/enqualcomm/support/LocationClient.java +++ b/app/src/main/java/com/enqualcomm/support/LocationClient.java @@ -70,8 +70,6 @@ public class LocationClient { private static NettyConnection connection; - - private static boolean isLocationCallBack = false; private static boolean linkOK = false; @@ -236,7 +234,7 @@ public class LocationClient { timeout=false; //延时2秒执行发送“读取定位”消息 if (mTimer==null) mTimer=new Timer(); - mTimer.schedule(new MyTimerTask(), 0,1000L); + mTimer.schedule(new MyTimerTask(), 1000L,1000L); } class MyTimerTask extends TimerTask { public void run() { diff --git a/app/src/main/java/com/enqualcomm/support/NMEAListener.java b/app/src/main/java/com/enqualcomm/support/NMEAListener.java index 8d8ff56c..e8e98c17 100644 --- a/app/src/main/java/com/enqualcomm/support/NMEAListener.java +++ b/app/src/main/java/com/enqualcomm/support/NMEAListener.java @@ -42,6 +42,11 @@ public class NMEAListener implements NmeaListener, LocationListener { int numberOfSatellites; Runtime runtime; + private static int MaxFixedTimes=5; + + private static int locationFixedCount=0; + + public void setNoStop(boolean nostop){ noStop=nostop; @@ -117,7 +122,7 @@ public class NMEAListener implements NmeaListener, LocationListener { gpsMode = GPS_CURRENT_STATUS.GPS_FIXED; - delaystop(); + // delaystop(); break; case GpsStatus.GPS_EVENT_STARTED: @@ -158,7 +163,8 @@ public class NMEAListener implements NmeaListener, LocationListener { //no start //do nothing - }else if (message.what==MSG_WHAT_GPS_FIXED){ + } + else if (message.what==MSG_WHAT_GPS_FIXED){ //fixed /* 只有当前GPS已经定位,且location不为空才给 runtime赋值GPS坐标。 @@ -303,7 +309,8 @@ public class NMEAListener implements NmeaListener, LocationListener { 只有当前GPS已经定位,且location不为空才给 runtime赋值GPS坐标。 延迟三秒后才设置runtime的定位标志,以便稳定坐标值。 */ - if (location != null && gpsMode == GPS_CURRENT_STATUS.GPS_FIXED ) { +// if (location != null && gpsMode == GPS_CURRENT_STATUS.GPS_FIXED ) { + if (location != null ) { longitude = location.getLongitude(); latitude = location.getLatitude(); @@ -348,15 +355,21 @@ public class NMEAListener implements NmeaListener, LocationListener { strLatitude = df.format(latitude); strLongitude = df.format(longitude); + locationFixedCount++; - sb.append(", gps time "+TimeUtil.getLocalTime(gpsTime)+" lon " + strLongitude + " lat " + strLatitude +" TimeToFirstFix "+status.getTimeToFirstFix()); - + sb.append(", gps time= "+TimeUtil.getLocalTime(gpsTime)+" ,lon= " + strLongitude + ", lat= " + strLatitude +" FixedCount="+locationFixedCount+", TimeToFirstFix="+status.getTimeToFirstFix()); ICLogger.i( sb.toString()); - if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(this.runtime.getCacheDir(),"GPS",sb.toString()); runtime.getLocationInstance().setLocation(latitude,longitude,speed,0,status.getMaxSatellites()); - if (noStop){//如果是不停止gps,那么每次确认定位的数据都设置标志位,以便其他线程能及时更新数据 + if (locationFixedCount > MaxFixedTimes ){ + /* + 只有当前GPS已经定位,且location不为空才给 runtime赋值GPS坐标。 + 延迟MaxFixedTimes秒后才设置runtime的定位标志,以便稳定坐标值。 + */ runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_FIXED); + if(!noStop){ + stopListen(); + } } } @@ -385,6 +398,7 @@ public class NMEAListener implements NmeaListener, LocationListener { longitude = 0; latitude = 0; searchCout = 0; + locationFixedCount=0; gpsMode = GPS_CURRENT_STATUS.GPS_LISTENING; locationManager.addGpsStatusListener(statusListener);//监听搜星状态 // this.locationManager.addNmeaListener(this); diff --git a/app/src/main/java/com/enqualcomm/support/service/Deliver.java b/app/src/main/java/com/enqualcomm/support/service/Deliver.java index c1343aa7..e20ee01e 100644 --- a/app/src/main/java/com/enqualcomm/support/service/Deliver.java +++ b/app/src/main/java/com/enqualcomm/support/service/Deliver.java @@ -112,13 +112,13 @@ public class Deliver extends AbstractConnectionService { @Override public boolean handleMessage(Message message) { - switch (message.what){ - case 1: - mSendMSGHandler.post(delaySendMSG); - break; - default: - break; - } +// switch (message.what){ +// case 1: +// mSendMSGHandler.post(delaySendMSG); +// break; +// default: +// break; +// } return false; } }); @@ -141,7 +141,7 @@ public class Deliver extends AbstractConnectionService { // } // } if (getAndSendMsgFromQueue()==true){ - mSendMSGHandler.postDelayed(delaySendMSG,5000); + mSendMSGHandler.postDelayed(delaySendMSG,5000L); } // sendingMsg=false; // ICLogger.i("exit delaySendMSG!"); @@ -179,8 +179,8 @@ public class Deliver extends AbstractConnectionService { return ret; } public static void triggerSendThread() { - - mSendMSGHandler.sendEmptyMessage(1); + mSendMSGHandler.post(delaySendMSG); +// mSendMSGHandler.sendEmptyMessage(1); } public static boolean getAndSendMsgFromQueue(){ @@ -225,7 +225,7 @@ public class Deliver extends AbstractConnectionService { str = "no message!\n"; } ICLogger.i("send cached cmd : \n"+str); - ICLogger.i("\n"+queue.size()+" in Queue!"); + ICLogger.i("\n"+queue.size()+" left in Queue!"); }finally { if(mLock!=null && mLock.isLocked()) mLock.unlock(); @@ -289,7 +289,9 @@ public static void sendLocationMSG( String Msg){ if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(mRuntime.getCacheDir(), "APILog", " queueFullskip " + Msg); } - triggerSendThread(); + +// if(queue.size()>5) //测试queue 发送逻辑用 + triggerSendThread(); }else { if (checkNetwork()) { 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 7c7e1e36..7c7e39c3 100644 --- a/app/src/main/java/com/enqualcomm/support/service/KeepAlive.java +++ b/app/src/main/java/com/enqualcomm/support/service/KeepAlive.java @@ -111,7 +111,7 @@ public class KeepAlive extends AbstractConnectionService { public void run() { checkSrvResponse(); } - }, 0, heartBeatRetryTimeout*1000); //每5秒重试一次 + }, 3*1000, heartBeatRetryTimeout*1000); //delay 3秒先检查一次,然后每5秒重试一次 } } } diff --git a/app/src/main/java/com/enqualcomm/support/utils/DeviceInfoUtil.java b/app/src/main/java/com/enqualcomm/support/utils/DeviceInfoUtil.java index b4333fea..0d011ac8 100644 --- a/app/src/main/java/com/enqualcomm/support/utils/DeviceInfoUtil.java +++ b/app/src/main/java/com/enqualcomm/support/utils/DeviceInfoUtil.java @@ -194,7 +194,8 @@ public class DeviceInfoUtil { .append(DeviceInfoUtil.getVersionCode(runtime.getContextProxy().context)) .append(SimSignalUtil.hasSimCard(runtime.getContextProxy().context)?" SIM ":" NoSIM ") .append(sim.getNetworkType()==SimSignalUtil.IS_2G?"2G":(sim.getNetworkType()==SimSignalUtil.IS_3G)?"3G":(sim.getNetworkType()==SimSignalUtil.IS_4G?"4G":"unknown")) - .append(" [").append(runtime.getSignalStrength()).append(",Mini:").append(SimSignalUtil.getMinSignalStrength(sim.getNetworkType())).append("]") + .append(" [").append(runtime.getSignalStrength()).append(",Mini:").append(SimSignalUtil.getMinSignalStrength(sim.getNetworkType())).append("] ") + .append(runtime.IMEI()) .append("\n SocketConnection ").append(KeepAlive.isConnected).append(" , HBcycle ").append(runtime.getHeartBeatCycle()) .append("\n ServerConnected is ").append(runtime.isServerProtocolConnected()) .append(" \n Bat ").append(runtime.getBattery()).append(",").append(runtime.getBatteryVotage()) diff --git a/app/version_code.properties b/app/version_code.properties index 29f92bfa..c0f4754b 100644 --- a/app/version_code.properties +++ b/app/version_code.properties @@ -1,2 +1,2 @@ -#Fri Mar 06 15:30:32 CST 2020 -VERSION_CODE=371 +#Mon Mar 09 17:32:36 CST 2020 +VERSION_CODE=372