From 2f1c7586bcce334ca69022eb8dc6d8965ceb6a05 Mon Sep 17 00:00:00 2001 From: Eric Erfanian Date: Mon, 19 Jun 2017 11:26:01 -0700 Subject: Update AOSP Dialer source from internal google3 repository at cl/159428781. 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/152373142 (4/06/2017) to cl/159428781 (6/19/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: Ie60a84b3936efd0ea3d95d7c86bf96d2b1663030 --- .../dialer/notification/AndroidManifest.xml | 16 +- .../notification/GroupedNotificationUtil.java | 66 --- .../dialer/notification/NotificationChannelId.java | 41 ++ .../notification/NotificationChannelManager.java | 456 ++++++--------------- .../notification/PackageUpdatedReceiver.java | 37 -- .../dialer/notification/VoicemailChannelUtils.java | 217 ++++++++++ .../dialer/notification/res/values-af/strings.xml | 1 - .../dialer/notification/res/values-am/strings.xml | 1 - .../dialer/notification/res/values-ar/strings.xml | 1 - .../dialer/notification/res/values-az/strings.xml | 1 - .../notification/res/values-b+sr+Latn/strings.xml | 1 - .../dialer/notification/res/values-be/strings.xml | 1 - .../dialer/notification/res/values-bg/strings.xml | 1 - .../dialer/notification/res/values-bn/strings.xml | 1 - .../dialer/notification/res/values-bs/strings.xml | 1 - .../dialer/notification/res/values-ca/strings.xml | 1 - .../dialer/notification/res/values-cs/strings.xml | 1 - .../dialer/notification/res/values-da/strings.xml | 1 - .../dialer/notification/res/values-de/strings.xml | 1 - .../dialer/notification/res/values-el/strings.xml | 1 - .../notification/res/values-en-rAU/strings.xml | 1 - .../notification/res/values-en-rGB/strings.xml | 1 - .../notification/res/values-en-rIN/strings.xml | 1 - .../notification/res/values-es-rUS/strings.xml | 1 - .../dialer/notification/res/values-es/strings.xml | 1 - .../dialer/notification/res/values-et/strings.xml | 1 - .../dialer/notification/res/values-eu/strings.xml | 1 - .../dialer/notification/res/values-fa/strings.xml | 1 - .../dialer/notification/res/values-fi/strings.xml | 1 - .../notification/res/values-fr-rCA/strings.xml | 1 - .../dialer/notification/res/values-fr/strings.xml | 1 - .../dialer/notification/res/values-gl/strings.xml | 1 - .../dialer/notification/res/values-gu/strings.xml | 1 - .../dialer/notification/res/values-hi/strings.xml | 1 - .../dialer/notification/res/values-hr/strings.xml | 1 - .../dialer/notification/res/values-hu/strings.xml | 1 - .../dialer/notification/res/values-hy/strings.xml | 1 - .../dialer/notification/res/values-in/strings.xml | 1 - .../dialer/notification/res/values-is/strings.xml | 1 - .../dialer/notification/res/values-it/strings.xml | 1 - .../dialer/notification/res/values-iw/strings.xml | 1 - .../dialer/notification/res/values-ja/strings.xml | 1 - .../dialer/notification/res/values-ka/strings.xml | 1 - .../dialer/notification/res/values-kk/strings.xml | 1 - .../dialer/notification/res/values-km/strings.xml | 1 - .../dialer/notification/res/values-kn/strings.xml | 1 - .../dialer/notification/res/values-ko/strings.xml | 1 - .../dialer/notification/res/values-ky/strings.xml | 1 - .../dialer/notification/res/values-lo/strings.xml | 1 - .../dialer/notification/res/values-lt/strings.xml | 1 - .../dialer/notification/res/values-lv/strings.xml | 1 - .../dialer/notification/res/values-mk/strings.xml | 1 - .../dialer/notification/res/values-ml/strings.xml | 1 - .../dialer/notification/res/values-mn/strings.xml | 1 - .../dialer/notification/res/values-mr/strings.xml | 1 - .../dialer/notification/res/values-ms/strings.xml | 1 - .../dialer/notification/res/values-my/strings.xml | 1 - .../dialer/notification/res/values-nb/strings.xml | 1 - .../dialer/notification/res/values-ne/strings.xml | 1 - .../dialer/notification/res/values-nl/strings.xml | 1 - .../dialer/notification/res/values-no/strings.xml | 1 - .../dialer/notification/res/values-pa/strings.xml | 1 - .../dialer/notification/res/values-pl/strings.xml | 1 - .../notification/res/values-pt-rBR/strings.xml | 1 - .../notification/res/values-pt-rPT/strings.xml | 1 - .../dialer/notification/res/values-pt/strings.xml | 1 - .../dialer/notification/res/values-ro/strings.xml | 1 - .../dialer/notification/res/values-ru/strings.xml | 1 - .../dialer/notification/res/values-si/strings.xml | 1 - .../dialer/notification/res/values-sk/strings.xml | 1 - .../dialer/notification/res/values-sl/strings.xml | 1 - .../dialer/notification/res/values-sq/strings.xml | 1 - .../dialer/notification/res/values-sr/strings.xml | 1 - .../dialer/notification/res/values-sv/strings.xml | 1 - .../dialer/notification/res/values-sw/strings.xml | 1 - .../dialer/notification/res/values-ta/strings.xml | 1 - .../dialer/notification/res/values-te/strings.xml | 1 - .../dialer/notification/res/values-th/strings.xml | 1 - .../dialer/notification/res/values-tl/strings.xml | 1 - .../dialer/notification/res/values-tr/strings.xml | 1 - .../dialer/notification/res/values-uk/strings.xml | 1 - .../dialer/notification/res/values-ur/strings.xml | 1 - .../dialer/notification/res/values-uz/strings.xml | 1 - .../dialer/notification/res/values-vi/strings.xml | 1 - .../notification/res/values-zh-rCN/strings.xml | 1 - .../notification/res/values-zh-rHK/strings.xml | 1 - .../notification/res/values-zh-rTW/strings.xml | 1 - .../dialer/notification/res/values-zu/strings.xml | 1 - .../android/dialer/notification/res/values/ids.xml | 27 -- .../dialer/notification/res/values/strings.xml | 1 - 90 files changed, 383 insertions(+), 560 deletions(-) delete mode 100644 java/com/android/dialer/notification/GroupedNotificationUtil.java create mode 100644 java/com/android/dialer/notification/NotificationChannelId.java delete mode 100644 java/com/android/dialer/notification/PackageUpdatedReceiver.java create mode 100644 java/com/android/dialer/notification/VoicemailChannelUtils.java delete mode 100644 java/com/android/dialer/notification/res/values/ids.xml (limited to 'java/com/android/dialer/notification') diff --git a/java/com/android/dialer/notification/AndroidManifest.xml b/java/com/android/dialer/notification/AndroidManifest.xml index 741f481ca..b89d8f816 100644 --- a/java/com/android/dialer/notification/AndroidManifest.xml +++ b/java/com/android/dialer/notification/AndroidManifest.xml @@ -1,3 +1,4 @@ + - - - - - - - - - - - - diff --git a/java/com/android/dialer/notification/GroupedNotificationUtil.java b/java/com/android/dialer/notification/GroupedNotificationUtil.java deleted file mode 100644 index 3925248d5..000000000 --- a/java/com/android/dialer/notification/GroupedNotificationUtil.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2017 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License - */ - -package com.android.dialer.notification; - -import android.app.NotificationManager; -import android.service.notification.StatusBarNotification; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import java.util.Objects; - -/** Utilities for dealing with grouped notifications */ -public final class GroupedNotificationUtil { - - /** - * Remove notification(s) that were added as part of a group. Will ensure that if this is the last - * notification in the group the summary will be removed. - * - * @param tag String tag as included in {@link NotificationManager#notify(String, int, - * android.app.Notification)}. If null will remove all notifications under id - * @param id notification id as included with {@link NotificationManager#notify(String, int, - * android.app.Notification)}. - * @param summaryTag String tag of the summary notification - */ - public static void removeNotification( - @NonNull NotificationManager notificationManager, - @Nullable String tag, - int id, - @NonNull String summaryTag) { - if (tag == null) { - // Clear all grouped notifications - for (StatusBarNotification notification : notificationManager.getActiveNotifications()) { - if (notification.getId() == id) { - notificationManager.cancel(notification.getTag(), id); - } - } - } else { - notificationManager.cancel(tag, id); - - // 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())) { - clearSummary = false; - break; - } - } - if (clearSummary) { - notificationManager.cancel(summaryTag, id); - } - } - } -} diff --git a/java/com/android/dialer/notification/NotificationChannelId.java b/java/com/android/dialer/notification/NotificationChannelId.java new file mode 100644 index 000000000..4ab3d44f2 --- /dev/null +++ b/java/com/android/dialer/notification/NotificationChannelId.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.dialer.notification; + +import android.support.annotation.StringDef; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** Centralized source of all notification channels used by Dialer. */ +@Retention(RetentionPolicy.SOURCE) +@StringDef({ + NotificationChannelId.INCOMING_CALL, + NotificationChannelId.ONGOING_CALL, + NotificationChannelId.MISSED_CALL, + NotificationChannelId.DEFAULT, +}) +public @interface NotificationChannelId { + // This value is white listed in the system. + // See /vendor/google/nexus_overlay/common/frameworks/base/core/res/res/values/config.xml + String INCOMING_CALL = "phone_incoming_call"; + + String ONGOING_CALL = "phone_ongoing_call"; + + String MISSED_CALL = "phone_missed_call"; + + String DEFAULT = "phone_default"; +} diff --git a/java/com/android/dialer/notification/NotificationChannelManager.java b/java/com/android/dialer/notification/NotificationChannelManager.java index 88679066d..790aac36f 100644 --- a/java/com/android/dialer/notification/NotificationChannelManager.java +++ b/java/com/android/dialer/notification/NotificationChannelManager.java @@ -17,366 +17,156 @@ package com.android.dialer.notification; import android.annotation.TargetApi; -import android.app.Notification; import android.app.NotificationChannel; -import android.app.NotificationChannelGroup; import android.app.NotificationManager; import android.content.Context; -import android.content.Intent; -import android.content.SharedPreferences; import android.media.AudioAttributes; -import android.net.Uri; import android.os.Build.VERSION_CODES; -import android.provider.Settings; import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import android.support.annotation.RequiresApi; -import android.support.annotation.StringDef; import android.support.v4.os.BuildCompat; -import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; -import android.telecom.TelecomManager; -import android.telephony.TelephonyManager; -import com.android.contacts.common.compat.TelephonyManagerCompat; -import com.android.dialer.buildtype.BuildType; +import android.util.ArraySet; +import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; -import com.android.dialer.common.concurrent.DialerExecutors; -import com.android.dialer.telecom.TelecomUtil; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.util.List; -import java.util.Objects; +import java.util.Set; -/** Contains info on how to create {@link NotificationChannel NotificationChannels} */ -public class NotificationChannelManager { - - private static final String PREFS_FILENAME = "NotificationChannelManager"; - private static final String PREF_NEED_FIRST_INIT = "needFirstInit"; - private static NotificationChannelManager instance; - - public static NotificationChannelManager getInstance() { - if (instance == null) { - instance = new NotificationChannelManager(); - } - return instance; - } +/** Creates all notification channels for Dialer. */ +@TargetApi(VERSION_CODES.O) +public final 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). + * Creates all the notification channels Dialer will need. This method is called at app startup + * and must be fast. Currently it takes between 3 to 7 milliseconds on a Pixel XL. + * + *

An alternative approach would be to lazily create channels when we actualy post a + * notification. The advatange to precreating channels is that: * - *

phoneAccount should only be null if channelName is {@link Channel#DEFAULT} or {@link - * Channel#MISSED_CALL} since these do not have account-specific settings. + *