Send IS_REFRESH with ACTION_SHOW_VOICEMAIL_NOTIFICATION
Telephony will resend ACTION_SHOW_VOICEMAIL_NOTIFICATION when the
subscriptions has changed, so the MWI received when the SIM is not
loaded can be posted. For some carriers voicemail count is not
supported so dialer cannot distinguish between a refresh and a new
voicemail, and will post the notification every time (signal lost and
recovery).
Dialer cannot simply use setOnlyAlertOnce() because if it is a new
voicemail the user should be alerted again.
In this CL IS_REFRESH will be sent with
ACTION_SHOW_VOICEMAIL_NOTIFICATION so dialer can know the difference.
Change-Id: I9417e5553bbccfe4feba960c2497fffef48d2fd9
Fixes: 62119940
Test: manual - leave voicemail, toggle airplane mode.
diff --git a/src/com/android/phone/NotificationMgr.java b/src/com/android/phone/NotificationMgr.java
index bc67fd5..31bca92 100644
--- a/src/com/android/phone/NotificationMgr.java
+++ b/src/com/android/phone/NotificationMgr.java
@@ -81,6 +81,15 @@
private static final String MWI_SHOULD_CHECK_VVM_CONFIGURATION_KEY_PREFIX =
"mwi_should_check_vvm_configuration_state_";
+ /**
+ * Boolean value representing whether the {@link
+ * TelephonyManager#ACTION_SHOW_VOICEMAIL_NOTIFICATION} is new or a refresh of an existing
+ * notification.
+ *
+ * TODO(b/62202833): make public
+ */
+ private static final String EXTRA_IS_REFRESH = "is_refresh";
+
// notification types
static final int MMI_NOTIFICATION = 1;
static final int NETWORK_SELECTION_NOTIFICATION = 2;
@@ -196,7 +205,7 @@
if (mMwiVisible.containsKey(subId)) {
boolean mwiVisible = mMwiVisible.get(subId);
if (mwiVisible) {
- updateMwi(subId, mwiVisible, false /* enableNotificationSound */);
+ updateMwi(subId, mwiVisible, true /* isRefresh */);
}
}
}
@@ -228,7 +237,7 @@
* @param visible true if there are messages waiting
*/
/* package */ void updateMwi(int subId, boolean visible) {
- updateMwi(subId, visible, true /* enableNotificationSound */);
+ updateMwi(subId, visible, false /* isRefresh */);
}
/**
@@ -236,9 +245,10 @@
*
* @param subId the subId to update.
* @param visible true if there are messages waiting
- * @param enableNotificationSound {@code true} if the notification sound should be played.
+ * @param isRefresh {@code true} if the notification is a refresh and the user should not be
+ * notified again.
*/
- void updateMwi(int subId, boolean visible, boolean enableNotificationSound) {
+ void updateMwi(int subId, boolean visible, boolean isRefresh) {
if (!PhoneGlobals.sVoiceCapable) {
// Do not show the message waiting indicator on devices which are not voice capable.
// These events *should* be blocked at the telephony layer for such devices.
@@ -345,7 +355,8 @@
.setColor(res.getColor(R.color.dialer_theme_color))
.setOngoing(carrierConfig.getBoolean(
CarrierConfigManager.KEY_VOICEMAIL_NOTIFICATION_PERSISTENT_BOOL))
- .setChannel(NotificationChannelController.CHANNEL_ID_VOICE_MAIL);
+ .setChannel(NotificationChannelController.CHANNEL_ID_VOICE_MAIL)
+ .setOnlyAlertOnce(isRefresh);
final Notification notification = builder.build();
List<UserInfo> users = mUserManager.getUsers(true);
@@ -356,7 +367,7 @@
UserManager.DISALLOW_OUTGOING_CALLS, userHandle)
&& !user.isManagedProfile()) {
if (!maybeSendVoicemailNotificationUsingDefaultDialer(phone, vmCount, vmNumber,
- pendingIntent, isSettingsIntent, userHandle)) {
+ pendingIntent, isSettingsIntent, userHandle, isRefresh)) {
mNotificationManager.notifyAsUser(
Integer.toString(subId) /* tag */,
VOICEMAIL_NOTIFICATION,
@@ -374,7 +385,7 @@
UserManager.DISALLOW_OUTGOING_CALLS, userHandle)
&& !user.isManagedProfile()) {
if (!maybeSendVoicemailNotificationUsingDefaultDialer(phone, 0, null, null,
- false, userHandle)) {
+ false, userHandle, isRefresh)) {
mNotificationManager.cancelAsUser(
Integer.toString(subId) /* tag */,
VOICEMAIL_NOTIFICATION,
@@ -403,7 +414,7 @@
*/
private boolean maybeSendVoicemailNotificationUsingDefaultDialer(Phone phone, Integer count,
String number, PendingIntent pendingIntent, boolean isSettingsIntent,
- UserHandle userHandle) {
+ UserHandle userHandle, boolean isRefresh) {
if (shouldManageNotificationThroughDefaultDialer(userHandle)) {
Intent intent = getShowVoicemailIntentForDefaultDialer(userHandle);
@@ -411,6 +422,7 @@
intent.setAction(TelephonyManager.ACTION_SHOW_VOICEMAIL_NOTIFICATION);
intent.putExtra(TelephonyManager.EXTRA_PHONE_ACCOUNT_HANDLE,
PhoneUtils.makePstnPhoneAccountHandle(phone));
+ intent.putExtra(EXTRA_IS_REFRESH, isRefresh);
if (count != null) {
intent.putExtra(TelephonyManager.EXTRA_NOTIFICATION_COUNT, count);
}