<orderEntry type="library" name="Gradle: com.kymjs.rxvolley:rxvolley:1.1.3@aar" level="project"/>\r
<orderEntry type="library" name="Gradle: io.reactivex:rxandroid:1.1.0@aar" level="project"/>\r
<orderEntry type="module" module-name="dNSCache"/>\r
- <orderEntry type="module" module-name="dNSCache"/>\r
<orderEntry type="jdk" jdkName="Android API 25 Platform" jdkType="Android SDK"/>\r
</component>\r
</module>\r
<action android:name="com.enqualcomm.support.HEART_ALARM" />
<action android:name="com.enqualcomm.support.ANTI_ALARM" />
<action android:name="com.enqualcomm.support.TEMP_ALARM" />
+ <action android:name="com.ic.action.CHECK_ANTIOFF_EVENT"/>
</intent-filter>
</service>
<service android:name=".CoreService$InnerService" />
public static final String ACTION_EXIT_MONITOR_MODE = "com.enqualcomm.support.MONITOR_EXIT";\r
\r
public static final String ACTION_HEART_RATE_RESULT = "com.eqc.heartrate.action.RESULT";\r
- \r
+\r
public static final String ACTION_HEATR_RATE_START = "com.eqc.heartrate.action.SILENT_START";\r
- \r
+ public static final String ACTION_CHECK_ANTIOFF_EVENT = "com.ic.action.CHECK_ANTIOFF_EVENT";\r
+\r
public static final String ACTION_IMESSAGE = "action.message";\r
\r
public static final String ACTION_ISCONNECTED = "com.ic.protocol.ACTION_IS_SERVER_CONNECTED";\r
\r
import static android.app.PendingIntent.FLAG_UPDATE_CURRENT;\r
import static com.enqualcomm.support.Constants.ACTION_ALARM_ADD_DATAPOINTS;\r
+import static com.enqualcomm.support.Constants.ACTION_CHECK_ANTIOFF_EVENT;\r
import static com.enqualcomm.support.Constants.ACTION_EQC_ALARM;\r
import static com.enqualcomm.support.Constants.ACTION_HEATR_RATE_START;\r
import static com.enqualcomm.support.Constants.ACTION_LOCAL_SOS_ACTION;\r
Config.loadModCycleSettings(runtime); //回复之前的 工作模式即可\r
setLocationAlarm(runtime.getLocationInstance().getWorkingMod());//同时重置alarm并触发定位\r
\r
+ }else if(ACTION_CHECK_ANTIOFF_EVENT.equals(paramIntent.getAction())){\r
+ if (antiservice.check_ant_event()==1){\r
+ setAntiCheckAlarm();\r
+ }\r
}\r
\r
\r
if (heartRateDetectAlarmCycle>2)\r
AlarmHelper.setRealTimeAlarm(runtime.getContextProxy().context,heartRateDetectAlarmCycle,ACTION_HEATR_RATE_START);\r
}\r
+ public void setAntiCheckAlarm(){\r
+ AlarmHelper.setRealTimeAlarmInMicorSeconds(runtime.getContextProxy().context,500,ACTION_CHECK_ANTIOFF_EVENT);\r
+ }\r
\r
\r
public void setEmegencyLocationSTOPAlarm(int delayTimeInMinutes){\r
if (CoreService.getInstance()!=null)
Util.ShowToast(CoreService.getInstance().runtime,"Start ProtocolService!");
startService(new Intent(MainActivity.this,CoreService.class));// protocol service
- Observable.timer(5000L, TimeUnit.MILLISECONDS).subscribe(new Action1<Long>() {
- public void call(Long param1Long) {
- if (CoreService.getInstance()!=null) Util.ShowToast(CoreService.getInstance().runtime,"Stop ProtocolService!");
- stopService(new Intent(MainActivity.this,CoreService.class));// protocol service
- }
- });
- //delay 5秒再重启
- Observable.timer(10000L, TimeUnit.MILLISECONDS).subscribe(new Action1<Long>() {
- public void call(Long param1Long) {
- if (CoreService.getInstance()!=null) Util.ShowToast(CoreService.getInstance().runtime,"Start ProtocolService!");
- startService(new Intent(MainActivity.this,CoreService.class));// protocol service
- }
- });
+
+// Observable.timer(5000L, TimeUnit.MILLISECONDS).subscribe(new Action1<Long>() {
+//
+// public void call(Long param1Long) {
+// if (CoreService.getInstance()!=null) Util.ShowToast(CoreService.getInstance().runtime,"Stop ProtocolService!");
+// stopService(new Intent(MainActivity.this,CoreService.class));// protocol service
+// }
+// });
+// //delay 5秒再重启
+// Observable.timer(10000L, TimeUnit.MILLISECONDS).subscribe(new Action1<Long>() {
+// public void call(Long param1Long) {
+// if (CoreService.getInstance()!=null) Util.ShowToast(CoreService.getInstance().runtime,"Start ProtocolService!");
+// startService(new Intent(MainActivity.this,CoreService.class));// protocol service
+// }
+// });
break;
import android.hardware.SensorManager;\r
import android.os.Message;\r
import android.os.PowerManager;\r
-import android.util.Log;\r
\r
+import com.enqualcomm.support.CoreService;\r
import com.enqualcomm.support.bean.Runtime;\r
import com.enqualcomm.support.service.base.AbstractInvokeHandlerService;\r
import com.enqualcomm.support.utils.Connection;\r
import com.enqualcomm.support.utils.ICLogger;\r
-import com.enqualcomm.support.utils.WakeLockUtil;\r
+\r
import com.ic.protocols.protocolAPIHelper;\r
\r
+import java.util.Timer;\r
+import java.util.TimerTask;\r
+import java.util.concurrent.ScheduledThreadPoolExecutor;\r
+\r
import static java.lang.Thread.*;\r
\r
\r
\r
private SensorManager mSensorManager;\r
\r
+ private static int current_anti_status=10; //0 佩戴, 大于0 表示脱腕\r
+ private static int ant_status_event_reported=0; // 0 表示无消息, 1表示有消息需要发送, 大于1表示timeout时间内又有新消息,可以忽略不计\r
+ private static long anti_event_receivedTime=0;\r
+ private static int last_send_antoff_event=-1;\r
+ private AudioService mAudioService=null;\r
+\r
+\r
+ private void play_notify(){\r
+\r
+ if (this.mAudioService == null)\r
+ this.mAudioService = new AudioService();\r
+\r
+ this.mAudioService.play(mContext.getAssets(), "warning.mp3");\r
+\r
+ }\r
+ private void send_antiof_event(){\r
+\r
+ if (last_send_antoff_event==current_anti_status){\r
+ ICLogger.i("佩戴状态未变,skip!");\r
+ return;\r
+ }\r
+ if (current_anti_status==0){\r
+ //佩戴\r
+ play_notify();\r
+ mRuntime.setAlarmType(Runtime.AlarmType.ALARM_WEARED);\r
+ String msg=protocolAPIHelper.getWarningMSG(mRuntime);\r
+ Deliver.sendLocationMSG(msg); //消息很重要,所以利用带buffer的对列来发送!\r
+// try {\r
+// sleep(1000);\r
+// } catch (InterruptedException e) {\r
+// e.printStackTrace();\r
+// }\r
+// send_anti_event_broadcast(0);\r
+ }else{\r
+ //脱腕\r
+ play_notify();\r
+ // screen_on();\r
+ mRuntime.setAlarmType(Runtime.AlarmType.ALARM_ANTIOFF);\r
+ String msg=protocolAPIHelper.getWarningMSG(mRuntime);\r
+ Deliver.sendLocationMSG(msg); //消息很重要,所以利用带buffer的对列来发送!\r
+// try {\r
+// sleep(1000);\r
+// } catch (InterruptedException e) {\r
+// e.printStackTrace();\r
+// }\r
+// send_anti_event_broadcast(1);\r
+ }\r
+\r
+ last_send_antoff_event=current_anti_status;\r
+ ICLogger.i("AntiOff Timeout! send antioff event "+current_anti_status);\r
+ }\r
+\r
+ //return 0 表示check 结束, 1表示需要继续check 由coreService中 ACTION_CHECK_ANTIOFF_EVENT进行\r
+ public int check_ant_event(){\r
+\r
+ long currenttime=System.currentTimeMillis();\r
+ ICLogger.i("anti_event_receivedTime in "+ (currenttime - anti_event_receivedTime)\r
+ +"ms ago ,anti_event_count_when_start_timer "+ant_status_event_reported\r
+ );\r
+ if ((currenttime- anti_event_receivedTime) >= 1000){\r
+ send_antiof_event();\r
+\r
+ ant_status_event_reported=0;\r
+ return 0;\r
+ }else{\r
+ return 1;\r
+ }\r
+\r
+ }\r
+ private void reset_timer(){\r
+\r
+ if (1==ant_status_event_reported) //出现 ant_status_event_reported=0表示 有消息到来,需要开始,\r
+ {\r
+ // antioff_timer.schedule(antioff_timeout_handler,1000); //两秒后发送消息\r
+ CoreService.getInstance().setAntiCheckAlarm();\r
+ }\r
+ }\r
/**\r
* 启动传感器。\r
*/\r
\r
}\r
\r
-\r
private void screen_on(){\r
PowerManager mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);\r
PowerManager.WakeLock mWakeLock = mPowerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "tag");\r
\r
@Override\r
public void onSensorChanged(SensorEvent sensorEvent) {\r
- float proximity=sensorEvent.values[0];\r
- ICLogger.i("近距离 "+String.valueOf(proximity));\r
- if (proximity==0){\r
- //佩戴\r
- screen_on();\r
- mRuntime.setAlarmType(Runtime.AlarmType.ALARM_WEARED);\r
- String msg=protocolAPIHelper.getWarningMSG(mRuntime);\r
- Deliver.sendLocationMSG(msg); //消息很重要,所以利用带buffer的对列来发送!\r
- try {\r
- sleep(1000);\r
- } catch (InterruptedException e) {\r
- e.printStackTrace();\r
- }\r
- send_anti_event_broadcast(0);\r
- }else{\r
- //脱腕\r
- screen_on();\r
- mRuntime.setAlarmType(Runtime.AlarmType.ALARM_ANTIOFF);\r
- String msg=protocolAPIHelper.getWarningMSG(mRuntime);\r
- Deliver.sendLocationMSG(msg); //消息很重要,所以利用带buffer的对列来发送!\r
- try {\r
- sleep(1000);\r
- } catch (InterruptedException e) {\r
- e.printStackTrace();\r
- }\r
- send_anti_event_broadcast(1);\r
- }\r
+ current_anti_status=(int)sensorEvent.values[0];\r
+ ant_status_event_reported++;\r
+ ICLogger.i("近距离 "+current_anti_status+" get event "+ant_status_event_reported+" times !");\r
+ anti_event_receivedTime=System.currentTimeMillis();\r
+ reset_timer();\r
}\r
\r
@Override\r
}\r
alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, l + (minutes * 60 * 1000), pendingIntent);\r
}\r
-\r
+ public static void setRealTimeAlarmInMicorSeconds(Context context, int ms, String actionname) {\r
+ AlarmManager alarmManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);\r
+ Intent intent = new Intent(context, com.enqualcomm.support.CoreService.class);\r
+ intent.setAction(actionname);\r
+ PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);\r
+ alarmManager.cancel(pendingIntent);\r
+ long l = SystemClock.elapsedRealtime();\r
+ if (Build.VERSION.SDK_INT >= 19) {\r
+ alarmManager.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP, l + (ms ), pendingIntent);\r
+ return;\r
+ }\r
+ alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, l + (ms ), pendingIntent);\r
+ }\r
public static void setRealTimeAlarmInSeconds(Context context, int seconds, String actionname) {\r
AlarmManager alarmManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);\r
Intent intent = new Intent(context, com.enqualcomm.support.CoreService.class);\r
-#Tue Jun 30 18:16:52 CST 2020\r
-VERSION_CODE=430\r
+#Wed Jul 01 15:20:32 CST 2020\r
+VERSION_CODE=432\r