import android.content.Context;
import android.provider.Settings;
-import android.text.TextUtils;
import android.util.JsonReader;
import com.enqualcomm.support.bean.ICLocation;
import com.ic.jni.ICJniUtils;
import com.ic.protocols.protocolAPIHelper;
-import org.json.JSONException;
import org.json.JSONStringer;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
-import java.io.Reader;
import java.io.StringReader;
import java.util.HashMap;
-import java.util.List;
-
-import chestnut.Interface.json.Json;
import static com.enqualcomm.support.bean.ICLocation.CUSTOM_MOD8_GPS;
import static com.enqualcomm.support.bean.ICLocation.NORMAL_MOD;
final static String KeyLastUnReadMessage = "UnreadMsg";
private static HashMap<Integer, Boolean> AlarmConfiglist;
- static final boolean doJsonTest=false; //测试Jason文件标志
- static String JsonConfigFilePath="/system/etc/protocol_config.json"; // Config文件路径
+ static final boolean doJsonTest = false; //测试Jason文件标志
+ static String JsonConfigFilePath = "/system/etc/protocol_config.json"; // Config文件路径
- public static int DefaultLocationMode=CUSTOM_MOD8_GPS;
- public static int DefaultLocationCycle=60*60;
- public static int DefaultPPGTestCycle=60;
- public static int DefaultTemperatureTestCycle=60*60;
+ public static int DefaultLocationMode = CUSTOM_MOD8_GPS;
+ public static int DefaultLocationCycle = 60 * 60;
+ public static int DefaultPPGTestCycle = 60;
+ public static int DefaultTemperatureTestCycle = 60 * 60;
- public static int DefaultWifiStatus=0; //0 close , 1 open, 2 open and connect using default wifi
+ public static int DefaultWifiStatus = 0; //0 close , 1 open, 2 open and connect using default wifi
static {
AlarmConfiglist = new HashMap<Integer, Boolean>();
sendSOSAtOnce = Util.getSystemProperties("persist.sys.sos_at_once", "false").equals("true");
- do_broadCast_message = Util.getSystemProperties("persist.sys.doBroadcastMSG","false").equals("true");
+ do_broadCast_message = Util.getSystemProperties("persist.sys.doBroadcastMSG", "false").equals("true");
noPPGSensor = (ICJniUtils.isPPGavailable() == 0);
noTempSensor = (ICJniUtils.isTemperatureDevAvailable() == 0);
c43_branch_name = Util.getSystemProperties("persist.sys.c43.branch");
try {
- DefaultWifiStatus = Integer.valueOf(Util.getSystemProperties("persist.sys.DefaultWifiStatus","0"));
- }catch (Exception e){
- ICLogger.e(e.getMessage(),e);
+ DefaultWifiStatus = Integer.valueOf(Util.getSystemProperties("persist.sys.DefaultWifiStatus", "0"));
+ } catch (Exception e) {
+ ICLogger.e(e.getMessage(), e);
}
if ((c43_branch_name.equals("l03")) || (c43_branch_name.equals("l05"))) {
custom_name = Util.getSystemProperties("persist.sys.customname");
ICLogger.i("get CUSTOMNAME " + custom_name);
- if (custom_name.equals("H88") || custom_name.equals("H88A") ) {
+ if (custom_name.equals("H88") || custom_name.equals("H88A")) {
ConfigAlarm(Runtime.AlarmType.ALARM_ANTIOFF, true);
ConfigAlarm(Runtime.AlarmType.ALARM_WEARED, true);
- DefaultLocationMode=CUSTOM_MOD8_GPS;
- DefaultLocationCycle=60*60;
- DefaultPPGTestCycle=60;
- DefaultTemperatureTestCycle=60*60;
+ DefaultLocationMode = CUSTOM_MOD8_GPS;
+ DefaultLocationCycle = 60 * 60;
+ DefaultPPGTestCycle = 60;
+ DefaultTemperatureTestCycle = 60 * 60;
noPushTxtNotifyDialog = true;
noSMSNotifyDialog = false;
ConfigAlarm(Runtime.AlarmType.ALARM_CUTOFF, true);
ConfigAlarm(Runtime.AlarmType.ALARM_ILLEGAL_CUTOFF, true);
ConfigAlarm(Runtime.AlarmType.ALARM_LOCK_WATCH, true);
- DefaultLocationMode=CUSTOM_MOD8_GPS;
- DefaultLocationCycle=10*60;
- DefaultPPGTestCycle=0;
- DefaultTemperatureTestCycle=0;
+ DefaultLocationMode = CUSTOM_MOD8_GPS;
+ DefaultLocationCycle = 10 * 60;
+ DefaultPPGTestCycle = 0;
+ DefaultTemperatureTestCycle = 0;
noPushTxtNotifyDialog = true;
noSMSNotifyDialog = true;
ConfigAlarm(Runtime.AlarmType.ALARM_ANTIOFF, true);
ConfigAlarm(Runtime.AlarmType.ALARM_UNREADMSG, true);
ConfigAlarm(Runtime.AlarmType.ALARM_MSGREAD, true);
- DefaultLocationMode=NORMAL_MOD;
- DefaultLocationCycle=15*60;
- DefaultPPGTestCycle=0;
- DefaultTemperatureTestCycle=0;
+ DefaultLocationMode = NORMAL_MOD;
+ DefaultLocationCycle = 15 * 60;
+ DefaultPPGTestCycle = 0;
+ DefaultTemperatureTestCycle = 0;
noPushTxtNotifyDialog = false;
noSMSNotifyDialog = true;
ConfigAlarm(Runtime.AlarmType.ALARM_WEARED, true);
ConfigAlarm(Runtime.AlarmType.ALARM_ANTIOFF, true);
enableSleep = true;
- DefaultLocationMode=NORMAL_MOD;
- DefaultLocationCycle=900;
- DefaultPPGTestCycle=0;
- DefaultTemperatureTestCycle=0;
+ DefaultLocationMode = NORMAL_MOD;
+ DefaultLocationCycle = 900;
+ DefaultPPGTestCycle = 0;
+ DefaultTemperatureTestCycle = 0;
noPushTxtNotifyDialog = true;
noSMSNotifyDialog = true;
ConfigAlarm(Runtime.AlarmType.ALARM_ANTIOFF, true);
enableSleep = true;
- DefaultLocationMode=NORMAL_MOD;
- DefaultLocationCycle=900;
- DefaultPPGTestCycle=0;
- DefaultTemperatureTestCycle=0;
+ DefaultLocationMode = NORMAL_MOD;
+ DefaultLocationCycle = 900;
+ DefaultPPGTestCycle = 0;
+ DefaultTemperatureTestCycle = 0;
noPushTxtNotifyDialog = false;
noSMSNotifyDialog = false;
ConfigAlarm(Runtime.AlarmType.ALARM_ANTIOFF, true);
forceMoveCheck = false; //对定位不进行运动检测。
- DefaultLocationMode=CUSTOM_MOD8_GPS;
- DefaultLocationCycle=5 * 60;
- DefaultPPGTestCycle=0;
- DefaultTemperatureTestCycle=0;
+ DefaultLocationMode = CUSTOM_MOD8_GPS;
+ DefaultLocationCycle = 5 * 60;
+ DefaultPPGTestCycle = 0;
+ DefaultTemperatureTestCycle = 0;
noPushTxtNotifyDialog = false;
noSMSNotifyDialog = false;
} else if (Config.custom_name.equals("L02") || Config.custom_name.equals("L03") || Config.custom_name.equals("L05")) { //L02
Config.forceMoveCheck = false; //即爱对gps不进行运动检测,此变量专门为了给其他协议进行强制运动检测用的。
- DefaultLocationMode=NORMAL_MOD;
- DefaultLocationCycle=900;
- DefaultPPGTestCycle=0;
- DefaultTemperatureTestCycle=0;
+ DefaultLocationMode = NORMAL_MOD;
+ DefaultLocationCycle = 900;
+ DefaultPPGTestCycle = 0;
+ DefaultTemperatureTestCycle = 0;
noPushTxtReadReply = false;//即爱需要阅读反馈
noBroadCastPushTxtNotify = true;
} else if (Config.custom_name.equals("VitracK") || Config.custom_name.equals("wtsrui")) {
Config.ConfigAlarm(Runtime.AlarmType.ALARM_WEARED, true);
Config.ConfigAlarm(Runtime.AlarmType.ALARM_ANTIOFF, true);
enableSleep = false;
- DefaultLocationMode=CUSTOM_MOD8_GPS;
- DefaultLocationCycle=15 * 60;
- DefaultPPGTestCycle=15;
- DefaultTemperatureTestCycle=15 * 60;
+ DefaultLocationMode = CUSTOM_MOD8_GPS;
+ DefaultLocationCycle = 15 * 60;
+ DefaultPPGTestCycle = 15;
+ DefaultTemperatureTestCycle = 15 * 60;
} else {
- DefaultLocationMode=NORMAL_MOD;
- DefaultLocationCycle=900;
- DefaultPPGTestCycle=0;
- DefaultTemperatureTestCycle=0;
+ DefaultLocationMode = NORMAL_MOD;
+ DefaultLocationCycle = 900;
+ DefaultPPGTestCycle = 0;
+ DefaultTemperatureTestCycle = 0;
noBroadCastPushTxtNotify = true;
}
}
- static void load_config_fromfile(){
+ static void load_config_fromfile() {
try {
- JsonReader jsonReader=null;
- if(doJsonTest) {
+ JsonReader jsonReader = null;
+ if (doJsonTest) {
String jsonString = (new JSONStringer())
.object().key("pversion").value("V0.2.3").key("value").value("eiot_V1.0.0").key("protocol_version").value("2.0").key("product").value(String.valueOf(2L)).key("swReleaseNo").value(String.valueOf(sw_release_no)).endObject()
.toString();
- ICLogger.d("json String "+jsonString);
+ ICLogger.d("json String " + jsonString);
jsonReader = new JsonReader(new StringReader(jsonString));
- }else {
- File jsonFile=new File(JsonConfigFilePath);
- ICLogger.d("json file "+JsonConfigFilePath+(jsonFile.exists()?" exist":" not exist"));
+ } else {
+ File jsonFile = new File(JsonConfigFilePath);
+ ICLogger.d("json file " + JsonConfigFilePath + (jsonFile.exists() ? " exist" : " not exist"));
jsonReader = new JsonReader(new FileReader(jsonFile));
}
jsonReader.beginObject();
while (jsonReader.hasNext()) {
String name = jsonReader.nextName();
String value = jsonReader.nextString();
- setConfigValue(name,value);
+ setConfigValue(name, value);
}
jsonReader.endObject();
public static void LoadMessageConfigs() {
-
}
public static void loadTemperatureSettings(Runtime runtime) {
public static final int PROTOCOL_IC = 2;
public static final int PROTOCOL_FZD = 3;
public static final int PROTOCOL_MQTT = 4;
+ public static final int PROTOCOL_ANAN = 5;
public static int protocol_no = getProtocolNumber();
}
-
public static boolean isAlarmTypeEnabled(Runtime.AlarmType alarmType) {
boolean en = false;
}
- public static void setConfigValue(String key,String value){
- ICLogger.d("( "+key+" , "+value+")");
+ public static void setConfigValue(String key, String value) {
+ ICLogger.d("( " + key + " , " + value + ")");
try {
if (key.trim().equals("AlarmConfig")) {
try {
AlarmConfiglist.put(Runtime.AlarmType.valueOf(al).ordinal(), Boolean.valueOf(value));
} catch (Exception e) {
- ICLogger.e(e.getMessage(),e);
+ ICLogger.e(e.getMessage(), e);
}
}
} else if (key.trim().equals("disableWiFiScan")) {
- disableWiFiScan=Boolean.valueOf(value);
+ disableWiFiScan = Boolean.valueOf(value);
} else if (key.trim().equals("disableWristTemp")) {
- disableWristTemp=Boolean.valueOf(value);
+ disableWristTemp = Boolean.valueOf(value);
} else if (key.trim().equals("BLEScanProtocol")) {
- BLEScanProtocol=Integer.valueOf(value);
+ BLEScanProtocol = Integer.valueOf(value);
} else if (key.trim().equals("UsePolingCheckWeared")) {
/*
public static String DefaultWiFiEncryptType = "psk";
* */
}
- }catch (Exception e){
- ICLogger.e(e.getMessage(),e);
+ } catch (Exception e) {
+ ICLogger.e(e.getMessage(), e);
}
}
import com.enqualcomm.support.utils.ICLogger;
import com.enqualcomm.support.utils.TimeUtil;
+import static com.enqualcomm.support.Config.PROTOCOL_ANAN;
+
public class protocolAPIHelper {
private static protocol_ic protocolic_handler = null;
private static protocol_fzd protocolfzd_handler = null;
private static protocol_mqtt protocolmqtt_handler = null;
+ private static protocol_anan protocolanan_handler = null;
public static protocol_fzd getProtocolfzd_handler() {
return protocolfzd_handler;
public protocolAPIHelper(Connection connect, Runtime runtime) {
ICLogger.i("init Protocol " + Config.getProtocolNumber());
- if (protocolbeehome_handler == null)
+ if (protocolbeehome_handler == null) {
protocolbeehome_handler = new protocol_beehome(connect, runtime);
- if (protocoljiai_handler == null)
+ }
+ if (protocoljiai_handler == null) {
protocoljiai_handler = new protocol_jiai(connect, runtime);
- if (protocolic_handler == null)
+ }
+ if (protocolic_handler == null) {
protocolic_handler = new protocol_ic(connect, runtime);
- if (protocolfzd_handler == null)
+ }
+ if (protocolfzd_handler == null) {
protocolfzd_handler = new protocol_fzd(connect, runtime);
- if (protocolmqtt_handler == null)
+ }
+ if (protocolmqtt_handler == null) {
protocolmqtt_handler = new protocol_mqtt(connect, runtime);
+ }
+ if (protocolanan_handler == null) {
+ protocolanan_handler = new protocol_anan(connect, runtime);
+ }
}
private static boolean is_protocol_not_Initialled() {
- return (protocolbeehome_handler == null || protocoljiai_handler == null || protocolic_handler == null || protocolfzd_handler == null || protocolmqtt_handler == null);
-
+ return (protocolbeehome_handler == null || protocoljiai_handler == null
+ || protocolic_handler == null ||
+ protocolfzd_handler == null ||
+ protocolmqtt_handler == null ||
+ protocolanan_handler == null);
}
/*
case Config.PROTOCOL_MQTT:
protocolmqtt_handler.parserCmd(cmd_type, bytes);
break;
+ case PROTOCOL_ANAN:
+ protocolanan_handler.parseCmd(cmd_type, bytes);
+ break;
+
}
return true;
}
case Config.PROTOCOL_MQTT:
ret = protocol_mqtt.defaultServerIP;
break;
+ case PROTOCOL_ANAN:
+ ret = protocol_anan.defaultServerIp;
+ break;
}
ICLogger.d("ip ==> " + ret);
return ret;
case Config.PROTOCOL_MQTT:
ret = protocol_mqtt.defaultServerPort;
break;
+ case PROTOCOL_ANAN:
+ ret = protocol_anan.defaultServerPort;
+ break;
}
return ret;
}
case Config.PROTOCOL_MQTT:
ret = null;
break;
+ case PROTOCOL_ANAN:
+ ret = null;
+ break;
}
return ret;
}