release 432
authorsnickersun <scy@incartech.cn>
Wed, 1 Jul 2020 07:24:05 +0000 (15:24 +0800)
committersnickersun <scy@incartech.cn>
Wed, 1 Jul 2020 07:24:05 +0000 (15:24 +0800)
根据客户要求去掉亮屏提示窗口,暂时用一个短提示音提示佩戴摘除。后面再删除。
给佩戴提示做1秒防抖,1秒内多次以最后一次为准。

app/app.iml
app/release/ICSer_V432_2007011520_release.apk [moved from app/release/ICSer_V430_2006301816_release.apk with 79% similarity]
app/src/main/AndroidManifest.xml
app/src/main/assets/warning.mp3 [new file with mode: 0644]
app/src/main/java/com/enqualcomm/support/Constants.java
app/src/main/java/com/enqualcomm/support/CoreService.java
app/src/main/java/com/enqualcomm/support/MainActivity.java
app/src/main/java/com/enqualcomm/support/service/AntiMonitorService.java
app/src/main/java/com/enqualcomm/support/utils/AlarmHelper.java
app/version_code.properties

index 23bf84d..96972aa 100644 (file)
     <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
similarity index 79%
rename from app/release/ICSer_V430_2006301816_release.apk
rename to app/release/ICSer_V432_2007011520_release.apk
index a4e426b..020c4ee 100644 (file)
Binary files a/app/release/ICSer_V430_2006301816_release.apk and b/app/release/ICSer_V432_2007011520_release.apk differ
index b02434e..8a7e5d5 100644 (file)
                 <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" />
diff --git a/app/src/main/assets/warning.mp3 b/app/src/main/assets/warning.mp3
new file mode 100644 (file)
index 0000000..9d48e45
Binary files /dev/null and b/app/src/main/assets/warning.mp3 differ
index c643df9..7dcef29 100644 (file)
@@ -40,9 +40,10 @@ public interface Constants {
   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
index a63c2bf..0255662 100644 (file)
@@ -63,6 +63,7 @@ import java.util.concurrent.TimeUnit;
 \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
@@ -809,6 +810,10 @@ public class CoreService extends Service {
                 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
@@ -829,6 +834,9 @@ public class CoreService extends Service {
         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
index 74b5642..5597658 100644 (file)
@@ -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<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;
 
index c39fbee..e93d95e 100644 (file)
@@ -8,15 +8,19 @@ import android.hardware.SensorEventListener;
 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
@@ -31,6 +35,83 @@ public class AntiMonitorService extends AbstractInvokeHandlerService {
 \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
@@ -64,7 +145,6 @@ public class AntiMonitorService extends AbstractInvokeHandlerService {
 \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
@@ -74,33 +154,11 @@ public class AntiMonitorService extends AbstractInvokeHandlerService {
 \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
index da1dcf7..f659755 100644 (file)
@@ -88,7 +88,19 @@ public class AlarmHelper {
     }\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
index cd9fe54..cc507bf 100644 (file)
@@ -1,2 +1,2 @@
-#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