}\r
\r
public static int getPPGTestCycle(Context context){\r
- return SharPreferenceUtil.getPrefInt(context,KeyPpgTestCycle,30);\r
+ return SharPreferenceUtil.getPrefInt(context,KeyPpgTestCycle,0);\r
}\r
\r
\r
//设置5分钟后结束紧急定位模式\r
setEmegencyLocationSTOPAlarm(5);\r
\r
- //5秒后开始拨打电话\r
+ //50ms后开始拨打电话\r
Observable.timer(500L, TimeUnit.MILLISECONDS).subscribe(new Action1<Long>() {\r
public void call(Long param1Long) {\r
trigger_SOS_Call();\r
}else if(ACTION_SEND_EMEGENCY_LOCATION_STOP.equals(paramIntent.getAction())){\r
//stop Emegency location Stop\r
Config.loadModCycleSettings(runtime); //回复之前的 工作模式即可\r
+ setLocationAlarm(runtime.getLocationInstance().getWorkingMod());//同时重置alarm并触发定位\r
}\r
this.invokeHandlerServiceChain.processUserRequest(paramIntent, this.connection, this.runtime);\r
}\r
}\r
\r
public void setHeartRateDetectAlarm(int heartRateDetectAlarmCycle){\r
+ if (heartRateDetectAlarmCycle>2)\r
AlarmHelper.setRealTimeAlarm(runtime.getContextProxy().context,heartRateDetectAlarmCycle,ACTION_HEATR_RATE_START);\r
}\r
\r
public void setLocationAlarm(int mod) {\r
// int mod=runtime.getLocationInstance().getWorkingMod();\r
StringBuilder sb=new StringBuilder();\r
- int cycle=1;\r
+ int cycle=60;\r
switch(mod){\r
case EMERGNECY_MOD:\r
case REALTIME_MOD:\r
}\r
}\r
\r
+\r
public void ReConnectToServer(){\r
\r
if (SimSignalUtil.checkNet(runtime.getContextProxy().context) ) {\r
import android.telephony.SmsMessage;\r
import android.widget.Toast;\r
\r
+import com.enqualcomm.support.bean.ICLocation;\r
import com.enqualcomm.support.bean.Runtime;\r
import com.enqualcomm.support.utils.APNUtil;\r
import com.enqualcomm.support.utils.DeviceInfoUtil;\r
e.printStackTrace();\r
}\r
if(mod<6&& mod>0 && cycle>=30 ){\r
+ switch(mod){\r
+ case ICLocation.NORMAL_MOD:\r
+ cycle=60*15;\r
+ break;\r
+ case ICLocation.LOWPOWER_MOD:\r
+ cycle=60*60;\r
+ break;\r
+ case ICLocation.REALTIME_MOD:\r
+ case ICLocation.EMERGNECY_MOD:\r
+ cycle=60;\r
+ break;\r
+ }\r
+ LocationClient.setForceLocation(1); //短信设置的至少强制执行第一次定位。否则NORMAL_MOD和LOWPOWER_MOD如果没有运动就无法正常定位\r
runtime.getLocationInstance().setLocation_cycle(cycle);\r
runtime.getLocationInstance().setWorkingMod(mod);\r
CoreService.getInstance().setLocationAlarm(runtime.getLocationInstance().getWorkingMod());\r
+ if (mod == 4){\r
+ CoreService.getInstance().setEmegencyLocationSTOPAlarm(5);\r
+ }\r
sendSMS(phonenumber, "set to Location Mode="+runtime.getLocationInstance().getWorkingMod()+", Cycle="+runtime.getLocationInstance().getLocation_cycle());\r
}else{\r
sendSMS(phonenumber, "set to Location Failed ,value range should be 1<= Mode <=5 and cycle >=30!");\r
// public void EqcAlgorithmInterfaceMethod2() {\r
public void startGpsLocate() {\r
Logger.i("开启GPS扫描");\r
- Settings.Secure.setLocationProviderEnabled(runtime.getContextProxy().getResolver(), GPS_PROVIDER, true);\r
+ runtime.getLocationInstance().setLocationStat( ICLocation.LOCATION_STAT.LOCATION_OPEN); //此处为了检测是否定位时可以正确识别状态,以防一直处于GPS定位成功状态\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) { LocationClient.this.nmeaListener.startListen(); }\r
});\r
\r
}\r
\r
+ public void clearGPSlocateStat(){\r
+ Logger.i("clearGPSlocateStat");\r
+ stopGpsLocate();\r
+ runtime.getLocationInstance().setLocationStat( ICLocation.LOCATION_STAT.LOCATION_CLOSED);//此处为了检测是否定位时可以正确识别状态,以防一直处于GPS定位成功状态\r
+ }\r
+\r
public void startCheckResult(){\r
checktimes=0;\r
timeout=false;\r
//GPS 优先的话多给些时间(10秒)\r
if (checktimes> 50) timeout=true;\r
\r
- if ((lbs_ok && timeout==true) ||(lbs_ok && ( gps_ok || startSOSLocation==true ) && wifi_ok )||(lbs_ok&&gps_nosignal&&wifi_ok)){\r
+ 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)){\r
\r
\r
if (startSOSLocation==true){\r
\r
// public void EqcAlgorithmInterfaceMethod3() {\r
public void stopGpsLocate() {\r
- if (Deliver.is_active_location) {\r
- Deliver.is_active_location = false;\r
- getLocationWakeLock();\r
- }\r
+// if (Deliver.is_active_location) {\r
+// Deliver.is_active_location = false;\r
+// getLocationWakeLock();\r
+// }\r
Settings.Secure.setLocationProviderEnabled(runtime.getContextProxy().getResolver(), GPS_PROVIDER, false);\r
Single.just(null).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<Object>() {\r
public void call(Object param1Object) { LocationClient.this.nmeaListener.stopListen(); }\r
}\r
\r
// 不强制定位 且 WorkingMod 不是紧急模式,且 没有移动过\r
- if ( !(( forceLocation == 1 ) || ( mod == ICLocation.REALTIME_MOD ) || (mod == ICLocation.CUSTOM_MOD)) && ( runtime.getLastStepCount() == runtime.getTotalStepCount()) ){\r
+ if ( ( forceLocation != 1 ) && ( mod != ICLocation.REALTIME_MOD )&& ( mod != ICLocation.EMERGNECY_MOD ) && (mod != ICLocation.CUSTOM_MOD) && ( runtime.getLastStepCount() == runtime.getTotalStepCount()) ){\r
Logger.i("No Move ,skip location!");\r
return ;\r
}\r
}else{\r
nmeaListener.setNoStop(false);\r
}\r
+ startGpsLocate();\r
+ break;\r
case ICLocation.EMERGNECY_MOD:\r
case ICLocation.REALTIME_MOD:\r
+ nmeaListener.setNoStop(false);//保证从Custom切换回来的时候不至于不关闭gps\r
startGpsLocate();\r
break;\r
+ case ICLocation.LOWPOWER_MOD:\r
+ case ICLocation.NORMAL_MOD:\r
+ default:\r
+ clearGPSlocateStat(); //如果wifi优先,则确保gps关闭,防止切换回来gps状态错误,尤其是不NoStop模式下的gps切换回来有此风险。\r
+ break;\r
}\r
\r
startCheckResult();\r
}\r
\r
+ public static void setForceLocation(int _forcelocation){\r
+ forceLocation=_forcelocation;\r
+ }\r
private static int forceLocation=0;\r
public void onReceive(StringMessage paramStringMessage) {\r
\r
if ("StartLocate".equals(paramStringMessage.cmd()) ){\r
forceLocation=1;\r
this.startLocationProcess(runtime.getLocationInstance().getWorkingMod());\r
- }\r
- if ("setWorkMod".equals(paramStringMessage.cmd())) {\r
+ }else if ("setWorkMod".equals(paramStringMessage.cmd())) {\r
+ //此处不负责给工作模式赋值,在API接收的位置能够直接拿到变量,可以直接赋值较方便。\r
int mod = runtime.getLocationInstance().getWorkingMod();\r
Logger.i("Set WorkMODE "+mod +" and reset Location AlarmCycle");\r
- CoreService.getInstance().setLocationAlarm(mod);\r
- forceLocation=1;\r
- this.startLocationProcess(mod);\r
+ CoreService.getInstance().setLocationAlarm(mod); //默认设置好Alarm后会触发一次定位,无需后面再触发定位了。\r
+ forceLocation=1; //不管是什么模式,都强制定位一次,然后再说其他情况\r
+ if(mod==ICLocation.EMERGNECY_MOD)\r
+ CoreService.getInstance().setEmegencyLocationSTOPAlarm(5);//Emergency模式5分钟自动停止\r
+// this.startLocationProcess(mod);\r
\r
}\r
}\r
*/\r
runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_FIXED);\r
\r
- }else if (message.what== MSG_WHAT_GPS_FIXED_NO_STOP){\r
- runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_FIXED);\r
- return true;\r
}\r
\r
- NMEAListener.this.stopListen();\r
+ if (!noStop){\r
+ NMEAListener.this.stopListen();\r
+ }\r
return true;\r
}\r
});\r
}\r
}\r
\r
- if (searchCout>SearchTimeout){\r
- sb2.append(" 搜索"+searchCout+"次未定位,超过"+SearchTimeout+"限制退出GPS定位");\r
- gpsMode=GPS_CURRENT_STATUS.GPS_TIMEOUT;\r
- runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_GPS_TIEMOUT);\r
+ if(!noStop) {\r
+ if (searchCout > SearchTimeout) {\r
+ sb2.append(" 搜索" + searchCout + "次未定位,超过" + SearchTimeout + "限制退出GPS定位");\r
+ gpsMode = GPS_CURRENT_STATUS.GPS_TIMEOUT;\r
+ runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_GPS_TIEMOUT);\r
\r
- stop(MSG_WHAT_GPS_TIMEOUT);\r
- }\r
- if (noSignalCount> 10){\r
- sb2.append(" 搜索"+searchCout+"次,超过"+noSignalCount+"次没有收到星,退出GPS定位");\r
- gpsMode=GPS_CURRENT_STATUS.GPS_NOSINGAL;\r
- runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_GPS_TIEMOUT);\r
+ stop(MSG_WHAT_GPS_TIMEOUT);\r
+ }\r
+ if (noSignalCount > 10) {\r
+ sb2.append(" 搜索" + searchCout + "次,超过" + noSignalCount + "次没有收到星,退出GPS定位");\r
+ gpsMode = GPS_CURRENT_STATUS.GPS_NOSINGAL;\r
+ runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_GPS_TIEMOUT);\r
\r
- stop(MSG_WHAT_GPS_NOSTAR);\r
+ stop(MSG_WHAT_GPS_NOSTAR);\r
+ }\r
}\r
if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(this.runtime.getCacheDir(),"GPS",sb2.toString());\r
-\r
Logger.i( sb2.toString());\r
getBestLocation(locationManager,status);\r
\r
}\r
private void delaystop(){\r
\r
- if (noStop){\r
- NMEAListener.this.temHandler.sendEmptyMessageDelayed(MSG_WHAT_GPS_FIXED_NO_STOP, 3000L);\r
- }else {\r
/*\r
只有当前GPS已经定位,且location不为空才给 runtime赋值GPS坐标。\r
延迟三秒后才设置runtime的定位标志,以便稳定坐标值。\r
*/\r
//发送停止消息\r
NMEAListener.this.temHandler.sendEmptyMessageDelayed(MSG_WHAT_GPS_FIXED, 3000L);\r
- }\r
+\r
}\r
boolean isFrist = true;\r
\r
\r
if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(this.runtime.getCacheDir(),"GPS",sb.toString());\r
runtime.getLocationInstance().setLocation(latitude,longitude,speed,0,status.getMaxSatellites());\r
+ if (noStop){//如果是不停止gps,那么每次确认定位的数据都设置标志位,以便其他线程能及时更新数据\r
+ runtime.getLocationInstance().setLocationStat(ICLocation.LOCATION_STAT.LOCATION_FIXED);\r
+ }\r
}\r
\r
}\r
\r
long l = SystemClock.elapsedRealtime();\r
\r
- //如果 没有连接成功 或者 时间超过了11分钟 ,则进行重新连接服务\r
- if (!isConnected || l - this.idleTimeMillis > 660000L) {\r
- StringBuilder stringBuilder = new StringBuilder();\r
- stringBuilder.append("重连");\r
- stringBuilder.append(isConnected);\r
- Logger.i(stringBuilder.toString());\r
- if (!isConnected && this.firstReConnected) {\r
- this.reConnectionNumber++;\r
- this.firstReConnected = false;\r
- } \r
-// if (paramRuntime.getLockSimInfo()) {\r
-// paramConnection.disconnect();\r
-// return;\r
+// //如果 没有连接成功 或者 时间超过了11分钟 ,则进行重新连接服务\r
+// if (!isConnected || l - this.idleTimeMillis > 660000L) {\r
+// StringBuilder stringBuilder = new StringBuilder();\r
+// stringBuilder.append("重连");\r
+// stringBuilder.append(isConnected);\r
+// Logger.i(stringBuilder.toString());\r
+// if (!isConnected && this.firstReConnected) {\r
+// this.reConnectionNumber++;\r
+// this.firstReConnected = false;\r
// }\r
- CoreService.getInstance().ReConnectToServer();\r
- } \r
+//\r
+// CoreService.getInstance().ReConnectToServer();\r
+// }\r
}\r
\r
public void onAttach(final Connection connection, final Runtime runtime) {\r
paramRuntime.getContextProxy().sendBroadcast(isConnected);\r
LauncherCtrl.getInstance(this.mContext).setStatusBarIcon("server_connected", STATUS_BAR_STATE_SERVER_CONNECTED_ON);\r
// Deliver.triggerSendThread(); //链接上就尝试清除 buffer中的数据\r
+ CoreService.getInstance().stopConnectionRetryTimer();\r
+\r
}\r
return false;\r
}\r
break;\r
case BP33:\r
//设置工作模式\r
- DeliverCMDMessageToSystem("setWorkMod",cmd);//通知下面线程状态变化\r
- DeliverCMDMessageToSystem("AP33",cmd);//通知下面线程状态变化\r
API.handleBP33(NettyConnection.this,runtime,cmd);\r
+ DeliverCMDMessageToSystem("setWorkMod",cmd);//通知下面线程状态变化\r
\r
break;\r
case BP16:\r
-#Wed Feb 12 23:18:01 CST 2020\r
-VERSION_CODE=351\r
+#Sun Feb 16 18:44:00 CST 2020\r
+VERSION_CODE=354\r