Create TM for each subId to register phonestatelistner

To register phonestatelistner for different subscription, do not
create phonestatelistener(subId) this contructor is going to be removed.
instead, create TelephonyManager instance for each subId and pass
separate phonestateListener object.

Bug: 117555407
Test: Maunal test
Change-Id: Ia2a1be6e559c3a5b98e178a02d0eee14cc14eb47
This commit is contained in:
chen xu
2019-03-20 13:42:54 -07:00
parent 7d7eb8b509
commit 96d0c484f3
2 changed files with 8 additions and 8 deletions

View File

@@ -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);

View File

@@ -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);