diff --git a/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java b/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java index d95320fba8f..a014c2975eb 100644 --- a/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java +++ b/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java @@ -174,7 +174,8 @@ public class SimStatusDialogController implements LifecycleObserver, OnResume, O return; } - mTelephonyManager.listen(mPhoneStateListener, + mTelephonyManager.createForSubscriptionId(mSubscriptionInfo.getSubscriptionId()) + .listen(mPhoneStateListener, PhoneStateListener.LISTEN_DATA_CONNECTION_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_SERVICE_STATE); @@ -197,8 +198,8 @@ public class SimStatusDialogController implements LifecycleObserver, OnResume, O return; } - mTelephonyManager.listen(mPhoneStateListener, - PhoneStateListener.LISTEN_NONE); + mTelephonyManager.createForSubscriptionId(mSubscriptionInfo.getSubscriptionId()) + .listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE); if (mShowLatestAreaInfo) { mContext.unregisterReceiver(mAreaInfoReceiver); @@ -432,8 +433,7 @@ public class SimStatusDialogController implements LifecycleObserver, OnResume, O @VisibleForTesting PhoneStateListener getPhoneStateListener() { - return new PhoneStateListener( - mSubscriptionInfo.getSubscriptionId()) { + return new PhoneStateListener() { @Override public void onDataConnectionStateChanged(int state) { updateDataState(state); diff --git a/src/com/android/settings/sim/SimSettings.java b/src/com/android/settings/sim/SimSettings.java index b646b3b750b..e43c6a5d83f 100644 --- a/src/com/android/settings/sim/SimSettings.java +++ b/src/com/android/settings/sim/SimSettings.java @@ -220,7 +220,7 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable Log.d(TAG, "Register for call state change"); for (int i = 0; i < mPhoneCount; i++) { int subId = mSelectableSubInfos.get(i).getSubscriptionId(); - tm.listen(getPhoneStateListener(i, subId), + tm.createForSubscriptionId(subId).listen(getPhoneStateListener(i), PhoneStateListener.LISTEN_CALL_STATE); } } @@ -239,13 +239,13 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable } } - private PhoneStateListener getPhoneStateListener(int phoneId, int subId) { + private PhoneStateListener getPhoneStateListener(int phoneId) { // Disable Sim selection for Data when voice call is going on as changing the default data // sim causes a modem reset currently and call gets disconnected // ToDo : Add subtext on disabled preference to let user know that default data sim cannot // be changed while call is going on final int i = phoneId; - mPhoneStateListener[phoneId] = new PhoneStateListener(subId) { + mPhoneStateListener[phoneId] = new PhoneStateListener() { @Override public void onCallStateChanged(int state, String incomingNumber) { if (DBG) log("PhoneStateListener.onCallStateChanged: state=" + state);