import rx.Observable;
import rx.schedulers.Schedulers;
-import static com.enqualcomm.support.Constants.ACTION_ANTI_OFF;
import static com.enqualcomm.support.Constants.ACTION_ANTI_OFF0;
import static com.enqualcomm.support.Constants.ACTION_CHECK_ANTIOFF_EVENT;
import static com.enqualcomm.support.Constants.ACTION_CHECK_CUTOFF_EVENT;
+import static com.enqualcomm.support.Constants.ACTION_CUT_OFF;
import static com.enqualcomm.support.Constants.KEY_ANTI_EVENT;
import static com.enqualcomm.support.Constants.KEY_ANTI_TXT;
import static java.lang.Thread.sleep;
}
/***
- * 广播给其他应用,用于UI在客户操作
+ * 广播给其他应用,用于UI在客户操作,主要是佩戴检测影响心率,体温检测,
+ * 所以必须发送,不然可能造成应用不能及时更新,无法正常检测。
* @param antioff
*/
private void broadcast_antioff_event_to_other_application(boolean antioff) {
if (antioff) {
//脱落
mHandler.postDelayed(mDeleteTimeFlagTask, getAntiOffDelayTime());
- Util.setSystemProperties("persist.sys.ic_antioff", "true");
//Util.setSystemProperties("persist.sys.ic.antioff_time", TimeUtil.getSystemTimeyyyyMMddHHmmss());
intent.putExtra(KEY_ANTI_EVENT, 1);
} else {
mHandler.removeCallbacks(mDeleteTimeFlagTask);
//佩戴的时候开始计时,5分钟后修改佩戴够长的标记值(脱落了会干掉这个任务)
mHandler.postDelayed(mUpdateTimeFlagTask, getWearEnoughTime());
- Util.setSystemProperties("persist.sys.ic_antioff", "false");
//Util.setSystemProperties("persist.sys.ic.weared_time", TimeUtil.getSystemTimeyyyyMMddHHmmss());
intent.putExtra(KEY_ANTI_EVENT, 0);
}
- mContext.sendBroadcast(intent);
+ //如果 needBroadcastAntiAlarm 意味着 后面会根据项目需求发送这个action,所以在此就不发送了
+ if (!Config.needBroadcastAntiAlarm) {
+ mContext.sendBroadcast(intent);
+ }
}
//5分钟
case STATUS_WEARED:
//佩戴
{
+
+ Util.setSystemProperties("persist.sys.ic_antioff", "false");
+ mRuntime.Anti_off_flag = 0;
+ broadcast_antioff_event_to_other_application(false);
if (Config.needBroadcastAntiAlarm) {
// play_notify();
- send_anti_event_broadcast(0);
+ send_anti_event_broadcast(0); //发送 Action
}
- mRuntime.Anti_off_flag = 0;
-
- broadcast_antioff_event_to_other_application(false);
-
if (mRuntime.setAlarmType(Runtime.AlarmType.ALARM_WEARED)) {
ICLogger.i("triggerSOSLocationProcess ");
LocationClient.getInstance().triggerSOSLocationProcess();
// StringMessage msg = protocolAPIHelper.getWarningMSG(mRuntime);
// Deliver.sendLocationMSG(msg); //消息很重要,所以利用带buffer的对列来发送!
}
-// try {
-// sleep(1000);
-// } catch (InterruptedException e) {
-// e.printStackTrace();
-// }
+
}
break;
case STATUS_ANTI_OFF: {
//脱腕
+ Util.setSystemProperties("persist.sys.ic_antioff", "true");
+ mRuntime.Anti_off_flag = 1;
+ broadcast_antioff_event_to_other_application(true);
if (Config.needBroadcastAntiAlarm) {
send_anti_event_broadcast(1);
}
- mRuntime.Anti_off_flag = 1;
- broadcast_antioff_event_to_other_application(true);
if (mRuntime.setAlarmType(Runtime.AlarmType.ALARM_ANTIOFF)) {
ICLogger.i("triggerSOSLocationProcess ");
LocationClient.getInstance().triggerSOSLocationProcess();
// StringMessage msg = protocolAPIHelper.getWarningMSG(mRuntime);
// Deliver.sendLocationMSG(msg); //消息很重要,所以利用带buffer的对列来发送!
}
-// try {
-// sleep(1000);
-// } catch (InterruptedException e) {
-// e.printStackTrace();
-// }
+
}
break;
default:
case STATUS_LOCK_ON:
//锁定
{
+ Util.setSystemProperties("persist.sys.ic_cutoff", "false");
+ mRuntime.Cut_off_flag = 0;
if (Config.needBroadcastCutoffAlarm) {
// play_notify();
send_cutoff_event_broadcast(0);
}
- mRuntime.Cut_off_flag = 0;
if (mRuntime.setAlarmType(Runtime.AlarmType.ALARM_LOCK_WATCH)) {
//发送消息定位报警消息
ICLogger.i("triggerSOSLocationProcess ");
break;
case STATUS_CUT_OFF: {
//非法解锁
+ Util.setSystemProperties("persist.sys.ic_cutoff", "true");
+ mRuntime.Cut_off_flag = 1;
if (Config.needBroadcastCutoffAlarm) {
send_cutoff_event_broadcast(1);
}
- mRuntime.Cut_off_flag = 1;
if (mRuntime.setAlarmType(Runtime.AlarmType.ALARM_CUTOFF)) {
ICLogger.i("triggerSOSLocationProcess ");
LocationClient.getInstance().triggerSOSLocationProcess();
// StringMessage msg = protocolAPIHelper.getWarningMSG(mRuntime);
// Deliver.sendLocationMSG(msg); //消息很重要,所以利用带buffer的对列来发送!
}
-// try {
-// sleep(1000);
-// } catch (InterruptedException e) {
-// e.printStackTrace();
-// }
}
break;
default:
public void send_cutoff_event_broadcast(int cutoff) {
ICLogger.i("send_cutoff_event_broadcast " + cutoff);
Intent intent = new Intent();
- intent.setAction(ACTION_ANTI_OFF);
+ intent.setAction(ACTION_CUT_OFF);
intent.putExtra(KEY_ANTI_EVENT, cutoff);
if (cutoff == 0) {
ICLogger.i("send_anti_event_broadcast " + antioff);
Intent intent = new Intent();
- intent.setAction(ACTION_ANTI_OFF);
+ intent.setAction(ACTION_ANTI_OFF0);
intent.putExtra(KEY_ANTI_EVENT, antioff);
if (antioff == 0) {
mRuntime.isAntioff = false;