From: snickersun Date: Tue, 7 Jan 2020 07:00:41 +0000 (+0800) Subject: update gps X-Git-Url: http://git.snicker.com.cn/sitemap.xml?a=commitdiff_plain;h=ff761a07a58d1c9cb49a17427e275020cb174a37;p=icsupport.git update gps --- diff --git a/.gradle/5.4.1/executionHistory/executionHistory.bin b/.gradle/5.4.1/executionHistory/executionHistory.bin index 24892496..b210b7bd 100644 Binary files a/.gradle/5.4.1/executionHistory/executionHistory.bin and b/.gradle/5.4.1/executionHistory/executionHistory.bin differ diff --git a/.gradle/5.4.1/executionHistory/executionHistory.lock b/.gradle/5.4.1/executionHistory/executionHistory.lock index 82d4bd2c..e83888bd 100644 Binary files a/.gradle/5.4.1/executionHistory/executionHistory.lock and b/.gradle/5.4.1/executionHistory/executionHistory.lock differ diff --git a/.gradle/5.4.1/fileHashes/fileHashes.bin b/.gradle/5.4.1/fileHashes/fileHashes.bin index 36d9f2df..e6dd7e5a 100644 Binary files a/.gradle/5.4.1/fileHashes/fileHashes.bin and b/.gradle/5.4.1/fileHashes/fileHashes.bin differ diff --git a/.gradle/5.4.1/fileHashes/fileHashes.lock b/.gradle/5.4.1/fileHashes/fileHashes.lock index 42ebb4bd..3e440393 100644 Binary files a/.gradle/5.4.1/fileHashes/fileHashes.lock and b/.gradle/5.4.1/fileHashes/fileHashes.lock differ diff --git a/.gradle/5.4.1/javaCompile/classAnalysis.bin b/.gradle/5.4.1/javaCompile/classAnalysis.bin index 21649e02..aeefaa1d 100644 Binary files a/.gradle/5.4.1/javaCompile/classAnalysis.bin and b/.gradle/5.4.1/javaCompile/classAnalysis.bin differ diff --git a/.gradle/5.4.1/javaCompile/javaCompile.lock b/.gradle/5.4.1/javaCompile/javaCompile.lock index 2ea28360..b07e8c11 100644 Binary files a/.gradle/5.4.1/javaCompile/javaCompile.lock and b/.gradle/5.4.1/javaCompile/javaCompile.lock differ diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 41c763b0..9aee7d13 100644 Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/.idea/workspace.xml b/.idea/workspace.xml index b40189b9..6e67cb5a 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -10,45 +10,14 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + @@ -97,17 +66,17 @@ - - + + - + - - + + @@ -121,8 +90,8 @@ - - + + @@ -149,6 +118,15 @@ + + + + + + + + + @@ -188,9 +166,6 @@ - queue - location - getApkBaseName bootClasspath TYPE_STEP_COUNTER CompileOptions @@ -205,19 +180,22 @@ EqcAlgorithmInterfaceMethod3 EqcAlgorithmInterfaceMethod2 H10 - Start gpstest - scanresult - locationManager - flag GPS_PROVIDER readGpsThread - ReadGpsThread locationListener requestLocationUpdates LocationManager locationInfo getBestLocation + isFrist + updateView + updateGpsStatus + flag + ReadGpsThread + scanresult + locationManager + Start @@ -453,11 +431,11 @@ - + - + - + @@ -682,13 +660,6 @@ - - - - - - - @@ -819,21 +790,6 @@ - - - - - - - - - - - - - - - @@ -858,13 +814,6 @@ - - - - - - - @@ -879,13 +828,6 @@ - - - - - - - @@ -920,10 +862,24 @@ + + + + + + + + + + + + + + - - + + @@ -933,5 +889,27 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/ic/protocol/NMEAListener.java b/app/src/main/java/com/ic/protocol/NMEAListener.java index 721babed..6efb6468 100644 --- a/app/src/main/java/com/ic/protocol/NMEAListener.java +++ b/app/src/main/java/com/ic/protocol/NMEAListener.java @@ -32,10 +32,13 @@ public class NMEAListener implements NmeaListener, LocationListener { private List numSatelliteList = new ArrayList(); // 卫星信号 private List max3Satellite = new ArrayList(); // 卫星信号 private int satelliteInfo = 0; - private ReadGpsThread readGpsThread; + private ReadGpsThread readGpsThread=null; private double longitude; private double latitude; private boolean flag; + private int SearchTimeout = 120; + private int noSignalCount=0; + private int searchCout=0; int gpsMode; int numberOfSatellites; Runtime runtime; @@ -43,6 +46,7 @@ public class NMEAListener implements NmeaListener, LocationListener { public NMEAListener(LocationManager paramLocationManager, Runtime paramRuntime) { this.locationManager = paramLocationManager; this.runtime = paramRuntime; +// readGpsThread=new ReadGpsThread(); } public void onLocationChanged(Location paramLocation) {} @@ -68,23 +72,23 @@ public class NMEAListener implements NmeaListener, LocationListener { case GpsStatus.GPS_EVENT_SATELLITE_STATUS: - //如果是自动测试,则有3颗大于20的就算通过 - if (max3Satellite.size() >= 3 && max3Satellite.get(2).getSnr()>=30) { - - if (readGpsThread != null) { - readGpsThread.endThread(); - } - if (flag) { - flag = false; - pass(); - } - } +// //如果是自动测试,则有3颗大于20的就算通过 +// if (max3Satellite.size() >= 3 && max3Satellite.get(2).getSnr()>=30) { +// +// if (readGpsThread != null) { +// readGpsThread.endThread(); +// } +// if (flag) { +// flag = false; +// pass(); +// } +// } //如果是pcba测试,则只要有一颗大于30的星就算通过。 - if (max3Satellite.size() > 0 && max3Satellite.get(0).getSnr()>=30) { - - +// if (max3Satellite.size() > 0 && max3Satellite.get(0).getSnr()>=30) { + //GPS 5秒钟搜不到足够多的星,认为不能定位,取消搜星 + if(noSignalCount > 5){ if (readGpsThread != null) { readGpsThread.endThread(); } @@ -103,10 +107,11 @@ public class NMEAListener implements NmeaListener, LocationListener { if (readGpsThread != null) { readGpsThread.endThread(); } - if (flag) { - flag = false; +// 定位算通过 +// if (flag) { + flag = true; pass(); - } +// } break; case GpsStatus.GPS_EVENT_STARTED: // tvGps.setText("GPS_EVENT_STARTED"); @@ -172,6 +177,7 @@ public class NMEAListener implements NmeaListener, LocationListener { if (readGpsThread != null) { readGpsThread.endThread(); } + NMEAListener.this.stopListen(); return false; } }); @@ -202,8 +208,10 @@ public class NMEAListener implements NmeaListener, LocationListener { private int updateGpsStatus(int event, GpsStatus status) { StringBuilder sb2 = new StringBuilder(""); float strengh = 0; + searchCout++; if (status == null) { - sb2.append("搜索到卫星个数:" + 0); + sb2.append("搜索"+searchCout+"次,搜到卫星个数:" + 0); + noSignalCount++; } else if (event == GpsStatus.GPS_EVENT_SATELLITE_STATUS) { int maxSatellites = status.getMaxSatellites(); Iterator it = status.getSatellites().iterator(); @@ -222,14 +230,27 @@ public class NMEAListener implements NmeaListener, LocationListener { count++; } - sb2.append("搜索到卫星个数(SNR>0):" + numSatelliteList.size()+" \n Max 3 SNRs[ " ); + sb2.append("搜索"+searchCout+"次,搜索到卫星个数(SNR>0):" + numSatelliteList.size()+" \n Max 3 SNRs[ " ); for (int i=0;iSearchTimeout){ + sb2.append(" 搜索"+searchCout+"次,超过"+SearchTimeout+"限制退出GPS定位"); + flag=false; + pass(); + } + if (noSignalCount> 5){ + sb2.append(" 搜索"+searchCout+"次,超过"+noSignalCount+"次没有收到星,退出GPS定位"); + flag=false; + pass(); + } Log.e("dxc", sb2.toString()); @@ -238,6 +259,14 @@ public class NMEAListener implements NmeaListener, LocationListener { } private void pass(){ + // 经纬度 保留6位小数点 + DecimalFormat df = new DecimalFormat("#.000000"); + String strLatitude = df.format(latitude); + String strLongitude = df.format(longitude); + runtime.setLatitude(strLatitude); + runtime.setLongitude(strLongitude); + runtime.setLocation(locationInfo); + NMEAListener.this.temHandler.sendMessage(new Message()); } boolean isFrist = true; @@ -328,13 +357,19 @@ public class NMEAListener implements NmeaListener, LocationListener { public boolean startListen() { this.locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0L, 0.0F, this); this.listening = true; + noSignalCount=0; + longitude=0; + latitude=0; + searchCout=0; locationManager.addGpsStatusListener(statusListener);//搜星 - return this.locationManager.addNmeaListener(this); +// this.locationManager.addNmeaListener(this); + + return true; } public void stopListen() { - this.locationManager.removeNmeaListener(this); +// this.locationManager.removeNmeaListener(this); this.locationManager.removeUpdates(this); this.listening = false; }