From 2ca4318cc1ee57dda907ba2069bd61d162b1baef Mon Sep 17 00:00:00 2001 From: Eric Erfanian Date: Thu, 31 Aug 2017 06:57:16 -0700 Subject: Update Dialer source to latest internal Google revision. Previously, Android's Dialer app was developed in an internal Google source control system and only exported to public during AOSP drops. The Dialer team is now switching to a public development model similar to the telephony team. This CL represents all internal Google changes that were committed to Dialer between the public O release and today's tip of tree on internal master. This CL squashes those changes into a single commit. In subsequent changes, changes will be exported on a per-commit basis. Test: make, flash install, run Merged-In: I45270eaa8ce732d71a1bd84b08c7fa0e99af3160 Change-Id: I529aaeb88535b9533c0ae4ef4e6c1222d4e0f1c8 PiperOrigin-RevId: 167068436 --- .../notification/NotificationChannelManager.java | 456 ++++++--------------- 1 file changed, 123 insertions(+), 333 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 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. + *