From: snickersun Date: Wed, 1 Jul 2020 07:24:05 +0000 (+0800) Subject: release 432 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.js?a=commitdiff_plain;h=0d983fb51272db7ea34037e798bf649505f929e9;p=protocol_srv.git release 432 根据客户要求去掉亮屏提示窗口,暂时用一个短提示音提示佩戴摘除。后面再删除。 给佩戴提示做1秒防抖,1秒内多次以最后一次为准。 --- diff --git a/app/app.iml b/app/app.iml index 23bf84d3..96972aaf 100644 --- a/app/app.iml +++ b/app/app.iml @@ -126,7 +126,6 @@ - diff --git a/app/release/ICSer_V430_2006301816_release.apk b/app/release/ICSer_V432_2007011520_release.apk similarity index 79% rename from app/release/ICSer_V430_2006301816_release.apk rename to app/release/ICSer_V432_2007011520_release.apk index a4e426bd..020c4eef 100644 Binary files a/app/release/ICSer_V430_2006301816_release.apk and b/app/release/ICSer_V432_2007011520_release.apk differ diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b02434ec..8a7e5d51 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -116,6 +116,7 @@ + diff --git a/app/src/main/assets/warning.mp3 b/app/src/main/assets/warning.mp3 new file mode 100644 index 00000000..9d48e456 Binary files /dev/null and b/app/src/main/assets/warning.mp3 differ diff --git a/app/src/main/java/com/enqualcomm/support/Constants.java b/app/src/main/java/com/enqualcomm/support/Constants.java index c643df96..7dcef293 100644 --- a/app/src/main/java/com/enqualcomm/support/Constants.java +++ b/app/src/main/java/com/enqualcomm/support/Constants.java @@ -40,9 +40,10 @@ public interface Constants { public static final String ACTION_EXIT_MONITOR_MODE = "com.enqualcomm.support.MONITOR_EXIT"; public static final String ACTION_HEART_RATE_RESULT = "com.eqc.heartrate.action.RESULT"; - + public static final String ACTION_HEATR_RATE_START = "com.eqc.heartrate.action.SILENT_START"; - + public static final String ACTION_CHECK_ANTIOFF_EVENT = "com.ic.action.CHECK_ANTIOFF_EVENT"; + public static final String ACTION_IMESSAGE = "action.message"; public static final String ACTION_ISCONNECTED = "com.ic.protocol.ACTION_IS_SERVER_CONNECTED"; diff --git a/app/src/main/java/com/enqualcomm/support/CoreService.java b/app/src/main/java/com/enqualcomm/support/CoreService.java index a63c2bfc..0255662f 100644 --- a/app/src/main/java/com/enqualcomm/support/CoreService.java +++ b/app/src/main/java/com/enqualcomm/support/CoreService.java @@ -63,6 +63,7 @@ import java.util.concurrent.TimeUnit; 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_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; @@ -809,6 +810,10 @@ public class CoreService extends Service { Config.loadModCycleSettings(runtime); //回复之前的 工作模式即可 setLocationAlarm(runtime.getLocationInstance().getWorkingMod());//同时重置alarm并触发定位 + }else if(ACTION_CHECK_ANTIOFF_EVENT.equals(paramIntent.getAction())){ + if (antiservice.check_ant_event()==1){ + setAntiCheckAlarm(); + } } @@ -829,6 +834,9 @@ public class CoreService extends Service { if (heartRateDetectAlarmCycle>2) AlarmHelper.setRealTimeAlarm(runtime.getContextProxy().context,heartRateDetectAlarmCycle,ACTION_HEATR_RATE_START); } + public void setAntiCheckAlarm(){ + AlarmHelper.setRealTimeAlarmInMicorSeconds(runtime.getContextProxy().context,500,ACTION_CHECK_ANTIOFF_EVENT); + } public void setEmegencyLocationSTOPAlarm(int delayTimeInMinutes){ diff --git a/app/src/main/java/com/enqualcomm/support/MainActivity.java b/app/src/main/java/com/enqualcomm/support/MainActivity.java index 74b56429..55976586 100644 --- a/app/src/main/java/com/enqualcomm/support/MainActivity.java +++ b/app/src/main/java/com/enqualcomm/support/MainActivity.java @@ -146,19 +146,21 @@ public class MainActivity extends AppCompatActivity { 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() { - 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() { - 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() { +// +// 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() { +// 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; diff --git a/app/src/main/java/com/enqualcomm/support/service/AntiMonitorService.java b/app/src/main/java/com/enqualcomm/support/service/AntiMonitorService.java index c39fbee0..e93d95e5 100644 --- a/app/src/main/java/com/enqualcomm/support/service/AntiMonitorService.java +++ b/app/src/main/java/com/enqualcomm/support/service/AntiMonitorService.java @@ -8,15 +8,19 @@ import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.os.Message; import android.os.PowerManager; -import android.util.Log; +import com.enqualcomm.support.CoreService; import com.enqualcomm.support.bean.Runtime; import com.enqualcomm.support.service.base.AbstractInvokeHandlerService; import com.enqualcomm.support.utils.Connection; import com.enqualcomm.support.utils.ICLogger; -import com.enqualcomm.support.utils.WakeLockUtil; + import com.ic.protocols.protocolAPIHelper; +import java.util.Timer; +import java.util.TimerTask; +import java.util.concurrent.ScheduledThreadPoolExecutor; + import static java.lang.Thread.*; @@ -31,6 +35,83 @@ public class AntiMonitorService extends AbstractInvokeHandlerService { private SensorManager mSensorManager; + private static int current_anti_status=10; //0 佩戴, 大于0 表示脱腕 + private static int ant_status_event_reported=0; // 0 表示无消息, 1表示有消息需要发送, 大于1表示timeout时间内又有新消息,可以忽略不计 + private static long anti_event_receivedTime=0; + private static int last_send_antoff_event=-1; + private AudioService mAudioService=null; + + + private void play_notify(){ + + if (this.mAudioService == null) + this.mAudioService = new AudioService(); + + this.mAudioService.play(mContext.getAssets(), "warning.mp3"); + + } + private void send_antiof_event(){ + + if (last_send_antoff_event==current_anti_status){ + ICLogger.i("佩戴状态未变,skip!"); + return; + } + if (current_anti_status==0){ + //佩戴 + play_notify(); + mRuntime.setAlarmType(Runtime.AlarmType.ALARM_WEARED); + String msg=protocolAPIHelper.getWarningMSG(mRuntime); + Deliver.sendLocationMSG(msg); //消息很重要,所以利用带buffer的对列来发送! +// try { +// sleep(1000); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } +// send_anti_event_broadcast(0); + }else{ + //脱腕 + play_notify(); + // screen_on(); + mRuntime.setAlarmType(Runtime.AlarmType.ALARM_ANTIOFF); + String msg=protocolAPIHelper.getWarningMSG(mRuntime); + Deliver.sendLocationMSG(msg); //消息很重要,所以利用带buffer的对列来发送! +// try { +// sleep(1000); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } +// send_anti_event_broadcast(1); + } + + last_send_antoff_event=current_anti_status; + ICLogger.i("AntiOff Timeout! send antioff event "+current_anti_status); + } + + //return 0 表示check 结束, 1表示需要继续check 由coreService中 ACTION_CHECK_ANTIOFF_EVENT进行 + public int check_ant_event(){ + + long currenttime=System.currentTimeMillis(); + ICLogger.i("anti_event_receivedTime in "+ (currenttime - anti_event_receivedTime) + +"ms ago ,anti_event_count_when_start_timer "+ant_status_event_reported + ); + if ((currenttime- anti_event_receivedTime) >= 1000){ + send_antiof_event(); + + ant_status_event_reported=0; + return 0; + }else{ + return 1; + } + + } + private void reset_timer(){ + + if (1==ant_status_event_reported) //出现 ant_status_event_reported=0表示 有消息到来,需要开始, + { + // antioff_timer.schedule(antioff_timeout_handler,1000); //两秒后发送消息 + CoreService.getInstance().setAntiCheckAlarm(); + } + } /** * 启动传感器。 */ @@ -64,7 +145,6 @@ public class AntiMonitorService extends AbstractInvokeHandlerService { } - private void screen_on(){ PowerManager mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock mWakeLock = mPowerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "tag"); @@ -74,33 +154,11 @@ public class AntiMonitorService extends AbstractInvokeHandlerService { @Override public void onSensorChanged(SensorEvent sensorEvent) { - float proximity=sensorEvent.values[0]; - ICLogger.i("近距离 "+String.valueOf(proximity)); - if (proximity==0){ - //佩戴 - screen_on(); - mRuntime.setAlarmType(Runtime.AlarmType.ALARM_WEARED); - String msg=protocolAPIHelper.getWarningMSG(mRuntime); - Deliver.sendLocationMSG(msg); //消息很重要,所以利用带buffer的对列来发送! - try { - sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - send_anti_event_broadcast(0); - }else{ - //脱腕 - screen_on(); - mRuntime.setAlarmType(Runtime.AlarmType.ALARM_ANTIOFF); - String msg=protocolAPIHelper.getWarningMSG(mRuntime); - Deliver.sendLocationMSG(msg); //消息很重要,所以利用带buffer的对列来发送! - try { - sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - send_anti_event_broadcast(1); - } + current_anti_status=(int)sensorEvent.values[0]; + ant_status_event_reported++; + ICLogger.i("近距离 "+current_anti_status+" get event "+ant_status_event_reported+" times !"); + anti_event_receivedTime=System.currentTimeMillis(); + reset_timer(); } @Override diff --git a/app/src/main/java/com/enqualcomm/support/utils/AlarmHelper.java b/app/src/main/java/com/enqualcomm/support/utils/AlarmHelper.java index da1dcf78..f6597550 100644 --- a/app/src/main/java/com/enqualcomm/support/utils/AlarmHelper.java +++ b/app/src/main/java/com/enqualcomm/support/utils/AlarmHelper.java @@ -88,7 +88,19 @@ public class AlarmHelper { } alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, l + (minutes * 60 * 1000), pendingIntent); } - + public static void setRealTimeAlarmInMicorSeconds(Context context, int ms, String actionname) { + AlarmManager alarmManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); + Intent intent = new Intent(context, com.enqualcomm.support.CoreService.class); + intent.setAction(actionname); + PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); + alarmManager.cancel(pendingIntent); + long l = SystemClock.elapsedRealtime(); + if (Build.VERSION.SDK_INT >= 19) { + alarmManager.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP, l + (ms ), pendingIntent); + return; + } + alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, l + (ms ), pendingIntent); + } public static void setRealTimeAlarmInSeconds(Context context, int seconds, String actionname) { AlarmManager alarmManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(context, com.enqualcomm.support.CoreService.class); diff --git a/app/version_code.properties b/app/version_code.properties index cd9fe541..cc507bf6 100644 --- a/app/version_code.properties +++ b/app/version_code.properties @@ -1,2 +1,2 @@ -#Tue Jun 30 18:16:52 CST 2020 -VERSION_CODE=430 +#Wed Jul 01 15:20:32 CST 2020 +VERSION_CODE=432