diff options
author | twyen <twyen@google.com> | 2017-11-14 16:52:54 -0800 |
---|---|---|
committer | zachh <zachh@google.com> | 2017-11-18 07:27:45 +0000 |
commit | 1569826821d3de13d580a33a570057c1445741f7 (patch) | |
tree | 46eb413e835e6384c493ddf30c588c052149dfab | |
parent | 9c327dac16eeb5bdf1a28eb64ce0c9ac7b73158c (diff) |
Use phone account ID for legacy voicemail notification.
This allows one notification per SIM to be shown on multi SIM devices
Bug: 64010653
Test: LegacyVoicemailNotifierTest
PiperOrigin-RevId: 175756590
Change-Id: I8c2fe3ec06c5e6868ddc647742ab9ef422494b3b
-rw-r--r-- | java/com/android/dialer/app/calllog/LegacyVoicemailNotifier.java | 20 | ||||
-rw-r--r-- | java/com/android/dialer/app/voicemail/LegacyVoicemailNotificationReceiver.java | 2 |
2 files changed, 18 insertions, 4 deletions
diff --git a/java/com/android/dialer/app/calllog/LegacyVoicemailNotifier.java b/java/com/android/dialer/app/calllog/LegacyVoicemailNotifier.java index 584f07fe3..a0bbfa0f1 100644 --- a/java/com/android/dialer/app/calllog/LegacyVoicemailNotifier.java +++ b/java/com/android/dialer/app/calllog/LegacyVoicemailNotifier.java @@ -40,6 +40,7 @@ import com.android.dialer.notification.NotificationChannelManager; /** Shows a notification in the status bar for legacy vociemail. */ @TargetApi(VERSION_CODES.O) public final class LegacyVoicemailNotifier { + private static final String NOTIFICATION_TAG_PREFIX = "LegacyVoicemail_"; private static final String NOTIFICATION_TAG = "LegacyVoicemail"; private static final int NOTIFICATION_ID = 1; @@ -77,7 +78,8 @@ public final class LegacyVoicemailNotifier { callVoicemailIntent, voicemailSettingsIntent, isRefresh); - DialerNotificationManager.notify(context, NOTIFICATION_TAG, NOTIFICATION_ID, notification); + DialerNotificationManager.notify( + context, getNotificationTag(context, handle), NOTIFICATION_ID, notification); } @NonNull @@ -146,10 +148,22 @@ public final class LegacyVoicemailNotifier { } } - public static void cancelNotification(@NonNull Context context) { + public static void cancelNotification( + @NonNull Context context, @NonNull PhoneAccountHandle phoneAccountHandle) { LogUtil.enterBlock("LegacyVoicemailNotifier.cancelNotification"); Assert.checkArgument(BuildCompat.isAtLeastO()); - DialerNotificationManager.cancel(context, NOTIFICATION_TAG, NOTIFICATION_ID); + Assert.isNotNull(phoneAccountHandle); + DialerNotificationManager.cancel( + context, getNotificationTag(context, phoneAccountHandle), NOTIFICATION_ID); + } + + @NonNull + private static String getNotificationTag( + @NonNull Context context, @NonNull PhoneAccountHandle phoneAccountHandle) { + if (context.getSystemService(TelephonyManager.class).getPhoneCount() <= 1) { + return NOTIFICATION_TAG; + } + return NOTIFICATION_TAG_PREFIX + phoneAccountHandle.getId(); } private LegacyVoicemailNotifier() {} diff --git a/java/com/android/dialer/app/voicemail/LegacyVoicemailNotificationReceiver.java b/java/com/android/dialer/app/voicemail/LegacyVoicemailNotificationReceiver.java index 3ce837b8c..fee845469 100644 --- a/java/com/android/dialer/app/voicemail/LegacyVoicemailNotificationReceiver.java +++ b/java/com/android/dialer/app/voicemail/LegacyVoicemailNotificationReceiver.java @@ -96,7 +96,7 @@ public class LegacyVoicemailNotificationReceiver extends BroadcastReceiver { if (count == 0) { LogUtil.i("LegacyVoicemailNotificationReceiver.onReceive", "clearing notification"); - LegacyVoicemailNotifier.cancelNotification(context); + LegacyVoicemailNotifier.cancelNotification(context, phoneAccountHandle); return; } |