summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChen Xu <fionaxu@google.com>2021-03-17 20:46:48 +0800
committerChen Xu <fionaxu@google.com>2021-03-17 20:46:48 +0800
commite39569163ce8ebceb8850f97a11511b3852f13cb (patch)
tree70198aa5ae3698038577cbfa1dfdadc0913b9a3e
parentbc8781a4a981532a94f4414aefeb6c6f52d74c61 (diff)
downloadCellBroadcastReceiver-e39569163ce8ebceb8850f97a11511b3852f13cb.tar.gz
seprate notification channels
notification for unacknowledged alerts should be high priority notification for alerts diaplyed accompanied by alert dialog (used to display alerts on companion devices) should remains to be low priority. Thus have separate channels. Bug: 171959758 Test: Manual Change-Id: Ic3a2de7085c7224c59bf2c93e50ff42fcc6e98a1
-rw-r--r--res/values/strings.xml2
-rw-r--r--src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java39
2 files changed, 21 insertions, 20 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 2a892a10f..cea1128ec 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -123,6 +123,8 @@
<string name="notification_channel_broadcast_messages">Broadcast messages</string>
<!-- Notification channel name for a channel containing emergency alert notifications. [CHAR LIMIT=50] -->
<string name="notification_channel_emergency_alerts">Emergency alerts</string>
+ <!-- Notification channel name for a channel containing emergency alert notifications for unacknowledged alerts. [CHAR LIMIT=50] -->
+ <string name="notification_channel_emergency_alerts_high_priority">Unacknowledged Emergency alerts</string>
<!-- Notification channel name for a channel containing emergency alert notifications during voice call. [CHAR LIMIT=100] -->
<string name="notification_channel_broadcast_messages_in_voicecall">Emergency alerts in voice call</string>
<!-- Notification channel name for a channel containing info about WEA settings updates. [CHAR LIMIT=100] -->
diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java b/src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java
index b5c28ce9d..bf9056cf7 100644
--- a/src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java
+++ b/src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java
@@ -94,20 +94,17 @@ public class CellBroadcastAlertService extends Service {
static final String NOTIFICATION_CHANNEL_NON_EMERGENCY_ALERTS = "broadcastMessagesNonEmergency";
/**
- * Notification channel for emergency alerts. This is used when users dismiss the alert
- * dialog without officially hitting "OK" (e.g. by pressing the home button). In this case we
- * pop up a notification for them to refer to later
- *
- * Deprecated, use NOTIFICATION_CHANNEL_HIGH_PRIORITY_EMERGENCY_ALERTS.
+ * Notification channel for notifications accompanied by the alert dialog.
+ * e.g, only show when the device has active connections to companion devices.
*/
- static final String NOTIFICATION_CHANNEL_EMERGENCY_ALERTS_DEPRECATED = "broadcastMessages";
+ static final String NOTIFICATION_CHANNEL_EMERGENCY_ALERTS = "broadcastMessages";
/**
* Notification channel for emergency alerts. This is used when users dismiss the alert
* dialog without officially hitting "OK" (e.g. by pressing the home button). In this case we
* pop up a notification for them to refer to later.
*
- * This notification channel is HIGH_PRIORITY while the deprecated channel is LOW_PRIORITY.
+ * This notification channel is HIGH_PRIORITY.
*/
static final String NOTIFICATION_CHANNEL_HIGH_PRIORITY_EMERGENCY_ALERTS =
"broadcastMessagesHighPriority";
@@ -727,12 +724,15 @@ public class CellBroadcastAlertService extends Service {
CellBroadcastChannelManager channelManager = new CellBroadcastChannelManager(
context, message.getSubscriptionId());
- String channelId = channelManager.isEmergencyMessage(message)
- ? NOTIFICATION_CHANNEL_HIGH_PRIORITY_EMERGENCY_ALERTS
- : NOTIFICATION_CHANNEL_NON_EMERGENCY_ALERTS;
- if (channelId == NOTIFICATION_CHANNEL_HIGH_PRIORITY_EMERGENCY_ALERTS
- && sRemindAfterCallFinish) {
+ String channelId;
+ if (!channelManager.isEmergencyMessage(message)) {
+ channelId = NOTIFICATION_CHANNEL_NON_EMERGENCY_ALERTS;
+ } else if (sRemindAfterCallFinish) {
channelId = NOTIFICATION_CHANNEL_EMERGENCY_ALERTS_IN_VOICECALL;
+ } else if (fromDialog) {
+ channelId = NOTIFICATION_CHANNEL_EMERGENCY_ALERTS;
+ } else {
+ channelId = NOTIFICATION_CHANNEL_HIGH_PRIORITY_EMERGENCY_ALERTS;
}
boolean nonSwipeableNotification = message.isEmergencyMessage()
@@ -816,18 +816,17 @@ public class CellBroadcastAlertService extends Service {
static void createNotificationChannels(Context context) {
NotificationManager notificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
- // delete deprecated notification channel if it exists
- if (notificationManager.getNotificationChannel(
- NOTIFICATION_CHANNEL_EMERGENCY_ALERTS_DEPRECATED) != null) {
- notificationManager.deleteNotificationChannel(
- NOTIFICATION_CHANNEL_EMERGENCY_ALERTS_DEPRECATED);
- }
-
notificationManager.createNotificationChannel(
new NotificationChannel(
NOTIFICATION_CHANNEL_HIGH_PRIORITY_EMERGENCY_ALERTS,
- context.getString(R.string.notification_channel_emergency_alerts),
+ context.getString(
+ R.string.notification_channel_emergency_alerts_high_priority),
NotificationManager.IMPORTANCE_HIGH));
+ notificationManager.createNotificationChannel(
+ new NotificationChannel(
+ NOTIFICATION_CHANNEL_EMERGENCY_ALERTS,
+ context.getString(R.string.notification_channel_emergency_alerts),
+ NotificationManager.IMPORTANCE_LOW));
final NotificationChannel nonEmergency = new NotificationChannel(
NOTIFICATION_CHANNEL_NON_EMERGENCY_ALERTS,
context.getString(R.string.notification_channel_broadcast_messages),