From: snickersun Date: Sat, 14 Mar 2020 09:55:05 +0000 (+0800) Subject: release V376 X-Git-Url: http://git.snicker.com.cn/sitemap.xml?a=commitdiff_plain;h=6eaf7cd5a6fcbf978cb6847fe5a52606713bae5d;p=icsupport.git release V376 1、修复定位检测 定时器不准造成的长时间无法继续定位(增加时间的判断,而不是只有计数) 2、优化定位精度,HDOP定位精度由原来的50米以内改为10米以内 , 原来需要定位5次,改为定位3次即可。 3、去掉多余的定位代码 4、增加更多的日志,方便分析问题。 --- diff --git a/app/release/ICSer_V375_2003131757_release.apk b/app/release/ICSer_V375_2003131757_release.apk deleted file mode 100644 index bc65c8cf..00000000 Binary files a/app/release/ICSer_V375_2003131757_release.apk and /dev/null differ diff --git a/app/release/ICSer_V376_2003141723_release.apk b/app/release/ICSer_V376_2003141723_release.apk new file mode 100644 index 00000000..7e0558ec Binary files /dev/null and b/app/release/ICSer_V376_2003141723_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 e4d590ea..1437020d 100644 --- a/app/src/main/java/com/enqualcomm/support/CoreService.java +++ b/app/src/main/java/com/enqualcomm/support/CoreService.java @@ -657,7 +657,7 @@ public class CoreService extends Service { stringBuilder1.append("LOCATION_ALARM work mod="); stringBuilder1.append(runtime.getLocationInstance().getWorkingMod()); if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(runtime.getCacheDir(), "alarmCycle", stringBuilder1.toString()); - this.locationClient.triggerLocationProcess(); +// this.locationClient.triggerLocationProcess(); } else { StringBuilder stringBuilder1; diff --git a/app/src/main/java/com/enqualcomm/support/LocationClient.java b/app/src/main/java/com/enqualcomm/support/LocationClient.java index edfb7f1b..f503f065 100644 --- a/app/src/main/java/com/enqualcomm/support/LocationClient.java +++ b/app/src/main/java/com/enqualcomm/support/LocationClient.java @@ -1,5 +1,6 @@ package com.enqualcomm.support; +import android.app.AlarmManager; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; @@ -10,6 +11,7 @@ import android.os.PowerManager; import android.os.SystemClock; import android.provider.Settings; +import com.enqualcomm.support.utils.AlarmHelper; import com.ic.jni.ICJniUtils; import com.enqualcomm.support.adapter.LBSHelper; import com.enqualcomm.support.adapter.protocolAPIHelper; @@ -49,7 +51,7 @@ import static com.enqualcomm.support.Constants.HEART_ALARM; public class LocationClient { private static final String TAG = LocationClient.class.getSimpleName(); private static final long CHANGENETMODETIME = 43200000L; - + private static long startCheckTime=0L; private static final int CLOSE_AIRMODE = 0; private static final int IS_GPS = 0; @@ -118,7 +120,7 @@ public class LocationClient { // private BroadcastReceiver screenOnReceiver = new BroadcastReceiver() { // public void onReceive(Context param1Context, Intent param1Intent) { // if ("android.intent.action.SCREEN_ON".equals(param1Intent.getAction())) { -// LocationClient.this.mSignalUtil.setAirMode("CloseAirplane"); +// mSignalUtil.setAirMode("CloseAirplane"); // } // } // }; @@ -178,7 +180,6 @@ public class LocationClient { } - private void performAlarm(PowerManager.WakeLock paramWakeLock) { if (!runtime.isAirMode) { updateStepCount();//update StepCount @@ -187,11 +188,11 @@ public class LocationClient { } } public void triggerLocationProcess(){ - mhandler.sendEmptyMessage(0); + mhandler.sendEmptyMessage(msgWhat_StartLocationProcess); } public void triggerSOSLocationProcess(){ - mhandler.sendEmptyMessage(2); + mhandler.sendEmptyMessage(msgWhat_StartSOSLocationProcess); } private static int checktimes=0; @@ -225,7 +226,7 @@ public class LocationClient { 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(); + nmeaListener.startListen(); } }); } @@ -243,35 +244,41 @@ public class LocationClient { public void startCheckResult(){ checktimes=0; timeout=false; + startCheckTime= System.currentTimeMillis(); //延时2秒执行发送“读取定位”消息 if (mTimer==null) mTimer=new Timer(); mTimer.schedule(new MyTimerTask(), 1000L,1000L); +// AlarmManager alarmManager=(AlarmManager)runtime.getContextProxy().context.getSystemService(Context.ALARM_SERVICE); +// AlarmHelper.setAlarm(alarmManager,0,1,); } class MyTimerTask extends TimerTask { public void run() { //发送读取计步消息 - LocationClient.this.mhandler.sendEmptyMessage(100); + mhandler.sendEmptyMessage(msgWhat_WaitAndSendLocation); } }; + + + + private final static int msgWhat_WaitAndSendLocation=100; + private final static int msgWhat_StartLocationProcess=0; + private final static int msgWhat_StartSOSLocationProcess=2; Handler mhandler=new Handler(){ public void handleMessage(Message msg) { super.handleMessage(msg); - if (msg.what == 100){ + if (msg.what == msgWhat_WaitAndSendLocation){ Single.just(null).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1() { - public void call(Object param1Object) { LocationClient.this.waitAndSendLocation(); } + public void call(Object param1Object) { waitAndSendLocation(); } }); - }else if (msg.what == 0){ + }else if (msg.what == msgWhat_StartLocationProcess){ startLocationProcess(runtime.getLocationInstance().getWorkingMod()); - }else if (msg.what == 2){ + }else if (msg.what == msgWhat_StartSOSLocationProcess){ startSOSLocation=true;//启动SOS定位,为了快速响应,只要wifi定位即可。 forceLocation=1; startLocationProcess(ICLocation.NORMAL_MOD); } - - } - }; @@ -296,7 +303,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("waitAndSendLocation lbs="+lbs_ok+", wifi="+ wifi_ok+ ", gps="+gps_ok + ", mode="+mode); + ICLogger.i("waitAndSendLocation "+checktimes+", lbs="+lbs_ok+", wifi="+ wifi_ok+ ", gps="+gps_ok + ", mode="+mode); switch(mode){ case ICLocation.CUSTOM_MOD: @@ -305,57 +312,65 @@ public class LocationClient { //GPS 优先的话多给些时间(10秒) - if (checktimes> 50) timeout=true; - - if ((lbs_ok && timeout==true) ||( gps_ok )||(lbs_ok && gps_ok )||(lbs_ok && ( gps_ok || startSOSLocation==true ) && wifi_ok )||(lbs_ok&&gps_nosignal&&wifi_ok)){ - - + if (checktimes> 50 || + ((startCheckTime!=0L)&&(System.currentTimeMillis()-startCheckTime > 50*1000L)) //有时timer计数不准,则根据实际时间计算 + ) timeout=true; + + // lbs only +timeout, lbs+wifi+gpsNosignal, libs+ , lbs+gps+wifi, Timeout can override wifi and gps + if ((lbs_ok && timeout==true) + ||( gps_ok ) + ||(lbs_ok && ( gps_ok || startSOSLocation==true ) ) + ||(lbs_ok && ( gps_ok || startSOSLocation==true ) && wifi_ok ) + ||(lbs_ok&&gps_nosignal&&wifi_ok) + ){ if (startSOSLocation==true){ - String AP10_CMD = protocolAPIHelper.AP10(runtime); Deliver.sendLocationMSG(AP10_CMD); startSOSLocation=false; - }else { String AP01_CMD = protocolAPIHelper.AP01(runtime); Deliver.sendLocationMSG(AP01_CMD); } - if (mTimer!=null){ - mTimer.cancel(); - mTimer=null; - } - isLocating = false; + stopCheckLocationResult(); + String locationtype="LBS"; if (gps_ok ){ locationtype="GPS"; }else if (wifi_ok){ locationtype="WiFi"; } + runtime.getLocationInstance().setLocationType(locationtype); runtime.getLocationInstance().setLocationTime(TimeUtil.getSystemTime3()); + + String msg="Location Fixed Type "+runtime.getLocationInstance().getLocationType()+" at "+runtime.getLocationInstance().getLocationTime(); + ICLogger.i(msg); + + if (Config.LOG_TOFILE) + FileOutputUtil.fileOutput(this.runtime.getCacheDir(),"GPS",msg); + + }else if (timeout==true){ + //timeout + noLBS +noGPS ICLogger.i("timeout no location "); - isLocating = false; - if (mTimer!=null){ - mTimer.cancel(); - mTimer=null; - } + stopCheckLocationResult(); + if (Config.LOG_TOFILE) + FileOutputUtil.fileOutput(this.runtime.getCacheDir(),"GPS","timeout no location "); } break; + + case ICLocation.NORMAL_MOD: + case ICLocation.LOWPOWER_MOD: default: //wifi优先的话给20秒时间 - if (checktimes> 20) timeout=true; + if (checktimes> 20 || + ((startCheckTime!=0L)&&(System.currentTimeMillis()-startCheckTime > 20*1000L)) //有时timer计数不准,则根据实际时间计算 + ) timeout=true; if ((lbs_ok && timeout==true) ||(lbs_ok && wifi_ok )){ - String locationtype="LBS"; - if (wifi_ok){ - locationtype="WiFi"; - } - runtime.getLocationInstance().setLocationType(locationtype); - runtime.getLocationInstance().setLocationTime(TimeUtil.getSystemTime3()); if (startSOSLocation==true){ String AP10_CMD = protocolAPIHelper.AP10(runtime); @@ -367,33 +382,50 @@ public class LocationClient { Deliver.sendLocationMSG(AP01_CMD); } - if (mTimer!=null){ - mTimer.cancel(); - mTimer=null; + stopCheckLocationResult(); + + String locationtype="LBS"; + if (wifi_ok){ + locationtype="WiFi"; } - isLocating = false; + runtime.getLocationInstance().setLocationType(locationtype); + runtime.getLocationInstance().setLocationTime(TimeUtil.getSystemTime3()); + + String msg="Location Fixed Type "+runtime.getLocationInstance().getLocationType()+" at "+runtime.getLocationInstance().getLocationTime(); + ICLogger.i(msg); + if (Config.LOG_TOFILE) + FileOutputUtil.fileOutput(this.runtime.getCacheDir(),"GPS",msg); }else if (timeout==true){ ICLogger.i("timeout no location "); - isLocating = false; - if (mTimer!=null){ - mTimer.cancel(); - mTimer=null; - } + stopCheckLocationResult(); + if (Config.LOG_TOFILE) + FileOutputUtil.fileOutput(this.runtime.getCacheDir(),"GPS","timeout no location "); } break; } } + public void stopCheckLocationResult(){ + ICLogger.i("stopCheckLocationResult!"); + if (mTimer!=null){ + mTimer.cancel(); + mTimer=null; + } + isLocating = false; + startCheckTime=0L; + } + // public void EqcAlgorithmInterfaceMethod3() { public void stopGpsLocate() { // if (Deliver.is_active_location) { // Deliver.is_active_location = false; // getLocationWakeLock(); // } + ICLogger.i("stopGpsLocate"); //防止与工厂测试冲突 if (!DeviceInfoUtil.isFactoryTestTopActivity(runtime.getContextProxy().context)) { @@ -401,7 +433,7 @@ public class LocationClient { Settings.Secure.setLocationProviderEnabled(runtime.getContextProxy().getResolver(), GPS_PROVIDER, false); Single.just(null).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1() { public void call(Object param1Object) { - LocationClient.this.nmeaListener.stopListen(); + nmeaListener.stopListen(); } }); } @@ -461,7 +493,7 @@ public void updateCellInfo() { runtime.setLastStepCount(runtime.getTotalStepCount()); updateCellInfo(); - startWifiScan(); + startWifiScan(); switch(mod){ case ICLocation.CUSTOM_MOD: if(runtime.getLocationInstance().getLocation_cycle()<60){ @@ -543,6 +575,7 @@ public void updateCellInfo() { public void deinit() { + ICLogger.i("GPS deinit!"); // (runtime.getContextProxy()).context.unregisterReceiver(this.screenOnReceiver); // mLbsHelper.unRegisterWiFiBroadReceiver(); // this.executor.execute(new Runnable() { @@ -560,7 +593,7 @@ public void updateCellInfo() { private void notifiSetAirModeMethod() { (new Thread(new Runnable() { public void run() { SystemClock.sleep(3000L); - boolean bool = LocationClient.this.mSignalUtil.IsAirModeOn(); + boolean bool = mSignalUtil.IsAirModeOn(); byte b = 1; if (bool != true) b = 0; diff --git a/app/src/main/java/com/enqualcomm/support/NMEAListener.java b/app/src/main/java/com/enqualcomm/support/NMEAListener.java index 5178d870..cd4ccd79 100644 --- a/app/src/main/java/com/enqualcomm/support/NMEAListener.java +++ b/app/src/main/java/com/enqualcomm/support/NMEAListener.java @@ -60,7 +60,7 @@ public class NMEAListener implements NmeaListener, LocationListener { int numberOfSatellites; Runtime runtime; - private static int MaxFixedTimes=5; + private static int MaxFixedTimes=3; private static int locationFixedCount=0; @@ -68,6 +68,7 @@ public class NMEAListener implements NmeaListener, LocationListener { public void setNoStop(boolean nostop){ noStop=nostop; + ICLogger.i("setNoStop"+nostop); if (noStop==false){ stopListen(); } @@ -228,6 +229,7 @@ public class NMEAListener implements NmeaListener, LocationListener { stop(MSG_WHAT_GPS_NOSTAR); } } + ICLogger.i( sb2.toString()); if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(this.runtime.getCacheDir(),"GPS",sb2.toString()); @@ -282,6 +284,31 @@ public class NMEAListener implements NmeaListener, LocationListener { 只有当前GPS已经定位,且location不为空才给 runtime赋值GPS坐标。 延迟MaxFixedTimes秒后才设置runtime的定位标志,以便稳定坐标值。 */ + + //log msg变量 + StringBuffer sb2 = new StringBuffer(); + sb2.append(" gps lat=").append(Lat).append(", gps lon=").append(lon); + + 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; + + // 经纬度 保留4位小数点 + DecimalFormat df = new DecimalFormat("#.000000"); + String strLatitude = df.format(latitude); + String strLongitude = df.format(longitude); + sb2.append(" real lat=").append(strLatitude).append(" lon=").append(strLongitude); + ICLogger.i(sb2.toString()); + runtime.getLocationInstance().setLocation(Lat,lon); runtime.getLocationInstance().setUsedStarts(Integer.valueOf(usedStarts.trim())); runtime.getLocationInstance().setHod(Float.valueOf(hdop.trim())); @@ -395,7 +422,9 @@ public class NMEAListener implements NmeaListener, LocationListener { } if (!noStop){ - NMEAListener.this.stopListen(); + ICLogger.i("handleMessage MSG_WHAT_GPS_TIMEOUT/ MSG_WHAT_GPS_NOSTAR/ MSG_WHAT_GPS_FIXED "+message.what); + + stopListen(); } return true; } @@ -437,17 +466,7 @@ public class NMEAListener implements NmeaListener, LocationListener { // // ICLogger.i("Location " +runtime.getLocationInstance().getLocationStat().name()); //发送停止消息 - NMEAListener.this.temHandler.sendEmptyMessage(id); - } - private void delaystop(){ - - /* - 只有当前GPS已经定位,且location不为空才给 runtime赋值GPS坐标。 - 延迟三秒后才设置runtime的定位标志,以便稳定坐标值。 - */ - //发送停止消息 - NMEAListener.this.temHandler.sendEmptyMessageDelayed(MSG_WHAT_GPS_FIXED, 3000L); - + temHandler.sendEmptyMessage(id); } boolean isFrist = true; @@ -479,6 +498,8 @@ public class NMEAListener implements NmeaListener, LocationListener { //做个热启动 return true;//gpsHotStart(); }else{ + ICLogger.i(" location listening, skip !"); + return true; } } @@ -488,6 +509,7 @@ public class NMEAListener implements NmeaListener, LocationListener { this.locationManager.removeNmeaListener(this); this.locationManager.removeUpdates(this); this.listening = false; + ICLogger.i("stopListen 定位 "); } public enum GPS_CURRENT_STATUS { 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 25cb8e36..d707df66 100644 --- a/app/src/main/java/com/enqualcomm/support/bean/ICLocation.java +++ b/app/src/main/java/com/enqualcomm/support/bean/ICLocation.java @@ -42,7 +42,7 @@ public class ICLocation { private int mworkingMod; private int location_cycle; - public static final float MAX_HDOP=50.0f; + public static final float MAX_HDOP=10.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;} diff --git a/app/src/main/java/com/enqualcomm/support/utils/TimeUtil.java b/app/src/main/java/com/enqualcomm/support/utils/TimeUtil.java index 5c6afb14..c2c3b272 100644 --- a/app/src/main/java/com/enqualcomm/support/utils/TimeUtil.java +++ b/app/src/main/java/com/enqualcomm/support/utils/TimeUtil.java @@ -16,7 +16,7 @@ public class TimeUtil { public static String getSystemTime() { return getSystemTime(System.currentTimeMillis()); } - public static String getSystemTime(long paramLong) { return (new SimpleDateFormat("yyyy-MM-dd;HH:mm:ss")).format(new Date(paramLong)); } + public static String getSystemTime(long paramLong) { return (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(new Date(paramLong)); } public static String getSystemTime2() { return getSystemTime2(System.currentTimeMillis()); } diff --git a/app/version_code.properties b/app/version_code.properties index fc5c50e9..439698ba 100644 --- a/app/version_code.properties +++ b/app/version_code.properties @@ -1,2 +1,2 @@ -#Fri Mar 13 17:57:22 CST 2020 -VERSION_CODE=375 +#Sat Mar 14 17:23:03 CST 2020 +VERSION_CODE=376