// public void EqcAlgorithmInterfaceMethod2() {\r
public void startGpsLocate() {\r
ICLogger.i("开启GPS扫描");\r
- runtime.getLocationInstance().setLocationStat( ICLocation.LOCATION_STAT.LOCATION_OPEN); //此处为了检测是否定位时可以正确识别状态,以防一直处于GPS定位成功状态\r
\r
- //防止与工厂测试冲突\r
- if (!DeviceInfoUtil.isFactoryTestTopActivity(runtime.getContextProxy().context)) {\r
+ if(!nmeaListener.isListening()) {\r
+ runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_OPEN); //此处为了检测是否定位时可以正确识别状态,以防一直处于GPS定位成功状态\r
\r
- Settings.Secure.setLocationProviderEnabled(runtime.getContextProxy().getResolver(), GPS_PROVIDER, true);\r
- Single.just(null).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<Object>() {\r
- public void call(Object param1Object) {\r
- LocationClient.this.nmeaListener.startListen();\r
- }\r
- });\r
+ //防止与工厂测试冲突\r
+ if (!DeviceInfoUtil.isFactoryTestTopActivity(runtime.getContextProxy().context)) {\r
+\r
+ Settings.Secure.setLocationProviderEnabled(runtime.getContextProxy().getResolver(), GPS_PROVIDER, true);\r
+ Single.just(null).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<Object>() {\r
+ public void call(Object param1Object) {\r
+ LocationClient.this.nmeaListener.startListen();\r
+ }\r
+ });\r
+ }\r
+ }else{\r
+ ICLogger.i("GPS is still listening, skip open it!");\r
}\r
}\r
\r
&& runtime.getLocationInstance().getGSMStationCID() ==0\r
&& runtime.getLocationInstance().getLAC()==0)) ?false:true;\r
// ICLogger.i("getMNC "+runtime.getLocationInstance().getMNC()+" getMCC "+runtime.getLocationInstance().getMCC()+" getGSMStationCID " + runtime.getLocationInstance().getGSMStationCID()+ " getLAC "+runtime.getLocationInstance().getLAC()+" changed "+runtime.getLocationInstance().isDataChanged());\r
- ICLogger.i("lbs_ok "+lbs_ok+" waitAndSendLocation wifi_ok " + wifi_ok+ " gps_ok "+gps_ok + " mode "+mode);\r
+ ICLogger.i("waitAndSendLocation lbs="+lbs_ok+", wifi="+ wifi_ok+ ", gps="+gps_ok + ", mode="+mode);\r
\r
switch(mode){\r
case ICLocation.CUSTOM_MOD:\r
public class NMEAListener implements NmeaListener, LocationListener {\r
private boolean listening=false;\r
\r
-\r
+ public boolean isListening(){\r
+ return listening;\r
+ }\r
public class GpsSatellitePriv {\r
int prn;\r
float snr;\r
\r
private boolean noStop=false;\r
\r
+\r
private int SearchTimeout = 120;\r
private int noSignalCount=0;\r
private int searchCout=0;\r
\r
StringBuilder sb2=new StringBuilder();\r
if(!noStop) {\r
- if (searchCout > SearchTimeout) {\r
- sb2.append(" 搜索" + searchCout + "次未定位,超过" + SearchTimeout + "限制退出GPS定位");\r
+ if (searchCout > ICLocation.MAX_GPS_SEARCH_TIMEOUT) {\r
+ sb2.append(" 搜索" + searchCout + "次未定位,超过" + ICLocation.MAX_GPS_SEARCH_TIMEOUT + "限制退出GPS定位");\r
\r
runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_GPS_TIEMOUT);\r
\r
stop(MSG_WHAT_GPS_TIMEOUT);\r
}\r
- if (noSignalCount > 10) {\r
+ if (noSignalCount > ICLocation.MAX_GPS_NOSIGNAL_COUNT) {\r
sb2.append(" 搜索" + searchCout + "次,超过" + noSignalCount + "次没有收到星,退出GPS定位");\r
runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_GPS_TIEMOUT);\r
stop(MSG_WHAT_GPS_NOSTAR);\r
if (Config.LOG_TOFILE)\r
FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "GPS", sb.toString());\r
//定位了,\r
-\r
- locationFixedCount++;\r
-\r
+ if (hdop!=null&& hdop.trim().length()>0 && Float.valueOf(hdop)>ICLocation.MAX_HDOP) {\r
+ locationFixedCount++;\r
+ }else{\r
+ ICLogger.i("HDOP is larger than "+ICLocation.MAX_HDOP+" , skip this location!");\r
+ if (Config.LOG_TOFILE)\r
+ FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "GPS", "HDOP is larger than "+ICLocation.MAX_HDOP+" , skip this location!");\r
+ }\r
if (locationFixedCount > MaxFixedTimes) {\r
/*\r
只有当前GPS已经定位,且location不为空才给 runtime赋值GPS坐标。\r
runtime.getLocationInstance().setHod(Float.valueOf(hdop.trim()));\r
runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_FIXED);\r
ICLogger.i("定位"+locationFixedCount+"次 > "+MaxFixedTimes+", set LOCATION_FIXED ");\r
+ if (Config.LOG_TOFILE)\r
+ FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "GPS", "定位"+locationFixedCount+"次 > "+MaxFixedTimes+", set LOCATION_FIXED ");\r
if (!noStop) {\r
stopListen();\r
}\r
private String wifiInfoResult;\r
private WifiManager wifiManager;\r
\r
+ private final int MsgWhat_GetWifiResult=104;\r
+ private int MaxWiFiScanRetryTimes=3;\r
+ private static int CurrentWiFiScanTimes=0;\r
\r
public LBSHelper(Context _context, WifiManager _wifiManager, Runtime dev) {\r
this.wifiManager = _wifiManager;\r
@Override\r
public void handleMessage(Message msg) {\r
super.handleMessage(msg);\r
- if (msg.what == 104) {\r
+ if (msg.what == MsgWhat_GetWifiResult) {\r
//停止扫描\r
- StringBuilder sb = LBSHelper.this.handScanResults();\r
+ StringBuilder sb = handScanResults();\r
if (sb == null) {\r
- LBSHelper.this.wifiInfoResult = null;\r
+ CurrentWiFiScanTimes++;\r
+ if (CurrentWiFiScanTimes< MaxWiFiScanRetryTimes) {\r
+ ICLogger.i("WiFi Scan get Result failed , retry scan "+CurrentWiFiScanTimes+ " times");\r
+ wifiManager.startScan();\r
+ delayedStopScan();\r
+ return;\r
+ }else {\r
+ wifiInfoResult = null;\r
+ }\r
} else {\r
- LBSHelper.this.wifiInfoResult = sb.toString();\r
+ wifiInfoResult = sb.toString();\r
}\r
- if (LBSHelper.this.mMyWifiListener != null) {\r
- LBSHelper.this.mMyWifiListener.getWifiInfoCallBack(LBSHelper.this.wifiInfoResult);\r
+ if (mMyWifiListener != null) {\r
+ mMyWifiListener.getWifiInfoCallBack(wifiInfoResult);\r
\r
if ((runtime.isNoTurnOffWifiOnScreenOff() && !SimSignalUtil.isScreenON(runtime.getContextProxy().context)) || DeviceInfoUtil.isFactoryTestTopActivity(runtime.getContextProxy().context))\r
{\r
\r
private StringBuilder handScanResults() {\r
List aplist = this.wifiManager.getScanResults();\r
- if (aplist.size() < 2) {\r
+ ICLogger.i("get Wifi Result "+aplist.size());\r
+ if (aplist.size() < 1) {\r
return null;\r
} else {\r
this.sortByLevel(aplist);\r
}\r
\r
private void delayedStopScan() {\r
- LBSHelper.this.mHandler.sendEmptyMessageDelayed(104,3000L);\r
+ mHandler.sendEmptyMessageDelayed(MsgWhat_GetWifiResult,3000L);\r
}\r
\r
// public void unRegisterWiFiBroadReceiver() {\r
e.printStackTrace();\r
}\r
}\r
+\r
+ CurrentWiFiScanTimes=0;\r
wifiManager.startScan();\r
delayedStopScan();\r
\r
\r
public void onSignalStrengthsChanged(SignalStrength ss) {\r
super.onSignalStrengthsChanged(ss);\r
- if (((TelephonyManager) LBSHelper.this.context.getSystemService(Context.TELEPHONY_SERVICE)).getNetworkType() == NETWORK_TYPE_LTE) {\r
+ if (((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getNetworkType() == NETWORK_TYPE_LTE) {\r
String[] siglist = ss.toString().split(" ");\r
- LBSHelper.this.mLastSignal = Integer.parseInt(siglist[9]) + 110;\r
+ mLastSignal = Integer.parseInt(siglist[9]) + 110;\r
} else {\r
- LBSHelper.this.mLastSignal = ss.getGsmSignalStrength() * 2 - 113 + 110;\r
+ mLastSignal = ss.getGsmSignalStrength() * 2 - 113 + 110;\r
}\r
- LBSHelper.this.runtime.setSignalStrength(LBSHelper.this.mLastSignal - 110);\r
-// LBSHelper.this.mLastSignal = ss.getGsmSignalStrength();//ss.getDbm();\r
-// LBSHelper.this.runtime.setSignalStrength(LBSHelper.this.mLastSignal);\r
+ runtime.setSignalStrength(mLastSignal - 110);\r
+// mLastSignal = ss.getGsmSignalStrength();//ss.getDbm();\r
+// runtime.setSignalStrength(mLastSignal);\r
\r
}\r
}\r
private int mworkingMod;\r
private int location_cycle;\r
\r
+ public static final float MAX_HDOP=50.0f;\r
+ public static final int MAX_GPS_NOSIGNAL_COUNT=10;\r
+ public static final int MAX_GPS_SEARCH_TIMEOUT=120;\r
public void setWorkingMod(int wkmod){ mworkingMod=wkmod;}\r
public void setLocation_cycle(int _locatCycle){ location_cycle=_locatCycle;}\r
public int getWorkingMod(){return mworkingMod;}\r
}\r
public static void fileOutputRaw(File dir, String filename, String msg) {\r
// String str = TimeUtil.getSystemTime();\r
+ if (msg!=null && msg.trim().length()>0) {\r
+ StringBuilder stringBuilder = new StringBuilder();\r
+ stringBuilder.append(filename);\r
+ stringBuilder.append(".txt");\r
+ File file = new File(dir, stringBuilder.toString());\r
+ try {\r
+ PrintStream printStream = new PrintStream(new FileOutputStream(file, true));\r
+ StringBuilder stringBuilder1 = new StringBuilder();\r
+ stringBuilder1.append(msg);\r
+ printStream.println(stringBuilder1.toString());\r
+ printStream.close();\r
\r
- StringBuilder stringBuilder = new StringBuilder();\r
- stringBuilder.append(filename);\r
- stringBuilder.append(".txt");\r
- File file = new File(dir, stringBuilder.toString());\r
- try {\r
- PrintStream printStream = new PrintStream(new FileOutputStream(file, true));\r
- StringBuilder stringBuilder1 = new StringBuilder();\r
- stringBuilder1.append(msg);\r
- printStream.println(stringBuilder1.toString());\r
- printStream.close();\r
-\r
- } catch (FileNotFoundException e) {\r
- e.printStackTrace();\r
+ } catch (FileNotFoundException e) {\r
+ e.printStackTrace();\r
\r
+ }\r
}\r
-\r
}\r
public static void fileOutput(File dir, String filename, String msg) {\r
String str = TimeUtil.getSystemTime();\r
-\r
- StringBuilder stringBuilder = new StringBuilder();\r
- stringBuilder.append(filename);\r
- stringBuilder.append(".txt");\r
- File file = new File(dir, stringBuilder.toString());\r
- try {\r
- PrintStream printStream = new PrintStream(new FileOutputStream(file, true));\r
- StringBuilder stringBuilder1 = new StringBuilder();\r
- stringBuilder1.append("响应时间==");\r
- stringBuilder1.append(str);\r
- stringBuilder1.append(" 文件内容==");\r
- stringBuilder1.append(msg);\r
- printStream.println(stringBuilder1.toString());\r
- printStream.close();\r
-\r
- } catch (FileNotFoundException e) {\r
- e.printStackTrace();\r
-\r
+ if (msg!=null && msg.trim().length()>0) {\r
+ StringBuilder stringBuilder = new StringBuilder();\r
+ stringBuilder.append(filename);\r
+ stringBuilder.append(".txt");\r
+ File file = new File(dir, stringBuilder.toString());\r
+ try {\r
+ PrintStream printStream = new PrintStream(new FileOutputStream(file, true));\r
+ StringBuilder stringBuilder1 = new StringBuilder();\r
+ stringBuilder1.append(str);\r
+ stringBuilder1.append(" ");\r
+ stringBuilder1.append(msg);\r
+ printStream.println(stringBuilder1.toString());\r
+ printStream.close();\r
+ } catch (FileNotFoundException e) {\r
+ e.printStackTrace();\r
+ }\r
}\r
-\r
}\r
}\r
\r
-#Fri Mar 13 10:11:53 CST 2020\r
-VERSION_CODE=374\r
+#Fri Mar 13 16:12:06 CST 2020\r
+VERSION_CODE=375\r