package com.enqualcomm.support;\r
\r
+import android.content.Context;\r
+import android.content.SharedPreferences;\r
import android.text.TextUtils;\r
+\r
+import com.enqualcomm.support.bean.ICLocation;\r
+import com.enqualcomm.support.utils.SharPreferenceUtil;\r
+\r
import org.json.JSONException;\r
import org.json.JSONStringer;\r
\r
public class Config {\r
+\r
+ public static final boolean LOG_TOFILE=true;\r
public static final String AUDIO_FORMAT = "1";\r
\r
private static final String BT = "1@4.0";\r
json = make(); \r
return json;\r
}\r
+\r
+ final static String KeyProtocolServerIP="ProtocolServerIP";\r
+ final static String KeyProtocolServerPort="ProtoclServerPort";;\r
+ final static String KeyFotaServerIP="FotaServerIP";\r
+ final static String KeyFotaServerPort="FotaServerPort";\r
+\r
+ final static String KeyPpgTestCycle="PPGTestCycle";\r
+ final static String KeyLocationCycle="LocationCycle";\r
+ final static String KeyLocationMode="LocationMode";;\r
+\r
+ final static String KeyAlarmCycle="HeartBeatCycle";\r
+\r
+ final static String KeyContactsList="ContactsList";\r
+ final static String KeySOSNumbersList="SOSNumbersList";\r
+\r
+\r
+\r
+ public static void setAlarmCycle(Context context, int cycle){\r
+ SharPreferenceUtil.setPrefInt(context,KeyAlarmCycle,cycle);\r
+ }\r
+\r
+ //默认3分钟,刚刚wakeup的时候1分钟\r
+ public static int getAlarmCycle(Context context){\r
+ return SharPreferenceUtil.getPrefInt(context,KeyAlarmCycle,3);\r
+ }\r
+\r
+ public static void setProtocolServerAddr(Context context, String serverIP,int serverPort){\r
+ SharPreferenceUtil.setPrefString(context,KeyProtocolServerIP,serverIP);\r
+ SharPreferenceUtil.setPrefInt(context,KeyProtocolServerPort,serverPort);\r
+ }\r
+\r
+ public static String getProtocolServerIP(Context context){\r
+ return SharPreferenceUtil.getPrefString(context,KeyProtocolServerIP,"118.178.155.223");\r
+ }\r
+\r
+ public static int getProtocolServerPort(Context context){\r
+ return SharPreferenceUtil.getPrefInt(context,KeyProtocolServerPort,8090);\r
+ }\r
+\r
+ public static void setFotaServerIP(Context context,String serverIP,int serverPort){\r
+\r
+ SharPreferenceUtil.setPrefString(context,KeyFotaServerIP,serverIP);\r
+ SharPreferenceUtil.setPrefInt(context,KeyFotaServerPort,serverPort);\r
+\r
+ }\r
+ public static String getFotaServerIP(Context context){\r
+ return SharPreferenceUtil.getPrefString(context,KeyFotaServerIP,"icfota.snicker.com.cn");\r
+ }\r
+\r
+ public static int getFotaServerPort(Context context){\r
+ return SharPreferenceUtil.getPrefInt(context,KeyFotaServerPort,8089);\r
+ }\r
+\r
+\r
+ public static void setPPGTestCycle(Context context,int cycle){\r
+ SharPreferenceUtil.setPrefInt(context,KeyPpgTestCycle,cycle);\r
+ }\r
+\r
+ public static int getPPGTestCycle(Context context){\r
+ return SharPreferenceUtil.getPrefInt(context,KeyPpgTestCycle,30);\r
+ }\r
+\r
+ public static void setLocationCycle(Context context,int cycle){\r
+ SharPreferenceUtil.setPrefInt(context,KeyLocationCycle,cycle);\r
+ }\r
+\r
+ public static int getLocationCycle(Context context){\r
+ return SharPreferenceUtil.getPrefInt(context,KeyLocationCycle,15);\r
+ }\r
+\r
+ public static void setLocationMode(Context context,int mode){\r
+ SharPreferenceUtil.setPrefInt(context,KeyLocationMode,mode);\r
+ }\r
+\r
+\r
+ public static int getLocationMode(Context context){\r
+ return SharPreferenceUtil.getPrefInt(context,KeyLocationMode, ICLocation.NORMAL_MOD);\r
+ }\r
+\r
}\r
\r
stringBuilder1.append(Integer.valueOf(str, 16));\r
stringBuilder1.append(",CELLID=");\r
stringBuilder1.append(Integer.valueOf(str1, 16));\r
- FileOutputUtil.fileOutput(runtime.getCacheDir(), "cellInfoTest", stringBuilder1.toString());\r
+ if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(runtime.getCacheDir(), "cellInfoTest", stringBuilder1.toString());\r
}\r
}\r
}\r
StringBuilder stringBuilder2 = new StringBuilder();\r
stringBuilder2.append("broadcastReceiver alarmCycle action==");\r
stringBuilder2.append(param1Intent.getAction());\r
- FileOutputUtil.fileOutput(runtime.getCacheDir(), "alarmCycle", stringBuilder2.toString());\r
+ if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(runtime.getCacheDir(), "alarmCycle", stringBuilder2.toString());\r
StringBuilder stringBuilder1 = new StringBuilder();\r
stringBuilder1.append("时间变化");\r
stringBuilder1.append(param1Intent.getAction());\r
CoreService.this.setSleepAlarm();\r
CoreService.this.setWakeAlarm();\r
CoreService.this.setHeartAlarm();\r
- CoreService.this.setHeartRateDetectAlarm(3);\r
+ CoreService.this.setHeartRateDetectAlarm(runtime.getPpgTestCycle());\r
CoreService.this.setWeatherAlarm();\r
CoreService.this.setLocationAlarm(runtime.getLocationInstance().getWorkingMod());\r
if (CoreService.this.cmcm_call_eiot_into_powersave_mode() == 0)\r
}\r
\r
\r
+ private void loadSettings(){\r
+ this.runtime.setPpgTestCycle(Config.getPPGTestCycle(this));\r
+ this.runtime.getLocationInstance().setLocation_cycle(Config.getLocationCycle(this));\r
+ this.runtime.getLocationInstance().setWorkingMod(Config.getLocationMode(this));\r
+ }\r
\r
private void loadStepCount() {\r
int i = SharPreferenceUtil.getPrefInt(this, KEY_STEP_COUNT, 0);\r
Logger.i("1 into powersave return");\r
return;\r
}\r
+\r
+\r
+ //保证获取正确的计步数据及其他参数初始化\r
+ loadStepCount();\r
+ loadSettings();\r
+\r
this.connectionServiceChain.processAttach(this.connection, this.runtime);\r
this.invokeHandlerServiceChain.processAttach(this.connection, this.runtime);\r
setAlarm(alarmCycle);\r
- FileOutputUtil.fileOutput(runtime.getCacheDir(), "alarmCycle", "设置闹钟服务 alarmCycle");\r
+ if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(runtime.getCacheDir(), "alarmCycle", "设置闹钟服务 alarmCycle");\r
this.locationClient = new LocationClient(this.connection, this.runtime);\r
this.connection.open();\r
this.connection.connect(this.runtime.getSrvIP(), this.runtime.getPort());\r
batteryUtil = new BatteryUtil(this.runtime);\r
batteryUtil.registerBroadReceiver();\r
\r
- //保证获取正确的计步数据\r
- loadStepCount();\r
\r
//设置计步清零时间。\r
setCleanStepCountAlarm();\r
setHeartAlarm();\r
\r
//设置心率检测频率\r
- setHeartRateDetectAlarm(3); //3分钟一次\r
+ setHeartRateDetectAlarm(runtime.getPpgTestCycle()); //3分钟一次\r
\r
//获取天气时间\r
setWeatherAlarm();\r
Logger.i("2 into powersave return");\r
return Service.START_NOT_STICKY;\r
}\r
+\r
+ //wakeup后1分钟唤醒一次,5分钟后,心跳改为从配置信息读取的值,默认为3分钟\r
if (this.startAlarmCount < 5 && alarmCycle == 1) {\r
this.startAlarmCount++;\r
} else {\r
- alarmCycle = SharPreferenceUtil.getPrefInt((this.runtime.getContextProxy()).context, "location_cycle", 3);\r
+ alarmCycle = Config.getAlarmCycle(this);\r
}\r
AlarmWakeUp.setAlarmWakeUpTime();\r
boolean screenon = ((PowerManager)getSystemService(POWER_SERVICE)).isScreenOn();\r
Util.turnOffWifiForSleep((this.runtime.getContextProxy()).context, this.runtime);\r
}\r
setAlarm(alarmCycle);\r
- FileOutputUtil.fileOutput(runtime.getCacheDir(), "alarmCycle", "ALARM alarmCycle");\r
+ if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(runtime.getCacheDir(), "alarmCycle", "ALARM alarmCycle");\r
\r
//发送心跳间隔广播给其他应用\r
this.runtime.getContextProxy().sendBroadcast(ACTION_EQC_ALARM, this.runtime);\r
if (Constants.SLEEP_ALARM.equals(paramIntent.getAction())) {\r
Logger.i("SLEEP_ALARM");\r
is_allowed_in_sleep_mode = 1;\r
- FileOutputUtil.fileOutput(runtime.getCacheDir(), "alarmCycle", "SLEEP_ALARM alarmCycle");\r
+ if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(runtime.getCacheDir(), "alarmCycle", "SLEEP_ALARM alarmCycle");\r
setSleepAlarm();\r
boolean bool = ((PowerManager)getSystemService(POWER_SERVICE)).isScreenOn();\r
stringBuilder1 = new StringBuilder();\r
if (Constants.WAKE_ALARM.equals(paramIntent.getAction())) {\r
if (is_in_sleep_mode) {\r
is_in_sleep_mode = false;\r
- FileOutputUtil.fileOutput(runtime.getCacheDir(), "alarmCycle", "WAKE_ALARM alarmCycle");\r
+ if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(runtime.getCacheDir(), "alarmCycle", "WAKE_ALARM alarmCycle");\r
if (this.mKeepAlive != null)\r
this.mKeepAlive.setSleepMode(false);\r
wakeUpFromSleep();\r
if (this.mKeepAlive != null) {\r
this.mKeepAlive.onHeartAlarm(this.connection, this.runtime);\r
setHeartAlarm();\r
- FileOutputUtil.fileOutput(runtime.getCacheDir(), "alarmCycle", "HEART_ALARM alarmCycle " );\r
+ if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(runtime.getCacheDir(), "alarmCycle", "HEART_ALARM alarmCycle " );\r
return Service.START_STICKY;\r
}\r
} else {\r
stringBuilder1 = new StringBuilder();\r
stringBuilder1.append("STWORKMODE_ALARM alarmCycle=");\r
stringBuilder1.append(alarmCycle);\r
- FileOutputUtil.fileOutput(runtime.getCacheDir(), "alarmCycle", stringBuilder1.toString());\r
+ if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(runtime.getCacheDir(), "alarmCycle", stringBuilder1.toString());\r
return Service.START_STICKY;\r
}\r
if (ACTION_LOCATION_ALARM.equals(paramIntent.getAction())){\r
+ //收到定时定位消息\r
setLocationAlarm(runtime.getLocationInstance().getWorkingMod());\r
stringBuilder1 = new StringBuilder();\r
stringBuilder1.append("LOCATION_ALARM work mod=");\r
stringBuilder1.append(runtime.getLocationInstance().getWorkingMod());\r
- FileOutputUtil.fileOutput(runtime.getCacheDir(), "alarmCycle", stringBuilder1.toString());\r
+ if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(runtime.getCacheDir(), "alarmCycle", stringBuilder1.toString());\r
this.locationClient.triggerLocationProcess();\r
return Service.START_STICKY;\r
\r
}\r
if(ACTION_HEATR_RATE_START.equals(paramIntent.getAction())){\r
+ //此消息来源于BroadCaset以及Timer,收到开始测试的消息,马上发送消息给HeartRateManager开始测试。\r
+ //此时需要重置HeartRateDetect Timer\r
+ //倘若有 参数 PPGTestCycle,则根据这个数值进行设置\r
+ int ppgtestCycle=paramIntent.getIntExtra("PPGTestCycle",-1);\r
+ if (ppgtestCycle >0){\r
+ Config.setPPGTestCycle(this,ppgtestCycle);\r
+ runtime.setPpgTestCycle(Config.getPPGTestCycle(this));\r
+ Logger.i("get and set PPGTestCycle "+ppgtestCycle);\r
+ }\r
+ setHeartRateDetectAlarm(runtime.getPpgTestCycle());\r
this.invokeHandlerServiceChain.processUserRequest(paramIntent, this.connection, this.runtime);\r
+\r
}\r
}\r
}\r
locationClient.triggerLocationProcess();\r
\r
Logger.i(sb.toString());\r
- FileOutputUtil.fileOutput(runtime.getCacheDir(),"LocationAlarm",sb.toString());\r
+ if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(runtime.getCacheDir(),"LocationAlarm",sb.toString());\r
}\r
\r
public void setHeartAlarm(){\r
// 系统默认的UncaughtException处理类\r
private Thread.UncaughtExceptionHandler mDefaultHandler;\r
// CrashHandler实例\r
- private static CrashHandler INSTANCE = new CrashHandler();\r
+ private static CrashHandler INSTANCE = null;\r
// 程序的Context对象\r
private Context mContext;\r
// 用来存储设备信息和异常信息\r
/**\r
* 获取CrashHandler实例 ,单例模式\r
*/\r
- public static CrashHandler getInstance() {\r
+ public synchronized static CrashHandler getInstance() {\r
+ if (INSTANCE==null)\r
+ INSTANCE=new CrashHandler();\r
return INSTANCE;\r
}\r
\r
Logger.i(stringBuilder1.toString());\r
runtime.setTotalStepCount(CURRENT_STEP);\r
GSensorListener.getStepCountOver=false;\r
- FileOutputUtil.fileOutput(runtime.getCacheDir(), "CURRENT_STEP", stringBuilder1.toString());\r
+ if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(runtime.getCacheDir(), "CURRENT_STEP", stringBuilder1.toString());\r
}\r
};\r
\r
public void call(Object param1Object) { LocationClient.this.waitAndSendLocation(); }\r
});\r
}else if (msg.what == 0){\r
- startLocationProcess(WorkingMod);\r
+ startLocationProcess(runtime.getLocationInstance().getWorkingMod());\r
}\r
\r
\r
public void startLocationProcess(int mod){\r
\r
updateStepCount();//update StepCount,保证每次定位前,计步数据是最新的。防止丢数据。\r
- Logger.i("forceLocation="+forceLocation+", WorkingMod="+WorkingMod+", isLocating="+isLocating+", lastStep="+runtime.getLastStepCount()+", currentStep="+ runtime.getTotalStepCount());\r
+ Logger.i("forceLocation="+forceLocation+", WorkingMod="+mod+", isLocating="+isLocating+", lastStep="+runtime.getLastStepCount()+", currentStep="+ runtime.getTotalStepCount());\r
if (isLocating ) {\r
Logger.i("locating ,skip location!");\r
return;\r
}\r
\r
// 不强制定位 且 WorkingMod 不是紧急模式,且 没有移动过\r
- if ( !(( forceLocation == 1 ) || ( WorkingMod == 4 )) && ( runtime.getLastStepCount() == runtime.getTotalStepCount()) ){\r
+ if ( !(( forceLocation == 1 ) || ( mod == 4 )) && ( runtime.getLastStepCount() == runtime.getTotalStepCount()) ){\r
Logger.i("No Move ,skip location!");\r
return ;\r
}\r
startCheckResult();\r
}\r
\r
- private static int WorkingMod=1;\r
private static int forceLocation=0;\r
public void onReceive(StringMessage paramStringMessage) {\r
\r
//响应定位指令\r
if ("StartLocate".equals(paramStringMessage.cmd()) ){\r
forceLocation=1;\r
- this.startLocationProcess(WorkingMod);\r
+ this.startLocationProcess(runtime.getLocationInstance().getWorkingMod());\r
}\r
if ("setWorkMod".equals(paramStringMessage.cmd())) {\r
- int mod = 0;\r
- try\r
- {\r
- String[] cmdlist=paramStringMessage.isFromCache().split(",");\r
- if (cmdlist.length == 4)\r
- mod = Integer.valueOf(cmdlist[3]);\r
- }catch (Exception e){\r
- e.printStackTrace();\r
- }\r
- SharPreferenceUtil.setPrefInt((runtime.getContextProxy()).context, LOCATION_MODE, mod);\r
- runtime.getLocationInstance().setWorkingMod(mod);\r
-// runtime.getLocationInstance().setLocation_cycle(3);\r
+ int mod = runtime.getLocationInstance().getWorkingMod();\r
Logger.i("Set WorkMODE "+mod +" and reset Location AlarmCycle");\r
CoreService.getInstance().setLocationAlarm(mod);\r
-// Logger.i("ResartLOCATION_MODE 2");\r
- runtime.getContextProxy().sendBroadcast(LOCATION_MODE,runtime);\r
forceLocation=1;\r
this.startLocationProcess(mod);\r
- WorkingMod=mod;\r
+\r
}\r
}\r
\r
\r
//获取LBS定位服务\r
this.mLbsHelper = runtime.getLbsHelper();\r
- //初始化设定当前工作模式及循环频率\r
- if (SharPreferenceUtil.getPrefInt((runtime.getContextProxy()).context, "value_setting_ver", 0) == Config.value_setting) {\r
- //如果value_setting_ver = Config.value_setting 表示采用已经保存的模式\r
- runtime.getLocationInstance().setWorkingMod(SharPreferenceUtil.getPrefInt((runtime.getContextProxy()).context, LOCATION_MODE, ICLocation.NORMAL_MOD));\r
-// runtime.getLocationInstance().setLocation_cycle(SharPreferenceUtil.getPrefInt((runtime.getContextProxy()).context, LOCATION_CYCLE, 3));\r
-// runtime.getLocationInstance().setLocation_cycle(15);\r
- } else {\r
- //否则设置一个默认值\r
- SharPreferenceUtil.setPrefInt((runtime.getContextProxy()).context, "value_setting_ver", Config.value_setting);\r
- SharPreferenceUtil.setPrefInt((runtime.getContextProxy()).context, LOCATION_MODE, ICLocation.NORMAL_MOD);\r
-// SharPreferenceUtil.setPrefInt((runtime.getContextProxy()).context, LOCATION_CYCLE, 3);\r
- runtime.getLocationInstance().setWorkingMod(ICLocation.NORMAL_MOD);\r
-// runtime.getLocationInstance().setLocation_cycle(15);\r
- }\r
+//\r
StringBuilder stringBuilder = new StringBuilder();\r
- stringBuilder.append("value_setting=");\r
- stringBuilder.append(SharPreferenceUtil.getPrefInt((runtime.getContextProxy()).context, "value_setting_ver", 0));\r
stringBuilder.append("LOCATION_MODE=");\r
- stringBuilder.append(SharPreferenceUtil.getPrefInt((runtime.getContextProxy()).context, LOCATION_MODE, 1));\r
+ stringBuilder.append(runtime.getLocationInstance().getWorkingMod());\r
stringBuilder.append("LOCATION_CYCLE=");\r
- stringBuilder.append(SharPreferenceUtil.getPrefInt((runtime.getContextProxy()).context, LOCATION_CYCLE, 3));\r
+ stringBuilder.append(runtime.getLocationInstance().getLocation_cycle());\r
Logger.i(stringBuilder.toString());\r
\r
\r
\r
stop(200);\r
}\r
- FileOutputUtil.fileOutput(this.runtime.getCacheDir(),"GPS",sb2.toString());\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
Logger.i( sb.toString());\r
\r
- FileOutputUtil.fileOutput(this.runtime.getCacheDir(),"GPS",sb.toString());\r
+ if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(this.runtime.getCacheDir(),"GPS",sb.toString());\r
runtime.getLocationInstance().setLocation(latitude,longitude,speed,0,status.getMaxSatellites());\r
}\r
\r
import android.telephony.cdma.CdmaCellLocation;\r
import android.telephony.gsm.GsmCellLocation;\r
\r
+import com.enqualcomm.support.Config;\r
import com.enqualcomm.support.bean.Runtime;\r
import com.enqualcomm.support.utils.FileOutputUtil;\r
import com.enqualcomm.support.utils.Logger;\r
this.runtime.setCellinfo(gsmSb.toString());\r
this.runtime.setCdmaInfo(null);\r
Logger.i("GsmCellLocation "+ gsmSb.toString());\r
- FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "onCellLocationChanged", gsmSb.toString());\r
+ if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "onCellLocationChanged", gsmSb.toString());\r
\r
List neighboringCell_list = telephonyManager.getNeighboringCellInfo();\r
if (neighboringCell_list != null && !neighboringCell_list.isEmpty()) {\r
this.runtime.setCellinfo(null);\r
this.runtime.setCdmaInfo(cdmaSB.toString());\r
\r
- FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "onCellLocationChanged", var8.toString());\r
+ if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(this.runtime.getCacheDir(), "onCellLocationChanged", var8.toString());\r
return cdmaSB.toString();\r
\r
}\r
import java.util.HashMap;\r
\r
import static com.enqualcomm.support.Constants.ACTION_EQC_ALARM;\r
+import static com.enqualcomm.support.Constants.ACTION_HEATR_RATE_START;\r
import static com.enqualcomm.support.Constants.ACTION_IMESSAGE;\r
import static com.enqualcomm.support.LocationClient.LOCATION_CYCLE;\r
import static com.enqualcomm.support.LocationClient.LOCATION_MODE;\r
connection.send(genStringMessage("AP33",msg));\r
log("reply msg "+msg);\r
log("LOCATION_MODE "+LOCATION_MODE+" mod "+ mod);\r
- SharPreferenceUtil.setPrefInt((runtime.getContextProxy()).context, "value_setting_ver", Config.value_setting);\r
- SharPreferenceUtil.setPrefInt((runtime.getContextProxy()).context, LOCATION_MODE, mod);\r
-// SharPreferenceUtil.setPrefInt((runtime.getContextProxy()).context, LOCATION_CYCLE, Cycle);\r
- runtime.getLocationInstance().setWorkingMod(mod);\r
+ Config.setLocationMode(runtime.getContextProxy().context,mod);\r
+ Config.setLocationCycle(runtime.getContextProxy().context,Cycle);\r
runtime.getLocationInstance().setLocation_cycle(Cycle);\r
-\r
-\r
+ runtime.getLocationInstance().setWorkingMod(mod);\r
+ //此处设置好配置后,会在LocationClient通过消息开始执行及时定位操作。\r
}\r
\r
}\r
.append(CMDEND).toString();\r
}\r
\r
- public void handleBP86(String cmd,Connection connection){\r
+ public void handleBP86(String cmd,Connection connection,Runtime runtime){\r
\r
//示例:\r
//IWBP86, 353456789012345, 080835,1,720#\r
String cycle=list[4];\r
connection.send(protocolAPIHelper.genStringMessage("AP86",AP86(index)));\r
Logger.i("收到服务器指令:设置"+(type.equals("1")?"心率周期 ":"血压周期 ")+cycle+"分钟");\r
+\r
+ //发送重置PPGCycle的广播,会在CoreServer里面执行\r
+ Intent intent = new Intent();\r
+ intent.putExtra("PPGTestCycle",Integer.valueOf(cycle));\r
+ runtime.getContextProxy().sendBrodcast(ACTION_HEATR_RATE_START,intent);\r
}else{\r
Logger.i("BP86 format error!");\r
}\r
private String currentCellInfo;\r
\r
// public String currentWifiInfo="";\r
- \r
+ private int ppgTestCycle;\r
+\r
private DBHelper dbHelper;\r
\r
private String device_id;\r
private boolean lockSimInfo=false;\r
\r
\r
+ public void setPpgTestCycle(int cycle){\r
+ ppgTestCycle=cycle;\r
+ }\r
+\r
+ public int getPpgTestCycle(){\r
+ return ppgTestCycle;\r
+ }\r
+\r
public void setUseQueue(boolean usequeue){\r
UseQueue=usequeue;\r
}\r
\r
\r
private static voicePacket gvoicePacket=null;\r
- public static voicePacket getInstance(){\r
+ public synchronized static voicePacket getInstance(){\r
if (gvoicePacket==null)\r
gvoicePacket=new voicePacket();\r
return gvoicePacket;\r
}\r
private static voicePacket gvoicepacket_sent=null;\r
- public static voicePacket getInstanceSent(){\r
+ public synchronized static voicePacket getInstanceSent(){\r
if (gvoicepacket_sent==null)\r
gvoicepacket_sent=new voicePacket();\r
return gvoicepacket_sent;\r
import android.os.SystemClock;\r
import android.text.TextUtils;\r
\r
+import com.enqualcomm.support.Config;\r
import com.enqualcomm.support.CoreService;\r
import com.enqualcomm.support.LocationClient;\r
import com.enqualcomm.support.adapter.protocolAPIHelper;\r
stringBuilder.append(stringMessage.cmd());\r
stringBuilder.append(", ");\r
stringBuilder.append(stringMessage.isFromCache());\r
- FileOutputUtil.fileOutput(mRuntime.getCacheDir(), "MessageInfo", stringBuilder.toString());\r
+ if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(mRuntime.getCacheDir(), "MessageInfo", stringBuilder.toString());\r
Logger.i(stringBuilder.toString());\r
if( connection.isServerConnected() ==false && !KeepAlive.isConnected ) {\r
\r
connection.send(protocolAPIHelper.genStringMessage("queue",Msg));\r
} else {\r
Logger.i("offline skip " + Msg);\r
- FileOutputUtil.fileOutput(mRuntime.getCacheDir(), "APILog", " offlineskip " + Msg);\r
+ if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(mRuntime.getCacheDir(), "APILog", " offlineskip " + Msg);\r
}\r
}\r
}\r
import android.os.SystemClock;\r
import android.util.Log;\r
\r
+import com.enqualcomm.support.Config;\r
import com.enqualcomm.support.bean.Contact;\r
import com.enqualcomm.support.bean.Runtime;\r
import com.enqualcomm.support.CoreService;\r
public class AlarmWakeUp {\r
private static long lastAlarmTime;\r
\r
- public static void isNeedWakeUpAlarm(Runtime dev) {\r
+ public static void isNeedWakeUpAlarm(Runtime runtime) {\r
long l = SystemClock.elapsedRealtime();\r
- int i = SharPreferenceUtil.getPrefInt((dev.getContextProxy()).context, "location_cycle", 3);\r
+ int i = Config.getAlarmCycle(runtime.getContextProxy().context);\r
if (l - lastAlarmTime > ((i + 1) * 60 * 1000)) {\r
ComponentName componentName = new ComponentName("com.enqualcomm.support", "com.enqualcomm.support.CoreService");\r
Intent intent = (new Intent(CoreService.ACTION_ALARM)).setComponent(componentName);\r
- (dev.getContextProxy()).context.startService(intent);\r
+ (runtime.getContextProxy()).context.startService(intent);\r
\r
StringBuilder stringBuilder = new StringBuilder();\r
- stringBuilder.append("currentTimeMillis=");\r
+ stringBuilder.append("isNeedWakeUpAlarm currentTimeMillis=");\r
stringBuilder.append(l);\r
stringBuilder.append("---lastAlarmTime=");\r
stringBuilder.append(lastAlarmTime);\r
Logger.i("AlarmWakeUp "+ stringBuilder.toString());\r
- FileOutputUtil.fileOutput(dev.getCacheDir(), "alarmWakeUp", stringBuilder.toString());\r
+ if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(runtime.getCacheDir(), "alarmWakeUp", stringBuilder.toString());\r
} \r
}\r
\r
import android.content.Intent;\r
import android.content.IntentFilter;\r
\r
+import com.enqualcomm.support.Config;\r
import com.enqualcomm.support.bean.Runtime;\r
\r
public class BatteryUtil {\r
}\r
int i = param1Intent.getIntExtra("level", 0) * 100 / param1Intent.getIntExtra("scale", 100);\r
\r
- FileOutputUtil.fileOutput(mRuntime.getCacheDir(),"Battery","BatteryLevel "+i);\r
+ if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(mRuntime.getCacheDir(),"Battery","BatteryLevel "+i);\r
if (i >= 100) {\r
Runtime runtime = BatteryUtil.this.mRuntime;\r
StringBuffer stringBuffer = BatteryUtil.this.mBuffer;\r
import android.os.Message;\r
import android.os.PowerManager;\r
\r
+import com.enqualcomm.support.Config;\r
import com.enqualcomm.support.GSensorListener;\r
import com.enqualcomm.support.bean.Runtime;\r
\r
// EqcAlgorithmNative.native_EqcAlgorithmMethod4(0, 0, CellInfoUtil.BSSS, CellInfoUtil.MCC, CellInfoUtil.MNC, CellInfoUtil.LAC, CellInfoUtil.CELL_ID);\r
mRuntime.cellinfo = mCellInfo;\r
}\r
- FileOutputUtil.fileOutput(mRuntime.getCacheDir(),"onCellLocationChanged", mCellInfo);\r
+ if (Config.LOG_TOFILE)FileOutputUtil.fileOutput(mRuntime.getCacheDir(),"onCellLocationChanged", mCellInfo);\r
CellInfoUtil.releaseWakeLock(mWakeLock);\r
Logger.i(" setCurrentAttachCellInfo " + mCellInfo);\r
\r
stringBuilder.append(CellInfoUtil.BSSS);\r
runtime.cellinfo = stringBuilder.toString();\r
// EqcAlgorithmNative.native_EqcAlgorithmMethod4(1, 0, CellInfoUtil.BSSS, CellInfoUtil.MCC, CellInfoUtil.MNC, CellInfoUtil.LAC, CellInfoUtil.CELL_ID);\r
- FileOutputUtil.fileOutput(mRuntime.getCacheDir(), "onCellLocationChanged", mRuntime.cellinfo);\r
+ if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(mRuntime.getCacheDir(), "onCellLocationChanged", mRuntime.cellinfo);\r
CellInfoUtil.releaseWakeLock(mWakeLock);\r
Logger.i(" setCurrentAttachCellInfo " + mCellInfo);\r
\r
}\r
}\r
\r
+ public void sendBrodcast(String action,Intent intent){\r
+ intent.setAction(action);\r
+ this.context.sendBroadcast(intent);\r
+ }\r
\r
public void sendBroadcast(String cmd, Runtime dev) {\r
Intent intent = new Intent();\r
\r
import android.util.Log;\r
\r
+import com.enqualcomm.support.Config;\r
import com.enqualcomm.support.CoreService;\r
\r
public class Logger {\r
public static void log(String TAG, String msg) {\r
if (DEBUG) {\r
Log.e(TAG, msg);\r
- if (CoreService.getInstance()!=null)\r
- FileOutputUtil.fileOutput(CoreService.getInstance().getRuntime().getCacheDir(),"log",TAG + " "+ msg);\r
+ if (CoreService.getInstance()!=null) {\r
+ if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(CoreService.getInstance().getRuntime().getCacheDir(), "log", TAG + " " + msg);\r
+ }\r
}\r
\r
\r
public static void log(String TAG,String funcName, String msg) {\r
if (DEBUG) {\r
Log.e(TAG, "[" + funcName + "]" + msg);\r
- if (CoreService.getInstance()!=null)\r
- FileOutputUtil.fileOutput(CoreService.getInstance().getRuntime().getCacheDir(),"log",TAG + " "+ "[" + funcName + "]" + msg);\r
+ if (CoreService.getInstance()!=null) {\r
+ if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(CoreService.getInstance().getRuntime().getCacheDir(), "log", TAG + " " + "[" + funcName + "]" + msg);\r
+ }\r
}\r
}\r
}\r
import android.os.SystemClock;\r
\r
\r
+import com.enqualcomm.support.Config;\r
import com.enqualcomm.support.LocationClient;\r
import com.enqualcomm.support.adapter.protocolAPIHelper;\r
import com.enqualcomm.support.bean.StringMessage;\r
Runtime runtime=CoreService.getInstance().getRuntime();\r
boolean ret=true;\r
Logger.i("handleCmd "+type.name() + " strLen="+cmd.length());\r
- FileOutputUtil.fileOutput(CoreService.getInstance().getRuntime().getCacheDir(),"APILog", " recv " + cmd);\r
+ if (Config.LOG_TOFILE)FileOutputUtil.fileOutput(CoreService.getInstance().getRuntime().getCacheDir(),"APILog", " recv " + cmd);\r
switch (type){\r
case BP00:\r
API.handleBP00(cmd);\r
break;\r
\r
case BP86:\r
- API.handleBP86(cmd,NettyConnection.this);\r
+ API.handleBP86(cmd,NettyConnection.this,runtime);\r
// Logger.i("");\r
break;\r
case BP89:\r
Runtime runtime=CoreService.getInstance().getRuntime();\r
boolean ret=true;\r
Logger.i("handleCmd "+type.name() + " "+cmd+" bytelen="+bytes.length );\r
- FileOutputUtil.fileOutput(CoreService.getInstance().getRuntime().getCacheDir(),"APILog", " recv " +new String(bytes));\r
+ if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(CoreService.getInstance().getRuntime().getCacheDir(),"APILog", " recv " +new String(bytes));\r
switch (type) {\r
case BP28:\r
API.handleBP28(NettyConnection.this,cmd, runtime,bytes);\r
if (!isServerConnected()){\r
\r
log("skiped"+cmd);\r
- FileOutputUtil.fileOutput(CoreService.getInstance().getRuntime().getCacheDir(),"APILog"," skiped " + cmd);\r
+ if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(CoreService.getInstance().getRuntime().getCacheDir(),"APILog"," skiped " + cmd);\r
return false;\r
}else{\r
log("send "+cmd);\r
}\r
);\r
\r
- FileOutputUtil.fileOutput(CoreService.getInstance().getRuntime().getCacheDir(),"APILog"," sent " + cmd);\r
+ if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(CoreService.getInstance().getRuntime().getCacheDir(),"APILog"," sent " + cmd);\r
\r
}\r
\r
if (!isServerConnected()){\r
\r
log("skipedBytes "+new String(cmdArray));\r
- FileOutputUtil.fileOutput(CoreService.getInstance().getRuntime().getCacheDir(),"APILog"," skiped " + new String(cmdArray));\r
+ if (Config.LOG_TOFILE)FileOutputUtil.fileOutput(CoreService.getInstance().getRuntime().getCacheDir(),"APILog"," skiped " + new String(cmdArray));\r
return false;\r
}else{\r
log("sendBytes "+new String(cmdArray));\r
}\r
);\r
\r
- FileOutputUtil.fileOutput(CoreService.getInstance().getRuntime().getCacheDir(),"APILog"," sentBytes " + new String(cmdArray));\r
+ if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(CoreService.getInstance().getRuntime().getCacheDir(),"APILog"," sentBytes " + new String(cmdArray));\r
\r
}\r
\r
readSubject = new SerializedSubject(PublishSubject.create());
connectStatus = new SerializedSubject(PublishSubject.create());
}
- public static RxSocket getInstance() {
+ public synchronized static RxSocket getInstance() {
RxSocket rxSocket = defaultInstance;
if (defaultInstance == null) {
synchronized (chestnut.RxSocket.RxSocket.class) {
init();\r
}\r
\r
- public static SimSignalUtil getInstance(Context paramContext) {\r
+ public synchronized static SimSignalUtil getInstance(Context paramContext) {\r
if (simSignalUtil ==null)\r
simSignalUtil = new SimSignalUtil(paramContext);\r
return simSignalUtil;\r