Merge "create TM for each subId to register phonestatelistner"
diff --git a/src/com/android/phone/CallNotifier.java b/src/com/android/phone/CallNotifier.java
index 3796e64..7db17ff 100644
--- a/src/com/android/phone/CallNotifier.java
+++ b/src/com/android/phone/CallNotifier.java
@@ -610,8 +610,8 @@
for (int i = 0; i < subInfos.size(); i++) {
int subId = subInfos.get(i).getSubscriptionId();
if (!mPhoneStateListeners.containsKey(subId)) {
- CallNotifierPhoneStateListener listener = new CallNotifierPhoneStateListener(subId);
- mTelephonyManager.listen(listener,
+ CallNotifierPhoneStateListener listener = new CallNotifierPhoneStateListener();
+ mTelephonyManager.createForSubscriptionId(subId).listen(listener,
PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR
| PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR);
mPhoneStateListeners.put(subId, listener);
@@ -762,8 +762,8 @@
};
private class CallNotifierPhoneStateListener extends PhoneStateListener {
- public CallNotifierPhoneStateListener(int subId) {
- super(subId);
+ public CallNotifierPhoneStateListener() {
+ super();
}
@Override
diff --git a/src/com/android/phone/MobileNetworkSettings.java b/src/com/android/phone/MobileNetworkSettings.java
index 7ffa5cf..c123e66 100644
--- a/src/com/android/phone/MobileNetworkSettings.java
+++ b/src/com/android/phone/MobileNetworkSettings.java
@@ -454,11 +454,10 @@
return;
}
- PhoneCallStateListener.this.mSubId = subId;
-
mTelephonyManager.listen(this, PhoneStateListener.LISTEN_NONE);
- // Now, listen to new subId if it's valid.
+ // Now, listen to new subId if it's valid. register the listener with
+ // mTelephonyManager instance created for the new subId.
if (SubscriptionManager.isValidSubscriptionId(subId)) {
mTelephonyManager.listen(this, PhoneStateListener.LISTEN_CALL_STATE);
}
@@ -935,7 +934,8 @@
updatePreferredNetworkUIFromDb();
}
- mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);
+ mTelephonyManager.createForSubscriptionId(mSubId)
+ .listen(mPhoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);
// NOTE: Buttons will be enabled/disabled in mPhoneStateListener
updateEnhanced4gLteState();