summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/notification
diff options
context:
space:
mode:
Diffstat (limited to 'java/com/android/dialer/notification')
-rw-r--r--java/com/android/dialer/notification/GroupedNotificationUtil.java4
-rw-r--r--java/com/android/dialer/notification/NotificationChannelManager.java45
-rw-r--r--java/com/android/dialer/notification/res/values-de/strings.xml2
3 files changed, 34 insertions, 17 deletions
diff --git a/java/com/android/dialer/notification/GroupedNotificationUtil.java b/java/com/android/dialer/notification/GroupedNotificationUtil.java
index 63ea51739..3925248d5 100644
--- a/java/com/android/dialer/notification/GroupedNotificationUtil.java
+++ b/java/com/android/dialer/notification/GroupedNotificationUtil.java
@@ -41,7 +41,7 @@ public final class GroupedNotificationUtil {
int id,
@NonNull String summaryTag) {
if (tag == null) {
- // Clear all missed call notifications
+ // Clear all grouped notifications
for (StatusBarNotification notification : notificationManager.getActiveNotifications()) {
if (notification.getId() == id) {
notificationManager.cancel(notification.getTag(), id);
@@ -50,7 +50,7 @@ public final class GroupedNotificationUtil {
} else {
notificationManager.cancel(tag, id);
- // See if other non-summary missed call notifications exist, and if not then clear the summary
+ // See if other non-summary grouped notifications exist, and if not then clear the summary
boolean clearSummary = true;
for (StatusBarNotification notification : notificationManager.getActiveNotifications()) {
if (notification.getId() == id && !Objects.equals(summaryTag, notification.getTag())) {
diff --git a/java/com/android/dialer/notification/NotificationChannelManager.java b/java/com/android/dialer/notification/NotificationChannelManager.java
index 5cae3d8c8..f23c02ad3 100644
--- a/java/com/android/dialer/notification/NotificationChannelManager.java
+++ b/java/com/android/dialer/notification/NotificationChannelManager.java
@@ -53,25 +53,15 @@ public class NotificationChannelManager {
* Set the channel of notification appropriately. Will create the channel if it does not already
* exist. Safe to call pre-O (will no-op).
*
- * <p>phoneAccount should only be null if channelName is {@link Channel#MISC}.
+ * <p>phoneAccount should only be null if channelName is {@link Channel#MISC} or {@link
+ * Channel#MISSED_CALL} since these do not have account-specific settings.
*/
public static void applyChannel(
@NonNull Notification.Builder notification,
@NonNull Context context,
@Channel String channelName,
@Nullable PhoneAccountHandle phoneAccount) {
- if (phoneAccount == null) {
- if (!Channel.MISC.equals(channelName)) {
- IllegalArgumentException exception =
- new IllegalArgumentException(
- "Phone account handle must not be null unless on Channel.MISC");
- if (BuildType.get() >= BuildType.RELEASE) {
- LogUtil.e("NotificationChannelManager.applyChannel", null, exception);
- } else {
- throw exception;
- }
- }
- }
+ checkNullity(channelName, phoneAccount);
if (BuildCompat.isAtLeastO()) {
NotificationChannel channel =
@@ -80,6 +70,33 @@ public class NotificationChannelManager {
}
}
+ private static void checkNullity(
+ @Channel String channelName, @Nullable PhoneAccountHandle phoneAccount) {
+ if (phoneAccount != null || channelAllowsNullPhoneAccountHandle(channelName)) {
+ return;
+ }
+
+ // TODO (b/36568553): don't throw an exception once most cases have been identified
+ IllegalArgumentException exception =
+ new IllegalArgumentException(
+ "Phone account handle must not be null on channel " + channelName);
+ if (BuildType.get() == BuildType.RELEASE) {
+ LogUtil.e("NotificationChannelManager.applyChannel", null, exception);
+ } else {
+ throw exception;
+ }
+ }
+
+ private static boolean channelAllowsNullPhoneAccountHandle(@Channel String channelName) {
+ switch (channelName) {
+ case Channel.MISC:
+ case Channel.MISSED_CALL:
+ return true;
+ default:
+ return false;
+ }
+ }
+
/** The base Channel IDs for {@link NotificationChannel} */
@Retention(RetentionPolicy.SOURCE)
@StringDef({
@@ -136,7 +153,7 @@ public class NotificationChannelManager {
(account == null) ? phoneAccountHandle.getId() : account.getLabel().toString());
getNotificationManager(context)
.createNotificationChannelGroup(group); // No-op if already exists
- } else if (!Channel.MISC.equals(channelName)) {
+ } else if (!channelAllowsNullPhoneAccountHandle(channelName)) {
LogUtil.w(
"NotificationChannelManager.createChannel",
"Null PhoneAccountHandle with channel " + channelName);
diff --git a/java/com/android/dialer/notification/res/values-de/strings.xml b/java/com/android/dialer/notification/res/values-de/strings.xml
index a9dbd5b94..18a41291f 100644
--- a/java/com/android/dialer/notification/res/values-de/strings.xml
+++ b/java/com/android/dialer/notification/res/values-de/strings.xml
@@ -20,7 +20,7 @@
<string name="notification_channel_incoming_call" msgid="2478740764736158630">"Eingehende Anrufe"</string>
<string name="notification_channel_ongoing_call" msgid="5593444445363940672">"Laufende Anrufe"</string>
<string name="notification_channel_missed_call" msgid="5820652855908217695">"Entgangene Anrufe"</string>
- <string name="notification_channel_voicemail" msgid="9206363659849426204">"Mailbox-Nachrichten"</string>
+ <string name="notification_channel_voicemail" msgid="9206363659849426204">"Mailboxnachrichten"</string>
<string name="notification_channel_external_call" msgid="2200143959948071132">"Externe Anrufe"</string>
<string name="notification_channel_misc" msgid="5181419532951960166">"Sonstiges"</string>
</resources>