summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/notification
diff options
context:
space:
mode:
authorEric Erfanian <erfanian@google.com>2017-04-06 09:41:50 -0700
committerEric Erfanian <erfanian@google.com>2017-04-06 09:41:50 -0700
commitd8046e520a866b9948ee9ba47cf642b441ca8e23 (patch)
tree8d08d4f2292aa84dc435d455891e7ab633d95a25 /java/com/android/dialer/notification
parentcdb1edf966a892abebcba425a85b7d4e47758302 (diff)
Update AOSP Dialer source from internal google3 repository at
cl/152373142. Test: make, treehugger This CL updates the AOSP Dialer source with all the changes that have gone into the private google3 repository. This includes all the changes from cl/151342913 (3/27/2017) to cl/152373142 (4/06/2017). This goal of these drops is to keep the AOSP source in sync with the internal google3 repository. Currently these sync are done by hand with very minor modifications to the internal source code. See the Android.mk file for list of modifications. Our current goal is to do frequent drops (daily if possible) and eventually switched to an automated process. Change-Id: I2fbc88cf6867b90ac8b65f75e5e34468988c7217
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>