Listen to subscription info changes to update MWI.
MWI refers to "message waiting indicator" (aka. voicemail
notifications). Before, there custom delay/retry code to handle if
the SIM was not yet registered, but the network indicated a voicemail.
This CL deletes that custom logic, and instead listens for changes
to the subscription info (which should change with SIM registration)
as a trigger for retrying to show the message waiting. I moved some
logic into NotificationMgr so this behavior can be centralized in
one class.
This clears the way to implement some MSIM voicemail notification
settings; the retry logic was written assuming there was only one
internal.telephony.Phone, but there may now be multiple ones. This
change makes it easier to iterate over all the phones and update
their MWIs, which will be done in a subsequent CL.
It's a little tricky to test the exact scenario which this case
accounted for; I tested by removing/re-inserting a SIM to see if
it updated accordingly (which it did successfully).
Bug: 18232725
Change-Id: Ica2c5a2ddef8a2efc2c40c2f4d8729b485eb0bf7
diff --git a/src/com/android/phone/CallNotifier.java b/src/com/android/phone/CallNotifier.java
index bc13010..01a2449 100644
--- a/src/com/android/phone/CallNotifier.java
+++ b/src/com/android/phone/CallNotifier.java
@@ -143,7 +143,7 @@
BluetoothProfile.HEADSET);
}
- TelephonyManager telephonyManager = (TelephonyManager)app.getSystemService(
+ TelephonyManager telephonyManager = (TelephonyManager) app.getSystemService(
Context.TELEPHONY_SERVICE);
telephonyManager.listen(mPhoneStateListener,
PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR
@@ -191,10 +191,6 @@
onUnknownConnectionAppeared((AsyncResult) msg.obj);
break;
- case CallStateMonitor.INTERNAL_PHONE_MWI_CHANGED:
- onMwiChanged(mApplication.phone.getMessageWaitingIndicator());
- break;
-
case CallStateMonitor.PHONE_STATE_DISPLAYINFO:
if (DBG) log("Received PHONE_STATE_DISPLAYINFO event");
onDisplayInfo((AsyncResult) msg.obj);
@@ -245,13 +241,15 @@
PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
@Override
- public void onMessageWaitingIndicatorChanged(boolean mwi) {
- onMwiChanged(mwi);
+ public void onMessageWaitingIndicatorChanged(boolean visible) {
+ if (VDBG) log("onMessageWaitingIndicatorChanged(): " + visible);
+ mApplication.notificationMgr.updateMwi(visible);
}
@Override
- public void onCallForwardingIndicatorChanged(boolean cfi) {
- onCfiChanged(cfi);
+ public void onCallForwardingIndicatorChanged(boolean visible) {
+ if (VDBG) log("onCallForwardingIndicatorChanged(): " + visible);
+ mApplication.notificationMgr.updateCfi(visible);
}
};
@@ -610,38 +608,6 @@
PhoneUtils.setAudioMode(mCM);
}
- private void onMwiChanged(boolean visible) {
- if (VDBG) log("onMwiChanged(): " + visible);
-
- // "Voicemail" is meaningless on non-voice-capable devices,
- // so ignore MWI events.
- if (!PhoneGlobals.sVoiceCapable) {
- // ...but still log a warning, since we shouldn't have gotten this
- // event in the first place!
- // (PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR events
- // *should* be blocked at the telephony layer on non-voice-capable
- // capable devices.)
- Log.w(LOG_TAG, "Got onMwiChanged() on non-voice-capable device! Ignoring...");
- return;
- }
-
- mApplication.notificationMgr.updateMwi(visible);
- }
-
- /**
- * Posts a delayed PHONE_MWI_CHANGED event, to schedule a "retry" for a
- * failed NotificationMgr.updateMwi() call.
- */
- /* package */ void sendMwiChangedDelayed(long delayMillis) {
- Message message = Message.obtain(this, CallStateMonitor.INTERNAL_PHONE_MWI_CHANGED);
- sendMessageDelayed(message, delayMillis);
- }
-
- private void onCfiChanged(boolean visible) {
- if (VDBG) log("onCfiChanged(): " + visible);
- mApplication.notificationMgr.updateCfi(visible);
- }
-
/**
* Helper class to play tones through the earpiece (or speaker / BT)
* during a call, using the ToneGenerator.