From d8046e520a866b9948ee9ba47cf642b441ca8e23 Mon Sep 17 00:00:00 2001 From: Eric Erfanian Date: Thu, 6 Apr 2017 09:41:50 -0700 Subject: 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 --- .../notification/NotificationChannelManager.java | 45 +++++++++++++++------- 1 file changed, 31 insertions(+), 14 deletions(-) (limited to 'java/com/android/dialer/notification/NotificationChannelManager.java') 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). * - *

phoneAccount should only be null if channelName is {@link Channel#MISC}. + *

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); -- cgit v1.2.3