1、通过Config.LOG_TOFILE控制输出log到文件
authorsnickersun <snickersun@qq.com>
Thu, 6 Feb 2020 06:55:37 +0000 (14:55 +0800)
committersnickersun <snickersun@qq.com>
Thu, 6 Feb 2020 06:55:37 +0000 (14:55 +0800)
2、打通设置心率检测周期的协议
3、调整优化定位控制逻辑。为设置第5种随意定时cycle做准备

19 files changed:
app/src/main/java/com/enqualcomm/support/Config.java
app/src/main/java/com/enqualcomm/support/CoreService.java
app/src/main/java/com/enqualcomm/support/CrashHandler.java
app/src/main/java/com/enqualcomm/support/GSensorListener.java
app/src/main/java/com/enqualcomm/support/LocationClient.java
app/src/main/java/com/enqualcomm/support/NMEAListener.java
app/src/main/java/com/enqualcomm/support/adapter/LBSHelper.java
app/src/main/java/com/enqualcomm/support/adapter/protocolAPIHelper.java
app/src/main/java/com/enqualcomm/support/bean/Runtime.java
app/src/main/java/com/enqualcomm/support/bean/voicePacket.java
app/src/main/java/com/enqualcomm/support/service/Deliver.java
app/src/main/java/com/enqualcomm/support/utils/AlarmWakeUp.java
app/src/main/java/com/enqualcomm/support/utils/BatteryUtil.java
app/src/main/java/com/enqualcomm/support/utils/CellInfoUtil.java
app/src/main/java/com/enqualcomm/support/utils/ContextProxy.java
app/src/main/java/com/enqualcomm/support/utils/Logger.java
app/src/main/java/com/enqualcomm/support/utils/NettyConnection.java
app/src/main/java/com/enqualcomm/support/utils/RxSocket.java
app/src/main/java/com/enqualcomm/support/utils/SimSignalUtil.java

index d8f3975..351b79f 100644 (file)
@@ -1,10 +1,18 @@
 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
@@ -263,5 +271,84 @@ public class Config {
       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
index 415c55e..83f2bd2 100644 (file)
@@ -135,7 +135,7 @@ public class CoreService extends Service {
                         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
@@ -147,7 +147,7 @@ public class CoreService extends Service {
             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
@@ -155,7 +155,7 @@ public class CoreService extends Service {
             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
@@ -290,6 +290,11 @@ public class CoreService extends Service {
     }\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
@@ -399,10 +404,16 @@ public class CoreService extends Service {
             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
@@ -444,8 +455,6 @@ public class CoreService extends Service {
         batteryUtil = new BatteryUtil(this.runtime);\r
         batteryUtil.registerBroadReceiver();\r
 \r
-        //保证获取正确的计步数据\r
-        loadStepCount();\r
 \r
         //设置计步清零时间。\r
         setCleanStepCountAlarm();\r
@@ -460,7 +469,7 @@ public class CoreService extends Service {
         setHeartAlarm();\r
 \r
         //设置心率检测频率\r
-        setHeartRateDetectAlarm(3); //3分钟一次\r
+        setHeartRateDetectAlarm(runtime.getPpgTestCycle()); //3分钟一次\r
 \r
         //获取天气时间\r
         setWeatherAlarm();\r
@@ -489,10 +498,12 @@ public class CoreService extends Service {
                     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
@@ -505,7 +516,7 @@ public class CoreService extends Service {
                     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
@@ -522,7 +533,7 @@ public class CoreService extends Service {
                 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
@@ -540,7 +551,7 @@ public class CoreService extends Service {
                     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
@@ -553,7 +564,7 @@ public class CoreService extends Service {
                         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
@@ -579,21 +590,33 @@ public class CoreService extends Service {
                             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
@@ -657,7 +680,7 @@ public class CoreService extends Service {
         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
index e0fc802..5f95800 100644 (file)
@@ -34,7 +34,7 @@ public class CrashHandler implements Thread.UncaughtExceptionHandler {
     // 系统默认的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
@@ -52,7 +52,9 @@ public class CrashHandler implements Thread.UncaughtExceptionHandler {
     /**\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
index d660caf..0e744eb 100644 (file)
@@ -32,7 +32,7 @@ public class GSensorListener  {
         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
index b09d152..6beaf95 100644 (file)
@@ -242,7 +242,7 @@ public class LocationClient {
               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
@@ -377,14 +377,14 @@ public void updateCellInfo() {
   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
@@ -407,7 +407,6 @@ public void updateCellInfo() {
       startCheckResult();\r
   }\r
 \r
-  private static int WorkingMod=1;\r
   private static int forceLocation=0;\r
   public void onReceive(StringMessage paramStringMessage) {\r
 \r
@@ -416,28 +415,15 @@ public void updateCellInfo() {
     //响应定位指令\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
@@ -450,27 +436,12 @@ public void updateCellInfo() {
 \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
index b9bbaf5..11113ea 100644 (file)
@@ -234,7 +234,7 @@ public class NMEAListener implements NmeaListener, LocationListener {
 \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
@@ -336,7 +336,7 @@ public class NMEAListener implements NmeaListener, LocationListener {
 \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
index 98dc2bb..a4865ff 100644 (file)
@@ -21,6 +21,7 @@ import android.telephony.TelephonyManager;
 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
@@ -268,7 +269,7 @@ public class LBSHelper {
                      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
@@ -318,7 +319,7 @@ public class LBSHelper {
                      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
index f9c80cb..fa87037 100644 (file)
@@ -32,6 +32,7 @@ import java.util.ArrayList;
 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
@@ -910,13 +911,11 @@ public class protocolAPIHelper {
             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
@@ -1231,7 +1230,7 @@ public static String AP15(String index){
                 .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
@@ -1251,6 +1250,11 @@ public static String AP15(String index){
             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
index 2d34141..a5867ab 100644 (file)
@@ -39,7 +39,8 @@ public class Runtime {
   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
@@ -89,6 +90,14 @@ public class Runtime {
   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
index b7dcee4..bfcc992 100644 (file)
@@ -7,13 +7,13 @@ public class voicePacket {
 \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
index 31e05a8..4d6e802 100644 (file)
@@ -16,6 +16,7 @@ import android.os.PowerManager;
 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
@@ -279,7 +280,7 @@ public class Deliver extends AbstractConnectionService {
               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
@@ -341,7 +342,7 @@ public static void sendLocationMSG( String Msg){
         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
index 7b273be..56d82a7 100644 (file)
@@ -6,6 +6,7 @@ import android.content.Intent;
 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
@@ -13,21 +14,21 @@ import com.enqualcomm.support.CoreService;
 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
index 9d94eb7..7303f78 100644 (file)
@@ -6,6 +6,7 @@ import android.content.Context;
 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
@@ -20,7 +21,7 @@ public class BatteryUtil {
           }\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
index c0c1f5f..27b2877 100644 (file)
@@ -4,6 +4,7 @@ import android.os.Handler;
 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
@@ -106,7 +107,7 @@ public class CellInfoUtil {
 //                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
@@ -132,7 +133,7 @@ public class CellInfoUtil {
                 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
index 369852d..22a2b25 100644 (file)
@@ -280,6 +280,10 @@ public class ContextProxy {
     }\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
index eb8597a..6b6514b 100644 (file)
@@ -2,6 +2,7 @@ package com.enqualcomm.support.utils;
 \r
 import android.util.Log;\r
 \r
+import com.enqualcomm.support.Config;\r
 import com.enqualcomm.support.CoreService;\r
 \r
 public class Logger {\r
@@ -68,8 +69,9 @@ public class Logger {
   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
@@ -78,8 +80,9 @@ public class Logger {
   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
index 35b963e..932b643 100644 (file)
@@ -7,6 +7,7 @@ import android.os.Message;
 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
@@ -51,7 +52,7 @@ public class NettyConnection implements Connection {
                         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
@@ -158,7 +159,7 @@ public class NettyConnection implements Connection {
                                 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
@@ -177,7 +178,7 @@ public class NettyConnection implements Connection {
                     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
@@ -291,7 +292,7 @@ public class NettyConnection implements Connection {
     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
@@ -312,7 +313,7 @@ public class NettyConnection implements Connection {
                         }\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
@@ -329,7 +330,7 @@ public class NettyConnection implements Connection {
         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
@@ -349,7 +350,7 @@ public class NettyConnection implements Connection {
                             }\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
index 599e446..55bc205 100644 (file)
@@ -51,7 +51,7 @@ public class RxSocket {
         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) {
index baba202..640f45d 100644 (file)
@@ -45,7 +45,7 @@ public class SimSignalUtil {
     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