summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChen Xu <fionaxu@google.com>2021-03-18 00:03:10 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2021-03-18 00:03:10 +0000
commit093a940d7a52142c2a7c7feb679c61b50af4a75f (patch)
tree1f2bddf5cfe1f01011a1f8a932ecc16df9e8d3b2
parent6ab115a7589716f1074ed868d7efed671df76b62 (diff)
parente39569163ce8ebceb8850f97a11511b3852f13cb (diff)
downloadCellBroadcastReceiver-093a940d7a52142c2a7c7feb679c61b50af4a75f.tar.gz
Merge "seprate notification channels" into mainline-prod
-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),