From: TrillGates Date: Mon, 13 Sep 2021 12:27:00 +0000 (+0800) Subject: completed silent alarm receiver. X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=2506c5cbe6bfda380e93cd843428743fb9cedcfc;p=icsupport.git completed silent alarm receiver. --- diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b3e5c7cd..d8c9ec8e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -135,6 +135,12 @@ + + + + + + diff --git a/app/src/main/java/com/enqualcomm/support/ClassTimeSilentReceiver.java b/app/src/main/java/com/enqualcomm/support/ClassTimeSilentReceiver.java new file mode 100644 index 00000000..f9c53c94 --- /dev/null +++ b/app/src/main/java/com/enqualcomm/support/ClassTimeSilentReceiver.java @@ -0,0 +1,33 @@ +package com.enqualcomm.support; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; + +import com.enqualcomm.support.service.AlarmManagerUtil; +import com.enqualcomm.support.service.SilentManager; +import com.enqualcomm.support.utils.ICLogger; + +public class ClassTimeSilentReceiver extends BroadcastReceiver { + + @Override + public void onReceive(Context context, Intent intent) { + //判断action是打开,还是关闭 + String action = intent.getAction(); + ICLogger.d("action is ==> " + action); + if (AlarmManagerUtil.ALARM_SILENT_START_ACTION.equals(action)) { + //开始禁用模式 + SilentManager.getInstance().updateSettingAsSilent(true); + } else if (AlarmManagerUtil.ALARM_SILENT_END_ACTION.equals(action)) { + //结束禁用模式 + SilentManager.getInstance().updateSettingAsSilent(false); + } + long intervalMillis = intent.getLongExtra("intervalMillis", 0); + if (intervalMillis != 0) { + //设置下一个Alarm + AlarmManagerUtil.setAlarmTime(context, + System.currentTimeMillis() + intervalMillis, + intent); + } + } +} diff --git a/app/src/main/java/com/enqualcomm/support/Constants.java b/app/src/main/java/com/enqualcomm/support/Constants.java index b01f7fba..67e9be47 100644 --- a/app/src/main/java/com/enqualcomm/support/Constants.java +++ b/app/src/main/java/com/enqualcomm/support/Constants.java @@ -4,20 +4,16 @@ import android.net.Uri; public interface Constants { - String ACTION_LED = "com.enqualcomm.support.ACTION_LED"; - String ACTION_SHUTDOWN = "com.ic.action.shutdown"; String ACTION_PLAYTIME = "com.ic.action.playtime"; String ACTION_BROADCAST_PPG = "com.enqualcomm.support.ACTION_BROADCAST_PPG"; - String ACTION_ADDTEST_CONTACTS = "com.enqualcomm.imessage.ACTION_ADDTEST_CONTACTS"; String ACTION_ALARM_ADD_DATAPOINTS = "com.enqualcomm.support.ADD_DATAPOINTS"; String ACTION_ALARM_BLE_SCAN = "com.ic.Action.ALarm.bleScan"; - String ACTION_ALARM_CHECK_ANTI = "com.ic.Action.ALarm.CheckAnti"; String ACTION_ALARM_ALARM_CHANGE = "com.enqualcomm.support.ACTION_ALARM_ALARM_CHANGE"; String ACTION_ALARM_DELETE_ALARM = "com.ic.alarm.action.DELETE_ALARM"; @@ -26,26 +22,13 @@ public interface Constants { String ACTION_ANTIOFF_ALARM_CHANGE = "com.enqualcomm.support.ACTION_ANTIOFF_ALARM_CHANGE"; - String ACTION_AT_CALLBACK = "com.eqc.intent.action.callback.at"; - - String ACTION_BATTERY_LOW_MSG = "com.enqualcomm.support.lowbatteryMsg"; - - String ACTION_CALL_CMCM_SERVICE_INTERFACE = "com.cmcm.interface"; - - String ACTION_CALL_RING = "com.enqualcomm.support.phone.ring"; - String ACTION_IC_ALARM = "com.ic.alarm.action.ALARM"; String ACTION_CLOSE_UNREAD_MSG = "com.enqualcomm.support.CloseUnreadMsg"; - String ACTION_CM_POWERSAVE_MODE = "cmcm.call.eiot.into.powersave"; - String ACTION_EQC_ALARM = "com.enqualcomm.support.ACTION_EQC_ALARM"; String ACTION_LOCATION_ALARM = "com.enqualcomm.support.ACTION_LOCATION_ALARM"; - - String ACTION_EXIT_MONITOR_MODE = "com.enqualcomm.support.MONITOR_EXIT"; - String ACTION_HEATR_RATE_START = "com.eqc.heartrate.action.SILENT_START"; String ACTION_CHECK_ANTIOFF_EVENT = "com.ic.action.CHECK_ANTIOFF_EVENT"; String ACTION_CHECK_CUTOFF_EVENT = "com.ic.action.CHECK_CUTOFF_EVENT"; @@ -54,204 +37,37 @@ public interface Constants { String ACTION_ISCONNECTED = "com.ic.protocol.ACTION_IS_SERVER_CONNECTED"; - String ACTION_ISSILENCE = "com.enqualcomm.icare.ACTION_ISSILENCE"; - - String ACTION_ISSILENCE2IMESSAGE = "com.enqualcomm.support.ACTION_ISSILENCE2IMESSAGE"; - - String ACTION_MISSED_CALL_GET = "com.enqualcomm.support.ACTION_MISSED_CALL_GET"; - - String ACTION_NOTICE_ALARM = "com.enqualcomm.support.ACTION_NOTICE_ALARM"; - - String ACTION_NOTICE_ALARM_CHANGE = "com.enqualcomm.support.ACTION_NOTICE_ALARM_CHANGE"; - - String ACTION_PASS_DATA_TO_CM_SERVICES = "com.enqualcomm.support.PASS_DATA"; - String ACTION_REMOTE_CAMERA = "com.enqualcomm.support.ACTION_REMOTE_CAMERA"; - String ACTION_REMOTE_CAMERA_OSS = "com.enqualcomm.support.ACTION_REMOTE_CAMERA_OSS"; - - String ACTION_RESTORE_SYSTEM = "android.intent.action.MASTER_CLEAR"; - - String ACTION_SCANPAIRMESSAGE = "com.enqualcomm.imessage.scanPairMessage"; - - String ACTION_SEDN_VIDOE_CALL_REQ = "com.enqualcomm.imessage.sendVideoCall"; - - String ACTION_SEND_SOS_MSG = "com.enqualcomm.support.action_send_sos"; - String ACTION_SEND_EMEGENCY_LOCATION_START = "action.emegency.location.start"; String ACTION_SEND_EMEGENCY_LOCATION_STOP = "action.emegency.location.stop"; String ACTION_LOCAL_SOS_ACTION = "com.enqualcomm.support.local_sos"; - String ACTION_SEND_SOS_VIDEO_FILE = "com.enqualcomm.support.action_send_sos_video_file"; - - String ACTION_SEND_VIDEO_FILES = "com.enqualcomm.support.ACTION_SEND_VIDEO_FILES"; - - String ACTION_SHUTDOWN_MOREINFO = "android.intent.action.ACTION_SHUTDOWN_MOREINFO"; - - String ACTION_SOS_VIDEO_CHAT = "com.enqualcomm.imessage.ACTION_SOS_VIDEO_CHAT"; - - String ACTION_START_DOWNLOAD = "com.enqualcomm.imessage.START_DOWNLOAD_ACTION"; - - String ACTION_SYNC = "SYNC"; - - String ACTION_UNBOUND_TERMINAL = "com.enqualcomm.support.ACTION_UNBOUND_TERMINAL"; - - String ACTION_UPDATE_ICON = "com.enqualcomm.support.ACTION_UPDATE_ICON"; - - String ACTION_UPDATE_SECRET_KEY = "com.enqualcomm.support.UPDATE_SECRET_KEY"; - - String ACTION_VIDEO_END_CALL = "com.enqualcomm.support.ACTION_VIDEO_END_CALL"; - - String ACTION_VIDEO_LOGIN = "com.enqualcomm.imessage.ACTION_VIDEO_LOGIN"; - - String ACTION_VIDEO_LOGOUT = "com.enqualcomm.imessage.ACTION_VIDEO_LOGOUT"; - - String ACTION_VIDEO_RECEIVE_LOGIN = "com.enqualcomm.imessage.ACTION_VIDEO_RECEIVE_LOGIN"; - String ACTION_WAKEUP_ALARM = "com.eqc.deliverWakeupAlarm.action"; - String ACTION_YUN_ALARM_CHANGE = "com.eqc.deskclock.YUN_ALARM_CHANGE"; - String ACTION_PRACTICE_REPORT_ALARM = "com.enqualcomm.support.PRACTICE_ALARM"; - public static String ACTION_START_PRACTISE = "com.ic.action_start_practice"; - public static String KeyPractice = "cmd"; - - int ALARM_UPDATE_NOTICE = 206; - int CALL_RECORD_CHANGED = 103; - - String CMD_ID_CM = "cmdId"; Uri CONTACT_URI = Uri.parse("content://com.enqualcomm.support/contact"); - Uri CM_SERVICE_SETTING = Uri.parse("content://com.cmcm.service/cmsetting"); String DIALOG_ACTION = "com.enqualcomm.support.DIALOG"; String DIALOG_ACTION_WITH_IC_RESPONSE = "com.ic.dialog.action.DIALOG_RESPONSE"; - int ENTER_SILENT_MODE = 212; - - int EXIT_SILENT_MODE = 213; - - String FLAG = "flag"; - String TEMP_ALARM = "com.enqualcomm.support.TEMP_ALARM"; String HEARTBEAT_ALARM = "com.enqualcomm.support.HEARTBEAT_ALARM"; - int IDLE_MODE_CHANGED = 102; - - int INIT_SERVER_OK = 216; - - int IN_SILENCE = 600; - - boolean IS_OVERSEAS = false; - - int JUFENG_SDK_INIT = 215; - - String KEY_CATEGORY = "category"; - - String KEY_COMPANY = "KEY_COMPANY"; - - String KEY_CONTACT_ID = "contact_id"; - - String KEY_DELETE_FILE_TIME = "KEY_DELETE_FILE_TIME"; - - String KEY_DEVICE_ID = "key_device_id"; - - String KEY_DEVICE_KEY = "key_device_key"; - - String KEY_FILEPATH = "filepath"; - - String KEY_FILETYPE = "filetype"; - - String KEY_ID = "id"; - - String KEY_ISCONNECTED = "isConnected"; - - String KEY_ISSILENCE = "KEY_ISSILENCE"; - - String KEY_IS_RESUME = "key_is_resume"; - - String KEY_JUST_TALK = "KEY_JUST_TALK"; - - String KEY_NAME = "name"; - - String KEY_NET_WORK_TYPE = "NET_WORK_TYPE"; - - String KEY_NUMBER = "number"; - - String KEY_PAIR_CID = "PAIR_CID"; - - String KEY_REMOTE_NUMBER = "key_remote_number"; - String KEY_SAVE_STEP_COUNT = "key_save_step_count"; - String KEY_SOS_FILE_BODY = "key_sos_file_body"; - - String KEY_SOS_FILE_FILE_TYPE = "key_sos_file_file_type"; - - String KEY_STATUS = "key_status"; - String KEY_STEP_COUNT = "KEY_STEP_COUNT"; - String KEY_UNBOUND_FLAG = "KEY_UNBOUND_FLAG"; - - String KEY_VIDEO_PATH = "KEY_VIDEO_PATH"; - - int LOCATION_DATA = 217; - - int MONITOR_GOIN = 202; - - int MONITOR_GOOUT = 203; - - int MSG_WHAT_RELOAD_VOICE = 1000; - - int MSG_WHAT_SEND_OSSFILE = 1006; - - int MSG_WHAT_SEND_PAIR = 1003; - - int MSG_WHAT_SEND_PICTURE = 1002; - - int MSG_WHAT_SEND_VOICE = 1001; - - int MSG_WHAT_SILENCE_STATUS = 1005; - - int MSG_WHAT_VIDEO_CHAT = 1004; - - int MSG_WHAT_PPG = 1007; - String key_ppg = "ppg"; - String key_bph = "bph"; - String key_bpl = "bpl"; - String key_spo2 = "sp02"; - - - int NEW_MEDIA_PUSH = 100; - String ACTION_SMS_RECEIVED = "android.provider.Telephony.SMS_RECEIVED"; String OTHER_ALARM_END = "com.enqualcomm.support.OTHER_ALARM_END"; String OTHER_ALARM_START = "com.enqualcomm.support.OTHER_ALARM_START"; String ALARM_POWER_OFF = "com.ic.power.ACTION_ALARM_POWER_OFF"; - String OTHER_HEARTRATE_ALARM_END = "com.enqualcomm.support.OTHER_HEARTRATE_ALARM_END"; - - String OTHER_HEARTRATE_ALARM_START = "com.enqualcomm.support.OTHER_HEARTRATE_ALARM_START"; - - int OUT_SILENCE = 700; - - int PASS_DATA_DIRECTLY = 500; - - int PLAY_RECORD_UPDATE = 207; - - int REBOOT_SYSTEM = 208; - - int RESET_SYSTEM = 210; - - String RESTORE_EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE"; - - String RESTORE_REASON = "android.intent.extra.REASON"; - String ACTION_START_FOTA_UPDATE = "com.ic.action.startfotaUpdate"; String ACTION_SMSCMD = "com.enqualcomm.support.SMSCMD"; @@ -262,54 +78,26 @@ public interface Constants { String ACTION_SMSCMD_TEST = "com.ic.action.internaltest"; - int RESULT_ERROR = 500; - - int RESULT_OK = 200; - String RESUME_ACTION = "com.enqualcomm.imessage.RESUME_ACTION"; String SERVICE_CLS_NAME = "com.enqualcomm.support.CoreService"; String SERVICE_PKG_NAME = "com.enqualcomm.support"; - int SHUTDOWN_SYSTM = 209; String SLEEP_ALARM = "com.enqualcomm.support.SLEEP_ALARM"; - String SOS_ACTION = "com.enqualcomm.imessage.SOS_ACTION"; - - int SOS_GOIN = 204; - - int SOS_GOOUT = 205; String STEP_COUNT_ALARM_ACTION = "com.enqualcomm.support.ACTION_STEP_COUNT_ALARM"; - String STRING_CMD_JSON_DATA = "cmdJsonData"; - - String STWORKMODE_ALARM = "com.enqualcomm.support.ACTION_STWORKMODE_ALARM"; - - String VALUE_SETTIING_VERSION = "value_setting_ver"; - - int VIDEO_MESSAGE = 300; String WAKE_ALARM = "com.enqualcomm.support.WAKE_ALARM"; - String WEATHER_ALARM = "com.ic.alarm.ACTION_WEATHER_ALARM"; - String WEATHER_ACTION = "com.ic.action.ACTION_GET_WEATHER"; String ACTION_QUERY_WEATHER = "com.ic.action_query_weather"; String ACTION_WEATHER_RECEIVED = "com.ic.action_weather_recveived"; String KEY_Weather = "weather"; - - int WIFI_SET_RESULT = 217; - - int WORKMODE_CHANGED = 211; - String contact = "contact"; - - String wechat_contact = "content"; - - String ACTION_CHECK_SERVER_RESPONSE = "com.enqualcomm.support.ACTION_CHECK_SERVER_RESPONSE"; String ACTION_RETRY_SERVER_CONNECT = "com.enqualcomm.support.ACTION_RETRY_SERVER_CONNECT"; String ACTION_CHECK_LOCATION_RESULT = "com.enqualcomm.support.ACTION_CHECK_LOCATION_RESULT"; @@ -322,11 +110,6 @@ public interface Constants { String KEY_MESSAGE_FROM = "msgFrom"; // 消息来源(发送者名称),预留,暂时不用。 - String ACTION_TEMP_RESULT = "com.ic.action.temp_result"; - String KEY_TEMP_BODY = "body"; // double 体温 - String KEY_TEMP_WRIST = "wrist"; // double 腕温 - String KEY_TEMP_OUT = "out"; // double 腕温 - String ACTION_ANTI_OFF0 = "com.ic.ACTION_ANTIOFF"; String ACTION_CUT_OFF = "com.ic.ACTION_STRIP"; String KEY_ANTI_EVENT = "eventID"; //integer eventID =1 脱落, eventID =0 佩戴 @@ -384,12 +167,6 @@ public interface Constants { */ String KEY_SIT_RANGE = "sit_range"; - - /*** - * 内部定时器用action alarm - */ - String ACTION_SIT_ALARM = "com.ic.action.sit_alarm_local"; - /** * 发送给app做显示用 */ diff --git a/app/src/main/java/com/enqualcomm/support/service/AlarmManagerUtil.java b/app/src/main/java/com/enqualcomm/support/service/AlarmManagerUtil.java index 9b7bf30c..226b83db 100644 --- a/app/src/main/java/com/enqualcomm/support/service/AlarmManagerUtil.java +++ b/app/src/main/java/com/enqualcomm/support/service/AlarmManagerUtil.java @@ -14,7 +14,8 @@ import java.util.Date; public class AlarmManagerUtil { public static final String ALARM_ACTION = "com.ic.alarm.action.ALARM_CLOCK"; - public static final String ALARM_SILENT_ACTION = "com.ic.alarm.action.ALARM_SILENT"; + public static final String ALARM_SILENT_START_ACTION = "com.ic.alarm.action.ALARM_SILENT_START"; + public static final String ALARM_SILENT_END_ACTION = "com.ic.alarm.action.ALARM_SILENT_END"; public static void setAlarmTime(Context context, long timeInMillis, Intent intent) { AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); diff --git a/app/src/main/java/com/enqualcomm/support/service/SilentManager.java b/app/src/main/java/com/enqualcomm/support/service/SilentManager.java index aa188b30..27fcea22 100644 --- a/app/src/main/java/com/enqualcomm/support/service/SilentManager.java +++ b/app/src/main/java/com/enqualcomm/support/service/SilentManager.java @@ -53,7 +53,6 @@ import static com.enqualcomm.support.Constants.ACTION_ALARM_SILENT2_UPDATE; import static com.enqualcomm.support.Constants.ACTION_ANTIOFF_ALARM_CHANGE; import static com.enqualcomm.support.Constants.ACTION_CLOSE_UNREAD_MSG; import static com.enqualcomm.support.Constants.ACTION_IC_ALARM; -import static com.enqualcomm.support.Constants.ACTION_NOTICE_ALARM_CHANGE; public class SilentManager extends AbstractInvokeHandlerService { @@ -297,11 +296,6 @@ public class SilentManager extends AbstractInvokeHandlerService { return this.mDbHelper.queryAntioff(true); } - - private ArrayList querySilent() { - return this.mDbHelper.querySilence(true); - } - private void setNewAlarm(List alarmArrayList) { for (Alarm alarm : alarmArrayList) { Log.d("setNewAlarm======", "alarm == > " + alarm); @@ -361,7 +355,6 @@ public class SilentManager extends AbstractInvokeHandlerService { this.mInSilent = this.isSilentTime(); this.mAlarmReceiver = new AlarmReceiver(); IntentFilter intentFilter = new IntentFilter(); - intentFilter.addAction(ACTION_NOTICE_ALARM_CHANGE); intentFilter.addAction(ACTION_ALARM_ALARM_CHANGE); intentFilter.addAction(ACTION_ALARM_DELETE_ALARM); intentFilter.addAction(ACTION_ALARM_SILENT2_UPDATE); @@ -414,27 +407,8 @@ public class SilentManager extends AbstractInvokeHandlerService { ICLogger.e(e.getMessage(), e); } } - } else if ("com.enqualcomm.support.ACTION_NOTICE_ALARM".equals(action)) { - String alarmTime = intent.getDataString(); - if (this.isIdle(this.mContext)) { - try { - intent = new Intent("com.enqualcomm.icare.NOTICE", Uri.parse(alarmTime)); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - this.mContext.startActivity(intent); - } catch (Exception e) { - e.printStackTrace(); - ICLogger.e(e.getMessage(), e); - } - } } else { ICLogger.i("静默闹钟来了"); - boolean silentchange; - if (!"com.eqc.heartrate.action.SILENT_START".equals(action) && !"com.enqualcomm.support.OTHER_HEARTRATE_ALARM_START".equals(action)) { - silentchange = false; - } else { - silentchange = true; - } - //this.handleSilent(runtime, silentchange ^ true); } return false; } @@ -447,13 +421,8 @@ public class SilentManager extends AbstractInvokeHandlerService { class AlarmReceiver extends BroadcastReceiver { public void onReceive(Context context, Intent intent) { String action = intent.getAction(); - StringBuilder var3 = new StringBuilder(); - var3.append("action = "); - var3.append(action); - ICLogger.i(var3.toString()); - if (ACTION_NOTICE_ALARM_CHANGE.equals(action)) { - //SilentManager.this.voiceNotice = SilentManager.this.queryNotice(); - } else if (ACTION_ALARM_ALARM_CHANGE.equals(action)) { + ICLogger.d("action ==> " + action); + if (ACTION_ALARM_ALARM_CHANGE.equals(action)) { //这是英卡的闹钟库 updateIcAlarm(); } else if (ACTION_ANTIOFF_ALARM_CHANGE.equals(action)) { @@ -553,7 +522,7 @@ public class SilentManager extends AbstractInvokeHandlerService { startHour, startMinute, alarmStartId, Integer.parseInt(aChar + ""), "上课禁用开始" + startValue, - 2, AlarmManagerUtil.ALARM_SILENT_ACTION); + 2, AlarmManagerUtil.ALARM_SILENT_START_ACTION); //结束时间 String targetEndAlarm = SILENT_ALARM_REQUEST_CODE_END_PREFIX + idValue + aChar; int alarmEndId = Integer.parseInt(targetEndAlarm); @@ -562,7 +531,7 @@ public class SilentManager extends AbstractInvokeHandlerService { endHour, endMinute, alarmEndId, Integer.parseInt(aChar + ""), "上课禁用结束" + endValue, - 2, AlarmManagerUtil.ALARM_SILENT_ACTION); + 2, AlarmManagerUtil.ALARM_SILENT_END_ACTION); } } else { //单次 @@ -577,12 +546,12 @@ public class SilentManager extends AbstractInvokeHandlerService { String targetStartAlarm = SILENT_ALARM_REQUEST_CODE_START_PREFIX + idValue + aChar; int alarmStartId = Integer.parseInt(targetStartAlarm); ICLogger.d("alarmStartId ==> " + alarmStartId); - AlarmManagerUtil.cancelAlarm(mContext, AlarmManagerUtil.ALARM_SILENT_ACTION, alarmStartId); + AlarmManagerUtil.cancelAlarm(mContext, AlarmManagerUtil.ALARM_SILENT_START_ACTION, alarmStartId); // String targetEndAlarm = SILENT_ALARM_REQUEST_CODE_END_PREFIX + idValue + aChar; int alarmEndId = Integer.parseInt(targetEndAlarm); ICLogger.d("alarmEndId ==> " + alarmEndId); - AlarmManagerUtil.cancelAlarm(mContext, AlarmManagerUtil.ALARM_SILENT_ACTION, alarmEndId); + AlarmManagerUtil.cancelAlarm(mContext, AlarmManagerUtil.ALARM_SILENT_END_ACTION, alarmEndId); } } //判断当前是否需要开启,设置config里的比状态即可 @@ -602,7 +571,7 @@ public class SilentManager extends AbstractInvokeHandlerService { public static final String SILENT_KEY = "is_force_to_silent"; - private void updateSettingAsSilent(boolean isSilent) { + public void updateSettingAsSilent(boolean isSilent) { mHandler.post(() -> { ICLogger.d("isSilent ==> " + isSilent); ContentValues contentValues = new ContentValues();