private void onSilentStateChange(boolean var1) {
SharPreferenceUtil.setPrefBoolean(mContext, "KEY_ISSILENCE", var1);
setSilentConfig(mContext, var1);
- if (this.alarms != null) {
- if (var1) {
- this.cancelAlarm(this.alarms);
- } else {
- this.setNewAlarm(this.alarms);
+ try {
+ if (this.alarms != null) {
+ if (var1) {
+ this.cancelAlarm(this.alarms);
+ } else {
+ this.setNewAlarm(this.alarms);
+ }
}
+ } catch (Exception e) {
+ e.printStackTrace();
}
if (this.voiceNotice != null) {
if (this.alarms != null) {
this.cancelAlarm(this.alarms);
}
- this.setNewAlarm(alarmList);
+ try {
+ this.setNewAlarm(alarmList);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
return alarmList;
}
calendar.set(Calendar.SECOND, 0);
long currentTime = System.currentTimeMillis();
Iterator itAlarm = alarmArrayList.iterator();
-
-
while (itAlarm.hasNext()) {
Alarm alarm = (Alarm) itAlarm.next();
ICLogger.d("alarm == > " + alarm);
import com.enqualcomm.support.Config;
import com.enqualcomm.support.CoreService;
import com.enqualcomm.support.R;
+import com.enqualcomm.support.bean.Alarm;
import com.enqualcomm.support.bean.Contact;
import com.enqualcomm.support.bean.Content;
import com.enqualcomm.support.bean.ICLocation;
AP84/*白名单开关上行*/,
AP14/*白名单电话本上行*/,
AP32/*拨号上行*/,
- APSW/*定位开关上行*/
+ APSW/*定位开关上行*/,
+ AP98/*计步目标设置上行*/
}
private final static HashMap<CMD_TYPE, String> cmdMap;
cmdMap.put(CMD_TYPE.AP31, "AP31");
cmdMap.put(CMD_TYPE.APXL, "APXL");
cmdMap.put(CMD_TYPE.APSW, "APSW");
+ cmdMap.put(CMD_TYPE.AP98, "AP98");
}
ICLogger.d("收到闹钟设置指令..." + cmd);
handleBP75(cmd, mConnection);
break;
+ case BP98:
+ ICLogger.d("收到计步目标指令..." + cmd);
+ handleBP98(cmd, mConnection);
+ break;
+ }
+ }
+
+ /**
+ * 解析BP98
+ *
+ * @param cmd
+ * @param mConnection
+ */
+ private void handleBP98(String cmd, Connection mConnection) {
+ String[] split = cmd.split(CMD_SPLIT);
+ if (split.length == 4) {
+ String responseCode = split[2];
+ String value = split[3];
+ ICLogger.d("value == > " + value);
+ ContentValues contentValues = new ContentValues();
+ contentValues.put(FZDDatabaseHelper.sKey, cmdMap.get(CMD_TYPE.BP98));
+ contentValues.put(FZDDatabaseHelper.sValue, value);
+ //放到数据库里,需要的进行读取即可
+ mRuntime.getContextProxy().getResolver().insert(Uri.parse(FZDSettingsProvider.SETTINGS), contentValues);
+ mConnection.send(
+ genStringMessage(cmdMap.get(CMD_TYPE.AP98), new StringBuilder(CMDHEADER).append(
+ cmdMap.get(CMD_TYPE.AP98)
+ ).append(CMDSPLIT).append(responseCode).append(CMDEND).toString())
+ );
+ } else {
+ ICLogger.d("BP98 parse error...");
}
}
//闹钟数据解析
int startIndex = split.length - 1;
int countValue = Integer.parseInt(count);
+ ArrayList<Alarm> alarmList = new ArrayList<>();
for (int i = 0; i < countValue; i++) {
//开关
String sourceTrigger = split[startIndex].substring(0, 1);
if (i != countValue - 1) {
textCode = textCode.substring(2);
}
+ String text = Util.decodeUnicode2Utf8(textCode);
ICLogger.d("sourceTrigger == > "
+ sourceTrigger + " time == > "
+ time + " cycle === > "
- + cycle + " textCode => " + textCode);
+ + cycle + " textCode => " + text);
startIndex -= 3;
+ alarmList.add(new Alarm("ST" + time.substring(0, 2) + "." + time.substring(2),
+ "W" + cycle, "CON", "1".equals(sourceTrigger) ? "ON" : "OFF", "闹铃"));
+
}
- //todo:闹钟入库
mConnection.send(
genStringMessage(cmdMap.get(CMD_TYPE.AP75),
cmd.replace(cmdMap.get(BP75), cmdMap.get(CMD_TYPE.AP75)).replace(imeiCode + ",", "") + CMDEND)
);
+ //闹钟入库
+ mRuntime.getDbHelper().saveAlarm(alarmList);
} catch (Exception e) {
e.printStackTrace();
ICLogger.d("闹钟指令解析出错...");
//设置通讯录,白名单(10个)
public void handleBP14(Connection connection, String cmd, Runtime runtime) {
// IWBP14,867155030001063,357444,9b44529b|13554820016,,,,,,,,,
-/**
- * IWBP14,353456789012345,080835,
- * D3590D54|135xxxxxxxxxx,
- * D3590D54|135xxxxxxxxxx,
- * D3590D54|135xxxxxxxxxx,
- * D3590D54|135xxxxxxxxxx,
- * D3590D54|135xxxxxxxxxx,
- * D3590D54|135xxxxxxxxxx,
- * D3590D54|135xxxxxxxxxx,
- * D3590D54|135xxxxxxxxxx,
- * D3590D54|135xxxxxxxxxx,
- * D3590D54|135xxxxxxxxxx#
- */
+ /**
+ * IWBP14,353456789012345,080835,
+ * D3590D54|135xxxxxxxxxx,
+ * D3590D54|135xxxxxxxxxx,
+ * D3590D54|135xxxxxxxxxx,
+ * D3590D54|135xxxxxxxxxx,
+ * D3590D54|135xxxxxxxxxx,
+ * D3590D54|135xxxxxxxxxx,
+ * D3590D54|135xxxxxxxxxx,
+ * D3590D54|135xxxxxxxxxx,
+ * D3590D54|135xxxxxxxxxx,
+ * D3590D54|135xxxxxxxxxx#
+ */
String[] cmdlist = cmd.split(CMDSPLIT);
String[] phnums = new String[]{"", "", "", "", "", "", "", "", "", ""};
StringBuffer sb = new StringBuffer().append("recv phone Numbs ");