From: snickersun Date: Thu, 19 Mar 2020 04:20:52 +0000 (+0800) Subject: 编译 V380_2003191208_release X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=e3e2f35d0e1354ebe078a883142a5a7172b59b6b;p=protocol_srv.git 编译 V380_2003191208_release 配合 FactoryMode_V7_202003191209_release.apk 修复工厂模式下,只要进行过GPS测试,就很可能造成 ICProtocol无法继续GPS定位的问题。 --- diff --git a/app/debug/ICSer_V379_2003180939_debug.apk b/app/debug/ICSer_V379_2003180939_debug.apk new file mode 100644 index 00000000..bb52a32b Binary files /dev/null and b/app/debug/ICSer_V379_2003180939_debug.apk differ diff --git a/app/release/ICSer_V379_2003181740_release.apk b/app/release/ICSer_V379_2003181740_release.apk deleted file mode 100644 index 8c258ce4..00000000 Binary files a/app/release/ICSer_V379_2003181740_release.apk and /dev/null differ diff --git a/app/release/ICSer_V380_2003191208_release.apk b/app/release/ICSer_V380_2003191208_release.apk new file mode 100644 index 00000000..3694415c Binary files /dev/null and b/app/release/ICSer_V380_2003191208_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 0add0098..6baeee47 100644 --- a/app/src/main/java/com/enqualcomm/support/LocationClient.java +++ b/app/src/main/java/com/enqualcomm/support/LocationClient.java @@ -12,6 +12,7 @@ import android.os.SystemClock; import android.provider.Settings; import com.enqualcomm.support.utils.AlarmHelper; +import com.enqualcomm.support.utils.Util; import com.ic.jni.ICJniUtils; import com.enqualcomm.support.adapter.LBSHelper; import com.enqualcomm.support.adapter.protocolAPIHelper; @@ -213,10 +214,22 @@ public class LocationClient { }); this.mLbsHelper.getWifiInfo(); } -// public void EqcAlgorithmInterfaceMethod2() { public void startGpsLocate() { - //防止与工厂测试冲突 - if (!DeviceInfoUtil.isFactoryTestTopActivity(runtime.getContextProxy().context)) { + + + boolean FactryModeOpening=DeviceInfoUtil.isFactoryTestTopActivity(runtime.getContextProxy().context); + boolean needReOpenGPS=runtime.getFactoryTestingStat(); + + //防止与工厂测试冲突 + if (FactryModeOpening==false || needReOpenGPS==true) { + + if (needReOpenGPS==true) { + ICLogger.i("工厂模式关闭了GPS,需要重新关闭GPS以同步状态!"); + //处理过后,要把状态设置为初始状态,防止每次都重启。 + runtime.setFactoryTestingStat(false); + //如果发现需要重启GPS,为了状态正确,需要先停止GPS + nmeaListener.stopListen(); + } ICLogger.i("开启GPS扫描!"); if(Config.LOG_TOFILE) ICLogger.logToFile("GPS","开启GPS扫描!"); if (!nmeaListener.isListening()) { @@ -233,6 +246,7 @@ public class LocationClient { } }else{ ICLogger.i("工厂模式,skip 开启GPS扫描!"); + runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_OPEN); //此处为了检测是否定位时可以正确识别状态,以防一直处于GPS定位成功状态 if(Config.LOG_TOFILE) ICLogger.logToFile("GPS","工厂模式,skip 开启GPS扫描!"); } } @@ -427,8 +441,10 @@ public class LocationClient { // Deliver.is_active_location = false; // getLocationWakeLock(); // } + + boolean FactryModeOpening=DeviceInfoUtil.isFactoryTestTopActivity(runtime.getContextProxy().context); //防止与工厂测试冲突 - if (!DeviceInfoUtil.isFactoryTestTopActivity(runtime.getContextProxy().context)) { + if (FactryModeOpening==false ) { ICLogger.i("stopGpsLocate"); if(Config.LOG_TOFILE) ICLogger.logToFile("GPS","stopGpsLocate"); Single.just(null).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1() { @@ -438,6 +454,7 @@ public class LocationClient { }); }else{ ICLogger.i("工厂模式 skip stopGpsLocate"); + runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_OPEN); //此处为了检测是否定位时可以正确识别状态,以防一直处于GPS定位成功状态 if(Config.LOG_TOFILE) ICLogger.logToFile("GPS","工厂模式 skip stopGpsLocate"); } } @@ -546,12 +563,33 @@ public void updateCellInfo() { } } + private static String ACTION_GPSCMD="com.enqualcomm.support.gps"; + public void registerBroadReceiver() { + + IntentFilter intentFilter = new IntentFilter(); + intentFilter.addAction(ACTION_GPSCMD); + (this.runtime.getContextProxy()).context.registerReceiver(this.mLocationBroadcastReceiver, intentFilter); + } + public void unregisterBroadReceiver() { + (this.runtime.getContextProxy()).context.unregisterReceiver(this.mLocationBroadcastReceiver); + } + private final BroadcastReceiver mLocationBroadcastReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (ACTION_GPSCMD.equals(action)) { + String status = intent.getStringExtra("status"); + if( status.equals("needReopen")){ + runtime.setFactoryTestingStat(true); + } + } + } + }; public void init() { - this.mSignalUtil = SimSignalUtil.getInstance((runtime.getContextProxy()).context); //获取LBS定位服务 @@ -570,6 +608,7 @@ public void updateCellInfo() { // intentFilter.addAction("android.intent.action.SCREEN_ON"); // (runtime.getContextProxy()).context.registerReceiver(this.screenOnReceiver, intentFilter); + registerBroadReceiver(); //暂时没有处理4G、2G切换问题 @@ -587,6 +626,7 @@ public void updateCellInfo() { // } // }); stopGpsLocate(); + unregisterBroadReceiver(); } diff --git a/app/src/main/java/com/enqualcomm/support/NMEAListener.java b/app/src/main/java/com/enqualcomm/support/NMEAListener.java index 1f4480c6..a0297d2e 100644 --- a/app/src/main/java/com/enqualcomm/support/NMEAListener.java +++ b/app/src/main/java/com/enqualcomm/support/NMEAListener.java @@ -32,9 +32,9 @@ import rx.functions.Action1; import static android.location.LocationManager.GPS_PROVIDER; public class NMEAListener implements NmeaListener, LocationListener { - private static boolean listening=false; + private static boolean listening = false; - public boolean isListening(){ + public boolean isListening() { return listening; } @@ -44,40 +44,43 @@ public class NMEAListener implements NmeaListener, LocationListener { private double longitude; private double latitude; - private boolean noStop=false; + private boolean noStop = false; private int SearchTimeout = 120; - private int noSignalCount=0; - private int searchCout=0; - private GPS_CURRENT_STATUS gpsMode; + private int noSignalCount = 0; + private int searchCout = 0; + private GPS_CURRENT_STATUS gpsMode; int numberOfSatellites; Runtime runtime; - private static int MaxFixedTimes=3; + private static int MaxFixedTimes = 3; - private static int locationFixedCount=0; + private static int locationFixedCount = 0; - private static location_callback mCallback=null; - public interface location_callback{ + private static location_callback mCallback = null; + + public interface location_callback { public void on_locating_changed(GPS_locationStatus gps_status); } - public static void set_callback(location_callback callback){ - mCallback=callback; + + public static void set_callback(location_callback callback) { + mCallback = callback; } private GPS_locationStatus gps_status = new GPS_locationStatus(); - public GPS_locationStatus get_gps_status(){ + + public GPS_locationStatus get_gps_status() { return gps_status; } - public void setNoStop(boolean nostop){ - noStop=nostop; - ICLogger.i("setNoStop "+nostop); - if (noStop==false ){ - switch (runtime.getLocationInstance().getWorkingMod()){ + public void setNoStop(boolean nostop) { + noStop = nostop; + ICLogger.i("setNoStop " + nostop); + if (noStop == false) { + switch (runtime.getLocationInstance().getWorkingMod()) { case ICLocation.CUSTOM_MOD: case ICLocation.EMERGNECY_MOD: case ICLocation.REALTIME_MOD: @@ -95,30 +98,33 @@ public class NMEAListener implements NmeaListener, LocationListener { } } + public NMEAListener(LocationManager paramLocationManager, Runtime paramRuntime) { this.locationManager = paramLocationManager; this.runtime = paramRuntime; } - static int satindex=0; + static int satindex = 0; + public void onNmeaReceived(long paramLong, String nmeastr) { // EqcAlgorithmNative.native_EqcAlgorithmMethod5(paramString); // ICLogger.i("Nmea :"+nmeastr+" "+paramLong); - if (Config.LOG_TOFILE) FileOutputUtil.fileOutputRaw(this.runtime.getCacheDir(),"Nmea",nmeastr); + if (Config.LOG_TOFILE) + FileOutputUtil.fileOutputRaw(this.runtime.getCacheDir(), "Nmea", nmeastr); - if(nmeastr.startsWith("$RD_RSSI")) { + if (nmeastr.startsWith("$RD_RSSI")) { searchCout++; - if (mCallback !=null) + if (mCallback != null) mCallback.on_locating_changed(get_gps_status()); gps_status.numSatelliteList.clear(); - gps_status.search_time_cost=searchCout; + gps_status.search_time_cost = searchCout; } - if (nmeastr.startsWith("$GPGLL,")){ - String tmplist[]=nmeastr.split(","); + if (nmeastr.startsWith("$GPGLL,")) { + String tmplist[] = nmeastr.split(","); // GPGLL编辑 //(地理定位信息) // 例:$GPGLL,4250.5589,S,14718.5084,E,092204.999,A*2D @@ -130,12 +136,12 @@ public class NMEAListener implements NmeaListener, LocationListener { // 字段5:UTC时间,hhmmss.sss格式 // 字段6:状态,A=定位,V=未定位 // 字段7:校验值($与*之间的数异或后的值) - String Lat=tmplist[1]; - String lon=tmplist[3]; - String fixed=tmplist[6]; + String Lat = tmplist[1]; + String lon = tmplist[3]; + String fixed = tmplist[6]; // ICLogger.i("GPGLL Lat="+Lat+",Lon="+lon+",fixed="+fixed); - }else if (nmeastr.startsWith("$GPRMC,")) { + } else if (nmeastr.startsWith("$GPRMC,")) { // GPRMC编辑 //(推荐定位信息数据格式) // 例:$GPRMC,024813.640,A,3158.4608,N,11848.3737,E,10.05,324.27,150706,,,A*50 @@ -153,12 +159,12 @@ public class NMEAListener implements NmeaListener, LocationListener { // 字段11:磁偏角方向,E=东W=西 // 字段12:模式,A=自动,D=差分,E=估测,N=数据无效(3.0协议内容) // 字段13:校验值($与*之间的数异或后的值) - String tmplist[]=nmeastr.split(","); - String utctime=tmplist[1]; - String Lat=tmplist[3]; - String lon=tmplist[5]; - String fixed=tmplist[2]; - String speed=tmplist[7]; + String tmplist[] = nmeastr.split(","); + String utctime = tmplist[1]; + String Lat = tmplist[3]; + String lon = tmplist[5]; + String fixed = tmplist[2]; + String speed = tmplist[7]; // ICLogger.i("GPRMC GPSTime="+utctime+",Lat="+Lat+",Lon="+lon+",fixed="+fixed+",speed="+speed); // if (Config.LOG_TOFILE) // FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "GPS", "GPRMC GPSTime="+utctime+",Lat="+Lat+",Lon="+lon+",fixed="+fixed+",speed="+speed); @@ -168,7 +174,7 @@ public class NMEAListener implements NmeaListener, LocationListener { } - }else if (nmeastr.startsWith("$GPGSV,")) { + } else if (nmeastr.startsWith("$GPGSV,")) { // GPGSV编辑 // (可见卫星信息) @@ -191,36 +197,36 @@ public class NMEAListener implements NmeaListener, LocationListener { //// 字段15:信噪比(00-99)dbHz // 字段16:校验值($与*之间的数异或后的值) - String tmplist[]=nmeastr.split(","); - int maxPageCount=Integer.valueOf(tmplist[1]); - int currentPage=Integer.valueOf(tmplist[2]); - int SatlitesCount=Integer.valueOf(tmplist[3]); - if (maxPageCount>0 && currentPage==1){ + String tmplist[] = nmeastr.split(","); + int maxPageCount = Integer.valueOf(tmplist[1]); + int currentPage = Integer.valueOf(tmplist[2]); + int SatlitesCount = Integer.valueOf(tmplist[3]); + if (maxPageCount > 0 && currentPage == 1) { //第一页把数组初始化一遍。 - satindex=0; + satindex = 0; runtime.getLocationInstance().numSatelliteList.clear(); //清除 SNR >0的卫星 runtime.getLocationInstance().max3Satellite.clear(); //清除 最大3个星值 - gps_status.satlite_numbss=SatlitesCount; + gps_status.satlite_numbss = SatlitesCount; } - int satcount=(tmplist.length-4)/4; + int satcount = (tmplist.length - 4) / 4; // ICLogger.i("Nmea :"+nmeastr+" "+satcount); runtime.getLocationInstance().set_adding_satlite_flag(true); - for (int i=0;i0] ="+ runtime.getLocationInstance().numSatelliteList.size()); + StringBuilder sb = new StringBuilder(); + sb.append("搜索" + searchCout + "次,搜索到卫星个数" + SatlitesCount + ", [SNR>0] =" + runtime.getLocationInstance().numSatelliteList.size()); sb.append(", Max 5 SNR ["); - for (int i=0;i< runtime.getLocationInstance().max3Satellite.size();i++){ - sb.append( runtime.getLocationInstance().max3Satellite.get(i).getSnr()+","); + for (int i = 0; i < runtime.getLocationInstance().max3Satellite.size(); i++) { + sb.append(runtime.getLocationInstance().max3Satellite.get(i).getSnr() + ","); } sb.append("]"); if (Config.LOG_TOFILE) - FileOutputUtil.fileOutput(this.runtime.getCacheDir(),"GPS",sb.toString()); - ICLogger.i( sb.toString()); + FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "GPS", sb.toString()); + ICLogger.i(sb.toString()); // 卫星总数小于2 ,或者 snr小于20 - if ( runtime.getLocationInstance().numSatelliteList.size()< 3 && ( runtime.getLocationInstance().max3Satellite.size()>0?( runtime.getLocationInstance().max3Satellite.get(0).getSnr()<20?true:false) : true)){ + if (runtime.getLocationInstance().numSatelliteList.size() < 3 && (runtime.getLocationInstance().max3Satellite.size() > 0 ? (runtime.getLocationInstance().max3Satellite.get(0).getSnr() < 20 ? true : false) : true)) { noSignalCount++; } - StringBuilder sb2=new StringBuilder(); - if(!noStop) { + StringBuilder sb2 = new StringBuilder(); + if (!noStop) { if (searchCout > ICLocation.MAX_GPS_SEARCH_TIMEOUT) { sb2.append(" 搜索" + searchCout + "次未定位,超过" + ICLocation.MAX_GPS_SEARCH_TIMEOUT + "限制退出GPS定位"); @@ -263,12 +269,12 @@ public class NMEAListener implements NmeaListener, LocationListener { stop(MSG_WHAT_GPS_NOSTAR); } } - ICLogger.i( sb2.toString()); + ICLogger.i(sb2.toString()); if (Config.LOG_TOFILE) - FileOutputUtil.fileOutput(this.runtime.getCacheDir(),"GPS",sb2.toString()); + FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "GPS", sb2.toString()); } - }else if (nmeastr.startsWith("$GPGGA,")) { + } else if (nmeastr.startsWith("$GPGGA,")) { // GPGGA编辑 //(定位信息) @@ -290,76 +296,76 @@ public class NMEAListener implements NmeaListener, LocationListener { // 字段14:差分站ID号0000 - 1023(前导位数不足则补0,如果不是差分定位将为空) // 字段15:校验值($与*之间的数异或后的值) - String tmplist[]=nmeastr.split(","); - String utctime=tmplist[1]; - String Lat=tmplist[2]; - String lon=tmplist[4]; - String fixed=tmplist[6]; - String usedStarts=tmplist[7]; - String hdop=tmplist[8]; + String tmplist[] = nmeastr.split(","); + String utctime = tmplist[1]; + String Lat = tmplist[2]; + String lon = tmplist[4]; + String fixed = tmplist[6]; + String usedStarts = tmplist[7]; + String hdop = tmplist[8]; - if ( (fixed.trim().equals("1"))||(fixed.trim().equals("2"))||(fixed.trim().equals("6"))){ + if ((fixed.trim().equals("1")) || (fixed.trim().equals("2")) || (fixed.trim().equals("6"))) { - // 转换GPS坐标为度,以便在各种应用中可以方便查找。 - latitude=Double.valueOf(Lat); - longitude=Double.valueOf(lon); - // 转换单位,从分转换到度 + // 转换GPS坐标为度,以便在各种应用中可以方便查找。 + latitude = Double.valueOf(Lat); + longitude = Double.valueOf(lon); + // 转换单位,从分转换到度 - double intdu= (int)(longitude /100f); //小数转换到分为单位 - double du=(longitude - intdu*100)/60f; - double last= intdu+du; - longitude =last; - intdu= (int)(latitude /100f); //小数转换到分为单位 - du=(latitude - intdu*100)/60f; - last= intdu+du; - latitude=last; + double intdu = (int) (longitude / 100f); //小数转换到分为单位 + double du = (longitude - intdu * 100) / 60f; + double last = intdu + du; + longitude = last; + intdu = (int) (latitude / 100f); //小数转换到分为单位 + du = (latitude - intdu * 100) / 60f; + last = intdu + du; + latitude = last; - // 经纬度 保留4位小数点 - DecimalFormat df = new DecimalFormat("#.000000"); - String strLatitude = df.format(latitude); - String strLongitude = df.format(longitude); + // 经纬度 保留4位小数点 + DecimalFormat df = new DecimalFormat("#.000000"); + String strLatitude = df.format(latitude); + String strLongitude = df.format(longitude); //定位 - StringBuilder sb=new StringBuilder(); - sb.append("GPGGA, location time= " + TimeUtil.getLocalTime() + ", FixedCount=" + locationFixedCount + ", GPSTime="+utctime+", Lat="+Lat+" ("+strLatitude+"), Lon="+lon+" ("+strLongitude+"), fixed="+fixed+", hdop="+hdop+", usedStarts="+usedStarts); + StringBuilder sb = new StringBuilder(); + sb.append("GPGGA, location time= " + TimeUtil.getLocalTime() + ", FixedCount=" + locationFixedCount + ", GPSTime=" + utctime + ", Lat=" + Lat + " (" + strLatitude + "), Lon=" + lon + " (" + strLongitude + "), fixed=" + fixed + ", hdop=" + hdop + ", usedStarts=" + usedStarts); ICLogger.i(sb.toString()); if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "GPS", sb.toString()); //定位了, - if (hdop!=null&& hdop.trim().length()>0 && Float.valueOf(hdop) MaxFixedTimes) { + 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坐标。 延迟MaxFixedTimes秒后才设置runtime的定位标志,以便稳定坐标值。 */ - runtime.getLocationInstance().setLocation(Lat,lon); - runtime.getLocationInstance().setUsedStarts(Integer.valueOf(usedStarts.trim())); - 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(); - } + runtime.getLocationInstance().setLocation(Lat, lon); + runtime.getLocationInstance().setUsedStarts(Integer.valueOf(usedStarts.trim())); + 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(); } - gps_status.locating_status=1; //fixed - }else{ - gps_status.locating_status=0; //notfixed + } + gps_status.locating_status = 1; //fixed + } else { + gps_status.locating_status = 0; //notfixed } - gps_status.hdop=Float.valueOf(hdop.trim()); - gps_status.used_gps_numbs=Integer.valueOf(usedStarts.trim()); + gps_status.hdop = Float.valueOf(hdop.trim()); + gps_status.used_gps_numbs = Integer.valueOf(usedStarts.trim()); - }else if (nmeastr.startsWith("$GPGSA,")) { + } else if (nmeastr.startsWith("$GPGSA,")) { // GPGSA编辑 //( 当前卫星信息) @@ -394,19 +400,22 @@ public class NMEAListener implements NmeaListener, LocationListener { // } } } - - public void onProviderDisabled(String paramString) {} - - public void onProviderEnabled(String paramString) {} + + public void onProviderDisabled(String paramString) { + } + + public void onProviderEnabled(String paramString) { + } @Override public void onLocationChanged(Location location) { } - public void onStatusChanged(String paramString, int paramInt, Bundle paramBundle) {} + public void onStatusChanged(String paramString, int paramInt, Bundle paramBundle) { + } - public boolean gpsColdStart(){ + public boolean gpsColdStart() { //冷启动 Bundle bundle = null; locationManager.sendExtraCommand("gps", "force_xtra_injection", bundle); //command @@ -416,7 +425,7 @@ public class NMEAListener implements NmeaListener, LocationListener { } - public boolean gpsWormStart(){ + public boolean gpsWormStart() { //温启动 Bundle bundleWarm = new Bundle(); @@ -427,7 +436,7 @@ public class NMEAListener implements NmeaListener, LocationListener { return b2; } - public boolean gpsHotStart(){ + public boolean gpsHotStart() { //热启动 Bundle bundleHot = new Bundle(); bundleHot.putBoolean("almanac", true); @@ -438,21 +447,20 @@ public class NMEAListener implements NmeaListener, LocationListener { } - private final int MSG_WHAT_GPS_FIXED=300; - private final int MSG_WHAT_GPS_TIMEOUT=100; - private final int MSG_WHAT_GPS_NOSTAR=200; - private final int MSG_WHAT_GPS_FIXED_NO_STOP=400; + private final int MSG_WHAT_GPS_FIXED = 300; + private final int MSG_WHAT_GPS_TIMEOUT = 100; + private final int MSG_WHAT_GPS_NOSTAR = 200; + private final int MSG_WHAT_GPS_FIXED_NO_STOP = 400; Handler temHandler = new Handler(new Handler.Callback() { @Override public boolean handleMessage(Message message) { - if( message.what== MSG_WHAT_GPS_TIMEOUT|| message.what==MSG_WHAT_GPS_NOSTAR){ - //no start - //do nothing + if (message.what == MSG_WHAT_GPS_TIMEOUT || message.what == MSG_WHAT_GPS_NOSTAR) { + //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坐标。 @@ -462,41 +470,42 @@ public class NMEAListener implements NmeaListener, LocationListener { } - if (!noStop){ - ICLogger.i("handleMessage MSG_WHAT_GPS_TIMEOUT/ MSG_WHAT_GPS_NOSTAR/ MSG_WHAT_GPS_FIXED "+message.what); + if (!noStop) { + ICLogger.i("handleMessage MSG_WHAT_GPS_TIMEOUT/ MSG_WHAT_GPS_NOSTAR/ MSG_WHAT_GPS_FIXED " + message.what); stopListen(); } return true; } }); - private void get3MaxSnrSatellite(ICLocation.GpsSatellitePriv gst){ + + private void get3MaxSnrSatellite(ICLocation.GpsSatellitePriv gst) { float snr = gst.getSnr(); - for (int k=0;k< runtime.getLocationInstance().max3Satellite.size();k++) { - if( runtime.getLocationInstance().max3Satellite.get(k).getPrn()==gst.getPrn()) + for (int k = 0; k < runtime.getLocationInstance().max3Satellite.size(); k++) { + if (runtime.getLocationInstance().max3Satellite.get(k).getPrn() == gst.getPrn()) runtime.getLocationInstance().max3Satellite.remove(k); } runtime.getLocationInstance().max3Satellite.add(gst);//先添加进来。 //从大到小排序 - for(int i=0;i< runtime.getLocationInstance().max3Satellite.size();i++) { - for (int j=i;j< runtime.getLocationInstance().max3Satellite.size();j++) { - if ( runtime.getLocationInstance().max3Satellite.get(i).getSnr() < runtime.getLocationInstance().max3Satellite.get(j).getSnr()) { - ICLocation.GpsSatellitePriv ts = runtime.getLocationInstance().max3Satellite.get(j); + for (int i = 0; i < runtime.getLocationInstance().max3Satellite.size(); i++) { + for (int j = i; j < runtime.getLocationInstance().max3Satellite.size(); j++) { + if (runtime.getLocationInstance().max3Satellite.get(i).getSnr() < runtime.getLocationInstance().max3Satellite.get(j).getSnr()) { + ICLocation.GpsSatellitePriv ts = runtime.getLocationInstance().max3Satellite.get(j); runtime.getLocationInstance().max3Satellite.remove(j); runtime.getLocationInstance().max3Satellite.add(i, ts);//大的放前面 } } } - if ( runtime.getLocationInstance().max3Satellite.size()>5){ //超过三个,谁小就删掉 + if (runtime.getLocationInstance().max3Satellite.size() > 5) { //超过三个,谁小就删掉 runtime.getLocationInstance().max3Satellite.remove(5); } } //停止定位 - private void stop(int id){ + private void stop(int id) { // 经纬度 保留6位小数点 // DecimalFormat df = new DecimalFormat("#.000000"); @@ -509,6 +518,7 @@ public class NMEAListener implements NmeaListener, LocationListener { //发送停止消息 temHandler.sendEmptyMessage(id); } + boolean isFrist = true; @@ -530,7 +540,7 @@ public class NMEAListener implements NmeaListener, LocationListener { ICLogger.i("GPS StartListen with Provider " + provider); - if( Config.LOG_TOFILE) ICLogger.logToFile("GPS","GPS StartListen with Provider " + provider); + if (Config.LOG_TOFILE) ICLogger.logToFile("GPS", "GPS StartListen with Provider " + provider); this.locationManager.requestLocationUpdates(provider, 0L, 0.0F, this); @@ -539,21 +549,23 @@ public class NMEAListener implements NmeaListener, LocationListener { longitude = 0; latitude = 0; searchCout = 0; - locationFixedCount=0; + locationFixedCount = 0; gpsMode = GPS_CURRENT_STATUS.GPS_LISTENING; // locationManager.addGpsStatusListener(statusListener);//监听搜星状态 locationManager.addNmeaListener(this); //监听NMEA 协议数据。 //做个热启动 return true;//gpsHotStart(); - }else{ + } else { ICLogger.i(" location listening, skip !"); - if( Config.LOG_TOFILE)ICLogger.logToFile("GPS"," location listening, skip !"); + if (Config.LOG_TOFILE) ICLogger.logToFile("GPS", " location listening, skip !"); return true; } } - + public boolean isGpsOpening() { + return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); + } public void stopListen() { this.locationManager.removeNmeaListener(this); 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 4133d808..b685f0ac 100644 --- a/app/src/main/java/com/enqualcomm/support/bean/Runtime.java +++ b/app/src/main/java/com/enqualcomm/support/bean/Runtime.java @@ -25,7 +25,8 @@ public class Runtime { private boolean batteryLow; private boolean batterychanging; - + + public String belong; private File cacheDir; @@ -90,7 +91,14 @@ public class Runtime { private heartRateStatus HRS=null; + private boolean FactoryTestingStat=false; + public void setFactoryTestingStat(boolean testing){ + FactoryTestingStat=testing; + } + public boolean getFactoryTestingStat(){ + return FactoryTestingStat; + } private boolean UseQueue=false; private boolean lockSimInfo=false; diff --git a/app/version_code.properties b/app/version_code.properties index 1559b7d8..8db02b4d 100644 --- a/app/version_code.properties +++ b/app/version_code.properties @@ -1,2 +1,2 @@ -#Wed Mar 18 17:40:12 CST 2020 -VERSION_CODE=379 +#Thu Mar 19 12:08:30 CST 2020 +VERSION_CODE=380