From: snickersun Date: Fri, 13 Mar 2020 08:19:05 +0000 (+0800) Subject: release V375 版本 X-Git-Url: http://git.snicker.com.cn/sitemap.xml?a=commitdiff_plain;h=2aa67880e69709f5939b6f63eb8d0fc3eaef7a9d;p=icsupport.git release V375 版本 1、增加Wifi扫描重试,最多3次 2、修复GPS 60分钟就会被重启,造成一直无法定位问题。 3、日志文件裁剪,去掉不必要的提示。 4、GPS定位对HDOP进行校验,如果误差大于50米,则直接剔除。 --- diff --git a/app/debug/ICSer_V374_2003131611_debug.apk b/app/debug/ICSer_V374_2003131611_debug.apk new file mode 100644 index 00000000..574e15c8 Binary files /dev/null and b/app/debug/ICSer_V374_2003131611_debug.apk differ diff --git a/app/release/ICSer_V374_2003131011_release.apk b/app/release/ICSer_V374_2003131011_release.apk deleted file mode 100644 index d3c557ce..00000000 Binary files a/app/release/ICSer_V374_2003131011_release.apk and /dev/null differ diff --git a/app/release/ICSer_V375_2003131612_release.apk b/app/release/ICSer_V375_2003131612_release.apk new file mode 100644 index 00000000..55df8804 Binary files /dev/null and b/app/release/ICSer_V375_2003131612_release.apk differ diff --git a/app/src/main/java/com/enqualcomm/support/LocationClient.java b/app/src/main/java/com/enqualcomm/support/LocationClient.java index c2e8bce7..edfb7f1b 100644 --- a/app/src/main/java/com/enqualcomm/support/LocationClient.java +++ b/app/src/main/java/com/enqualcomm/support/LocationClient.java @@ -215,17 +215,22 @@ public class LocationClient { // public void EqcAlgorithmInterfaceMethod2() { public void startGpsLocate() { ICLogger.i("开启GPS扫描"); - runtime.getLocationInstance().setLocationStat( ICLocation.LOCATION_STAT.LOCATION_OPEN); //此处为了检测是否定位时可以正确识别状态,以防一直处于GPS定位成功状态 - //防止与工厂测试冲突 - if (!DeviceInfoUtil.isFactoryTestTopActivity(runtime.getContextProxy().context)) { + if(!nmeaListener.isListening()) { + runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_OPEN); //此处为了检测是否定位时可以正确识别状态,以防一直处于GPS定位成功状态 - Settings.Secure.setLocationProviderEnabled(runtime.getContextProxy().getResolver(), GPS_PROVIDER, true); - Single.just(null).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1() { - public void call(Object param1Object) { - LocationClient.this.nmeaListener.startListen(); - } - }); + //防止与工厂测试冲突 + if (!DeviceInfoUtil.isFactoryTestTopActivity(runtime.getContextProxy().context)) { + + Settings.Secure.setLocationProviderEnabled(runtime.getContextProxy().getResolver(), GPS_PROVIDER, true); + Single.just(null).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1() { + public void call(Object param1Object) { + LocationClient.this.nmeaListener.startListen(); + } + }); + } + }else{ + ICLogger.i("GPS is still listening, skip open it!"); } } @@ -291,7 +296,7 @@ public class LocationClient { && runtime.getLocationInstance().getGSMStationCID() ==0 && runtime.getLocationInstance().getLAC()==0)) ?false:true; // ICLogger.i("getMNC "+runtime.getLocationInstance().getMNC()+" getMCC "+runtime.getLocationInstance().getMCC()+" getGSMStationCID " + runtime.getLocationInstance().getGSMStationCID()+ " getLAC "+runtime.getLocationInstance().getLAC()+" changed "+runtime.getLocationInstance().isDataChanged()); - ICLogger.i("lbs_ok "+lbs_ok+" waitAndSendLocation wifi_ok " + wifi_ok+ " gps_ok "+gps_ok + " mode "+mode); + ICLogger.i("waitAndSendLocation lbs="+lbs_ok+", wifi="+ wifi_ok+ ", gps="+gps_ok + ", mode="+mode); switch(mode){ case ICLocation.CUSTOM_MOD: diff --git a/app/src/main/java/com/enqualcomm/support/NMEAListener.java b/app/src/main/java/com/enqualcomm/support/NMEAListener.java index d7ed096e..c7764924 100644 --- a/app/src/main/java/com/enqualcomm/support/NMEAListener.java +++ b/app/src/main/java/com/enqualcomm/support/NMEAListener.java @@ -25,7 +25,9 @@ import java.util.List; public class NMEAListener implements NmeaListener, LocationListener { private boolean listening=false; - + public boolean isListening(){ + return listening; + } public class GpsSatellitePriv { int prn; float snr; @@ -50,6 +52,7 @@ public class NMEAListener implements NmeaListener, LocationListener { private boolean noStop=false; + private int SearchTimeout = 120; private int noSignalCount=0; private int searchCout=0; @@ -212,14 +215,14 @@ public class NMEAListener implements NmeaListener, LocationListener { StringBuilder sb2=new StringBuilder(); if(!noStop) { - if (searchCout > SearchTimeout) { - sb2.append(" 搜索" + searchCout + "次未定位,超过" + SearchTimeout + "限制退出GPS定位"); + if (searchCout > ICLocation.MAX_GPS_SEARCH_TIMEOUT) { + sb2.append(" 搜索" + searchCout + "次未定位,超过" + ICLocation.MAX_GPS_SEARCH_TIMEOUT + "限制退出GPS定位"); runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_GPS_TIEMOUT); stop(MSG_WHAT_GPS_TIMEOUT); } - if (noSignalCount > 10) { + if (noSignalCount > ICLocation.MAX_GPS_NOSIGNAL_COUNT) { sb2.append(" 搜索" + searchCout + "次,超过" + noSignalCount + "次没有收到星,退出GPS定位"); runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_GPS_TIEMOUT); stop(MSG_WHAT_GPS_NOSTAR); @@ -267,9 +270,13 @@ public class NMEAListener implements NmeaListener, LocationListener { if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "GPS", sb.toString()); //定位了, - - locationFixedCount++; - + if (hdop!=null&& hdop.trim().length()>0 && Float.valueOf(hdop)>ICLocation.MAX_HDOP) { + locationFixedCount++; + }else{ + ICLogger.i("HDOP is larger than "+ICLocation.MAX_HDOP+" , skip this location!"); + if (Config.LOG_TOFILE) + FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "GPS", "HDOP is larger than "+ICLocation.MAX_HDOP+" , skip this location!"); + } if (locationFixedCount > MaxFixedTimes) { /* 只有当前GPS已经定位,且location不为空才给 runtime赋值GPS坐标。 @@ -280,6 +287,8 @@ public class NMEAListener implements NmeaListener, LocationListener { runtime.getLocationInstance().setHod(Float.valueOf(hdop.trim())); runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_FIXED); ICLogger.i("定位"+locationFixedCount+"次 > "+MaxFixedTimes+", set LOCATION_FIXED "); + if (Config.LOG_TOFILE) + FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "GPS", "定位"+locationFixedCount+"次 > "+MaxFixedTimes+", set LOCATION_FIXED "); if (!noStop) { stopListen(); } diff --git a/app/src/main/java/com/enqualcomm/support/adapter/LBSHelper.java b/app/src/main/java/com/enqualcomm/support/adapter/LBSHelper.java index cd605851..3f950b60 100644 --- a/app/src/main/java/com/enqualcomm/support/adapter/LBSHelper.java +++ b/app/src/main/java/com/enqualcomm/support/adapter/LBSHelper.java @@ -55,6 +55,9 @@ public class LBSHelper { private String wifiInfoResult; private WifiManager wifiManager; + private final int MsgWhat_GetWifiResult=104; + private int MaxWiFiScanRetryTimes=3; + private static int CurrentWiFiScanTimes=0; public LBSHelper(Context _context, WifiManager _wifiManager, Runtime dev) { this.wifiManager = _wifiManager; @@ -73,16 +76,24 @@ public class LBSHelper { @Override public void handleMessage(Message msg) { super.handleMessage(msg); - if (msg.what == 104) { + if (msg.what == MsgWhat_GetWifiResult) { //停止扫描 - StringBuilder sb = LBSHelper.this.handScanResults(); + StringBuilder sb = handScanResults(); if (sb == null) { - LBSHelper.this.wifiInfoResult = null; + CurrentWiFiScanTimes++; + if (CurrentWiFiScanTimes< MaxWiFiScanRetryTimes) { + ICLogger.i("WiFi Scan get Result failed , retry scan "+CurrentWiFiScanTimes+ " times"); + wifiManager.startScan(); + delayedStopScan(); + return; + }else { + wifiInfoResult = null; + } } else { - LBSHelper.this.wifiInfoResult = sb.toString(); + wifiInfoResult = sb.toString(); } - if (LBSHelper.this.mMyWifiListener != null) { - LBSHelper.this.mMyWifiListener.getWifiInfoCallBack(LBSHelper.this.wifiInfoResult); + if (mMyWifiListener != null) { + mMyWifiListener.getWifiInfoCallBack(wifiInfoResult); if ((runtime.isNoTurnOffWifiOnScreenOff() && !SimSignalUtil.isScreenON(runtime.getContextProxy().context)) || DeviceInfoUtil.isFactoryTestTopActivity(runtime.getContextProxy().context)) { @@ -106,7 +117,8 @@ public class LBSHelper { private StringBuilder handScanResults() { List aplist = this.wifiManager.getScanResults(); - if (aplist.size() < 2) { + ICLogger.i("get Wifi Result "+aplist.size()); + if (aplist.size() < 1) { return null; } else { this.sortByLevel(aplist); @@ -144,7 +156,7 @@ public class LBSHelper { } private void delayedStopScan() { - LBSHelper.this.mHandler.sendEmptyMessageDelayed(104,3000L); + mHandler.sendEmptyMessageDelayed(MsgWhat_GetWifiResult,3000L); } // public void unRegisterWiFiBroadReceiver() { @@ -271,6 +283,8 @@ public class LBSHelper { e.printStackTrace(); } } + + CurrentWiFiScanTimes=0; wifiManager.startScan(); delayedStopScan(); @@ -294,15 +308,15 @@ public class LBSHelper { public void onSignalStrengthsChanged(SignalStrength ss) { super.onSignalStrengthsChanged(ss); - if (((TelephonyManager) LBSHelper.this.context.getSystemService(Context.TELEPHONY_SERVICE)).getNetworkType() == NETWORK_TYPE_LTE) { + if (((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getNetworkType() == NETWORK_TYPE_LTE) { String[] siglist = ss.toString().split(" "); - LBSHelper.this.mLastSignal = Integer.parseInt(siglist[9]) + 110; + mLastSignal = Integer.parseInt(siglist[9]) + 110; } else { - LBSHelper.this.mLastSignal = ss.getGsmSignalStrength() * 2 - 113 + 110; + mLastSignal = ss.getGsmSignalStrength() * 2 - 113 + 110; } - LBSHelper.this.runtime.setSignalStrength(LBSHelper.this.mLastSignal - 110); -// LBSHelper.this.mLastSignal = ss.getGsmSignalStrength();//ss.getDbm(); -// LBSHelper.this.runtime.setSignalStrength(LBSHelper.this.mLastSignal); + runtime.setSignalStrength(mLastSignal - 110); +// mLastSignal = ss.getGsmSignalStrength();//ss.getDbm(); +// runtime.setSignalStrength(mLastSignal); } } diff --git a/app/src/main/java/com/enqualcomm/support/bean/ICLocation.java b/app/src/main/java/com/enqualcomm/support/bean/ICLocation.java index 3b5dff2f..25cb8e36 100644 --- a/app/src/main/java/com/enqualcomm/support/bean/ICLocation.java +++ b/app/src/main/java/com/enqualcomm/support/bean/ICLocation.java @@ -42,6 +42,9 @@ public class ICLocation { private int mworkingMod; private int location_cycle; + public static final float MAX_HDOP=50.0f; + public static final int MAX_GPS_NOSIGNAL_COUNT=10; + public static final int MAX_GPS_SEARCH_TIMEOUT=120; public void setWorkingMod(int wkmod){ mworkingMod=wkmod;} public void setLocation_cycle(int _locatCycle){ location_cycle=_locatCycle;} public int getWorkingMod(){return mworkingMod;} diff --git a/app/src/main/java/com/enqualcomm/support/utils/FileOutputUtil.java b/app/src/main/java/com/enqualcomm/support/utils/FileOutputUtil.java index dad44ac7..718bfba0 100644 --- a/app/src/main/java/com/enqualcomm/support/utils/FileOutputUtil.java +++ b/app/src/main/java/com/enqualcomm/support/utils/FileOutputUtil.java @@ -120,46 +120,43 @@ public class FileOutputUtil { } public static void fileOutputRaw(File dir, String filename, String msg) { // String str = TimeUtil.getSystemTime(); + if (msg!=null && msg.trim().length()>0) { + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append(filename); + stringBuilder.append(".txt"); + File file = new File(dir, stringBuilder.toString()); + try { + PrintStream printStream = new PrintStream(new FileOutputStream(file, true)); + StringBuilder stringBuilder1 = new StringBuilder(); + stringBuilder1.append(msg); + printStream.println(stringBuilder1.toString()); + printStream.close(); - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append(filename); - stringBuilder.append(".txt"); - File file = new File(dir, stringBuilder.toString()); - try { - PrintStream printStream = new PrintStream(new FileOutputStream(file, true)); - StringBuilder stringBuilder1 = new StringBuilder(); - stringBuilder1.append(msg); - printStream.println(stringBuilder1.toString()); - printStream.close(); - - } catch (FileNotFoundException e) { - e.printStackTrace(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } } - } public static void fileOutput(File dir, String filename, String msg) { String str = TimeUtil.getSystemTime(); - - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append(filename); - stringBuilder.append(".txt"); - File file = new File(dir, stringBuilder.toString()); - try { - PrintStream printStream = new PrintStream(new FileOutputStream(file, true)); - StringBuilder stringBuilder1 = new StringBuilder(); - stringBuilder1.append("响应时间=="); - stringBuilder1.append(str); - stringBuilder1.append(" 文件内容=="); - stringBuilder1.append(msg); - printStream.println(stringBuilder1.toString()); - printStream.close(); - - } catch (FileNotFoundException e) { - e.printStackTrace(); - + if (msg!=null && msg.trim().length()>0) { + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append(filename); + stringBuilder.append(".txt"); + File file = new File(dir, stringBuilder.toString()); + try { + PrintStream printStream = new PrintStream(new FileOutputStream(file, true)); + StringBuilder stringBuilder1 = new StringBuilder(); + stringBuilder1.append(str); + stringBuilder1.append(" "); + stringBuilder1.append(msg); + printStream.println(stringBuilder1.toString()); + printStream.close(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } } - } } diff --git a/app/version_code.properties b/app/version_code.properties index 139e467c..f4b17a47 100644 --- a/app/version_code.properties +++ b/app/version_code.properties @@ -1,2 +1,2 @@ -#Fri Mar 13 10:11:53 CST 2020 -VERSION_CODE=374 +#Fri Mar 13 16:12:06 CST 2020 +VERSION_CODE=375