add CH version for fall down.
authorTrillGates <williamtrillgates@gmail.com>
Wed, 10 Mar 2021 02:42:57 +0000 (10:42 +0800)
committerTrillGates <williamtrillgates@gmail.com>
Wed, 10 Mar 2021 02:42:57 +0000 (10:42 +0800)
app/src/main/java/com/enqualcomm/support/Config.java
app/src/main/java/com/enqualcomm/support/CoreService.java

index e5c6c7a..ff36321 100644 (file)
@@ -23,840 +23,861 @@ import java.util.HashMap;
 import static com.enqualcomm.support.utils.Util.getSystemProperties;\r
 \r
 public class Config {\r
-  public static final boolean LOG_TOFILE=true;\r
-  public static int antioff = 0;\r
-  public static int heart_rate = 0;\r
-  private static String json;\r
-  public static int defaultHeartbeatCycle=5;\r
-  public static int sw_release_no = -1;\r
-\r
-\r
-  //如果重试都失败,则丢弃命令不进行盲点续传\r
-  public static boolean discard_cmd_after_retryfailed=true;\r
-\r
-  public static boolean forceMoveCheck=true;\r
-  public static boolean forceWearCheck=true;\r
-\r
-  private static final String KEYDurationOfVibration = "DurationVib";\r
-  private static final String KeyMasterVolume = "MasterVolume";\r
-\r
-  public static final String DefaultLogFtpServer="icfota.snicker.com.cn";\r
-  public static final String DefaultLogFtpUser="ftpuser";\r
-  public static final String DefaultLogFtpPWD="iclog";\r
-\r
+    public static final boolean LOG_TOFILE = true;\r
+    public static int antioff = 0;\r
+    public static int heart_rate = 0;\r
+    private static String json;\r
+    public static int defaultHeartbeatCycle = 5;\r
+    public static int sw_release_no = -1;\r
 \r
-  public static final String DefaultWiFiSSID="Xplay6";\r
-  public static final String DefaultWiFiPWD="87654321";\r
-  public static final String DefaultWiFiEncryptType="psk";\r
 \r
-  public static final int GPSLocationTimeoutInSeconds=50;\r
-  public static final int WiFiLocationTimeoutInSeconds=12;\r
+    //如果重试都失败,则丢弃命令不进行盲点续传\r
+    public static boolean discard_cmd_after_retryfailed = true;\r
 \r
-  public static String c43_branch_name="none";\r
-  public static String custom_name="none";\r
+    public static boolean forceMoveCheck = true;\r
+    public static boolean forceWearCheck = true;\r
 \r
-  //配置是否广播提示框信息给外部应用显示\r
-  public static boolean noBroadCastSMSNotify=false;\r
-  public static boolean noBroadCastPushTxtNotify=false;\r
+    private static final String KEYDurationOfVibration = "DurationVib";\r
+    private static final String KeyMasterVolume = "MasterVolume";\r
 \r
+    public static final String DefaultLogFtpServer = "icfota.snicker.com.cn";\r
+    public static final String DefaultLogFtpUser = "ftpuser";\r
+    public static final String DefaultLogFtpPWD = "iclog";\r
 \r
-  //protocol内部Dialog配置,true表示用外部提示窗,false表示用协议内部提示窗\r
-  public static boolean noSMSNotifyDialog=false;\r
-  public static boolean noPushTxtNotifyDialog=false;\r
-  public static boolean noVoiceNotifyDialog=false;\r
 \r
-  //是否SOS拨号的开关,false表示只发送系统sosalarm,不发起SOS拨号\r
-  public static boolean SOSNoNeedDial=false;\r
+    public static final String DefaultWiFiSSID = "Xplay6";\r
+    public static final String DefaultWiFiPWD = "87654321";\r
+    public static final String DefaultWiFiEncryptType = "psk";\r
 \r
-  //ic68只有体温没有腕温,它开启代表原来的腕温函数取出的就是体温,不需要再进行换算了。\r
-  public static boolean disableWristTemp=false;\r
-  //配置是否有温度传感器\r
-  public static boolean noTempSensor=false;\r
-  //配置是否有心率传感器\r
-  public static boolean noPPGSensor=false;\r
-  //配置脱腕报警是否需要弹出脱腕提示 默认关闭\r
-  public static boolean needBroadcastAntiAlarm=false;\r
-  //配置脱腕报警是否需要弹出剪断提示 默认开启\r
-  public static boolean needBroadcastCutoffAlarm=true;\r
+    public static final int GPSLocationTimeoutInSeconds = 50;\r
+    public static final int WiFiLocationTimeoutInSeconds = 12;\r
 \r
+    public static String c43_branch_name = "none";\r
+    public static String custom_name = "none";\r
 \r
-  //定位是否使用wifi的配置。\r
-  public static boolean disableWiFiScan=false;\r
+    //配置是否广播提示框信息给外部应用显示\r
+    public static boolean noBroadCastSMSNotify = false;\r
+    public static boolean noBroadCastPushTxtNotify = false;\r
 \r
-  public static int BLEScanProtocol=0; /** 0 代表扫描beacon后 自行判断是否在指定区域,需要协议绑定beacon地址。\r
-                                        *  1  代表扫描beacon后,直接把扫描结果上报即可。\r
-                                        **/\r
 \r
-  public static boolean UsePolingCheckWeared=false;\r
+    //protocol内部Dialog配置,true表示用外部提示窗,false表示用协议内部提示窗\r
+    public static boolean noSMSNotifyDialog = false;\r
+    public static boolean noPushTxtNotifyDialog = false;\r
+    public static boolean noVoiceNotifyDialog = false;\r
 \r
-  static  {\r
-    disableWiFiScan=Util.getSystemProperties("persist.sys.disableWiFiLocation","false").equals("true");\r
-    disableWristTemp=Util.getSystemProperties("persist.sys.disableWristTemp","false").equals("true");\r
-    BLEScanProtocol=Util.getSystemPropertiesInt("persist.sys.BLEScanProtocol",0);\r
-    UsePolingCheckWeared=Util.getSystemProperties("persist.sys.PolingCheckAnti","false").equals("true");\r
-  }\r
-  \r
-  private static String make() {\r
-    try {\r
-      return (new JSONStringer()).object()\r
-              .key("cmd").value("Init")\r
-              .key("sw_version").value("eiot_V1.0.0")\r
-              .key("protocol_version").value("2.0")\r
-              .key("product").value(2L)\r
-              .key("swReleaseNo").value(sw_release_no)\r
-              .endObject().toString();\r
-    } catch (JSONException jSONException) {\r
-      jSONException.printStackTrace();\r
-      return "";\r
-    } \r
-  }\r
-  \r
-  public static String toJson() {\r
-    if (TextUtils.isEmpty(json))\r
-      json = make(); \r
-    return json;\r
-  }\r
+    //是否SOS拨号的开关,false表示只发送系统sosalarm,不发起SOS拨号\r
+    public static boolean SOSNoNeedDial = false;\r
 \r
+    //ic68只有体温没有腕温,它开启代表原来的腕温函数取出的就是体温,不需要再进行换算了。\r
+    public static boolean disableWristTemp = false;\r
+    //配置是否有温度传感器\r
+    public static boolean noTempSensor = false;\r
+    //配置是否有心率传感器\r
+    public static boolean noPPGSensor = false;\r
+    //配置脱腕报警是否需要弹出脱腕提示 默认关闭\r
+    public static boolean needBroadcastAntiAlarm = false;\r
+    //配置脱腕报警是否需要弹出剪断提示 默认开启\r
+    public static boolean needBroadcastCutoffAlarm = true;\r
 \r
-  public final static boolean isL03Tracker=getIsL03tracker();\r
-  public final  static boolean upload_logs_via_ftp=false;\r
-  final static String KeyProtocolServerIP="ProtocolServerIP";\r
-  final static String KeyProtocolServerHOST="ProtocolServerHOST";\r
-  final static String KeyProtocolServerPort="ProtoclServerPort";;\r
-  final static String KeyLogServerIP="LogServerIP";\r
-  final static String KeyLogServerPort="LogServerPort";\r
-  final static String KeyFotaServerUrl="FotaServerUrl";\r
 \r
+    //定位是否使用wifi的配置。\r
+    public static boolean disableWiFiScan = false;\r
 \r
-  final static String KeyPpgTestCycle="PPGTestCycle";\r
-  final static String KeyLocationCycle="LocationCycle";\r
-  final static String  KeyLocationMode="LocationMode";;\r
+    public static int BLEScanProtocol = 0;\r
+    /**\r
+     * 0 代表扫描beacon后 自行判断是否在指定区域,需要协议绑定beacon地址。\r
+     * 1  代表扫描beacon后,直接把扫描结果上报即可。\r
+     **/\r
 \r
-  final static String KeyAlarmCycle="HeartBeatCycle";\r
+    public static boolean UsePolingCheckWeared = false;\r
 \r
-  final static String  KeyContactsList="ContactsList";\r
-  final static String  KeySOSNumbersList="SOSNumbersList";\r
+    static {\r
+        disableWiFiScan = Util.getSystemProperties("persist.sys.disableWiFiLocation", "false").equals("true");\r
+        disableWristTemp = Util.getSystemProperties("persist.sys.disableWristTemp", "false").equals("true");\r
+        BLEScanProtocol = Util.getSystemPropertiesInt("persist.sys.BLEScanProtocol", 0);\r
+        UsePolingCheckWeared = Util.getSystemProperties("persist.sys.PolingCheckAnti", "false").equals("true");\r
+    }\r
 \r
-  final static String KeyIMEI = "persist.sys.protocol_IMEI";\r
-  public final static String KeyQRURIFILE = "persist.sys.qrUriFile";\r
+    private static String make() {\r
+        try {\r
+            return (new JSONStringer()).object()\r
+                    .key("cmd").value("Init")\r
+                    .key("sw_version").value("eiot_V1.0.0")\r
+                    .key("protocol_version").value("2.0")\r
+                    .key("product").value(2L)\r
+                    .key("swReleaseNo").value(sw_release_no)\r
+                    .endObject().toString();\r
+        } catch (JSONException jSONException) {\r
+            jSONException.printStackTrace();\r
+            return "";\r
+        }\r
+    }\r
 \r
-  final static String KeyPractiseState = "persist.sys.practising";\r
+    public static String toJson() {\r
+        if (TextUtils.isEmpty(json))\r
+            json = make();\r
+        return json;\r
+    }\r
 \r
-  final static String KeyHeartBeatCycle="ServerHeartBeatCycle";\r
 \r
+    public final static boolean isL03Tracker = getIsL03tracker();\r
+    public final static boolean upload_logs_via_ftp = false;\r
+    final static String KeyProtocolServerIP = "ProtocolServerIP";\r
+    final static String KeyProtocolServerHOST = "ProtocolServerHOST";\r
+    final static String KeyProtocolServerPort = "ProtoclServerPort";\r
+    ;\r
+    final static String KeyLogServerIP = "LogServerIP";\r
+    final static String KeyLogServerPort = "LogServerPort";\r
+    final static String KeyFotaServerUrl = "FotaServerUrl";\r
 \r
-  final static String KeyLogFtpServer="FtpServerHost";\r
-  final static String KeyLogFtpUser="FtpServerUser";\r
-  final static String KeyLogFtpPWD="FtpServerPWD";\r
 \r
+    final static String KeyPpgTestCycle = "PPGTestCycle";\r
+    final static String KeyLocationCycle = "LocationCycle";\r
+    final static String KeyLocationMode = "LocationMode";\r
+    ;\r
 \r
-  final static String KeyWiFiSSID="WiFiSSID";\r
-  final static String KeyWiFiPasswd="WiFiPWD";\r
-  final static String KeyWiFiEncyptType="WiFiEncryptType";\r
+    final static String KeyAlarmCycle = "HeartBeatCycle";\r
 \r
-  final static String KeySMSPassword="SMSPWD";\r
-  final static String DefaultSMSPassword="non";\r
+    final static String KeyContactsList = "ContactsList";\r
+    final static String KeySOSNumbersList = "SOSNumbersList";\r
 \r
-  final static String KeyTempTestCycle="TempTestCycle";\r
+    final static String KeyIMEI = "persist.sys.protocol_IMEI";\r
+    public final static String KeyQRURIFILE = "persist.sys.qrUriFile";\r
 \r
+    final static String KeyPractiseState = "persist.sys.practising";\r
 \r
-  final static String KeyPPGadust="KeyPPGAdjust";\r
-  final static String KeyBPHadust="KeyBPHAdjust";\r
-  final static String KeyBPLadust="KeyBPLAdjust";\r
-  final static String KeySPo2adust="KeySPo2Adjust";\r
+    final static String KeyHeartBeatCycle = "ServerHeartBeatCycle";\r
 \r
-  final static String KeyPolingCycleCheckAnti="PolingCycleCheckAnti";\r
-  final static String KeyBleScanCycle="BleScanCycle";\r
 \r
-  final static String KeyLastUnReadMessage="UnreadMsg";\r
+    final static String KeyLogFtpServer = "FtpServerHost";\r
+    final static String KeyLogFtpUser = "FtpServerUser";\r
+    final static String KeyLogFtpPWD = "FtpServerPWD";\r
 \r
 \r
-  public static void setDurationOfVibration(Context context, int cycle){\r
-    SharPreferenceUtil.setPrefInt(context,KEYDurationOfVibration,cycle);\r
-  }\r
+    final static String KeyWiFiSSID = "WiFiSSID";\r
+    final static String KeyWiFiPasswd = "WiFiPWD";\r
+    final static String KeyWiFiEncyptType = "WiFiEncryptType";\r
 \r
-  public static int getDurationOfVibration(Context context){\r
-    return SharPreferenceUtil.getPrefInt(context,KEYDurationOfVibration,1);\r
-  }\r
+    final static String KeySMSPassword = "SMSPWD";\r
+    final static String DefaultSMSPassword = "non";\r
 \r
-  public static void setMasterVolume(Context context, int cycle){\r
-    SharPreferenceUtil.setPrefInt(context,KeyMasterVolume,cycle);\r
-  }\r
+    final static String KeyTempTestCycle = "TempTestCycle";\r
 \r
-  public static int getMasterVolume(Context context){\r
-    return SharPreferenceUtil.getPrefInt(context,KeyMasterVolume,15);\r
-  }\r
 \r
+    final static String KeyPPGadust = "KeyPPGAdjust";\r
+    final static String KeyBPHadust = "KeyBPHAdjust";\r
+    final static String KeyBPLadust = "KeyBPLAdjust";\r
+    final static String KeySPo2adust = "KeySPo2Adjust";\r
 \r
-  public static void setCheckAntiPolingCycle(Context context, int cycle){\r
-    SharPreferenceUtil.setPrefInt(context,KeyPolingCycleCheckAnti,cycle);\r
-  }\r
+    final static String KeyPolingCycleCheckAnti = "PolingCycleCheckAnti";\r
+    final static String KeyBleScanCycle = "BleScanCycle";\r
 \r
-  public static int getCheckAntiPolingCycle(Context context){\r
-    return SharPreferenceUtil.getPrefInt(context,KeyPolingCycleCheckAnti,0);\r
-  }\r
+    final static String KeyLastUnReadMessage = "UnreadMsg";\r
 \r
-  public static void setBleScanCycle(Context context, int cycle){\r
-    SharPreferenceUtil.setPrefInt(context,KeyBleScanCycle,cycle);\r
-  }\r
 \r
-  public static int getBleScanCycle(Context context){\r
-    return SharPreferenceUtil.getPrefInt(context,KeyBleScanCycle,0);\r
-  }\r
+    public static void setDurationOfVibration(Context context, int cycle) {\r
+        SharPreferenceUtil.setPrefInt(context, KEYDurationOfVibration, cycle);\r
+    }\r
 \r
-  public static String getLastUnReadMessage(Context context){\r
-    return SharPreferenceUtil.getPrefString(context,KeyLastUnReadMessage,"");\r
-  }\r
+    public static int getDurationOfVibration(Context context) {\r
+        return SharPreferenceUtil.getPrefInt(context, KEYDurationOfVibration, 1);\r
+    }\r
 \r
-  public static void setLastUnReadMessage(Context context,String smsPWD){\r
-    SharPreferenceUtil.setPrefString(context,KeyLastUnReadMessage,smsPWD);\r
-  }\r
+    public static void setMasterVolume(Context context, int cycle) {\r
+        SharPreferenceUtil.setPrefInt(context, KeyMasterVolume, cycle);\r
+    }\r
 \r
-  public static String getSMSPwd(Context context){\r
-    return SharPreferenceUtil.getPrefString(context,KeySMSPassword,DefaultSMSPassword);\r
-  }\r
+    public static int getMasterVolume(Context context) {\r
+        return SharPreferenceUtil.getPrefInt(context, KeyMasterVolume, 15);\r
+    }\r
 \r
-  public static void setSMSPwd(Context context,String smsPWD){\r
-    SharPreferenceUtil.setPrefString(context,KeySMSPassword,smsPWD);\r
-  }\r
-  public static boolean getIsL03tracker(){\r
-    boolean ret=getSystemProperties("persist.sys.isL03tracker").toLowerCase().equals("true");\r
-    return ret;\r
-  }\r
-  public static String getWiFiSSID(Context context){\r
-    return SharPreferenceUtil.getPrefString(context,KeyWiFiSSID,DefaultWiFiSSID);\r
-  }\r
 \r
-  public static void setWiFiSSID(Context context,String ssid){\r
-    SharPreferenceUtil.setPrefString(context,KeyWiFiSSID,ssid);\r
-  }\r
+    public static void setCheckAntiPolingCycle(Context context, int cycle) {\r
+        SharPreferenceUtil.setPrefInt(context, KeyPolingCycleCheckAnti, cycle);\r
+    }\r
 \r
-  public static String getWiFiPasswd(Context context){\r
-    return SharPreferenceUtil.getPrefString(context,KeyWiFiPasswd,DefaultWiFiPWD);\r
-  }\r
+    public static int getCheckAntiPolingCycle(Context context) {\r
+        return SharPreferenceUtil.getPrefInt(context, KeyPolingCycleCheckAnti, 0);\r
+    }\r
 \r
-  public static void setWiFiPasswd(Context context,String pwd){\r
-    SharPreferenceUtil.setPrefString(context,KeyWiFiPasswd,pwd);\r
-  }\r
+    public static void setBleScanCycle(Context context, int cycle) {\r
+        SharPreferenceUtil.setPrefInt(context, KeyBleScanCycle, cycle);\r
+    }\r
 \r
-    public static String getWiFiEncryptType(Context context){\r
-        return SharPreferenceUtil.getPrefString(context,KeyWiFiEncyptType,DefaultWiFiEncryptType);\r
+    public static int getBleScanCycle(Context context) {\r
+        return SharPreferenceUtil.getPrefInt(context, KeyBleScanCycle, 0);\r
     }\r
 \r
-    public static void setWiFiEncryptType(Context context,String type){\r
-        SharPreferenceUtil.setPrefString(context,KeyWiFiEncyptType,type);\r
+    public static String getLastUnReadMessage(Context context) {\r
+        return SharPreferenceUtil.getPrefString(context, KeyLastUnReadMessage, "");\r
     }\r
 \r
-  public static String getFotaServerUrl(Context context){\r
-    return SharPreferenceUtil.getPrefString(context,KeyFotaServerUrl,"");\r
-  }\r
+    public static void setLastUnReadMessage(Context context, String smsPWD) {\r
+        SharPreferenceUtil.setPrefString(context, KeyLastUnReadMessage, smsPWD);\r
+    }\r
+\r
+    public static String getSMSPwd(Context context) {\r
+        return SharPreferenceUtil.getPrefString(context, KeySMSPassword, DefaultSMSPassword);\r
+    }\r
+\r
+    public static void setSMSPwd(Context context, String smsPWD) {\r
+        SharPreferenceUtil.setPrefString(context, KeySMSPassword, smsPWD);\r
+    }\r
 \r
-  public static void setFotaServerUrl(Context context,String url){\r
-    SharPreferenceUtil.setPrefString(context,KeyFotaServerUrl,url);\r
-  }\r
-    public static String getFtpUser(Context context){\r
-    return SharPreferenceUtil.getPrefString(context,KeyLogFtpUser,DefaultLogFtpUser);\r
-  }\r
+    public static boolean getIsL03tracker() {\r
+        boolean ret = getSystemProperties("persist.sys.isL03tracker").toLowerCase().equals("true");\r
+        return ret;\r
+    }\r
 \r
-  public static void setFtpUser(Context context,String user){\r
-    SharPreferenceUtil.setPrefString(context,KeyLogFtpUser,user);\r
-  }\r
+    public static String getWiFiSSID(Context context) {\r
+        return SharPreferenceUtil.getPrefString(context, KeyWiFiSSID, DefaultWiFiSSID);\r
+    }\r
 \r
-  public static String getFtpServer(Context context){\r
-    return SharPreferenceUtil.getPrefString(context,KeyLogFtpServer,DefaultLogFtpServer);\r
-  }\r
+    public static void setWiFiSSID(Context context, String ssid) {\r
+        SharPreferenceUtil.setPrefString(context, KeyWiFiSSID, ssid);\r
+    }\r
 \r
-  public static void setFtpServer(Context context,String host){\r
-    SharPreferenceUtil.setPrefString(context,KeyLogFtpServer,host);\r
-  }\r
+    public static String getWiFiPasswd(Context context) {\r
+        return SharPreferenceUtil.getPrefString(context, KeyWiFiPasswd, DefaultWiFiPWD);\r
+    }\r
 \r
-  public static String getFtpPWD(Context context){\r
-    return SharPreferenceUtil.getPrefString(context,KeyLogFtpPWD,DefaultLogFtpPWD);\r
-  }\r
-  public static void setFtpPWD(Context context,String PWD){\r
-    SharPreferenceUtil.setPrefString(context,KeyLogFtpPWD,PWD);\r
-  }\r
+    public static void setWiFiPasswd(Context context, String pwd) {\r
+        SharPreferenceUtil.setPrefString(context, KeyWiFiPasswd, pwd);\r
+    }\r
+\r
+    public static String getWiFiEncryptType(Context context) {\r
+        return SharPreferenceUtil.getPrefString(context, KeyWiFiEncyptType, DefaultWiFiEncryptType);\r
+    }\r
+\r
+    public static void setWiFiEncryptType(Context context, String type) {\r
+        SharPreferenceUtil.setPrefString(context, KeyWiFiEncyptType, type);\r
+    }\r
+\r
+    public static String getFotaServerUrl(Context context) {\r
+        return SharPreferenceUtil.getPrefString(context, KeyFotaServerUrl, "");\r
+    }\r
+\r
+    public static void setFotaServerUrl(Context context, String url) {\r
+        SharPreferenceUtil.setPrefString(context, KeyFotaServerUrl, url);\r
+    }\r
+\r
+    public static String getFtpUser(Context context) {\r
+        return SharPreferenceUtil.getPrefString(context, KeyLogFtpUser, DefaultLogFtpUser);\r
+    }\r
+\r
+    public static void setFtpUser(Context context, String user) {\r
+        SharPreferenceUtil.setPrefString(context, KeyLogFtpUser, user);\r
+    }\r
+\r
+    public static String getFtpServer(Context context) {\r
+        return SharPreferenceUtil.getPrefString(context, KeyLogFtpServer, DefaultLogFtpServer);\r
+    }\r
+\r
+    public static void setFtpServer(Context context, String host) {\r
+        SharPreferenceUtil.setPrefString(context, KeyLogFtpServer, host);\r
+    }\r
+\r
+    public static String getFtpPWD(Context context) {\r
+        return SharPreferenceUtil.getPrefString(context, KeyLogFtpPWD, DefaultLogFtpPWD);\r
+    }\r
+\r
+    public static void setFtpPWD(Context context, String PWD) {\r
+        SharPreferenceUtil.setPrefString(context, KeyLogFtpPWD, PWD);\r
+    }\r
 \r
-  public static void setAlarmCycle(Context context, int cycle){\r
-    SharPreferenceUtil.setPrefInt(context,KeyAlarmCycle,cycle);\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
+    //默认3分钟,刚刚wakeup的时候1分钟\r
+    public static int getAlarmCycle(Context context) {\r
+        return SharPreferenceUtil.getPrefInt(context, KeyAlarmCycle, 3);\r
+    }\r
 \r
-  public static void setProtocolServerPort(Context context, int serverPort){\r
+    public static void setProtocolServerPort(Context context, int serverPort) {\r
 //    SharPreferenceUtil.setPrefString(context,KeyProtocolServerIP,serverIP);\r
-    SharPreferenceUtil.setPrefInt(context,KeyProtocolServerPort,serverPort);\r
-  }\r
-\r
-  public static void setProtocolServerHost(Context context,String host){\r
-    SharPreferenceUtil.setPrefString(context,KeyProtocolServerHOST,host);\r
-  }\r
-  //public static String getProtocolServerIP(Context context){\r
- //   return SharPreferenceUtil.getPrefString(context,KeyProtocolServerIP,"118.178.155.223");\r
- // }\r
+        SharPreferenceUtil.setPrefInt(context, KeyProtocolServerPort, serverPort);\r
+    }\r
 \r
-  public static void loadModCycleSettings(Runtime runtime){\r
-    Context context=runtime.getContextProxy().context;\r
-    ICLogger.i("current Cycles PPG "+ runtime.getPpgTestCycle()+" , LocationCycle "+runtime.getLocationInstance().getLocation_cycle()+" LocationMode "+runtime.getLocationInstance().getWorkingMod());\r
-    runtime.setPpgTestCycle(Config.getPPGTestCycle(context));\r
-    runtime.getLocationInstance().setLocation_cycle(Config.getLocationCycle(context));\r
-    runtime.getLocationInstance().setWorkingMod(Config.getLocationMode(context));\r
-    ICLogger.i("current Cycles PPG "+ runtime.getPpgTestCycle()+" , LocationCycle "+runtime.getLocationInstance().getLocation_cycle()+" LocationMode "+runtime.getLocationInstance().getWorkingMod());\r
+    public static void setProtocolServerHost(Context context, String host) {\r
+        SharPreferenceUtil.setPrefString(context, KeyProtocolServerHOST, host);\r
+    }\r
+    //public static String getProtocolServerIP(Context context){\r
+    //   return SharPreferenceUtil.getPrefString(context,KeyProtocolServerIP,"118.178.155.223");\r
+    // }\r
 \r
-    int mastervolume = getMasterVolume(context);\r
-    ICAudioManager.setMasterVolumn(context,mastervolume);\r
+    public static void loadModCycleSettings(Runtime runtime) {\r
+        Context context = runtime.getContextProxy().context;\r
+        ICLogger.i("current Cycles PPG " + runtime.getPpgTestCycle() + " , LocationCycle " + runtime.getLocationInstance().getLocation_cycle() + " LocationMode " + runtime.getLocationInstance().getWorkingMod());\r
+        runtime.setPpgTestCycle(Config.getPPGTestCycle(context));\r
+        runtime.getLocationInstance().setLocation_cycle(Config.getLocationCycle(context));\r
+        runtime.getLocationInstance().setWorkingMod(Config.getLocationMode(context));\r
+        ICLogger.i("current Cycles PPG " + runtime.getPpgTestCycle() + " , LocationCycle " + runtime.getLocationInstance().getLocation_cycle() + " LocationMode " + runtime.getLocationInstance().getWorkingMod());\r
 \r
-    int duration= getDurationOfVibration(context);\r
-    VibrateUtil.setVibPattern(duration*1000);\r
+        int mastervolume = getMasterVolume(context);\r
+        ICAudioManager.setMasterVolumn(context, mastervolume);\r
 \r
-  }\r
+        int duration = getDurationOfVibration(context);\r
+        VibrateUtil.setVibPattern(duration * 1000);\r
 \r
-  public static void loadHearBeatSetting(Runtime runtime){\r
-    runtime.setHeartBeatCycle(Config.getHeartBeatCycle(runtime.getContextProxy().context));\r
-  }\r
-  public static void loadServerSettings(Runtime runtime){\r
-    runtime.setHostAndPort(Config.getProtocolServerHost(runtime.getContextProxy().context),Config.getProtocolServerPort(runtime.getContextProxy().context));\r
-  }\r
+    }\r
 \r
-  public static void setIMEI(Context context, String imei){\r
-    Util.setSystemProperties(KeyIMEI,imei);\r
-  }\r
+    public static void loadHearBeatSetting(Runtime runtime) {\r
+        runtime.setHeartBeatCycle(Config.getHeartBeatCycle(runtime.getContextProxy().context));\r
+    }\r
 \r
-  public static String getIMEI(Context context){\r
-    return Util.getSystemProperties(KeyIMEI,"");\r
-  }\r
+    public static void loadServerSettings(Runtime runtime) {\r
+        runtime.setHostAndPort(Config.getProtocolServerHost(runtime.getContextProxy().context), Config.getProtocolServerPort(runtime.getContextProxy().context));\r
+    }\r
 \r
-  public static String getProtocolServerHost(Context context){\r
-    String host;\r
-    host= SharPreferenceUtil.getPrefString(context,KeyProtocolServerHOST,protocolAPIHelper.getDefaultServerIP());\r
-    return host;\r
-   }\r
+    public static void setIMEI(Context context, String imei) {\r
+        Util.setSystemProperties(KeyIMEI, imei);\r
+    }\r
 \r
+    public static String getIMEI(Context context) {\r
+        return Util.getSystemProperties(KeyIMEI, "");\r
+    }\r
 \r
-  public static int getProtocolServerPort(Context context){\r
-      int port;\r
-      port= SharPreferenceUtil.getPrefInt(context,KeyProtocolServerPort,protocolAPIHelper.getDefaultServerPort());\r
-      return port;\r
-  }\r
+    public static String getProtocolServerHost(Context context) {\r
+        String host;\r
+        host = SharPreferenceUtil.getPrefString(context, KeyProtocolServerHOST, protocolAPIHelper.getDefaultServerIP());\r
+        return host;\r
+    }\r
 \r
-  public static void setConfigInitFlag(Context context,int flag){\r
-    SharPreferenceUtil.setPrefInt(context,"ConfigInitFlag",flag);\r
-  }\r
 \r
-  public static int getConfigInitFlag(Context context){\r
-    return SharPreferenceUtil.getPrefInt(context,"ConfigInitFlag",0);\r
-  }\r
-  public static void setLogServerIP(Context context,String serverIP,int serverPort){\r
+    public static int getProtocolServerPort(Context context) {\r
+        int port;\r
+        port = SharPreferenceUtil.getPrefInt(context, KeyProtocolServerPort, protocolAPIHelper.getDefaultServerPort());\r
+        return port;\r
+    }\r
 \r
-    SharPreferenceUtil.setPrefString(context,KeyLogServerIP,serverIP);\r
-    SharPreferenceUtil.setPrefInt(context,KeyLogServerPort,serverPort);\r
+    public static void setConfigInitFlag(Context context, int flag) {\r
+        SharPreferenceUtil.setPrefInt(context, "ConfigInitFlag", flag);\r
+    }\r
 \r
-  }\r
-  public static String getLogServerIP(Context context){\r
-    return SharPreferenceUtil.getPrefString(context,KeyLogServerIP,"http://icfota.snicker.com.cn:8089/UploadFile.jsp");\r
-  }\r
+    public static int getConfigInitFlag(Context context) {\r
+        return SharPreferenceUtil.getPrefInt(context, "ConfigInitFlag", 0);\r
+    }\r
 \r
-  public static int getLogServerPort(Context context){\r
-    return SharPreferenceUtil.getPrefInt(context,KeyLogServerPort,8089);\r
-  }\r
+    public static void setLogServerIP(Context context, String serverIP, int serverPort) {\r
 \r
+        SharPreferenceUtil.setPrefString(context, KeyLogServerIP, serverIP);\r
+        SharPreferenceUtil.setPrefInt(context, KeyLogServerPort, serverPort);\r
 \r
-  public static void setPPGTestCycle(Context context,int cycle){\r
-    SharPreferenceUtil.setPrefInt(context,KeyPpgTestCycle,cycle);\r
-  }\r
+    }\r
 \r
-  public static int getPPGTestCycle(Context context){\r
-    return SharPreferenceUtil.getPrefInt(context,KeyPpgTestCycle,0);\r
-  }\r
+    public static String getLogServerIP(Context context) {\r
+        return SharPreferenceUtil.getPrefString(context, KeyLogServerIP, "http://icfota.snicker.com.cn:8089/UploadFile.jsp");\r
+    }\r
 \r
+    public static int getLogServerPort(Context context) {\r
+        return SharPreferenceUtil.getPrefInt(context, KeyLogServerPort, 8089);\r
+    }\r
 \r
-  public static int getHeartBeatCycle(Context context){\r
-    return SharPreferenceUtil.getPrefInt(context,KeyHeartBeatCycle,5);\r
-  }\r
 \r
-  public static void setHeartBeatCycle(Context context,int cycle){\r
-    SharPreferenceUtil.setPrefInt(context,KeyHeartBeatCycle,cycle);\r
-  }\r
-  public static void setLocationCycle(Context context,int cycle_second){\r
-    SharPreferenceUtil.setPrefInt(context,KeyLocationCycle,cycle_second);\r
-  }\r
+    public static void setPPGTestCycle(Context context, int cycle) {\r
+        SharPreferenceUtil.setPrefInt(context, KeyPpgTestCycle, cycle);\r
+    }\r
 \r
-  public static int getLocationCycle(Context context){\r
-    return SharPreferenceUtil.getPrefInt(context,KeyLocationCycle,900);\r
-  }\r
+    public static int getPPGTestCycle(Context context) {\r
+        return SharPreferenceUtil.getPrefInt(context, KeyPpgTestCycle, 0);\r
+    }\r
 \r
-  public static void setLocationMode(Context context,int mode){\r
-    ICLogger.i("setLocationMode "+mode);\r
-    SharPreferenceUtil.setPrefInt(context,KeyLocationMode,mode);\r
-  }\r
 \r
+    public static int getHeartBeatCycle(Context context) {\r
+        return SharPreferenceUtil.getPrefInt(context, KeyHeartBeatCycle, 5);\r
+    }\r
 \r
-  public static int getLocationMode(Context context){\r
-    return SharPreferenceUtil.getPrefInt(context,KeyLocationMode, ICLocation.NORMAL_MOD);\r
-  }\r
+    public static void setHeartBeatCycle(Context context, int cycle) {\r
+        SharPreferenceUtil.setPrefInt(context, KeyHeartBeatCycle, cycle);\r
+    }\r
+\r
+    public static void setLocationCycle(Context context, int cycle_second) {\r
+        SharPreferenceUtil.setPrefInt(context, KeyLocationCycle, cycle_second);\r
+    }\r
+\r
+    public static int getLocationCycle(Context context) {\r
+        return SharPreferenceUtil.getPrefInt(context, KeyLocationCycle, 900);\r
+    }\r
+\r
+    public static void setLocationMode(Context context, int mode) {\r
+        ICLogger.i("setLocationMode " + 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
     private static final String KeyBootUpDate = "bootupdate";\r
-  public static boolean logBootDate(Context context){\r
-  //如果时间和最后一次时间不同,则重置,否则启动次数+1\r
-    if (isFirstBootToday(context)) {\r
-      SharPreferenceUtil.setPrefString(context, KeyBootUpDate, TimeUtil.getSystemTime4());\r
-      return true;\r
-    }else{\r
-      return false;\r
-    }\r
-  }\r
-\r
-  private static String getLastBootupDate(Context context){\r
-    return SharPreferenceUtil.getPrefString(context,KeyBootUpDate,"");\r
-  }\r
-  private static boolean isFirstBootToday(Context context){\r
-      //第一次启动记录的日期,当前日期只要相同,就认为有启动过。\r
-      //如果手表一直没有重启过,则每次resetStepCount的时候把启动时间更新到当天,\r
-      //从而解决第二天重启就会被重置的问题!\r
-    String currentDate=TimeUtil.getSystemTime4();\r
-    String lastDate=getLastBootupDate(context);\r
-    boolean ret=false;\r
-    if (currentDate.equals(lastDate)) {\r
-      ret= false;\r
-    }else\r
-    {\r
-      ret= true;\r
-    }\r
-    ICLogger.i("Current BootDate="+currentDate+", Last BootDate="+lastDate+", ret="+ret);\r
-    return ret;\r
-  }\r
-\r
-  //收到语音微聊广播消息给外部窗口\r
-  public static boolean do_broadCast_message=false;\r
-\r
-  //每次心跳时都检测逃逸并报警\r
-  public static boolean needAllwaysAlarmFenceOut=false;\r
-  //每次心跳时都检测剪断并报警,只报警\r
-  public static boolean needAllwaysAlarmCutOff=false;\r
-\r
-  //体温非正常报警\r
-  public static boolean needTemperature_abnormal_alarm=false;\r
-  public static boolean A9_noBroadCastActionStrip=false;\r
-  public static boolean C5_noBroadCastActionStrip=false;\r
-  public static boolean L004_BroadCastActionStrip=false;\r
-\r
-  //停止系统NTP时钟同步标志\r
-  public static boolean disable_ntp_server=false;\r
-\r
-  //需要系统发送已阅读消息的标志\r
-  public static boolean noPushTxtReadReply=true;\r
-  //蓝牙定位扫描 协议0模式,扫到beacon信标时,如果属于第一次扫到的进入状态(解除逃逸状态),发送服务器的标志位,主要由于C5客户只要逃逸,不要解除逃逸消息。\r
-  public static boolean noBLE_RelaseEscapeAlarm=true;\r
-\r
-  public static void enable_NTP_Server(Context context,boolean enable){\r
-    try {\r
-      int autotime = Settings.Global.getInt(context.getContentResolver(),Settings.Global.AUTO_TIME);\r
-      int autotimezone = Settings.Global.getInt(context.getContentResolver(),Settings.Global.AUTO_TIME_ZONE);\r
-\r
-      ICLogger.i("get NTP Settings AutoTime "+autotime+" AutoTimeZone "+autotimezone);\r
-\r
-      if(enable)\r
-      {\r
-        Settings.Global.putInt(context.getContentResolver(), Settings.Global.AUTO_TIME_ZONE, 1);\r
-        Settings.Global.putInt(context.getContentResolver(), Settings.Global.AUTO_TIME, 1);\r
-      }else {\r
-        Settings.Global.putInt(context.getContentResolver(), Settings.Global.AUTO_TIME_ZONE, 0);\r
-        Settings.Global.putInt(context.getContentResolver(), Settings.Global.AUTO_TIME, 0);\r
-      }\r
-      autotime = Settings.Global.getInt(context.getContentResolver(),Settings.Global.AUTO_TIME);\r
-      autotimezone = Settings.Global.getInt(context.getContentResolver(),Settings.Global.AUTO_TIME_ZONE);\r
-      ICLogger.i("get NTP Settings AutoTime "+autotime+" AutoTimeZone "+autotimezone);\r
-    } catch (Settings.SettingNotFoundException e) {\r
-      e.printStackTrace();\r
-      ICLogger.e(e.getMessage(),e);\r
-    }\r
-  }\r
-  public static void LoadMessageConfigs(){\r
-\r
-    String tmp=Util.getSystemProperties("persist.sys.doBroadcastMSG");\r
-    boolean ret=false;\r
-    if (tmp.equals("true"))\r
-      ret=true;\r
-\r
-    do_broadCast_message = ret;\r
-\r
-    noPPGSensor=(ICJniUtils.isPPGavailable()==0);\r
-    noTempSensor=(ICJniUtils.isTemperatureDevAvailable()==0);\r
-\r
-    //默认关闭NTP\r
-    disable_ntp_server=Util.getSystemProperties("persist.sys.disableNTP","false").equals("true");\r
-\r
-    c43_branch_name=Util.getSystemProperties("persist.sys.c43.branch");\r
-\r
-    if ((c43_branch_name.equals("l03")) ||(c43_branch_name.equals("l05"))){\r
-        noPushTxtNotifyDialog=true;\r
-        noSMSNotifyDialog=true;\r
-        noVoiceNotifyDialog=true;\r
-        noTempSensor=true;\r
-        if (c43_branch_name.equals("l05")) {\r
-          SOSNoNeedDial=true;//采用新写的SOS,协议只需要发送消息,无需控制拨号。\r
-          noPPGSensor=false;\r
-        }else{\r
-          noPPGSensor=true;\r
+\r
+    public static boolean logBootDate(Context context) {\r
+        //如果时间和最后一次时间不同,则重置,否则启动次数+1\r
+        if (isFirstBootToday(context)) {\r
+            SharPreferenceUtil.setPrefString(context, KeyBootUpDate, TimeUtil.getSystemTime4());\r
+            return true;\r
+        } else {\r
+            return false;\r
+        }\r
+    }\r
+\r
+    private static String getLastBootupDate(Context context) {\r
+        return SharPreferenceUtil.getPrefString(context, KeyBootUpDate, "");\r
+    }\r
+\r
+    private static boolean isFirstBootToday(Context context) {\r
+        //第一次启动记录的日期,当前日期只要相同,就认为有启动过。\r
+        //如果手表一直没有重启过,则每次resetStepCount的时候把启动时间更新到当天,\r
+        //从而解决第二天重启就会被重置的问题!\r
+        String currentDate = TimeUtil.getSystemTime4();\r
+        String lastDate = getLastBootupDate(context);\r
+        boolean ret = false;\r
+        if (currentDate.equals(lastDate)) {\r
+            ret = false;\r
+        } else {\r
+            ret = true;\r
+        }\r
+        ICLogger.i("Current BootDate=" + currentDate + ", Last BootDate=" + lastDate + ", ret=" + ret);\r
+        return ret;\r
+    }\r
+\r
+    //收到语音微聊广播消息给外部窗口\r
+    public static boolean do_broadCast_message = false;\r
+\r
+    //每次心跳时都检测逃逸并报警\r
+    public static boolean needAllwaysAlarmFenceOut = false;\r
+    //每次心跳时都检测剪断并报警,只报警\r
+    public static boolean needAllwaysAlarmCutOff = false;\r
+\r
+    //体温非正常报警\r
+    public static boolean needTemperature_abnormal_alarm = false;\r
+    public static boolean A9_noBroadCastActionStrip = false;\r
+    public static boolean C5_noBroadCastActionStrip = false;\r
+    public static boolean L004_BroadCastActionStrip = false;\r
+\r
+    //停止系统NTP时钟同步标志\r
+    public static boolean disable_ntp_server = false;\r
+\r
+    //需要系统发送已阅读消息的标志\r
+    public static boolean noPushTxtReadReply = true;\r
+    //蓝牙定位扫描 协议0模式,扫到beacon信标时,如果属于第一次扫到的进入状态(解除逃逸状态),发送服务器的标志位,主要由于C5客户只要逃逸,不要解除逃逸消息。\r
+    public static boolean noBLE_RelaseEscapeAlarm = true;\r
+\r
+    public static void enable_NTP_Server(Context context, boolean enable) {\r
+        try {\r
+            int autotime = Settings.Global.getInt(context.getContentResolver(), Settings.Global.AUTO_TIME);\r
+            int autotimezone = Settings.Global.getInt(context.getContentResolver(), Settings.Global.AUTO_TIME_ZONE);\r
+\r
+            ICLogger.i("get NTP Settings AutoTime " + autotime + " AutoTimeZone " + autotimezone);\r
+\r
+            if (enable) {\r
+                Settings.Global.putInt(context.getContentResolver(), Settings.Global.AUTO_TIME_ZONE, 1);\r
+                Settings.Global.putInt(context.getContentResolver(), Settings.Global.AUTO_TIME, 1);\r
+            } else {\r
+                Settings.Global.putInt(context.getContentResolver(), Settings.Global.AUTO_TIME_ZONE, 0);\r
+                Settings.Global.putInt(context.getContentResolver(), Settings.Global.AUTO_TIME, 0);\r
+            }\r
+            autotime = Settings.Global.getInt(context.getContentResolver(), Settings.Global.AUTO_TIME);\r
+            autotimezone = Settings.Global.getInt(context.getContentResolver(), Settings.Global.AUTO_TIME_ZONE);\r
+            ICLogger.i("get NTP Settings AutoTime " + autotime + " AutoTimeZone " + autotimezone);\r
+        } catch (Settings.SettingNotFoundException e) {\r
+            e.printStackTrace();\r
+            ICLogger.e(e.getMessage(), e);\r
         }\r
     }\r
-    custom_name=Util.getSystemProperties("persist.sys.customname");\r
-    ICLogger.i("get CUSTOMNAME "+custom_name);\r
-    if (custom_name.equals("H88")||custom_name.equals("H88A") ){\r
-      noPushTxtNotifyDialog=true;\r
-      noSMSNotifyDialog=false;\r
-      noVoiceNotifyDialog=false;\r
-      noPPGSensor=false;\r
-      noTempSensor=false;\r
-      needBroadcastAntiAlarm=false;\r
-    }else if  ((custom_name.equals("AK")) ){\r
-        noPushTxtNotifyDialog=true;\r
-        noSMSNotifyDialog=true;\r
-        noVoiceNotifyDialog=true;\r
-      noPPGSensor=false;\r
-      noTempSensor=true;\r
-      SOSNoNeedDial=true; //采用新写的SOS,协议只需要发送消息,无需控制拨号。\r
-    }else if  ((custom_name.equals("YT")) ){\r
-      noPushTxtNotifyDialog=false;\r
-      noSMSNotifyDialog=false;\r
-      noVoiceNotifyDialog=false;\r
-      noPPGSensor=false;\r
-      noTempSensor=true;\r
-    }else if ((custom_name.equals("l004")) ) {\r
-      noPushTxtNotifyDialog=true;\r
-      noSMSNotifyDialog=true;\r
-      noVoiceNotifyDialog=true;\r
-      needBroadcastAntiAlarm=false;\r
-      needBroadcastCutoffAlarm=true;\r
-      needAllwaysAlarmCutOff=false;\r
-      needAllwaysAlarmFenceOut=false;\r
-      needTemperature_abnormal_alarm=false;\r
-      noPPGSensor=false;\r
-      noTempSensor=false;\r
-      L004_BroadCastActionStrip=true;\r
-    }else if (custom_name.equals("YQ") ||custom_name.equals("YQ_EN")  ) { //A9-YQ\r
-      noPushTxtNotifyDialog=false;\r
-      noSMSNotifyDialog=true;\r
-      noVoiceNotifyDialog=true;\r
-      noBroadCastPushTxtNotify=true;\r
-      noBroadCastSMSNotify=true;\r
-      needBroadcastAntiAlarm=false;\r
-      needBroadcastCutoffAlarm=true;\r
-      needAllwaysAlarmCutOff=true;\r
-      needAllwaysAlarmFenceOut=true;\r
-      needTemperature_abnormal_alarm=true;\r
-      noPushTxtReadReply=false;//A9需要阅读反馈\r
-      noPPGSensor=false;\r
-      noTempSensor=false;\r
-      A9_noBroadCastActionStrip=true;\r
-    }else if (custom_name.equals("SGL"))\r
-    {\r
-      noPushTxtNotifyDialog=false;\r
-      noSMSNotifyDialog=false;\r
-      noVoiceNotifyDialog=true;\r
-      needBroadcastAntiAlarm=true;\r
-      needBroadcastCutoffAlarm=true;\r
-      needAllwaysAlarmCutOff=true;\r
-      needAllwaysAlarmFenceOut=false;\r
-      needTemperature_abnormal_alarm=false;\r
-      noPPGSensor=true;\r
-      noTempSensor=true;\r
-      C5_noBroadCastActionStrip=true;\r
-    }else if(custom_name.equals("L02")){\r
-      noPushTxtReadReply=false;//即爱需要阅读反馈\r
-    }else{\r
-      noBroadCastPushTxtNotify=true;\r
-    }\r
-\r
-\r
-  }\r
-\r
-  public static void loadTemperatureSettings(Runtime runtime){\r
-    runtime.temp_test_Cycle = SharPreferenceUtil.getPrefInt(runtime.getContextProxy().context, KeyTempTestCycle, 60*60);\r
-  }\r
-\r
-  public static void setTemperatureTestCycle(Runtime runtime,int cycle_seconds) {\r
-    SharPreferenceUtil.setPrefInt(runtime.getContextProxy().context,KeyTempTestCycle,cycle_seconds);\r
-    loadTemperatureSettings(runtime);\r
-  }\r
-    public static boolean isUsingCustomServer=false;\r
-\r
-  public static void setCustomServer(Context context,boolean isusingCutomerServer,String serverip,int serverport) {\r
-\r
-      if (isusingCutomerServer)\r
-          Util.setSystemProperties("persist.sys.UsingCustomServer","true");\r
-      else\r
-          Util.setSystemProperties("persist.sys.UsingCustomServer","false");\r
-\r
-\r
-    Util.setSystemProperties("persist.sys.customserverip",serverip);\r
-    Util.setSystemProperties("persist.sys.customserverport",String.valueOf(serverport));\r
-    setProtocolServerHost(context,serverip);\r
-    setProtocolServerPort(context,serverport);\r
-\r
-    loadCustomServerAddr(context);\r
-\r
-  }\r
-  public static void loadCustomServerAddr(Context context){\r
-    String tmp=Util.getSystemProperties("persist.sys.UsingCustomServer");\r
-    boolean ret=false;\r
-    if (tmp.equals("true"))\r
-      ret=true;\r
-\r
-    isUsingCustomServer=ret;\r
-\r
-    String serverip="";\r
-    int serverport=0;\r
-    if(isUsingCustomServer){\r
-      serverip= Util.getSystemProperties("persist.sys.customserverip");\r
-      serverport= Integer.valueOf(Util.getSystemProperties("persist.sys.customserverport"));\r
-      setProtocolServerHost(context,serverip);\r
-      setProtocolServerPort(context,serverport);\r
-\r
-    }else{\r
-      setProtocolServerHost(context, protocolAPIHelper.getDefaultServerIP());\r
-      setProtocolServerPort(context,protocolAPIHelper.getDefaultServerPort());\r
-    }\r
-    ICLogger.i("current protocol_no="+protocol_no+" , isUsingCustomServier="+isUsingCustomServer+", server host="+\r
-            getProtocolServerHost(context)+", server port="+getProtocolServerPort(context));\r
-  }\r
-\r
-  public static boolean noLocationCycle=getNoLocationCycleFlag();\r
-  public static boolean getNoLocationCycleFlag(){\r
-      String tmp=Util.getSystemProperties("persist.sys.NoLocationCycle");\r
-      boolean ret=false;\r
-      if (tmp.equals("true"))\r
-          ret=true;\r
-\r
-      noLocationCycle=ret;\r
-     return ret;\r
-  }\r
-\r
-  public static final int PROTOCOL_JIAI=0;\r
-  public static final int PROTOCOL_BEEHOME=1;\r
-  public static final int PROTOCOL_IC=2;\r
-  public static final int PROTOCOL_FZD=3;\r
-  public static final int PROTOCOL_MQTT=4;\r
-\r
-  public static int protocol_no=getProtocolNumber();\r
-  public static int getProtocolNumber(){\r
-    String tmp=Util.getSystemProperties("persist.sys.protocol_no");\r
-    int ret=0;\r
-    if (tmp!=null && !tmp.isEmpty()&& Util.isNumeric(tmp)) {\r
-      ret = Integer.parseInt(tmp);\r
-      switch(ret){\r
-        case PROTOCOL_JIAI:\r
-          ICLogger.i("协议 JIAI");\r
-          break;\r
-        case PROTOCOL_BEEHOME:\r
-          ICLogger.i("协议 BEEHOME");\r
-          break;\r
-        case PROTOCOL_IC:\r
-          ICLogger.i("协议 IC");\r
-          break;\r
-        case PROTOCOL_FZD:\r
-          ICLogger.i("协议 FZD");\r
-          break;\r
-        case PROTOCOL_MQTT:\r
-          ICLogger.i("协议 MQTT");\r
-          break;\r
-        default:\r
-          ICLogger.i("协议版本 目前支持0,1,2,3,4 。");\r
-          break;\r
-      }\r
-    }else{\r
-      ICLogger.i("协议版本要是数字,目前支持0,1,2,3,4 。");\r
-    }\r
-    protocol_no=ret;\r
-    return ret;\r
-  }\r
-\r
-\r
-  public static void setPPGAdjust(Context context,int adjust){\r
-    SharPreferenceUtil.setPrefInt(context,KeyPPGadust,adjust);\r
-  }\r
-\r
-\r
-  public static int getPPGAdjust(Context context){\r
-    return SharPreferenceUtil.getPrefInt(context,KeyPPGadust, 0);\r
-  }\r
-\r
-  public static void setBPHAdjust(Context context,int adjust){\r
-    SharPreferenceUtil.setPrefInt(context,KeyBPHadust,adjust);\r
-  }\r
-\r
-\r
-  public static int getBPHAdjust(Context context){\r
-    return SharPreferenceUtil.getPrefInt(context,KeyBPHadust, 0);\r
-  }\r
-\r
-\r
-\r
-  public static int getBPLAdjust(Context context){\r
-    return SharPreferenceUtil.getPrefInt(context,KeyBPLadust, 0);\r
-  }\r
-\r
-  public static void setBPLAdjust(Context context,int adjust){\r
-    SharPreferenceUtil.setPrefInt(context,KeyBPLadust,adjust);\r
-  }\r
-\r
-  public static void setSPo2Adjust(Context context,int adjust){\r
-    SharPreferenceUtil.setPrefInt(context,KeySPo2adust,adjust);\r
-  }\r
-\r
-  public static int getSPo2Adjust(Context context){\r
-    return SharPreferenceUtil.getPrefInt(context,KeySPo2adust, 0);\r
-  }\r
-\r
-  public static void loadPPG_BPH_BPL_SPO2_adjustvalue(Context context,Runtime runtime){\r
-    int ppgadj,bphadj,bpladj,spo2adj;\r
-    ppgadj=getPPGAdjust(context);\r
-    bphadj=getBPHAdjust(context);\r
-    bpladj=getBPLAdjust(context);\r
-    spo2adj=getSPo2Adjust(context);\r
-    runtime.getHRS().setAdjust(ppgadj,bphadj,bpladj,spo2adj);\r
-    ICLogger.i("Load Health adjust value  ppg "+ppgadj+", bph "+bphadj+", bpl "+bpladj+", spo2 "+spo2adj);\r
-  }\r
-\r
-\r
-\r
-  //心率血压血氧校准值\r
-  public static String getPPG_ECG_adjustValue(){\r
-    return Util.getSystemProperties("persist.sys."+Constants.SHAREKEY_SETTING_PPG_ECG_ADJUST,"0,0,0,0");\r
-  }\r
-\r
-  public static void setPPG_ECG_adjustValue(String adjvalue){\r
-    Util.setSystemProperties("persist.sys."+Constants.SHAREKEY_SETTING_PPG_ECG_ADJUST,adjvalue);\r
-  }\r
-\r
-  //久坐时间获取\r
-  public static int getKeepSitRangeInMinutes(Context context ){\r
-    return Util.getSystemPropertiesInt("persist.sys."+Constants.SHAREKEY_SETTING_SIT_ALARM_RANGE_IN_MINUTES,0);\r
+\r
+    public static void LoadMessageConfigs() {\r
+\r
+        String tmp = Util.getSystemProperties("persist.sys.doBroadcastMSG");\r
+        boolean ret = false;\r
+        if (tmp.equals("true"))\r
+            ret = true;\r
+\r
+        do_broadCast_message = ret;\r
+\r
+        noPPGSensor = (ICJniUtils.isPPGavailable() == 0);\r
+        noTempSensor = (ICJniUtils.isTemperatureDevAvailable() == 0);\r
+\r
+        //默认关闭NTP\r
+        disable_ntp_server = Util.getSystemProperties("persist.sys.disableNTP", "false").equals("true");\r
+\r
+        c43_branch_name = Util.getSystemProperties("persist.sys.c43.branch");\r
+\r
+        if ((c43_branch_name.equals("l03")) || (c43_branch_name.equals("l05")) || (c43_branch_name.equals("CH"))) {\r
+            noPushTxtNotifyDialog = true;\r
+            noSMSNotifyDialog = true;\r
+            noVoiceNotifyDialog = true;\r
+            noTempSensor = true;\r
+            if (c43_branch_name.equals("l05") || c43_branch_name.equals("CH")) {\r
+                SOSNoNeedDial = true;//采用新写的SOS,协议只需要发送消息,无需控制拨号。\r
+                noPPGSensor = false;\r
+            } else {\r
+                noPPGSensor = true;\r
+            }\r
+        }\r
+        custom_name = Util.getSystemProperties("persist.sys.customname");\r
+        ICLogger.i("get CUSTOMNAME " + custom_name);\r
+        if (custom_name.equals("H88") || custom_name.equals("H88A")) {\r
+            noPushTxtNotifyDialog = true;\r
+            noSMSNotifyDialog = false;\r
+            noVoiceNotifyDialog = false;\r
+            noPPGSensor = false;\r
+            noTempSensor = false;\r
+            needBroadcastAntiAlarm = false;\r
+        } else if ((custom_name.equals("AK"))) {\r
+            noPushTxtNotifyDialog = true;\r
+            noSMSNotifyDialog = true;\r
+            noVoiceNotifyDialog = true;\r
+            noPPGSensor = false;\r
+            noTempSensor = true;\r
+            SOSNoNeedDial = true; //采用新写的SOS,协议只需要发送消息,无需控制拨号。\r
+        } else if ((custom_name.equals("YT"))) {\r
+            noPushTxtNotifyDialog = false;\r
+            noSMSNotifyDialog = false;\r
+            noVoiceNotifyDialog = false;\r
+            noPPGSensor = false;\r
+            noTempSensor = true;\r
+        } else if ((custom_name.equals("l004"))) {\r
+            noPushTxtNotifyDialog = true;\r
+            noSMSNotifyDialog = true;\r
+            noVoiceNotifyDialog = true;\r
+            needBroadcastAntiAlarm = false;\r
+            needBroadcastCutoffAlarm = true;\r
+            needAllwaysAlarmCutOff = false;\r
+            needAllwaysAlarmFenceOut = false;\r
+            needTemperature_abnormal_alarm = false;\r
+            noPPGSensor = false;\r
+            noTempSensor = false;\r
+            L004_BroadCastActionStrip = true;\r
+        } else if (custom_name.equals("YQ") || custom_name.equals("YQ_EN")) { //A9-YQ\r
+            noPushTxtNotifyDialog = false;\r
+            noSMSNotifyDialog = true;\r
+            noVoiceNotifyDialog = true;\r
+            noBroadCastPushTxtNotify = true;\r
+            noBroadCastSMSNotify = true;\r
+            needBroadcastAntiAlarm = false;\r
+            needBroadcastCutoffAlarm = true;\r
+            needAllwaysAlarmCutOff = true;\r
+            needAllwaysAlarmFenceOut = true;\r
+            needTemperature_abnormal_alarm = true;\r
+            noPushTxtReadReply = false;//A9需要阅读反馈\r
+            noPPGSensor = false;\r
+            noTempSensor = false;\r
+            A9_noBroadCastActionStrip = true;\r
+        } else if (custom_name.equals("SGL")) {\r
+            noPushTxtNotifyDialog = false;\r
+            noSMSNotifyDialog = false;\r
+            noVoiceNotifyDialog = true;\r
+            needBroadcastAntiAlarm = true;\r
+            needBroadcastCutoffAlarm = true;\r
+            needAllwaysAlarmCutOff = true;\r
+            needAllwaysAlarmFenceOut = false;\r
+            needTemperature_abnormal_alarm = false;\r
+            noPPGSensor = true;\r
+            noTempSensor = true;\r
+            C5_noBroadCastActionStrip = true;\r
+        } else if (custom_name.equals("L02")) {\r
+            noPushTxtReadReply = false;//即爱需要阅读反馈\r
+        } else {\r
+            noBroadCastPushTxtNotify = true;\r
+        }\r
+\r
+\r
+    }\r
+\r
+    public static void loadTemperatureSettings(Runtime runtime) {\r
+        runtime.temp_test_Cycle = SharPreferenceUtil.getPrefInt(runtime.getContextProxy().context, KeyTempTestCycle, 60 * 60);\r
+    }\r
+\r
+    public static void setTemperatureTestCycle(Runtime runtime, int cycle_seconds) {\r
+        SharPreferenceUtil.setPrefInt(runtime.getContextProxy().context, KeyTempTestCycle, cycle_seconds);\r
+        loadTemperatureSettings(runtime);\r
+    }\r
+\r
+    public static boolean isUsingCustomServer = false;\r
+\r
+    public static void setCustomServer(Context context, boolean isusingCutomerServer, String serverip, int serverport) {\r
+\r
+        if (isusingCutomerServer)\r
+            Util.setSystemProperties("persist.sys.UsingCustomServer", "true");\r
+        else\r
+            Util.setSystemProperties("persist.sys.UsingCustomServer", "false");\r
+\r
+\r
+        Util.setSystemProperties("persist.sys.customserverip", serverip);\r
+        Util.setSystemProperties("persist.sys.customserverport", String.valueOf(serverport));\r
+        setProtocolServerHost(context, serverip);\r
+        setProtocolServerPort(context, serverport);\r
+\r
+        loadCustomServerAddr(context);\r
+\r
+    }\r
+\r
+    public static void loadCustomServerAddr(Context context) {\r
+        String tmp = Util.getSystemProperties("persist.sys.UsingCustomServer");\r
+        boolean ret = false;\r
+        if (tmp.equals("true"))\r
+            ret = true;\r
+\r
+        isUsingCustomServer = ret;\r
+\r
+        String serverip = "";\r
+        int serverport = 0;\r
+        if (isUsingCustomServer) {\r
+            serverip = Util.getSystemProperties("persist.sys.customserverip");\r
+            serverport = Integer.valueOf(Util.getSystemProperties("persist.sys.customserverport"));\r
+            Integer.valueOf(Util.getSystemProperties("persist.sys.customserverport"));\r
+            setProtocolServerHost(context, serverip);\r
+            setProtocolServerPort(context, serverport);\r
+\r
+        } else {\r
+            setProtocolServerHost(context, protocolAPIHelper.getDefaultServerIP());\r
+            setProtocolServerPort(context, protocolAPIHelper.getDefaultServerPort());\r
+        }\r
+        ICLogger.i("current protocol_no=" + protocol_no + " , isUsingCustomServier=" + isUsingCustomServer + ", server host=" +\r
+                getProtocolServerHost(context) + ", server port=" + getProtocolServerPort(context));\r
+    }\r
+\r
+    public static boolean noLocationCycle = getNoLocationCycleFlag();\r
+\r
+    public static boolean getNoLocationCycleFlag() {\r
+        String tmp = Util.getSystemProperties("persist.sys.NoLocationCycle");\r
+        boolean ret = false;\r
+        if (tmp.equals("true"))\r
+            ret = true;\r
+\r
+        noLocationCycle = ret;\r
+        return ret;\r
+    }\r
+\r
+    public static final int PROTOCOL_JIAI = 0;\r
+    public static final int PROTOCOL_BEEHOME = 1;\r
+    public static final int PROTOCOL_IC = 2;\r
+    public static final int PROTOCOL_FZD = 3;\r
+    public static final int PROTOCOL_MQTT = 4;\r
+\r
+    public static int protocol_no = getProtocolNumber();\r
+\r
+    public static int getProtocolNumber() {\r
+        String tmp = Util.getSystemProperties("persist.sys.protocol_no");\r
+        int ret = 0;\r
+        if (tmp != null && !tmp.isEmpty() && Util.isNumeric(tmp)) {\r
+            ret = Integer.parseInt(tmp);\r
+            switch (ret) {\r
+                case PROTOCOL_JIAI:\r
+                    ICLogger.i("协议 JIAI");\r
+                    break;\r
+                case PROTOCOL_BEEHOME:\r
+                    ICLogger.i("协议 BEEHOME");\r
+                    break;\r
+                case PROTOCOL_IC:\r
+                    ICLogger.i("协议 IC");\r
+                    break;\r
+                case PROTOCOL_FZD:\r
+                    ICLogger.i("协议 FZD");\r
+                    break;\r
+                case PROTOCOL_MQTT:\r
+                    ICLogger.i("协议 MQTT");\r
+                    break;\r
+                default:\r
+                    ICLogger.i("协议版本 目前支持0,1,2,3,4 。");\r
+                    break;\r
+            }\r
+        } else {\r
+            ICLogger.i("协议版本要是数字,目前支持0,1,2,3,4 。");\r
+        }\r
+        protocol_no = ret;\r
+        return ret;\r
+    }\r
+\r
+\r
+    public static void setPPGAdjust(Context context, int adjust) {\r
+        SharPreferenceUtil.setPrefInt(context, KeyPPGadust, adjust);\r
+    }\r
+\r
+\r
+    public static int getPPGAdjust(Context context) {\r
+        return SharPreferenceUtil.getPrefInt(context, KeyPPGadust, 0);\r
+    }\r
+\r
+    public static void setBPHAdjust(Context context, int adjust) {\r
+        SharPreferenceUtil.setPrefInt(context, KeyBPHadust, adjust);\r
+    }\r
+\r
+\r
+    public static int getBPHAdjust(Context context) {\r
+        return SharPreferenceUtil.getPrefInt(context, KeyBPHadust, 0);\r
+    }\r
+\r
+\r
+    public static int getBPLAdjust(Context context) {\r
+        return SharPreferenceUtil.getPrefInt(context, KeyBPLadust, 0);\r
+    }\r
+\r
+    public static void setBPLAdjust(Context context, int adjust) {\r
+        SharPreferenceUtil.setPrefInt(context, KeyBPLadust, adjust);\r
+    }\r
+\r
+    public static void setSPo2Adjust(Context context, int adjust) {\r
+        SharPreferenceUtil.setPrefInt(context, KeySPo2adust, adjust);\r
+    }\r
+\r
+    public static int getSPo2Adjust(Context context) {\r
+        return SharPreferenceUtil.getPrefInt(context, KeySPo2adust, 0);\r
+    }\r
+\r
+    public static void loadPPG_BPH_BPL_SPO2_adjustvalue(Context context, Runtime runtime) {\r
+        int ppgadj, bphadj, bpladj, spo2adj;\r
+        ppgadj = getPPGAdjust(context);\r
+        bphadj = getBPHAdjust(context);\r
+        bpladj = getBPLAdjust(context);\r
+        spo2adj = getSPo2Adjust(context);\r
+        runtime.getHRS().setAdjust(ppgadj, bphadj, bpladj, spo2adj);\r
+        ICLogger.i("Load Health adjust value  ppg " + ppgadj + ", bph " + bphadj + ", bpl " + bpladj + ", spo2 " + spo2adj);\r
+    }\r
+\r
+\r
+    //心率血压血氧校准值\r
+    public static String getPPG_ECG_adjustValue() {\r
+        return Util.getSystemProperties("persist.sys." + Constants.SHAREKEY_SETTING_PPG_ECG_ADJUST, "0,0,0,0");\r
+    }\r
+\r
+    public static void setPPG_ECG_adjustValue(String adjvalue) {\r
+        Util.setSystemProperties("persist.sys." + Constants.SHAREKEY_SETTING_PPG_ECG_ADJUST, adjvalue);\r
+    }\r
+\r
+    //久坐时间获取\r
+    public static int getKeepSitRangeInMinutes(Context context) {\r
+        return Util.getSystemPropertiesInt("persist.sys." + Constants.SHAREKEY_SETTING_SIT_ALARM_RANGE_IN_MINUTES, 0);\r
 //    return SharPreferenceUtil.getPrefIntPublic(context,Constants.SHAREKEY_SETTING_SIT_ALARM_RANGE_IN_MINUTES,0);\r
-  }\r
+    }\r
 \r
-  //久坐时间设置\r
-  public static void setKeepSitRangeInMinutes(Context context, int RangeInMinutes){\r
-      Util.setSystemProperties("persist.sys."+Constants.SHAREKEY_SETTING_SIT_ALARM_RANGE_IN_MINUTES,RangeInMinutes);\r
+    //久坐时间设置\r
+    public static void setKeepSitRangeInMinutes(Context context, int RangeInMinutes) {\r
+        Util.setSystemProperties("persist.sys." + Constants.SHAREKEY_SETTING_SIT_ALARM_RANGE_IN_MINUTES, RangeInMinutes);\r
 //    SharPreferenceUtil.setPrefIntPublic(context,Constants.SHAREKEY_SETTING_SIT_ALARM_RANGE_IN_MINUTES,RangeInMinutes);\r
-  }\r
+    }\r
 \r
-  public static void setSleepDate(Context context,String dateyyyyMMddHHmmss){\r
-    Util.setSystemProperties("persist.sys."+Constants.SHAREKEY_SETTING_SLEEP_SCORE_DATE,dateyyyyMMddHHmmss);\r
+    public static void setSleepDate(Context context, String dateyyyyMMddHHmmss) {\r
+        Util.setSystemProperties("persist.sys." + Constants.SHAREKEY_SETTING_SLEEP_SCORE_DATE, dateyyyyMMddHHmmss);\r
 //    SharPreferenceUtil.setPrefStringPublic(context,Constants.SHAREKEY_SETTING_SLEEP_SCORE_DATE,dateyyyyMMddHHmmss);\r
-  }\r
+    }\r
 \r
 \r
-  public static void setSleepScore(Context context,int score){\r
+    public static void setSleepScore(Context context, int score) {\r
 //    SharPreferenceUtil.setPrefIntPublic(context,Constants.SHAREKEY_SETTING_SLEEP_SCORE,score);\r
-    Util.setSystemProperties("persist.sys."+Constants.SHAREKEY_SETTING_SLEEP_SCORE,score);\r
+        Util.setSystemProperties("persist.sys." + Constants.SHAREKEY_SETTING_SLEEP_SCORE, score);\r
+\r
+    }\r
+\r
+    public static String getSleepDate(Context context) {\r
+        return Util.getSystemProperties("persist.sys." + Constants.SHAREKEY_SETTING_SLEEP_SCORE_DATE, "");\r
+    }\r
+\r
+\r
+    public static int getSleepScore(Context context) {\r
+\r
+        return Util.getSystemPropertiesInt("persist.sys." + Constants.SHAREKEY_SETTING_SLEEP_SCORE, 0);\r
+\r
+    }\r
 \r
-  }\r
+    public static void setNeedCutOff(Context context, boolean enAnti) {\r
+        SharPreferenceUtil.setPrefBoolean(context, "NeedCutOff", enAnti);\r
+    }\r
 \r
-    public static String getSleepDate(Context context){\r
-        return Util.getSystemProperties("persist.sys."+Constants.SHAREKEY_SETTING_SLEEP_SCORE_DATE,"");\r
+    public static boolean getNeedCutOff(Context context) {\r
+        return SharPreferenceUtil.getPrefBoolean(context, "NeedCutOff", false);\r
     }\r
 \r
+    public static void setNeedAntiOff(Context context, boolean enAnti) {\r
+        SharPreferenceUtil.setPrefBoolean(context, "NeedAntiOff", enAnti);\r
+    }\r
 \r
-    public static int getSleepScore(Context context){\r
+    public static boolean getNeedAntiOff(Context context) {\r
+        return SharPreferenceUtil.getPrefBoolean(context, "NeedAntiOff", false);\r
+    }\r
 \r
-        return Util.getSystemPropertiesInt("persist.sys."+Constants.SHAREKEY_SETTING_SLEEP_SCORE,0);\r
+    public static boolean enableSleep = false;\r
+    /**\r
+     * 参考数据,平均每分钟步数来判断,大于 KeepSitJudgementRefValue 认为没有坐着。小于等于这个值认为坐着。\r
+     */\r
+    public static int KeepSitJudgementRefValue = 30;\r
+\r
+    /***\r
+     * persist.sys.alarmConfig=ALARM_SOS,ALARM_LOWBATTERY,ALARM_ANTIOFF,ALARM_WEARED,ALARM_CUTOFF,ALARM_FALL,ALARM_ABNORMAL_HEART_RATE,ALARM_HEART_RATE_HIGH,ALARM_HEART_RATE_LOW,ALARM_BPH_HIGH,ALARM_BPH_LOW,ALARM_BPL_HIGH,ALARM_BPL_LOW,ALARM_SEDENTARY,ALARM_ILLEGAL_CUTOFF,ALARM_LOCK_WATCH,ALARM_TEMP_HIGH,ALARM_TEMP_LOW,ALARM_POWER_OFF,ALARM_ESCAPE,ALARM_NONE\r
+     * 配在里面的表示开启,没配的表示关闭。 默认ALARM_SOS,ALARM_LOWBATTERY,ALARM_POWER_OFF开启\r
+     * ALARM_ILLEGAL_CUTOFF,ALARM_FALL,ALARM_ABNORMAL_HEART_RATE 没有使用,设置了也没有用\r
+     */\r
+    public static void loadAlarmConfig() {\r
+        String configvalues = Util.getSystemProperties("persist.sys.alarmConfig", "");\r
+        String[] values = configvalues.split(",");\r
+        if (values.length > 0) {\r
+            for (int i = 0; i < values.length; i++) {\r
+                for (Runtime.AlarmType at : Runtime.AlarmType.values()) {\r
+                    if (values[i].trim().equals(at.name())) {\r
+                        ConfigAlarm(at, true);\r
+                        break;\r
+                    }\r
+                }\r
+            }\r
+        }\r
+        dumpAlarmConfig();\r
+    }\r
 \r
+    public static void ConfigAlarm(Runtime.AlarmType alarmType, boolean enabled) {\r
+        AlarmConfiglist.put(alarmType.ordinal(), enabled);\r
     }\r
-  public static void setNeedCutOff(Context context,boolean enAnti){\r
-    SharPreferenceUtil.setPrefBoolean(context,"NeedCutOff",enAnti);\r
-  }\r
 \r
-  public static boolean getNeedCutOff(Context context){\r
-    return SharPreferenceUtil.getPrefBoolean(context,"NeedCutOff", false);\r
-  }\r
-    public static void setNeedAntiOff(Context context,boolean enAnti){\r
-      SharPreferenceUtil.setPrefBoolean(context,"NeedAntiOff",enAnti);\r
+    public static void dumpAlarmConfig() {\r
+        for (int i = 0; i < AlarmConfiglist.size(); i++) {\r
+            ICLogger.i(Runtime.AlarmType.values()[i].name() + " " + AlarmConfiglist.get(i));\r
+        }\r
     }\r
 \r
-    public static boolean getNeedAntiOff(Context context){\r
-      return SharPreferenceUtil.getPrefBoolean(context,"NeedAntiOff", false);\r
+    private static HashMap<Integer, Boolean> AlarmConfiglist;\r
+\r
+    static {\r
+        AlarmConfiglist = new HashMap<Integer, Boolean>();\r
+        AlarmConfiglist.put(Runtime.AlarmType.ALARM_SOS.ordinal(), true);\r
+        AlarmConfiglist.put(Runtime.AlarmType.ALARM_LOWBATTERY.ordinal(), true);\r
+        AlarmConfiglist.put(Runtime.AlarmType.ALARM_ANTIOFF.ordinal(), false);\r
+        AlarmConfiglist.put(Runtime.AlarmType.ALARM_WEARED.ordinal(), false);\r
+        AlarmConfiglist.put(Runtime.AlarmType.ALARM_CUTOFF.ordinal(), false);\r
+        AlarmConfiglist.put(Runtime.AlarmType.ALARM_FALL.ordinal(), false);\r
+        AlarmConfiglist.put(Runtime.AlarmType.ALARM_ABNORMAL_HEART_RATE.ordinal(), false);\r
+        AlarmConfiglist.put(Runtime.AlarmType.ALARM_HEART_RATE_HIGH.ordinal(), false);\r
+        AlarmConfiglist.put(Runtime.AlarmType.ALARM_HEART_RATE_LOW.ordinal(), false);\r
+        AlarmConfiglist.put(Runtime.AlarmType.ALARM_BPH_HIGH.ordinal(), false);\r
+        AlarmConfiglist.put(Runtime.AlarmType.ALARM_BPH_LOW.ordinal(), false);\r
+        AlarmConfiglist.put(Runtime.AlarmType.ALARM_BPL_HIGH.ordinal(), false);\r
+        AlarmConfiglist.put(Runtime.AlarmType.ALARM_BPL_LOW.ordinal(), false);\r
+        AlarmConfiglist.put(Runtime.AlarmType.ALARM_SEDENTARY.ordinal(), false);\r
+        AlarmConfiglist.put(Runtime.AlarmType.ALARM_ILLEGAL_CUTOFF.ordinal(), false);\r
+        AlarmConfiglist.put(Runtime.AlarmType.ALARM_LOCK_WATCH.ordinal(), false);\r
+        AlarmConfiglist.put(Runtime.AlarmType.ALARM_TEMP_HIGH.ordinal(), false);\r
+        AlarmConfiglist.put(Runtime.AlarmType.ALARM_TEMP_LOW.ordinal(), false);\r
+        AlarmConfiglist.put(Runtime.AlarmType.ALARM_POWER_OFF.ordinal(), true);\r
+        AlarmConfiglist.put(Runtime.AlarmType.ALARM_ESCAPE.ordinal(), false);\r
+        AlarmConfiglist.put(Runtime.AlarmType.ALARM_NONE.ordinal(), false);\r
+        AlarmConfiglist.put(Runtime.AlarmType.ALARM_REMOVE_SOS.ordinal(), true);\r
     }\r
-    public static boolean enableSleep=false;\r
-  /**\r
-   * 参考数据,平均每分钟步数来判断,大于 KeepSitJudgementRefValue 认为没有坐着。小于等于这个值认为坐着。\r
-   */\r
-  public static int  KeepSitJudgementRefValue=30;\r
 \r
-  /***\r
-   * persist.sys.alarmConfig=ALARM_SOS,ALARM_LOWBATTERY,ALARM_ANTIOFF,ALARM_WEARED,ALARM_CUTOFF,ALARM_FALL,ALARM_ABNORMAL_HEART_RATE,ALARM_HEART_RATE_HIGH,ALARM_HEART_RATE_LOW,ALARM_BPH_HIGH,ALARM_BPH_LOW,ALARM_BPL_HIGH,ALARM_BPL_LOW,ALARM_SEDENTARY,ALARM_ILLEGAL_CUTOFF,ALARM_LOCK_WATCH,ALARM_TEMP_HIGH,ALARM_TEMP_LOW,ALARM_POWER_OFF,ALARM_ESCAPE,ALARM_NONE\r
-   * 配在里面的表示开启,没配的表示关闭。 默认ALARM_SOS,ALARM_LOWBATTERY,ALARM_POWER_OFF开启\r
-   * ALARM_ILLEGAL_CUTOFF,ALARM_FALL,ALARM_ABNORMAL_HEART_RATE 没有使用,设置了也没有用\r
-   */\r
-  public static void loadAlarmConfig(){\r
-    String configvalues=Util.getSystemProperties("persist.sys.alarmConfig","");\r
-    String[] values=configvalues.split(",");\r
-    if (values.length>0){\r
-      for (int i=0; i< values.length;i++)\r
-      {\r
-        for (Runtime.AlarmType at: Runtime.AlarmType.values()) {\r
-          if (values[i].trim().equals(at.name())){\r
-            ConfigAlarm(at,true);\r
-            break;\r
-          }\r
+    public static boolean isAlarmTypeEnabled(Runtime.AlarmType alarmType) {\r
+\r
+        boolean en = false;\r
+        if (AlarmConfiglist.containsKey(alarmType.ordinal())) {\r
+            en = AlarmConfiglist.get(alarmType.ordinal());\r
         }\r
-      }\r
-    }\r
-    dumpAlarmConfig();\r
-  }\r
-\r
-  public static void ConfigAlarm(Runtime.AlarmType alarmType,boolean enabled){\r
-    AlarmConfiglist.put(alarmType.ordinal(),enabled);\r
-  }\r
-  public static void dumpAlarmConfig(){\r
-    for (int i=0;i<AlarmConfiglist.size();i++) {\r
-      ICLogger.i(Runtime.AlarmType.values()[i].name()+" "+AlarmConfiglist.get(i));\r
-    }\r
-  }\r
-  private static HashMap<Integer,Boolean> AlarmConfiglist;\r
-  static {\r
-    AlarmConfiglist=new HashMap<Integer,Boolean>();\r
-    AlarmConfiglist.put(Runtime.AlarmType.ALARM_SOS.ordinal(),true);\r
-    AlarmConfiglist.put(Runtime.AlarmType.ALARM_LOWBATTERY.ordinal(),true);\r
-    AlarmConfiglist.put(Runtime.AlarmType.ALARM_ANTIOFF.ordinal(),false);\r
-    AlarmConfiglist.put(Runtime.AlarmType.ALARM_WEARED.ordinal(),false);\r
-    AlarmConfiglist.put(Runtime.AlarmType.ALARM_CUTOFF.ordinal(),false);\r
-    AlarmConfiglist.put(Runtime.AlarmType.ALARM_FALL.ordinal(),false);\r
-    AlarmConfiglist.put(Runtime.AlarmType.ALARM_ABNORMAL_HEART_RATE.ordinal(),false);\r
-    AlarmConfiglist.put(Runtime.AlarmType.ALARM_HEART_RATE_HIGH.ordinal(),false);\r
-    AlarmConfiglist.put(Runtime.AlarmType.ALARM_HEART_RATE_LOW.ordinal(),false);\r
-    AlarmConfiglist.put(Runtime.AlarmType.ALARM_BPH_HIGH.ordinal(),false);\r
-    AlarmConfiglist.put(Runtime.AlarmType.ALARM_BPH_LOW.ordinal(),false);\r
-    AlarmConfiglist.put(Runtime.AlarmType.ALARM_BPL_HIGH.ordinal(),false);\r
-    AlarmConfiglist.put(Runtime.AlarmType.ALARM_BPL_LOW.ordinal(),false);\r
-    AlarmConfiglist.put(Runtime.AlarmType.ALARM_SEDENTARY.ordinal(),false);\r
-    AlarmConfiglist.put(Runtime.AlarmType.ALARM_ILLEGAL_CUTOFF.ordinal(),false);\r
-    AlarmConfiglist.put(Runtime.AlarmType.ALARM_LOCK_WATCH.ordinal(),false);\r
-    AlarmConfiglist.put(Runtime.AlarmType.ALARM_TEMP_HIGH.ordinal(),false);\r
-    AlarmConfiglist.put(Runtime.AlarmType.ALARM_TEMP_LOW.ordinal(),false);\r
-    AlarmConfiglist.put(Runtime.AlarmType.ALARM_POWER_OFF.ordinal(),true);\r
-    AlarmConfiglist.put(Runtime.AlarmType.ALARM_ESCAPE.ordinal(),false);\r
-    AlarmConfiglist.put(Runtime.AlarmType.ALARM_NONE.ordinal(),false);\r
-    AlarmConfiglist.put(Runtime.AlarmType.ALARM_REMOVE_SOS.ordinal(),true);\r
-  }\r
-\r
-  public static boolean isAlarmTypeEnabled(Runtime.AlarmType alarmType){\r
-\r
-    boolean en=false;\r
-    if (AlarmConfiglist.containsKey(alarmType.ordinal())){\r
-      en=AlarmConfiglist.get(alarmType.ordinal());\r
-    }\r
-    return en;\r
-  }\r
-  public static boolean needWaterMark(){\r
-    String customname=getSystemProperties("persist.sys.needWaterMark","true");\r
-    if(customname.trim().equals("true")){\r
-      return true;\r
-    }else\r
-      return false;\r
-  }\r
+        return en;\r
+    }\r
+\r
+    public static boolean needWaterMark() {\r
+        String customname = getSystemProperties("persist.sys.needWaterMark", "true");\r
+        if (customname.trim().equals("true")) {\r
+            return true;\r
+        } else\r
+            return false;\r
+    }\r
 }\r
 \r
index 9756a51..9e9acfe 100644 (file)
@@ -4,42 +4,27 @@ import android.app.AlarmManager;
 import android.app.Notification;
 import android.app.PendingIntent;
 import android.app.Service;
-import android.content.IClipboard;
+import android.content.BroadcastReceiver;
+import android.content.Context;
 import android.content.Intent;
+import android.content.IntentFilter;
 import android.media.AudioManager;
-import android.media.MediaRouter;
 import android.os.Handler;
 import android.os.IBinder;
-
 import android.os.Message;
 import android.os.Messenger;
 import android.os.PowerManager;
 import android.os.SystemClock;
 import android.widget.Toast;
 
-import com.enqualcomm.support.adapter.BTHelper;
+import com.enqualcomm.support.adapter.LBSHelper;
 import com.enqualcomm.support.bean.Contact;
-import com.enqualcomm.support.bean.ICLocation;
+import com.enqualcomm.support.bean.Runtime;
 import com.enqualcomm.support.bean.SleepInfo;
 import com.enqualcomm.support.bean.SleepRecord;
-import com.enqualcomm.support.service.AntiMonitorService;
-import com.enqualcomm.support.utils.CellInfoUtil;
-import com.enqualcomm.support.utils.Connection;
-import com.enqualcomm.support.utils.DeviceInfoUtil;
-import com.enqualcomm.support.utils.ICHttpUtil;
-import com.enqualcomm.support.utils.LedUtil;
-import com.enqualcomm.support.utils.StorageUtils;
-import com.enqualcomm.support.utils.TemperatureUtil;
-import com.enqualcomm.support.utils.TimeUtil;
-import com.enqualcomm.support.utils.VibrateUtil;
-import com.enqualcomm.support.utils.WakeLockUtil;
-import com.enqualcomm.support.utils.mqttConnection;
-import com.ic.jni.ICJniUtils;
-import com.enqualcomm.support.adapter.LBSHelper;
-import com.ic.protocols.protocolAPIHelper;
-import com.enqualcomm.support.bean.Runtime;
 import com.enqualcomm.support.bean.StringMessage;
 import com.enqualcomm.support.bean.heartRateStatus;
+import com.enqualcomm.support.service.AntiMonitorService;
 import com.enqualcomm.support.service.CheckSIM;
 import com.enqualcomm.support.service.Deliver;
 import com.enqualcomm.support.service.HeartRateManager;
@@ -52,39 +37,44 @@ import com.enqualcomm.support.service.base.AbstractInvokeHandlerService;
 import com.enqualcomm.support.utils.AlarmHelper;
 import com.enqualcomm.support.utils.AlarmWakeUp;
 import com.enqualcomm.support.utils.BatteryUtil;
+import com.enqualcomm.support.utils.CellInfoUtil;
+import com.enqualcomm.support.utils.Connection;
 import com.enqualcomm.support.utils.ConnectionListener;
 import com.enqualcomm.support.utils.ContextProxy;
 import com.enqualcomm.support.utils.DBHelper;
+import com.enqualcomm.support.utils.DeviceInfoUtil;
 import com.enqualcomm.support.utils.FileOutputUtil;
 import com.enqualcomm.support.utils.ICLogger;
+import com.enqualcomm.support.utils.LedUtil;
 import com.enqualcomm.support.utils.NettyConnection;
 import com.enqualcomm.support.utils.SharPreferenceUtil;
 import com.enqualcomm.support.utils.SimSignalUtil;
+import com.enqualcomm.support.utils.TemperatureUtil;
+import com.enqualcomm.support.utils.TimeUtil;
 import com.enqualcomm.support.utils.Util;
+import com.enqualcomm.support.utils.VibrateUtil;
+import com.enqualcomm.support.utils.WakeLockUtil;
+import com.enqualcomm.support.utils.mqttConnection;
+import com.ic.jni.ICJniUtils;
+import com.ic.protocols.protocolAPIHelper;
 
 import java.lang.ref.WeakReference;
-import chestnut.ui.Toastc;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.IntentFilter;
-
 import java.util.ArrayList;
 import java.util.Random;
 import java.util.concurrent.ScheduledThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 
+import chestnut.ui.Toastc;
+
 import static android.app.PendingIntent.FLAG_UPDATE_CURRENT;
 import static com.enqualcomm.support.Constants.ACTION_ALARM_ADD_DATAPOINTS;
 import static com.enqualcomm.support.Constants.ACTION_ALARM_ALARM_CHANGE;
 import static com.enqualcomm.support.Constants.ACTION_ALARM_BLE_SCAN;
-import static com.enqualcomm.support.Constants.ACTION_ALARM_CHECK_ANTI;
 import static com.enqualcomm.support.Constants.ACTION_CHECK_ANTIOFF_EVENT;
 import static com.enqualcomm.support.Constants.ACTION_EQC_ALARM;
 import static com.enqualcomm.support.Constants.ACTION_HEATR_RATE_START;
 import static com.enqualcomm.support.Constants.ACTION_LOCAL_SOS_ACTION;
 import static com.enqualcomm.support.Constants.ACTION_LOCATION_ALARM;
-import static com.enqualcomm.support.Constants.ACTION_PRACTICE_REPORT_ALARM;
 import static com.enqualcomm.support.Constants.ACTION_QUERY_WEATHER;
 import static com.enqualcomm.support.Constants.ACTION_SEND_EMEGENCY_LOCATION_START;
 import static com.enqualcomm.support.Constants.ACTION_SEND_EMEGENCY_LOCATION_STOP;
@@ -92,12 +82,15 @@ import static com.enqualcomm.support.Constants.ANTI_ALARM;
 import static com.enqualcomm.support.Constants.HEART_ALARM;
 import static com.enqualcomm.support.Constants.KEY_SAVE_STEP_COUNT;
 import static com.enqualcomm.support.Constants.KEY_STEP_COUNT;
-import static com.enqualcomm.support.Constants.KEY_TEMP_BODY;
-import static com.enqualcomm.support.Constants.KEY_TEMP_WRIST;
 import static com.enqualcomm.support.Constants.STEP_COUNT_ALARM_ACTION;
 import static com.enqualcomm.support.Constants.TEMP_ALARM;
-import static com.enqualcomm.support.bean.ICLocation.*;
-import static com.ic.protocols.protocolAPIHelper.getTemperatureMSG;
+import static com.enqualcomm.support.bean.ICLocation.CUSTOM_MOD;
+import static com.enqualcomm.support.bean.ICLocation.CUSTOM_MOD8_GPS;
+import static com.enqualcomm.support.bean.ICLocation.CUSTOM_MOD8_WIFI;
+import static com.enqualcomm.support.bean.ICLocation.EMERGNECY_MOD;
+import static com.enqualcomm.support.bean.ICLocation.LOWPOWER_MOD;
+import static com.enqualcomm.support.bean.ICLocation.NORMAL_MOD;
+import static com.enqualcomm.support.bean.ICLocation.REALTIME_MOD;
 
 
 public class CoreService extends Service {
@@ -105,20 +98,20 @@ public class CoreService extends Service {
 
     private Toastc toast = null;
 
-    private static CoreService mProtocolServer=null;
-    private static LBSHelper lbshelper=null;
+    private static CoreService mProtocolServer = null;
+    private static LBSHelper lbshelper = null;
 
     public static final String ACTION_ALARM = "com.enqualcomm.support.ACTION_ALARM";
 
-    private static final int GRAY_SERVICE_ID =android.os.Process.myPid();
+    private static final int GRAY_SERVICE_ID = android.os.Process.myPid();
 
-    private static final String MY_WAKE_LOCKTAG =CoreService.class.getSimpleName();
+    private static final String MY_WAKE_LOCKTAG = CoreService.class.getSimpleName();
 
     public static int alarmCycle = 5;
 
     public static final int interval = 60000;
 
-    public static boolean needLocateInAfterHeartBeat=false;
+    public static boolean needLocateInAfterHeartBeat = false;
     private static int is_allowed_in_sleep_mode = 1;
 
     private static boolean is_in_sleep_mode = false;
@@ -127,10 +120,11 @@ public class CoreService extends Service {
     // SPRD: add outdoorMode
     public static final int RINGER_MODE_OUTDOOR = 3;
 
-    public static Handler mHandler=new Handler();
-    private static ICSmsManager smsManager=null;
-    public String getServerAlive(){
-       return DeviceInfoUtil.getDeviceInfo(runtime);
+    public static Handler mHandler = new Handler();
+    private static ICSmsManager smsManager = null;
+
+    public String getServerAlive() {
+        return DeviceInfoUtil.getDeviceInfo(runtime);
     }
 
     private BroadcastReceiver AtCallbackBroadcastReceiver = new BroadcastReceiver() {
@@ -152,7 +146,7 @@ public class CoreService extends Service {
                         stringBuilder1.append(Integer.valueOf(str, 16));
                         stringBuilder1.append(",CELLID=");
                         stringBuilder1.append(Integer.valueOf(str1, 16));
-                        if (Config.LOG_TOFILE) ICLogger.logToFile( "LBS", stringBuilder1.toString());
+                        if (Config.LOG_TOFILE) ICLogger.logToFile("LBS", stringBuilder1.toString());
                     }
                 }
             }
@@ -164,10 +158,10 @@ public class CoreService extends Service {
             StringBuilder stringBuilder2 = new StringBuilder();
             stringBuilder2.append("broadcastReceiver  alarmCycle action==");
             stringBuilder2.append(param1Intent.getAction());
-            if (Config.LOG_TOFILE) ICLogger.logToFile( "alarmCycle", stringBuilder2.toString());
+            if (Config.LOG_TOFILE) ICLogger.logToFile("alarmCycle", stringBuilder2.toString());
             StringBuilder stringBuilder1 = new StringBuilder();
             stringBuilder1.append("时间变化");
-            stringBuilder1.append(param1Intent.getAction()+stringBuilder2.toString());
+            stringBuilder1.append(param1Intent.getAction() + stringBuilder2.toString());
             ICLogger.i(stringBuilder1.toString());
 
             //只有需要确定绝对时间点启动的Alarm需要重置,相对时间点的Alarm不需要重置。防止永远不能正常登陆。
@@ -176,8 +170,8 @@ public class CoreService extends Service {
 //            setHeartAlarm();
 //           setHeartRateDetectAlarm(runtime.getPpgTestCycle());
             setWeatherAlarm();
-            runtime.getContextProxy().sendBroadcast(ACTION_ALARM_ALARM_CHANGE,runtime); //更新Alarm
-           // setLocationAlarm(runtime.getLocationInstance().getWorkingMod());
+            runtime.getContextProxy().sendBroadcast(ACTION_ALARM_ALARM_CHANGE, runtime); //更新Alarm
+            // setLocationAlarm(runtime.getLocationInstance().getWorkingMod());
             if (cmcm_call_eiot_into_powersave_mode() == 0)
                 AlarmWakeUp.isNeedWakeUpAlarm(runtime);
         }
@@ -190,7 +184,7 @@ public class CoreService extends Service {
             stringBuilder2.append(param1Intent.getAction());
             ICLogger.i(stringBuilder2.toString());
 
-            if (ACTION_SEND_EMEGENCY_LOCATION_START.equals(param1Intent.getAction())){
+            if (ACTION_SEND_EMEGENCY_LOCATION_START.equals(param1Intent.getAction())) {
                 runtime.getLocationInstance().setWorkingMod(EMERGNECY_MOD);
                 //runtime.setPpgTestCycle(1);
                 setLocationAlarm(runtime.getLocationInstance().getWorkingMod());
@@ -200,67 +194,69 @@ public class CoreService extends Service {
 
 
                 setEmegencyLocationSTOPAlarm(5);
-            }else if (ACTION_LOCAL_SOS_ACTION.endsWith(param1Intent.getAction())){
+            } else if (ACTION_LOCAL_SOS_ACTION.endsWith(param1Intent.getAction())) {
 
 
                 VibrateUtil.getInstance(runtime.getContextProxy().context).VibrateOn(true);
 //               if( param1Intent.getIntExtra("type", 1) == 1) {
-                boolean needHRSTestOnSOS = Util.getSystemProperties("persist.sys.needHRSOnSOS","false").equals("true");
-                if(needHRSTestOnSOS) {
+                boolean needHRSTestOnSOS = Util.getSystemProperties("persist.sys.needHRSOnSOS", "false").equals("true");
+                if (needHRSTestOnSOS) {
                     //触发一次心率检测
                     setHeartRateDetectAlarm(1);
                 }
-                    runtime.setAlarmType(Runtime.AlarmType.ALARM_SOS);
-                    //trigger AP10 报警定位
-                     ICLogger.i("triggerSOSLocationProcess ");
-                    LocationClient.getInstance().triggerSOSLocationProcess();
+                runtime.setAlarmType(Runtime.AlarmType.ALARM_SOS);
+                //trigger AP10 报警定位
+                ICLogger.i("triggerSOSLocationProcess ");
+                LocationClient.getInstance().triggerSOSLocationProcess();
 //                    Deliver.sendLocationMSG(protocolAPIHelper.getWarningMSG(runtime));
 
-                    //开启紧急定位模式,GPS 优先1分钟一次定位,持续5分钟
-                    runtime.getLocationInstance().setWorkingMod(EMERGNECY_MOD);
-                    setLocationAlarm(runtime.getLocationInstance().getWorkingMod());
+                //开启紧急定位模式,GPS 优先1分钟一次定位,持续5分钟
+                runtime.getLocationInstance().setWorkingMod(EMERGNECY_MOD);
+                setLocationAlarm(runtime.getLocationInstance().getWorkingMod());
 
-                    //SOS模式,心率测试1分钟一次,持续5分钟
-                    if(needHRSTestOnSOS) {
-                        //只触发一次心率检测
-                        setHeartRateDetectAlarm(1);
-                    }
-                    //设置5分钟后结束紧急定位模式
-                   setEmegencyLocationSTOPAlarm(5);
+                //SOS模式,心率测试1分钟一次,持续5分钟
+                if (needHRSTestOnSOS) {
+                    //只触发一次心率检测
+                    setHeartRateDetectAlarm(1);
+                }
+                //设置5分钟后结束紧急定位模式
+                setEmegencyLocationSTOPAlarm(5);
 
 
-                   if(Config.SOSNoNeedDial==false) {
-                       //50ms后开始拨打电话
-                       mHandler.postDelayed(mTriggerSOSCALLThread,500);
-                   }
-            }else if (ACTION_QUERY_WEATHER.equals(param1Intent.getAction())) {
+                if (Config.SOSNoNeedDial == false) {
+                    //50ms后开始拨打电话
+                    mHandler.postDelayed(mTriggerSOSCALLThread, 500);
+                }
+            } else if (ACTION_QUERY_WEATHER.equals(param1Intent.getAction())) {
 
                 ICLogger.i("ACTION_QUERY_WEATHER ");
                 connection.send(protocolAPIHelper.getWeatherMSG(runtime));
-                }
+            }
         }
     };
 
-    private TriggerSOSCALLThread mTriggerSOSCALLThread=new TriggerSOSCALLThread();
+    private TriggerSOSCALLThread mTriggerSOSCALLThread = new TriggerSOSCALLThread();
 
-    private  class TriggerSOSCALLThread implements  Runnable{
+    private class TriggerSOSCALLThread implements Runnable {
 
         @Override
         public void run() {
             trigger_SOS_Call();
         }
     }
-    private void trigger_SOS_Call(){
+
+    private void trigger_SOS_Call() {
         try {
             Intent intent = new Intent("com.eqc.shutdown_sos");
-            intent.putExtra("type",1);
+            intent.putExtra("type", 1);
             intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
             this.startActivity(intent);
-        }catch (Exception e){
+        } catch (Exception e) {
             e.printStackTrace();
         }
     }
-    private  Runnable mupdatePracticeData=new Runnable(){
+
+    private Runnable mupdatePracticeData = new Runnable() {
         @Override
         public void run() {
             //ICHttpUtil.uploadData(Runtime.healthInfo.getBufferDataStr(),runtime,TimeUtil.getSystemTime2(),null);
@@ -272,31 +268,30 @@ public class CoreService extends Service {
 
     private BroadcastReceiver broadcastPracticeCMDReceiver = new BroadcastReceiver() {
         public void onReceive(Context param1Context, Intent param1Intent) {
-            if(param1Intent.getAction().equals(Constants.ACTION_START_PRACTISE))
-            {
-                int cmd=param1Intent.getIntExtra(Constants.KeyPractice,0);
-                if (cmd==1){
+            if (param1Intent.getAction().equals(Constants.ACTION_START_PRACTISE)) {
+                int cmd = param1Intent.getIntExtra(Constants.KeyPractice, 0);
+                if (cmd == 1) {
                     //开始自由锻炼
-                    Runtime.practising=true;
-                    Util.setSystemProperties( Config.KeyPractiseState,"true");
+                    Runtime.practising = true;
+                    Util.setSystemProperties(Config.KeyPractiseState, "true");
                     Runtime.healthInfo.reset();
                     Runtime.healthInfo.resetBuffer();
                     setPracticeAlarm();
 
-                }else{
+                } else {
                     //停止自由锻炼,恢复正常
-                    Runtime.practising=false;
-                    Util.setSystemProperties( Config.KeyPractiseState,"false");
+                    Runtime.practising = false;
+                    Util.setSystemProperties(Config.KeyPractiseState, "false");
                     HeartRateManager.stopPPGtest();
 
                     //最后检测是否还有数据需要发送
-                    if(Runtime.healthInfo.check_info_item_finished()){
+                    if (Runtime.healthInfo.check_info_item_finished()) {
                         Runtime.healthInfo.appendBuffer(Runtime.healthInfo.getHealthInfoString());
                         Runtime.healthInfo.reset();
-                     }
-                    if(Runtime.healthInfo.getInfoCount()>=0){
+                    }
+                    if (Runtime.healthInfo.getInfoCount() >= 0) {
                         //超过30次发送数据给服务器
-                        ICLogger.i("自由锻炼结束,发送数据给服务器 "+Runtime.healthInfo.getBufferData().length);
+                        ICLogger.i("自由锻炼结束,发送数据给服务器 " + Runtime.healthInfo.getBufferData().length);
                         mHandler.post(mupdatePracticeData);
                     }
 
@@ -308,19 +303,22 @@ public class CoreService extends Service {
     private static class ServerHandler implements ConnectionListener {
         private final WeakReference<CoreService> mReference;
 
-        ServerHandler(CoreService param1CoreService) { this.mReference = new WeakReference(param1CoreService); }
+        ServerHandler(CoreService param1CoreService) {
+            this.mReference = new WeakReference(param1CoreService);
+        }
 
         @Override
         public void onConnectionClose(String errorName) {
-            CoreService coreService = (CoreService)this.mReference.get();
+            CoreService coreService = (CoreService) this.mReference.get();
             if (coreService == null)
                 return;
-            ICLogger.i("onConnectionClose++ retry to connect again!  Close Error "+errorName);
-            coreService.connectionServiceChain.processConnectionClose(coreService.connection, coreService.runtime,errorName);
+            ICLogger.i("onConnectionClose++ retry to connect again!  Close Error " + errorName);
+            coreService.connectionServiceChain.processConnectionClose(coreService.connection, coreService.runtime, errorName);
         }
+
         @Override
         public void onConnectionOpen() {
-            CoreService coreService = (CoreService)this.mReference.get();
+            CoreService coreService = (CoreService) this.mReference.get();
             if (coreService == null)
                 return;
             coreService.connectionServiceChain.processConnectionOpen(coreService.connection, coreService.runtime);
@@ -329,14 +327,15 @@ public class CoreService extends Service {
 
         public void onReceive(StringMessage param1StringMessage) {
 
-            CoreService coreService = (CoreService)this.mReference.get();
-            ICLogger.i("onReceive " +param1StringMessage.cmd() +" coreService " + coreService  );
+            CoreService coreService = (CoreService) this.mReference.get();
+            ICLogger.i("onReceive " + param1StringMessage.cmd() + " coreService " + coreService);
             if (coreService == null)
                 return;
             coreService.connectionServiceChain.processServerResponse(param1StringMessage, coreService.connection, coreService.runtime);
             coreService.locationClient.onReceive(param1StringMessage);
         }
     }
+
     Connection connection = null;
     AbstractConnectionService connectionServiceChain;
 
@@ -389,7 +388,7 @@ public class CoreService extends Service {
                 //为了保证唤醒时各个状态及时更新到服务器,发送一个同步心跳包,这样用户体验更好
                 CoreService.this.locationClient.updateStepCount();
 
-                mHandler.postDelayed(mRetryConnectSrvThread,500);
+                mHandler.postDelayed(mRetryConnectSrvThread, 500);
 
 
                 if (CoreService.is_wifi_network_ok) {
@@ -399,35 +398,35 @@ public class CoreService extends Service {
 //                    if (!Util.isWifiIsOpen(runtime.getContextProxy().context,runtime))
 //                        Util.turnOnWifiForConnect(runtime.getContextProxy().context, runtime);
                 }
-            } else if ("android.intent.action.SCREEN_OFF".equals(intent.getAction()) && Util.isWifiIsOpen(runtime.getContextProxy().context,runtime)) {
-               // CoreService.is_wifi_network_ok = true;
+            } else if ("android.intent.action.SCREEN_OFF".equals(intent.getAction()) && Util.isWifiIsOpen(runtime.getContextProxy().context, runtime)) {
+                // CoreService.is_wifi_network_ok = true;
                 if (!runtime.isNoTurnOffWifiOnScreenOff()) {
                     //不关闭wifi when ScreenOff
                     ICLogger.i("turnOffWifiForConnect");
 //                    if (Util.isWifiIsOpen(runtime.getContextProxy().context,runtime))
 //                        Util.turnOffWifiForSleep(runtime.getContextProxy().context, runtime);
                 }
-            }else if  (intent.getAction().equals("android.media.VOLUME_CHANGED_ACTION")) {
+            } else if (intent.getAction().equals("android.media.VOLUME_CHANGED_ACTION")) {
                 int streamType = intent.getIntExtra("android.media.EXTRA_VOLUME_STREAM_TYPE", -1);
-                ICLogger.i("Volume changed stream type "+streamType);
+                ICLogger.i("Volume changed stream type " + streamType);
 
                 int newVolume = intent.getIntExtra("android.media.EXTRA_VOLUME_STREAM_VALUE", 0);
                 int oldVolume = intent.getIntExtra("android.media.EXTRA_PREV_VOLUME_STREAM_VALUE", 0);
-                boolean   isSilence = SharPreferenceUtil.getPrefBoolean(context, "KEY_ISSILENCE", false);
+                boolean isSilence = SharPreferenceUtil.getPrefBoolean(context, "KEY_ISSILENCE", false);
                 if (newVolume != oldVolume && !isSilence) {
-                   ICLogger.i("Volume changed old "+oldVolume+" new "+newVolume);
-                   Config.setMasterVolume(context,newVolume);
+                    ICLogger.i("Volume changed old " + oldVolume + " new " + newVolume);
+                    Config.setMasterVolume(context, newVolume);
                 }
             }
         }
     };
 
-    private Runnable mRetryConnectSrvThread=new Runnable(){
+    private Runnable mRetryConnectSrvThread = new Runnable() {
         @Override
         public void run() {
-            if (connection.isServerConnected()&& runtime.isServerProtocolConnected()) {
+            if (connection.isServerConnected() && runtime.isServerProtocolConnected()) {
                 mKeepAlive.onHeartAlarm(connection, runtime);
-            }else{
+            } else {
                 ICLogger.i("mRetryConnectSrvThread 发送心跳包时,如果发现服务器没有响应,或者socket连接,则重新尝试连接服务器!");
                 connection.disconnectServer();
                 startConnectionRetryTimer();
@@ -444,7 +443,7 @@ public class CoreService extends Service {
 //        Initialize initialize = new Initialize();
         CheckSIM checkSIM = new CheckSIM();
         this.mKeepAlive = new KeepAlive();
-        this.mDeliver = new Deliver(this.connection,this.runtime);
+        this.mDeliver = new Deliver(this.connection, this.runtime);
 //        initialize.setNext(checkSIM);
         checkSIM.setNext(this.mKeepAlive);
         this.mKeepAlive.setNext(this.mDeliver);
@@ -453,10 +452,11 @@ public class CoreService extends Service {
 
 
     SilentManager silentManager;
+
     private AbstractInvokeHandlerService getInvokeHandlerServiceChain() {
         ICLogger.i("getInvokeHandlerServiceChain");
         SendChatMessage sendChatMessage = new SendChatMessage();
-        HeartRateManager heartRateManager= new HeartRateManager(this.runtime,this.connection);
+        HeartRateManager heartRateManager = new HeartRateManager(this.runtime, this.connection);
         antiservice = new AntiMonitorService();
         silentManager = SilentManager.getInstance();// new SilentManager();
         sendChatMessage.setNext(heartRateManager);
@@ -465,35 +465,38 @@ public class CoreService extends Service {
         return sendChatMessage;
     }
 
-    private void resetStepCount(){
-        if ( ICJniUtils.isPedometerEnabled() == 0)ICJniUtils.enablePedometer();
+    private void resetStepCount() {
+        if (ICJniUtils.isPedometerEnabled() == 0) ICJniUtils.enablePedometer();
         ICJniUtils.resetStepCount();
         SharPreferenceUtil.setPrefInt(this, KEY_STEP_COUNT, 0);
         SharPreferenceUtil.setPrefInt(this, KEY_SAVE_STEP_COUNT, 0);
-        ICLogger.i("Reset StepCount , "+ICJniUtils.getStepCount());
+        ICLogger.i("Reset StepCount , " + ICJniUtils.getStepCount());
         this.runtime.setSaveStepCount(0);
         this.runtime.setTotalStepCount(0);
     }
+
     private void loadStepCount() {
         int i = SharPreferenceUtil.getPrefInt(this, KEY_STEP_COUNT, 0);
         int j = SharPreferenceUtil.getPrefInt(this, KEY_SAVE_STEP_COUNT, 0);
-        if ( ICJniUtils.isPedometerEnabled() == 0)ICJniUtils.enablePedometer();
+        if (ICJniUtils.isPedometerEnabled() == 0) ICJniUtils.enablePedometer();
         //ICJniUtils.recoverStepCount();
-        if (ICJniUtils.getStepCount()>i){
-            i=ICJniUtils.getStepCount();
+        if (ICJniUtils.getStepCount() > i) {
+            i = ICJniUtils.getStepCount();
         }
         this.runtime.setSaveStepCount(j);
         this.runtime.setTotalStepCount(i);
         runtime.setLastStepCountForBT(runtime.getTotalStepCount());
         runtime.setLastStepCount(runtime.getTotalStepCount());
     }
-    public void saveStepCount(){
+
+    public void saveStepCount() {
         int i = runtime.getTotalStepCount();
         int j = runtime.getSaveStepCount();
         SharPreferenceUtil.setPrefInt(this, KEY_STEP_COUNT, i);
         SharPreferenceUtil.setPrefInt(this, KEY_SAVE_STEP_COUNT, j);
         //ICJniUtils.saveStepCount();
     }
+
     private void setCleanStepCountAlarm() {
         /*一天清零一次 计步*/
 //        AlarmHelper.setCleanStepCountAlarm(this, 23, 59, STEP_COUNT_ALARM_ACTION);
@@ -534,38 +537,39 @@ public class CoreService extends Service {
 
     private void setPracticeAlarm() {
 
-        ICLogger.i("setPracticeAlarm "+Runtime.practice_cycle+ " seconds!");
+        ICLogger.i("setPracticeAlarm " + Runtime.practice_cycle + " seconds!");
         //只有周期大于1才有效,否则就等于单次测量
-        if (Runtime.practice_cycle>1)
-            AlarmHelper.setRealTimeAlarmInSeconds(runtime.getContextProxy().context,Runtime.practice_cycle,Constants.ACTION_PRACTICE_REPORT_ALARM);
+        if (Runtime.practice_cycle > 1)
+            AlarmHelper.setRealTimeAlarmInSeconds(runtime.getContextProxy().context, Runtime.practice_cycle, Constants.ACTION_PRACTICE_REPORT_ALARM);
         mHandler.post(mdoPracticeCheck);
     }
-    private Runnable mdoPracticeCheck=new Runnable(){
+
+    private Runnable mdoPracticeCheck = new Runnable() {
         @Override
         public void run() {
             //获取并设置当前步数
-            ICLogger.i("自由锻炼中,设置步数 "+runtime.getTotalStepCount());
+            ICLogger.i("自由锻炼中,设置步数 " + runtime.getTotalStepCount());
             Runtime.healthInfo.setStepCount(runtime.getTotalStepCount());
             //开启定位
             //        locationClient.triggerLocationProcess();
             //开启测温
-            if(runtime.check_stat_do_temp_test())
+            if (runtime.check_stat_do_temp_test())
                 TemperatureUtil.DoTempTest();
 
             //开启测量PPG
-            if(runtime.check_stat_do_ppg_test())
+            if (runtime.check_stat_do_ppg_test())
                 HeartRateManager.triggerPPGtest();
 
         }
     };
 
-    private void checkconnection(){
+    private void checkconnection() {
 
-        if (!this.connection.isServerConnected())
-        {
+        if (!this.connection.isServerConnected()) {
             startConnectionRetryTimer();
         }
     }
+
     private void wakeUpFromSleep() {
         this.startAlarmCount = 0;
 //        alarmCycle = 1;
@@ -588,11 +592,13 @@ public class CoreService extends Service {
         Toast.makeText((this.runtime.getContextProxy()).context, "从深度睡眠中切换模式,联网中", Toast.LENGTH_SHORT).show();
     }
 
-    public int cmcm_call_eiot_into_powersave_mode() { return 0; }
+    public int cmcm_call_eiot_into_powersave_mode() {
+        return 0;
+    }
 
 
     public PowerManager.WakeLock getWakeLock(int paramInt) {
-         PowerManager.WakeLock wakeLock = ((PowerManager)(this.runtime.getContextProxy()).context.getSystemService(POWER_SERVICE)).newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, MY_WAKE_LOCKTAG);
+        PowerManager.WakeLock wakeLock = ((PowerManager) (this.runtime.getContextProxy()).context.getSystemService(POWER_SERVICE)).newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, MY_WAKE_LOCKTAG);
 //        wakeLock.acquire(paramInt*60*1000L);
         wakeLock.acquire(3000L);
         return wakeLock;
@@ -603,27 +609,29 @@ public class CoreService extends Service {
     }
 
 
-
-    public Runtime getRuntime(){
+    public Runtime getRuntime() {
         return runtime;
     }
-    public Connection getConnection(){
+
+    public Connection getConnection() {
         return connection;
     }
-    private static boolean server_starting=true;
+
+    private static boolean server_starting = true;
+
     @Override
     public void onCreate() {
 
-        server_starting=true;
+        server_starting = true;
         log("初始化网络协议服务");
-        mProtocolServer=this;
-        java.lang.Runtime.getRuntime().addShutdownHook(new Thread(){
+        mProtocolServer = this;
+        java.lang.Runtime.getRuntime().addShutdownHook(new Thread() {
             @Override
             public void run() {
                 super.run();
                 //设置断网状态
                 ICLogger.i("shutdown !");
-                Util.setSystemProperties("persist.sys.server_connected","false");
+                Util.setSystemProperties("persist.sys.server_connected", "false");
             }
         });
         this.runtime = new Runtime();
@@ -631,17 +639,16 @@ public class CoreService extends Service {
         this.runtime.setCacheDir(getExternalCacheDir());
         this.runtime.setDBHelper(new DBHelper(getContentResolver(), this));
         this.runtime.setContextProxy(new ContextProxy(this));
-        this.runtime.setLbsHelper(new LBSHelper(this,this.runtime.getContextProxy().getWifiManager(), this.runtime));
+        this.runtime.setLbsHelper(new LBSHelper(this, this.runtime.getContextProxy().getWifiManager(), this.runtime));
 
         this.runtime.setHRS(new heartRateStatus());
         this.runtime.setUseQueue(true);
         this.runtime.initDnsUtil(ICApplication.getInstance().getApplicationContext());
 
 
-        if (Config.protocol_no==Config.PROTOCOL_MQTT)
-        {
+        if (Config.protocol_no == Config.PROTOCOL_MQTT) {
             connection = new mqttConnection(new ServerHandler(this), runtime);
-        }else {
+        } else {
             connection = new NettyConnection(new ServerHandler(this), runtime);
         }
         this.connectionServiceChain = getConnectionServiceChain();
@@ -651,12 +658,12 @@ public class CoreService extends Service {
 //            return;
 //        }
 
-        smsManager= new ICSmsManager(runtime);
+        smsManager = new ICSmsManager(runtime);
 
         //保证获取正确的计步数据及其他参数初始化
         loadStepCount();
 
-        if (Config.logBootDate(this)){
+        if (Config.logBootDate(this)) {
             resetStepCount();
         }
 
@@ -665,8 +672,8 @@ public class CoreService extends Service {
         Config.LoadMessageConfigs();
 
         if (Config.custom_name.equals("H88")) {
-            Config.ConfigAlarm(Runtime.AlarmType.ALARM_ANTIOFF,true);
-            Config.ConfigAlarm(Runtime.AlarmType.ALARM_WEARED,true);
+            Config.ConfigAlarm(Runtime.AlarmType.ALARM_ANTIOFF, true);
+            Config.ConfigAlarm(Runtime.AlarmType.ALARM_WEARED, true);
             if (Config.getConfigInitFlag(this) == 0) {
                 Config.setLocationMode(this, CUSTOM_MOD8_GPS);
                 Config.setLocationCycle(this, 3600);
@@ -674,10 +681,10 @@ public class CoreService extends Service {
                 Config.setTemperatureTestCycle(runtime, 60 * 60);
                 Config.setConfigInitFlag(this, 1);
             }
-        }else if (Config.custom_name.equals("l004")) {
-            Config.ConfigAlarm(Runtime.AlarmType.ALARM_CUTOFF,true);
-            Config.ConfigAlarm(Runtime.AlarmType.ALARM_ILLEGAL_CUTOFF,true);
-            Config.ConfigAlarm(Runtime.AlarmType.ALARM_LOCK_WATCH,true);
+        } else if (Config.custom_name.equals("l004")) {
+            Config.ConfigAlarm(Runtime.AlarmType.ALARM_CUTOFF, true);
+            Config.ConfigAlarm(Runtime.AlarmType.ALARM_ILLEGAL_CUTOFF, true);
+            Config.ConfigAlarm(Runtime.AlarmType.ALARM_LOCK_WATCH, true);
 
             if (Config.getConfigInitFlag(this) == 0) {
                 Config.setLocationMode(this, CUSTOM_MOD8_GPS);
@@ -687,32 +694,32 @@ public class CoreService extends Service {
                 Config.setConfigInitFlag(this, 1);
 
             }
-        }else if (Config.custom_name.equals("YQ") || Config.custom_name.equals("YQ_EN")) {
-            Config.ConfigAlarm(Runtime.AlarmType.ALARM_CUTOFF,true);
-            Config.ConfigAlarm(Runtime.AlarmType.ALARM_ILLEGAL_CUTOFF,true);
-            Config.ConfigAlarm(Runtime.AlarmType.ALARM_LOCK_WATCH,true);
-            Config.ConfigAlarm(Runtime.AlarmType.ALARM_WEARED,true);
-            Config.ConfigAlarm(Runtime.AlarmType.ALARM_ANTIOFF,true);
-            Config.ConfigAlarm(Runtime.AlarmType.ALARM_UNREADMSG,true);
-            Config.ConfigAlarm(Runtime.AlarmType.ALARM_MSGREAD,true);
+        } else if (Config.custom_name.equals("YQ") || Config.custom_name.equals("YQ_EN")) {
+            Config.ConfigAlarm(Runtime.AlarmType.ALARM_CUTOFF, true);
+            Config.ConfigAlarm(Runtime.AlarmType.ALARM_ILLEGAL_CUTOFF, true);
+            Config.ConfigAlarm(Runtime.AlarmType.ALARM_LOCK_WATCH, true);
+            Config.ConfigAlarm(Runtime.AlarmType.ALARM_WEARED, true);
+            Config.ConfigAlarm(Runtime.AlarmType.ALARM_ANTIOFF, true);
+            Config.ConfigAlarm(Runtime.AlarmType.ALARM_UNREADMSG, true);
+            Config.ConfigAlarm(Runtime.AlarmType.ALARM_MSGREAD, true);
 
             if (Config.getConfigInitFlag(this) == 0) {
                 Config.setLocationMode(this, NORMAL_MOD);
-                Config.setLocationCycle(this, 15*60);
+                Config.setLocationCycle(this, 15 * 60);
                 Config.setPPGTestCycle(this, 0);
                 Config.setTemperatureTestCycle(runtime, 0);
                 Config.setConfigInitFlag(this, 1);
 
             }
-        }else if (Config.custom_name.equals("AK")) {
+        } else if (Config.custom_name.equals("AK")) {
 
-            Config.ConfigAlarm(Runtime.AlarmType.ALARM_SOS,true);
-            Config.ConfigAlarm(Runtime.AlarmType.ALARM_LOWBATTERY,true);
-            Config.ConfigAlarm(Runtime.AlarmType.ALARM_WEARED,true);
-            Config.ConfigAlarm(Runtime.AlarmType.ALARM_ANTIOFF,true);
-            Config.enableSleep=true;
+            Config.ConfigAlarm(Runtime.AlarmType.ALARM_SOS, true);
+            Config.ConfigAlarm(Runtime.AlarmType.ALARM_LOWBATTERY, true);
+            Config.ConfigAlarm(Runtime.AlarmType.ALARM_WEARED, true);
+            Config.ConfigAlarm(Runtime.AlarmType.ALARM_ANTIOFF, true);
+            Config.enableSleep = true;
 
-            if (Config.getConfigInitFlag(this)==0) {
+            if (Config.getConfigInitFlag(this) == 0) {
                 Config.setPPGTestCycle(this, 0);
                 Config.setTemperatureTestCycle(runtime, 0);
                 Config.setConfigInitFlag(this, 1);
@@ -726,38 +733,38 @@ public class CoreService extends Service {
 //                    runtime.getDbHelper().saveContacts(contactArray,false,false,false,false,false,true);
 //                }
             }
-        }else if (Config.custom_name.equals("YT")) {
+        } else if (Config.custom_name.equals("YT")) {
 
-            Config.ConfigAlarm(Runtime.AlarmType.ALARM_SOS,true);
-            Config.ConfigAlarm(Runtime.AlarmType.ALARM_LOWBATTERY,true);
-            Config.ConfigAlarm(Runtime.AlarmType.ALARM_WEARED,true);
-            Config.ConfigAlarm(Runtime.AlarmType.ALARM_ANTIOFF,true);
-            Config.enableSleep=true;
+            Config.ConfigAlarm(Runtime.AlarmType.ALARM_SOS, true);
+            Config.ConfigAlarm(Runtime.AlarmType.ALARM_LOWBATTERY, true);
+            Config.ConfigAlarm(Runtime.AlarmType.ALARM_WEARED, true);
+            Config.ConfigAlarm(Runtime.AlarmType.ALARM_ANTIOFF, true);
+            Config.enableSleep = true;
 
-            if (Config.getConfigInitFlag(this)==0) {
+            if (Config.getConfigInitFlag(this) == 0) {
                 Config.setPPGTestCycle(this, 0);
                 Config.setTemperatureTestCycle(runtime, 0);
                 Config.setConfigInitFlag(this, 1);
 
-                int contactcount=runtime.getDbHelper().getContactCount(getContentResolver());
-                ICLogger.i("=====Contact count "+contactcount);
-                if(contactcount==0){ //如果没有SOS
+                int contactcount = runtime.getDbHelper().getContactCount(getContentResolver());
+                ICLogger.i("=====Contact count " + contactcount);
+                if (contactcount == 0) { //如果没有SOS
                     ICLogger.i("=====add hotline 96885 ");
-                    ArrayList<Contact> contactArray=new ArrayList<Contact>();
+                    ArrayList<Contact> contactArray = new ArrayList<Contact>();
                     contactArray.add(new Contact(Contact.CATEGORY_CALL, this.getResources().getString(R.string.hotline), "96885"));
-                    runtime.getDbHelper().saveContacts(contactArray,false,false,false,false,false,true);
+                    runtime.getDbHelper().saveContacts(contactArray, false, false, false, false, false, true);
                 }
             }
-        }else if (Config.custom_name.equals("SGL")) { //C5项目
-            Config.ConfigAlarm(Runtime.AlarmType.ALARM_ESCAPE,true);
-            Config.ConfigAlarm(Runtime.AlarmType.ALARM_CUTOFF,true);
-            Config.ConfigAlarm(Runtime.AlarmType.ALARM_ILLEGAL_CUTOFF,true);
-            Config.ConfigAlarm(Runtime.AlarmType.ALARM_LOCK_WATCH,true);
+        } else if (Config.custom_name.equals("SGL")) { //C5项目
+            Config.ConfigAlarm(Runtime.AlarmType.ALARM_ESCAPE, true);
+            Config.ConfigAlarm(Runtime.AlarmType.ALARM_CUTOFF, true);
+            Config.ConfigAlarm(Runtime.AlarmType.ALARM_ILLEGAL_CUTOFF, true);
+            Config.ConfigAlarm(Runtime.AlarmType.ALARM_LOCK_WATCH, true);
             Config.forceMoveCheck = false; //对定位不进行运动检测。
-            if (Config.getConfigInitFlag(this)==0) {
+            if (Config.getConfigInitFlag(this) == 0) {
                 Config.setLocationMode(this, CUSTOM_MOD8_GPS);
 //                Config.setLocationMode(this, CUSTOM_MOD8_WIFI);
-                Config.setLocationCycle(this, 5*60);
+                Config.setLocationCycle(this, 5 * 60);
                 Config.setPPGTestCycle(this, 0);
                 Config.setTemperatureTestCycle(runtime, 0);
                 Config.setConfigInitFlag(this, 1);
@@ -771,11 +778,14 @@ public class CoreService extends Service {
 //                    runtime.getDbHelper().saveContacts(contactArray,false,false,false,false,false,true);
 //                }
             }
-        }else if (Config.custom_name.equals("L02") || Config.custom_name.equals("L03")||Config.custom_name.equals("L05")) { //L02
+        } else if (Config.custom_name.equals("L02") ||
+                Config.custom_name.equals("L03")
+                || Config.custom_name.equals("L05")
+                || Config.custom_name.equals("CH")) { //L02
             Config.forceMoveCheck = false; //即爱对gps不进行运动检测,此变量专门为了给其他协议进行强制运动检测用的。
-            Config.ConfigAlarm(Runtime.AlarmType.ALARM_SOS,true);
-            Config.ConfigAlarm(Runtime.AlarmType.ALARM_LOWBATTERY,true);
-            Config.ConfigAlarm(Runtime.AlarmType.ALARM_FALL,true);
+            Config.ConfigAlarm(Runtime.AlarmType.ALARM_SOS, true);
+            Config.ConfigAlarm(Runtime.AlarmType.ALARM_LOWBATTERY, true);
+            Config.ConfigAlarm(Runtime.AlarmType.ALARM_FALL, true);
 
             if (Config.getConfigInitFlag(this) == 0) {
                 Config.setPPGTestCycle(this, 0);
@@ -783,24 +793,24 @@ public class CoreService extends Service {
                 Config.setConfigInitFlag(this, 1);
             }
 
-        }else if (Config.custom_name.equals("VitracK")){
+        } else if (Config.custom_name.equals("VitracK")) {
 
-            Config.ConfigAlarm(Runtime.AlarmType.ALARM_SOS,true);
-            Config.ConfigAlarm(Runtime.AlarmType.ALARM_LOWBATTERY,true);
-            Config.ConfigAlarm(Runtime.AlarmType.ALARM_WEARED,true);
-            Config.ConfigAlarm(Runtime.AlarmType.ALARM_ANTIOFF,true);
-            Config.enableSleep=false;
-            if (Config.getConfigInitFlag(this)==0) {
+            Config.ConfigAlarm(Runtime.AlarmType.ALARM_SOS, true);
+            Config.ConfigAlarm(Runtime.AlarmType.ALARM_LOWBATTERY, true);
+            Config.ConfigAlarm(Runtime.AlarmType.ALARM_WEARED, true);
+            Config.ConfigAlarm(Runtime.AlarmType.ALARM_ANTIOFF, true);
+            Config.enableSleep = false;
+            if (Config.getConfigInitFlag(this) == 0) {
                 Config.setLocationMode(this, CUSTOM_MOD8_GPS);
-                Config.setLocationCycle(this, 30*60);
+                Config.setLocationCycle(this, 30 * 60);
                 Config.setPPGTestCycle(this, 0);
                 Config.setTemperatureTestCycle(runtime, 0);
                 Config.setConfigInitFlag(this, 1);
             }
 
-        }else{
+        } else {
 
-            if (Config.getConfigInitFlag(this)==0) {
+            if (Config.getConfigInitFlag(this) == 0) {
                 Config.setPPGTestCycle(this, 0);
                 Config.setTemperatureTestCycle(runtime, 0);
                 Config.setConfigInitFlag(this, 1);
@@ -813,8 +823,7 @@ public class CoreService extends Service {
         runtime.setNeedAntioff(Config.getNeedAntiOff(this));
 
 
-
-        Config.setHeartBeatCycle(this,alarmCycle); //临时设置为5分钟,给L03测试用。测试断线问题未解决,取消测试。
+        Config.setHeartBeatCycle(this, alarmCycle); //临时设置为5分钟,给L03测试用。测试断线问题未解决,取消测试。
         //初始化ServerHeartBeat Cycle
         Config.loadHearBeatSetting(runtime);
         //初始化PPG,LocationMod,LocationCycle
@@ -826,7 +835,7 @@ public class CoreService extends Service {
         //读取Alarm环境配置,项目不需要的Alarm不要发送, 目前环境变量配置优先。默认值会被覆盖。
         Config.loadAlarmConfig();
 
-        Config.enable_NTP_Server(this,!Config.disable_ntp_server);
+        Config.enable_NTP_Server(this, !Config.disable_ntp_server);
 
 
         //初始化温度测试相关参数
@@ -835,7 +844,7 @@ public class CoreService extends Service {
 
 
         //加载存储的健康数据校准值
-        Config.loadPPG_BPH_BPL_SPO2_adjustvalue(this,runtime);
+        Config.loadPPG_BPH_BPL_SPO2_adjustvalue(this, runtime);
 
         this.connectionServiceChain.processAttach(this.connection, this.runtime);
         this.invokeHandlerServiceChain.processAttach(this.connection, this.runtime);
@@ -883,35 +892,35 @@ public class CoreService extends Service {
         intentFilter.addAction(ACTION_QUERY_WEATHER);
         intentFilter.addAction(ACTION_SEND_EMEGENCY_LOCATION_START);
         intentFilter.addAction(ACTION_LOCAL_SOS_ACTION);
-        registerReceiver(broadcastSOSReceiver,intentFilter);
+        registerReceiver(broadcastSOSReceiver, intentFilter);
 
         //添加自由锻炼 接收
         intentFilter = new IntentFilter();
         intentFilter.addAction(Constants.ACTION_START_PRACTISE);
-        registerReceiver(broadcastPracticeCMDReceiver,intentFilter);
+        registerReceiver(broadcastPracticeCMDReceiver, intentFilter);
 
         //初始化Sim信号
         this.mSignalUtil = SimSignalUtil.getInstance(this);
 
         //初始化 电池电量监控工具(内部注册接收电池变化)
-        batteryUtil = new BatteryUtil(this.runtime,connection);
+        batteryUtil = new BatteryUtil(this.runtime, connection);
 
         //保证发送心跳时提前获取BatLevel数据
-        int batlevel=batteryUtil.getBatteryLevel(this);
-        runtime.setBattery(String.format("%03d",batlevel));
+        int batlevel = batteryUtil.getBatteryLevel(this);
+        runtime.setBattery(String.format("%03d", batlevel));
         runtime.setBattery(batlevel);
-        ICLogger.i("Battery get from api "+batlevel);
+        ICLogger.i("Battery get from api " + batlevel);
 
 
         boolean charging = batteryUtil.isPowerConnected(this);
         runtime.setPowerConnected(charging);
-        ICLogger.i("Charging  "+charging);
+        ICLogger.i("Charging  " + charging);
 //        LedUtil.setRedLedOn(false);
-        if (Config.isL03Tracker){
+        if (Config.isL03Tracker) {
 
-            if (runtime.isPowerConnected())         {
+            if (runtime.isPowerConnected()) {
                 LedUtil.setRedLedOn(true);
-            }else{
+            } else {
                 LedUtil.setRedLedOn(false);
             }
         }
@@ -940,7 +949,7 @@ public class CoreService extends Service {
 
 
         //获取定位时间
-        needLocateInAfterHeartBeat=true;
+        needLocateInAfterHeartBeat = true;
         setLocationAlarm(runtime.getLocationInstance().getWorkingMod());
 
         //设置温度测量间隔时间
@@ -949,36 +958,35 @@ public class CoreService extends Service {
 
 
         //初始化佩戴检测
-        runtime.anti_test_cycle=Config.getCheckAntiPolingCycle(this);
-        if( runtime.anti_test_cycle>0){
-         //   setAntiAlarm();
+        runtime.anti_test_cycle = Config.getCheckAntiPolingCycle(this);
+        if (runtime.anti_test_cycle > 0) {
+            //   setAntiAlarm();
         }
 
         //初始化蓝牙检测
-        runtime.bleInfo.bleScanCycle=Config.getBleScanCycle(this);
-        if(Config.BLEScanProtocol==1 && runtime.bleInfo.bleScanCycle>0)
-        {
+        runtime.bleInfo.bleScanCycle = Config.getBleScanCycle(this);
+        if (Config.BLEScanProtocol == 1 && runtime.bleInfo.bleScanCycle > 0) {
 
             setBleScanAlarm(runtime.bleInfo.bleScanCycle);
         }
 
         //设置来电模式
-        Util.SetRingMode(this, AudioManager.RINGER_MODE_NORMAL,true);
+        Util.SetRingMode(this, AudioManager.RINGER_MODE_NORMAL, true);
 
         //备份DB数据到sd cache目录,为调试方便
         Util.getDBFile();
 //        test(); //test function
 
- //更新MCC MNC
+        //更新MCC MNC
         CellInfoUtil.setCurrentAttachCellInfo(CoreService.getInstance().runtime);
- //更新IMEI
+        //更新IMEI
         DeviceInfoUtil.updateImei(runtime);
 
         //设置断网状态
-        Util.setSystemProperties("persist.sys.server_connected","false");
+        Util.setSystemProperties("persist.sys.server_connected", "false");
 
         //启动结束设置标志位,让心率和体温检测可以正常执行。
-        server_starting=false;
+        server_starting = false;
 
         //重置缓存中的在等待命令
         Deliver.resetCMDReocrdsDB();
@@ -986,45 +994,46 @@ public class CoreService extends Service {
         ReConnectToServer();
     }
 
-    private void test(){
+    private void test() {
 
         ICLogger.i("周一清除所有睡眠数据Record");
         runtime.getDbHelper().deleteSleepData();
     }
 
     //检查是否有未读消息需要提醒
-    private  void checkUnreadMessage(){
+    private void checkUnreadMessage() {
 
-        String msg=Config.getLastUnReadMessage(this);
-        Util.checkMesageNeedNotifi(msg,runtime);
+        String msg = Config.getLastUnReadMessage(this);
+        Util.checkMesageNeedNotifi(msg, runtime);
 
 
     }
 
     //内部广播StringMessage
-    public static void DevliverStringMessage(String cmd){
-        CoreService.getInstance().connection.DeliverCMDMessageToSystem(cmd,"");
+    public static void DevliverStringMessage(String cmd) {
+        CoreService.getInstance().connection.DeliverCMDMessageToSystem(cmd, "");
     }
+
     //内部广播StringMessage
-    public static void DevliverStringMessage(String cmd,String str){
-        CoreService.getInstance().connection.DeliverCMDMessageToSystem(cmd,str);
+    public static void DevliverStringMessage(String cmd, String str) {
+        CoreService.getInstance().connection.DeliverCMDMessageToSystem(cmd, str);
     }
 
     //表带剪断检测报警,此处只是设备本地提醒,并不发送报警信息给服务器。
-    public void checkAlarmMessage(){
+    public void checkAlarmMessage() {
 
 
-        if (runtime.Fence_Warning_flag>0 &&  Config.needAllwaysAlarmFenceOut){
+        if (runtime.Fence_Warning_flag > 0 && Config.needAllwaysAlarmFenceOut) {
             runtime.Fence_Warning_flag++;
             WakeLockUtil.ScreenOnWakeLockTemperary(runtime.getContextProxy().context);
-            runtime.getContextProxy().sendMsgBroadcast(runtime.getContextProxy().context.getResources().getString(R.string.alarm_out_wall),2);
+            runtime.getContextProxy().sendMsgBroadcast(runtime.getContextProxy().context.getResources().getString(R.string.alarm_out_wall), 2);
         }
-        if(runtime.Cut_off_flag>0 && Config.needAllwaysAlarmCutOff){
+        if (runtime.Cut_off_flag > 0 && Config.needAllwaysAlarmCutOff) {
             runtime.Cut_off_flag++;
 //            WakeLockUtil.ScreenOnWakeLockTemperary(runtime.getContextProxy().context);
 
             if (Config.A9_noBroadCastActionStrip) {
-                if(Config.needBroadcastCutoffAlarm) {
+                if (Config.needBroadcastCutoffAlarm) {
                     antiservice.send_cutoff_event_broadcast(1);
                 }
 
@@ -1034,21 +1043,21 @@ public class CoreService extends Service {
     }
 
     //检测久坐提醒
-    public void checkKeepSitting(){
-        String dateyyyyMMDDhhmmss=TimeUtil.getSystemTime3();
+    public void checkKeepSitting() {
+        String dateyyyyMMDDhhmmss = TimeUtil.getSystemTime3();
         //为了更新 isInSleepRange, 下面的语句必须执行
         TimeUtil.getCurrentSleepRecordDate(dateyyyyMMDDhhmmss);
-         if(TimeUtil.isInSleepRange == false) { //不在睡眠时间就是久坐时间段。
-             if (Runtime.lastSitCheckStepCount == -1){
-                 Runtime.lastSitCheckStepCount=runtime.getTotalStepCount();
-                 Runtime.lastSitCheckTiimeyyyyMMddHHmmss=TimeUtil.getSystemTime3();
-             }
-             int keepsitRange=Config.getKeepSitRangeInMinutes(this);
-             int minutes=(int)TimeUtil.diffBetween2DateInMinutes(Runtime.lastSitCheckTiimeyyyyMMddHHmmss,dateyyyyMMDDhhmmss);
-             ICLogger.i("SitCheck last SitCheckTime "+ Runtime.lastSitCheckTiimeyyyyMMddHHmmss + " , current checktime "+dateyyyyMMDDhhmmss);
-             ICLogger.i("SitCheck minutes "+ minutes + " , keepsitRange "+keepsitRange);
-             if (minutes >=keepsitRange && keepsitRange>0){
-                if ( (runtime.getTotalStepCount() - Runtime.lastSitCheckStepCount)/minutes < Config.KeepSitJudgementRefValue){
+        if (TimeUtil.isInSleepRange == false) { //不在睡眠时间就是久坐时间段。
+            if (Runtime.lastSitCheckStepCount == -1) {
+                Runtime.lastSitCheckStepCount = runtime.getTotalStepCount();
+                Runtime.lastSitCheckTiimeyyyyMMddHHmmss = TimeUtil.getSystemTime3();
+            }
+            int keepsitRange = Config.getKeepSitRangeInMinutes(this);
+            int minutes = (int) TimeUtil.diffBetween2DateInMinutes(Runtime.lastSitCheckTiimeyyyyMMddHHmmss, dateyyyyMMDDhhmmss);
+            ICLogger.i("SitCheck last SitCheckTime " + Runtime.lastSitCheckTiimeyyyyMMddHHmmss + " , current checktime " + dateyyyyMMDDhhmmss);
+            ICLogger.i("SitCheck minutes " + minutes + " , keepsitRange " + keepsitRange);
+            if (minutes >= keepsitRange && keepsitRange > 0) {
+                if ((runtime.getTotalStepCount() - Runtime.lastSitCheckStepCount) / minutes < Config.KeepSitJudgementRefValue) {
                     //平均 每分钟活动数 小于参考久坐计步值,表示久坐
                     ICLogger.i("SitCheck 平均 每分钟活动数 小于参考久坐计步值,表示久坐");
                     WakeLockUtil.ScreenOnWakeLockTemperary(this);
@@ -1058,50 +1067,50 @@ public class CoreService extends Service {
 
 
                     //提醒后 重置 lastCheckSitTime 以及 lastSitCheckStepCount , 重新计时
-                    Runtime.lastSitCheckStepCount=runtime.getTotalStepCount();
-                    Runtime.lastSitCheckTiimeyyyyMMddHHmmss=TimeUtil.getSystemTime3();
+                    Runtime.lastSitCheckStepCount = runtime.getTotalStepCount();
+                    Runtime.lastSitCheckTiimeyyyyMMddHHmmss = TimeUtil.getSystemTime3();
 
-                    if(Config.isAlarmTypeEnabled(Runtime.AlarmType.ALARM_SEDENTARY)){
+                    if (Config.isAlarmTypeEnabled(Runtime.AlarmType.ALARM_SEDENTARY)) {
                         runtime.setAlarmType(Runtime.AlarmType.ALARM_SEDENTARY);
 //                        Deliver.sendLocationMSG(protocolAPIHelper.getWarningMSG(runtime));
                         ICLogger.i("triggerSOSLocationProcess ");
                         locationClient.triggerSOSLocationProcess();
                     }
-                }else{
+                } else {
                     //只要 平均每分钟活动数大于参考值,则重置 lastCheckSitTime 以及 lastSitCheckStepCount
                     ICLogger.i("SitCheck 平均每分钟活动数大于参考值,则重置 lastCheckSitTime 以及 lastSitCheckStepCount");
-                    Runtime.lastSitCheckStepCount=runtime.getTotalStepCount();
-                    Runtime.lastSitCheckTiimeyyyyMMddHHmmss=TimeUtil.getSystemTime3();
+                    Runtime.lastSitCheckStepCount = runtime.getTotalStepCount();
+                    Runtime.lastSitCheckTiimeyyyyMMddHHmmss = TimeUtil.getSystemTime3();
                 }
             }
-        }else{
-             Runtime.lastSitCheckStepCount=-1; //不在时间段就重置数据,以便下一次使用能过重新开始计数。
+        } else {
+            Runtime.lastSitCheckStepCount = -1; //不在时间段就重置数据,以便下一次使用能过重新开始计数。
         }
 
 
     }
 
-    public void updateSleepDate(){
-        String dateyyyyMMDDhhmmss=TimeUtil.getSystemTime3();
-        String sleepdate=TimeUtil.getCurrentSleepRecordDate(dateyyyyMMDDhhmmss);
-        ICLogger.i("updateSleepDate "+sleepdate);
-        if(TimeUtil.isInSleepRange == true) {
-            runtime.getDbHelper().insertSleepRecord(new SleepRecord(dateyyyyMMDDhhmmss,sleepdate,runtime.getTotalStepCount()));
-            runtime.sleepDataReported=false; //只要记录过数据 就证明有数据没有report
-        }else{
+    public void updateSleepDate() {
+        String dateyyyyMMDDhhmmss = TimeUtil.getSystemTime3();
+        String sleepdate = TimeUtil.getCurrentSleepRecordDate(dateyyyyMMDDhhmmss);
+        ICLogger.i("updateSleepDate " + sleepdate);
+        if (TimeUtil.isInSleepRange == true) {
+            runtime.getDbHelper().insertSleepRecord(new SleepRecord(dateyyyyMMDDhhmmss, sleepdate, runtime.getTotalStepCount()));
+            runtime.sleepDataReported = false; //只要记录过数据 就证明有数据没有report
+        } else {
             if (runtime.sleepDataReported == false) {
                 //calculate sleep data and report it randomly within 1 hour
                 runtime.sleepDataReported = true;
                 int score = runtime.getDbHelper().querySleepScore(sleepdate);
                 if (score > 0) {
-                    ICLogger.i("已经有"+sleepdate+"的睡眠数据!");
+                    ICLogger.i("已经有" + sleepdate + "的睡眠数据!");
                 } else {
                     SleepInfo si = SleepInfo.getInstance();
                     si.setDate(sleepdate);
                     si.calculate_sleepInfo(runtime);
 
                     runtime.getDbHelper().updateSleepInfo(si);
-                    if (TimeUtil.getWeek().equals("周一")){
+                    if (TimeUtil.getWeek().equals("周一")) {
                         ICLogger.i("周一清除所有睡眠数据Record");
                         runtime.getDbHelper().deleteSleepData();
                     }
@@ -1117,16 +1126,16 @@ public class CoreService extends Service {
 //                    Observable.timer(randomint * 60 * 1000L, TimeUnit.MILLISECONDS).subscribe(new Action1<Long>() {
 //                        public void call(Long param1Long) {
 //                        connection.send(protocolAPIHelper);
-                            ICLogger.i("Send  sleep info " + si.getCurrentDate()
-                                    + " deep " + si.getDeepsleep_minutes()
-                                    + " light " + si.getLightsleep_minutes()
-                                    + " score " + si.getScore()
-                            );
-                            if (Config.enableSleep) {
-                                Deliver.sendLocationMSG(protocolAPIHelper.getSleepMSG(SleepInfo.getInstance(), runtime));
-                            }else{
-                                ICLogger.i(" 没有开启睡眠协议,skip send message!");
-                            }
+                    ICLogger.i("Send  sleep info " + si.getCurrentDate()
+                            + " deep " + si.getDeepsleep_minutes()
+                            + " light " + si.getLightsleep_minutes()
+                            + " score " + si.getScore()
+                    );
+                    if (Config.enableSleep) {
+                        Deliver.sendLocationMSG(protocolAPIHelper.getSleepMSG(SleepInfo.getInstance(), runtime));
+                    } else {
+                        ICLogger.i(" 没有开启睡眠协议,skip send message!");
+                    }
 //                        }
 //                    });
 
@@ -1134,8 +1143,9 @@ public class CoreService extends Service {
             }
         }
     }
+
     public int onStartCommand(Intent paramIntent, int paramInt1, int paramInt2) {
-        if (paramIntent != null && paramIntent.getAction()!=null) {
+        if (paramIntent != null && paramIntent.getAction() != null) {
             StringBuilder stringBuilder = new StringBuilder();
             stringBuilder.append("onStartCommand action=");
             stringBuilder.append(paramIntent.getAction());
@@ -1184,7 +1194,7 @@ public class CoreService extends Service {
                 if (Config.LOG_TOFILE)
                     ICLogger.logToFile("alarmCycle", "HEART_ALARM alarmCycle  ");
                 return Service.START_STICKY;
-            }else if (ACTION_LOCATION_ALARM.equals(paramIntent.getAction())) {
+            } else if (ACTION_LOCATION_ALARM.equals(paramIntent.getAction())) {
 
 
 //                    if (cmcm_call_eiot_into_powersave_mode() == 1) {
@@ -1223,29 +1233,29 @@ public class CoreService extends Service {
                 if (Config.LOG_TOFILE) ICLogger.logToFile("alarmCycle", stringBuilder1.toString());
 //                this.locationClient.triggerLocationProcess();
 
-            }else if (Constants.OTHER_ALARM_END.equals(paramIntent.getAction())) {
+            } else if (Constants.OTHER_ALARM_END.equals(paramIntent.getAction())) {
                 ICLogger.i("OTHER_ALARM_END set Ringmode Normal vib true");
-               SilentManager.setSilentConfig(this,false);
-            }else if (Constants.OTHER_ALARM_START.equals(paramIntent.getAction())) {
+                SilentManager.setSilentConfig(this, false);
+            } else if (Constants.OTHER_ALARM_START.equals(paramIntent.getAction())) {
                 ICLogger.i("OTHER_ALARM_START set Ringmode Silent vib false");
-                SilentManager.setSilentConfig(this,true);
-            }else if (Constants.ACTION_ALARM_BLE_SCAN.equals(paramIntent.getAction())) {
-                    //循环蓝牙扫描
+                SilentManager.setSilentConfig(this, true);
+            } else if (Constants.ACTION_ALARM_BLE_SCAN.equals(paramIntent.getAction())) {
+                //循环蓝牙扫描
                 setBleScanAlarm(runtime.bleInfo.bleScanCycle);
 
-            }else if (Constants.ACTION_PRACTICE_REPORT_ALARM.equals(paramIntent.getAction())) {
+            } else if (Constants.ACTION_PRACTICE_REPORT_ALARM.equals(paramIntent.getAction())) {
                 //alarm是延迟的,所以这个判断主要是给最后一次可能无效的测量
-                if (Runtime.practising==true) {
+                if (Runtime.practising == true) {
                     //开始下一轮健康测量
                     setPracticeAlarm();
                 }
-            }else if (Constants.ACTION_CHECK_SERVER_RESPONSE.equals(paramIntent.getAction())) {
+            } else if (Constants.ACTION_CHECK_SERVER_RESPONSE.equals(paramIntent.getAction())) {
                 //暂时还使用 ScheduledThreadPoolExecutor , 时间要求不是那么的严格
-            }else if (Constants.ACTION_RETRY_SERVER_CONNECT.equals(paramIntent.getAction())) {
+            } else if (Constants.ACTION_RETRY_SERVER_CONNECT.equals(paramIntent.getAction())) {
                 //暂时还使用 ScheduledThreadPoolExecutor , 时间要求不是那么的严格
-            }else if (Constants.ACTION_CHECK_LOCATION_RESULT.equals(paramIntent.getAction())) {
+            } else if (Constants.ACTION_CHECK_LOCATION_RESULT.equals(paramIntent.getAction())) {
                 locationClient.waitAndSendLocation();
-            }else if (Constants.SLEEP_ALARM.equals(paramIntent.getAction())) {
+            } else if (Constants.SLEEP_ALARM.equals(paramIntent.getAction())) {
                 StringBuilder stringBuilder1;
                 ICLogger.i("SLEEP_ALARM");
                 is_allowed_in_sleep_mode = 1;
@@ -1293,7 +1303,7 @@ public class CoreService extends Service {
 
                 setTempAlarm();
 
-               return Service.START_STICKY;
+                return Service.START_STICKY;
             } else if (STEP_COUNT_ALARM_ACTION.equals(paramIntent.getAction())) {
                 ICLogger.i("Reset Count At 00:00 ");
                 //update stepCount and broadcast before reset
@@ -1304,7 +1314,7 @@ public class CoreService extends Service {
                 //更新 运动控制的上次步数 然后再resetstecount
                 //runtime.setLastStepCount(runtime.getTotalStepCount()-runtime.getLastStepCount());
                 //runtime.setLastStepCountForBT(runtime.getTotalStepCount()-runtime.getLastStepCountForBT());
-                 resetStepCount();
+                resetStepCount();
                 //此处本来应该把刚刚reset前运动的步数设置到计步器里,继续开始计步。
                 // 由于计步接口没有提供设置步数。所以暂时只能清零,不能解决午夜还在运动的情况,会丢失一两次的数据。但是影响不大
                 runtime.setLastStepCountForBT(0);
@@ -1324,11 +1334,11 @@ public class CoreService extends Service {
                 //此消息来源于BroadCaset,收到开始测试的消息。
                 //此时需要重置HeartRateDetect Timer
                 //倘若有 参数 PPGTestCycle,则根据这个数值进行设置
-                int ppgtestCycle=paramIntent.getIntExtra("PPGTestCycle",-1);
-                if (ppgtestCycle >0){
-                    Config.setPPGTestCycle(runtime.getContextProxy().context,ppgtestCycle);
+                int ppgtestCycle = paramIntent.getIntExtra("PPGTestCycle", -1);
+                if (ppgtestCycle > 0) {
+                    Config.setPPGTestCycle(runtime.getContextProxy().context, ppgtestCycle);
                     runtime.setPpgTestCycle(Config.getPPGTestCycle(runtime.getContextProxy().context));
-                    ICLogger.i("get and set PPGTestCycle "+ppgtestCycle);
+                    ICLogger.i("get and set PPGTestCycle " + ppgtestCycle);
                 }
                 setHeartRateDetectAlarm(runtime.getPpgTestCycle());//重置心率检测周期,并触发一次检测
 
@@ -1338,7 +1348,7 @@ public class CoreService extends Service {
                 LocationClient.setForceLocation(1);
                 setLocationAlarm(runtime.getLocationInstance().getWorkingMod());//同时重置alarm并触发定位
 
-            }else if(ACTION_CHECK_ANTIOFF_EVENT.equals(paramIntent.getAction())){
+            } else if (ACTION_CHECK_ANTIOFF_EVENT.equals(paramIntent.getAction())) {
                 //只在中断式检测过程中延时用
                 antiservice.check_ant_event();
             }
@@ -1349,93 +1359,96 @@ public class CoreService extends Service {
         return Service.START_NOT_STICKY;
     }
 
-    public boolean onUnbind(Intent paramIntent) { return false; }
+    public boolean onUnbind(Intent paramIntent) {
+        return false;
+    }
 
     //每一分钟设置一次
     public void setAlarm(int paramInt) {
 //        AlarmHelper.setRealTimeAlarm(runtime.getContextProxy().context,paramInt,ACTION_ALARM);
     }
 
-    public void setHeartRateDetectAlarm(int heartRateDetectAlarmCycle){
+    public void setHeartRateDetectAlarm(int heartRateDetectAlarmCycle) {
         if (Config.noPPGSensor) {
             ICLogger.i("setHeartRateDetectAlarm oPPGSensor");
             return;
         }
-        StringBuilder sb=new StringBuilder();
-        if (heartRateDetectAlarmCycle>1) {
+        StringBuilder sb = new StringBuilder();
+        if (heartRateDetectAlarmCycle > 1) {
             AlarmHelper.setRealTimeAlarm(runtime.getContextProxy().context, heartRateDetectAlarmCycle, ACTION_HEATR_RATE_START);
         }
 
-        if(runtime.check_stat_do_ppg_test()) {
+        if (runtime.check_stat_do_ppg_test()) {
             if (Runtime.practising == true) {
                 sb.append("自由锻炼中,跳过原有的循环心率检测!");
                 ICLogger.i("自由锻炼中,跳过原有的循环心率检测!");
             } else {
                 sb.append("setHeartRateDetectAlarm " + heartRateDetectAlarmCycle);
-                if(!server_starting)
+                if (!server_starting)
                     HeartRateManager.triggerPPGtest();
             }
         }
-        if (Config.LOG_TOFILE)ICLogger.logToFile("alarmCycle",sb.toString());
+        if (Config.LOG_TOFILE) ICLogger.logToFile("alarmCycle", sb.toString());
     }
 
-    public void setBleScanAlarm(int cycle){
+    public void setBleScanAlarm(int cycle) {
         //只有蓝牙扫描协议1才需要设置周期,蓝牙扫描协议0 为心跳及定位时才进行扫描
-        if (Config.BLEScanProtocol!=1) {
+        if (Config.BLEScanProtocol != 1) {
             ICLogger.i("BLEScanProtocol!=1  skip setPolingCheckAntiAlarm");
             return;
         }
-        StringBuilder sb=new StringBuilder();
-        if (cycle>=15) {
+        StringBuilder sb = new StringBuilder();
+        if (cycle >= 15) {
             //由于蓝牙扫描一次15秒,所以周期要大于等于15秒
-            AlarmHelper.setRealTimeAlarmInMicorSeconds(runtime.getContextProxy().context, cycle*1000, ACTION_ALARM_BLE_SCAN);
+            AlarmHelper.setRealTimeAlarmInMicorSeconds(runtime.getContextProxy().context, cycle * 1000, ACTION_ALARM_BLE_SCAN);
         }
-        sb.append("setBleScanAlarm " + cycle+" seconds");
+        sb.append("setBleScanAlarm " + cycle + " seconds");
         locationClient.triggerBLEProcess();
         ICLogger.i(sb.toString());
-        if (Config.LOG_TOFILE)ICLogger.logToFile("alarmCycle",sb.toString());
+        if (Config.LOG_TOFILE) ICLogger.logToFile("alarmCycle", sb.toString());
     }
 
-    public void setEmegencyLocationSTOPAlarm(int delayTimeInMinutes){
-        StringBuilder sb=new StringBuilder();
-        AlarmHelper.setRealTimeAlarm(runtime.getContextProxy().context,delayTimeInMinutes, ACTION_SEND_EMEGENCY_LOCATION_STOP);
-        sb.append(" tEmegencyLocationSTOPAlarm  "+ACTION_SEND_EMEGENCY_LOCATION_STOP);
+    public void setEmegencyLocationSTOPAlarm(int delayTimeInMinutes) {
+        StringBuilder sb = new StringBuilder();
+        AlarmHelper.setRealTimeAlarm(runtime.getContextProxy().context, delayTimeInMinutes, ACTION_SEND_EMEGENCY_LOCATION_STOP);
+        sb.append(" tEmegencyLocationSTOPAlarm  " + ACTION_SEND_EMEGENCY_LOCATION_STOP);
 //        ICLogger.i(sb.toString());
-        if (Config.LOG_TOFILE)ICLogger.logToFile("alarmCycle",sb.toString());
+        if (Config.LOG_TOFILE) ICLogger.logToFile("alarmCycle", sb.toString());
     }
+
     public void setLocationAlarm(int mod) {
 //        int mod=runtime.getLocationInstance().getWorkingMod();
-        StringBuilder sb=new StringBuilder();
-        int cycle=60;
-        switch(mod){
+        StringBuilder sb = new StringBuilder();
+        int cycle = 60;
+        switch (mod) {
             case EMERGNECY_MOD:
             case REALTIME_MOD:
-                cycle=60;
+                cycle = 60;
                 break;
             case NORMAL_MOD:
-                cycle=15*60;
+                cycle = 15 * 60;
                 break;
             case LOWPOWER_MOD:
-                cycle=60*60;
+                cycle = 60 * 60;
                 break;
             case CUSTOM_MOD:
             case CUSTOM_MOD8_GPS:
             case CUSTOM_MOD8_WIFI:
-                cycle=runtime.getLocationInstance().getLocation_cycle();
+                cycle = runtime.getLocationInstance().getLocation_cycle();
                 break;
         }
-        if(cycle == 0)
-        {
+        if (cycle == 0) {
             ICLogger.i("locationCycle == 0 stop Location !");
-            Config.noLocationCycle=true;
+            Config.noLocationCycle = true;
         }
-        if (Config.noLocationCycle==false)
-            AlarmHelper.setRealTimeAlarmInSeconds(runtime.getContextProxy().context,cycle, ACTION_LOCATION_ALARM);
+        if (Config.noLocationCycle == false)
+            AlarmHelper.setRealTimeAlarmInSeconds(runtime.getContextProxy().context, cycle, ACTION_LOCATION_ALARM);
         else
-            ICLogger.i("skip set LocationAlarm " );
-        sb.append(" setLocationAlarm  "+ACTION_LOCATION_ALARM+" mod "+mod+", cycle in Seconds "+cycle);
+            ICLogger.i("skip set LocationAlarm ");
+        sb.append(" setLocationAlarm  " + ACTION_LOCATION_ALARM + " mod " + mod + ", cycle in Seconds " + cycle);
         ICLogger.i(sb.toString());
-        if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(runtime.getCacheDir(),"alarmCycle",sb.toString());
+        if (Config.LOG_TOFILE)
+            FileOutputUtil.fileOutput(runtime.getCacheDir(), "alarmCycle", sb.toString());
 
 //        if (Runtime.practising==true) {
 //            ICLogger.i("自由锻炼中,跳过原有的循环定位!");
@@ -1446,63 +1459,66 @@ public class CoreService extends Service {
 
     }
 
-    public void setHeartAlarm(){
+    public void setHeartAlarm() {
 //        int mod=runtime.getLocationInstance().getWorkingMod();
-        StringBuilder sb=new StringBuilder();
-        int cycle=runtime.getHeartBeatCycle();
+        StringBuilder sb = new StringBuilder();
+        int cycle = runtime.getHeartBeatCycle();
 
         //心跳指令默认设置
-        AlarmHelper.setRealTimeAlarm(runtime.getContextProxy().context,cycle, HEART_ALARM);
-        sb.append(" setHeartAlarm  "+HEART_ALARM+", cycle "+cycle);
+        AlarmHelper.setRealTimeAlarm(runtime.getContextProxy().context, cycle, HEART_ALARM);
+        sb.append(" setHeartAlarm  " + HEART_ALARM + ", cycle " + cycle);
 //        locationClient.triggerLocationProcess();
         ICLogger.i(sb.toString());
-        FileOutputUtil.fileOutput(runtime.getCacheDir(),"alarmCycle",sb.toString());
+        FileOutputUtil.fileOutput(runtime.getCacheDir(), "alarmCycle", sb.toString());
 
 //        AlarmHelper.setRealTimeAlarm(runtime.getContextProxy().context,1, HEART_ALARM);
     }
-    public void setAntiAlarm(){
+
+    public void setAntiAlarm() {
 //        int mod=runtime.getLocationInstance().getWorkingMod();
-        StringBuilder sb=new StringBuilder();
-        int cycle=runtime.anti_test_cycle;
-        if(cycle>1) {
+        StringBuilder sb = new StringBuilder();
+        int cycle = runtime.anti_test_cycle;
+        if (cycle > 1) {
             AlarmHelper.setRealTimeAlarm(runtime.getContextProxy().context, cycle, ANTI_ALARM);
         }
-        sb.append(" setHeartAlarm  "+ANTI_ALARM+", cycle "+cycle);
+        sb.append(" setHeartAlarm  " + ANTI_ALARM + ", cycle " + cycle);
 
         ICLogger.i(sb.toString());
-        FileOutputUtil.fileOutput(runtime.getCacheDir(),"alarmCycle",sb.toString());
+        FileOutputUtil.fileOutput(runtime.getCacheDir(), "alarmCycle", sb.toString());
     }
-    public void setTempAlarm(){
+
+    public void setTempAlarm() {
 //        int mod=runtime.getLocationInstance().getWorkingMod();
-        StringBuilder sb=new StringBuilder();
-        int cycle=runtime.temp_test_Cycle;
+        StringBuilder sb = new StringBuilder();
+        int cycle = runtime.temp_test_Cycle;
 
-        if(Config.noTempSensor) {
+        if (Config.noTempSensor) {
             ICLogger.i("setTempAlarm noTempSensor");
             return;
         }
-        if (cycle>1) {
+        if (cycle > 1) {
             AlarmHelper.setRealTimeAlarmInSeconds(runtime.getContextProxy().context, cycle, TEMP_ALARM);
             sb.append(" setTempAlarm  " + TEMP_ALARM + ", cycle " + cycle);
-        }else {
-            sb.append(" setTempAlarm  " + TEMP_ALARM + ", cycle " + cycle+"<=1 skip!");
+        } else {
+            sb.append(" setTempAlarm  " + TEMP_ALARM + ", cycle " + cycle + "<=1 skip!");
         }
 //        locationClient.triggerLocationProcess();
         ICLogger.i(sb.toString());
-        FileOutputUtil.fileOutput(runtime.getCacheDir(),"alarmCycle",sb.toString());
+        FileOutputUtil.fileOutput(runtime.getCacheDir(), "alarmCycle", sb.toString());
 
-        if(runtime.check_stat_do_temp_test()) {
+        if (runtime.check_stat_do_temp_test()) {
             if (Runtime.practising == true) {
                 ICLogger.i("自由锻炼中,跳过原有的循环温度检测!");
             } else {
-                if(!server_starting)
+                if (!server_starting)
                     TemperatureUtil.doTempTestInThread();
             }
         }
 
     }
+
     public void setUpLocationDataAlarm(long paramLong) {
-        AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);
+        AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
         Intent intent = new Intent(this, CoreService.class);
         intent.setAction(ACTION_ALARM_ADD_DATAPOINTS);
         PendingIntent pendingIntent = PendingIntent.getService(this, 0, intent, FLAG_UPDATE_CURRENT);
@@ -1512,11 +1528,13 @@ public class CoreService extends Service {
         stringBuilder.append("interval=");
         stringBuilder.append(paramLong);
         ICLogger.i(stringBuilder.toString());
-        AlarmHelper.setRealTimeAlarm( runtime.getContextProxy().context,(int)((System.currentTimeMillis() + paramLong)/1000),ACTION_ALARM_ADD_DATAPOINTS);
+        AlarmHelper.setRealTimeAlarm(runtime.getContextProxy().context, (int) ((System.currentTimeMillis() + paramLong) / 1000), ACTION_ALARM_ADD_DATAPOINTS);
     }
 
     public static class InnerService extends Service {
-        public IBinder onBind(Intent param1Intent) { return null; }
+        public IBinder onBind(Intent param1Intent) {
+            return null;
+        }
 
         /*给 API >= 18 的平台上用的灰色保活手段*/
         public int onStartCommand(Intent param1Intent, int param1Int1, int param1Int2) {
@@ -1535,7 +1553,7 @@ public class CoreService extends Service {
         }
 
         public void handleMessage(Message param1Message) {
-            CoreService coreService = (CoreService)this.mReference.get();
+            CoreService coreService = (CoreService) this.mReference.get();
             if (coreService == null)
                 return;
             coreService.invokeHandlerServiceChain.processUserRequest(param1Message, coreService.connection, coreService.runtime);
@@ -1544,66 +1562,70 @@ public class CoreService extends Service {
 
     private static final String TAG = "ICSrv." + CoreService.class.getSimpleName();
 
-    private ScheduledThreadPoolExecutor mTimer_retry_connect=null;
+    private ScheduledThreadPoolExecutor mTimer_retry_connect = null;
+
+    private static int retry_connect_count = 0;  //当前重试次数
+    private static int retry_connect_max_times = 6; //最大重试次数 6次 , 即只重试2分钟,下一次重试将在下一个心跳包时进行。
+    private static int retry_cocnnect_cycle = 20; //重试间隔20秒
 
-    private static int retry_connect_count=0;  //当前重试次数
-    private static int retry_connect_max_times=6; //最大重试次数 6次 , 即只重试2分钟,下一次重试将在下一个心跳包时进行。
-    private static int retry_cocnnect_cycle=20; //重试间隔20秒
     private void log(String msg) {
-        ICLogger.log(TAG,msg);
+        ICLogger.log(TAG, msg);
     }
 
-    public static CoreService getInstance(){
+    public static CoreService getInstance() {
         return mProtocolServer;
     }
 
-    public void startConnectionRetryTimer(){
+    public void startConnectionRetryTimer() {
         //联网再重试连接服务器, 不能够联网的情况下不管是不是有sim卡,以及是否联网,都进行重试,以便处理下面情况:
         //1、sim卡接触不良,掉卡,可以尝试用此法恢复
         //2、网络信号不好,造成临时掉线,但是恢复慢或不恢复,可以用此法尝试恢复
 //        if (SimSignalUtil.checkNet(runtime.getContextProxy().context) ) {
-             stopConnectionRetryTimer();
-            if (mTimer_retry_connect == null) {
-                mTimer_retry_connect = new ScheduledThreadPoolExecutor(10);
-            }
-            //如果开始进行连接重
-                // {
-            // 试,证明网络断开的,那么KeepAlive也需要重连(心跳包)
-            retry_connect_count=0;
-            KeepAlive.isConnected = false;
-            if (mTimer_retry_connect != null) {
-                mTimer_retry_connect.remove(mReConnectSrvThread);
-                mTimer_retry_connect.scheduleAtFixedRate(mReConnectSrvThread, 5000, 20000, TimeUnit.MILLISECONDS); //每次都是断网才需要重连,delay 5秒重连,并且每20秒重试一次
-            }
+        stopConnectionRetryTimer();
+        if (mTimer_retry_connect == null) {
+            mTimer_retry_connect = new ScheduledThreadPoolExecutor(10);
+        }
+        //如果开始进行连接重
+        // {
+        // 试,证明网络断开的,那么KeepAlive也需要重连(心跳包)
+        retry_connect_count = 0;
+        KeepAlive.isConnected = false;
+        if (mTimer_retry_connect != null) {
+            mTimer_retry_connect.remove(mReConnectSrvThread);
+            mTimer_retry_connect.scheduleAtFixedRate(mReConnectSrvThread, 5000, 20000, TimeUnit.MILLISECONDS); //每次都是断网才需要重连,delay 5秒重连,并且每20秒重试一次
+        }
 //        }
     }
-    private ReConnectSrvThread mReConnectSrvThread=new ReConnectSrvThread();
-    private class ReConnectSrvThread implements  Runnable{
+
+    private ReConnectSrvThread mReConnectSrvThread = new ReConnectSrvThread();
+
+    private class ReConnectSrvThread implements Runnable {
         @Override
         public void run() {
             ReConnectToServer();
         }
     }
 
-    private static int no_network_Heartbeats_Count=0;
+    private static int no_network_Heartbeats_Count = 0;
 
-    public void ReConnectToServer(){
-        long timeSincelastReceive=0;
-        if(Runtime.lastLinkReceiveStamp>0)
-            timeSincelastReceive=(System.currentTimeMillis()-Runtime.lastLinkReceiveStamp)/1000;
-        if (timeSincelastReceive>0) ICLogger.i("距离上次从服务器收到数据,已经有 " + timeSincelastReceive + " 秒!");
-        if (SimSignalUtil.checkNet(runtime.getContextProxy().context) ) {
+    public void ReConnectToServer() {
+        long timeSincelastReceive = 0;
+        if (Runtime.lastLinkReceiveStamp > 0)
+            timeSincelastReceive = (System.currentTimeMillis() - Runtime.lastLinkReceiveStamp) / 1000;
+        if (timeSincelastReceive > 0)
+            ICLogger.i("距离上次从服务器收到数据,已经有 " + timeSincelastReceive + " 秒!");
+        if (SimSignalUtil.checkNet(runtime.getContextProxy().context)) {
             //里面如果连接成功 connectionOpen 会先发送 AP00 登录包 和发送AP03 心跳包 ,
             // isServerConnected 成功则停止重试, KeepAlive会检测AP03心跳包的成功与否。此处只管socket连接是否成功
             if (connection.isServerConnected()) {
                 ICLogger.i("retry  如果连接成功则停止重试!");
-                no_network_Heartbeats_Count=0;
+                no_network_Heartbeats_Count = 0;
                 stopConnectionRetryTimer();
-            }else {
+            } else {
                 if (retry_connect_count >= retry_connect_max_times) {
 
                     no_network_Heartbeats_Count++;
-                    ICLogger.i("retry " + retry_connect_count + " 次 >= " + retry_connect_max_times + " ,停止重试!等待下一次心跳再重试! 已经第"+no_network_Heartbeats_Count+"次心跳都没有连接服务器成功!");
+                    ICLogger.i("retry " + retry_connect_count + " 次 >= " + retry_connect_max_times + " ,停止重试!等待下一次心跳再重试! 已经第" + no_network_Heartbeats_Count + "次心跳都没有连接服务器成功!");
                     stopConnectionRetryTimer();
 
                 } else {
@@ -1617,32 +1639,34 @@ public class CoreService extends Service {
 
                 }
             }
-        }else{
+        } else {
             //没有网络就不用重新尝试连接网络了。网络连接后再重新尝试联网
-            ICLogger.i("retry "+no_network_Heartbeats_Count+" 没有网络就不用重新尝试连接网络了。网络连接后再重新尝试联网!");
+            ICLogger.i("retry " + no_network_Heartbeats_Count + " 没有网络就不用重新尝试连接网络了。网络连接后再重新尝试联网!");
             no_network_Heartbeats_Count++;
             stopConnectionRetryTimer();
         }
-        if( no_network_Heartbeats_Count >12){
-            ICLogger.i("当前第"+no_network_Heartbeats_Count+"次心跳都没有连接服务器成功 > 10 ,重置SIM卡尝试重新注册网络!");
+        if (no_network_Heartbeats_Count > 12) {
+            ICLogger.i("当前第" + no_network_Heartbeats_Count + "次心跳都没有连接服务器成功 > 10 ,重置SIM卡尝试重新注册网络!");
             SimSignalUtil.send_at_to_reset_simcard(runtime); //直接下此命令不能实现断网重连,所以干脆采用关闭网络再打开的方式。
-            SimSignalUtil.setAirMode(this,"OpenAirplane");
-            mHandler.postDelayed(reopenSim,5000); //5秒后重新链接服务器。
-            no_network_Heartbeats_Count=0;//重置Sim卡后重置计数。防止后面多次重置Sim卡。
+            SimSignalUtil.setAirMode(this, "OpenAirplane");
+            mHandler.postDelayed(reopenSim, 5000); //5秒后重新链接服务器。
+            no_network_Heartbeats_Count = 0;//重置Sim卡后重置计数。防止后面多次重置Sim卡。
         }
     }
-    private Runnable reopenSim =new Runnable(){
+
+    private Runnable reopenSim = new Runnable() {
         @Override
         public void run() {
-            if (CoreService.getInstance()!=null) {
+            if (CoreService.getInstance() != null) {
                 SimSignalUtil.setAirMode(CoreService.getInstance(), "CloseAirplane");
-             //   disconnect_server();
-              //  ReConnectToServer();
+                //   disconnect_server();
+                //  ReConnectToServer();
             }
         }
     };
-    public void stopConnectionRetryTimer(){
-        if (mTimer_retry_connect !=null){
+
+    public void stopConnectionRetryTimer() {
+        if (mTimer_retry_connect != null) {
             mTimer_retry_connect.shutdownNow();
 //            while(!mTimer_retry_connect.isTerminated())
 //            {
@@ -1658,13 +1682,11 @@ public class CoreService extends Service {
         }
     }
 
-    private boolean needLogin(){
+    private boolean needLogin() {
         return true;
     }
 
 
-
-
     @Override
     public void onDestroy() {
         super.onDestroy();
@@ -1682,7 +1704,7 @@ public class CoreService extends Service {
 
     }
 
-    public void disconnect_server(){
+    public void disconnect_server() {
         this.connection.close();
     }