Avoid wrong telephonymanager with wrong sub id.

When initialized SimStatusDialogController, also create TelephonyManager
with sub id.

Bug: 174171839
Test: Manual test passed, see b/174171839#25
Change-Id: I6bd6975e39c75884252b9d0bcd9d5548dbdfe6d5
This commit is contained in:
tom hsu
2020-12-29 20:03:08 +08:00
committed by Tom Hsu
parent f38af98895
commit ba845f7fe4
2 changed files with 3 additions and 2 deletions

View File

@@ -233,7 +233,8 @@ public class SimStatusDialogController implements LifecycleObserver {
if (mSubscriptionInfo == null) { if (mSubscriptionInfo == null) {
return; return;
} }
mTelephonyManager =
mTelephonyManager.createForSubscriptionId(mSubscriptionInfo.getSubscriptionId());
mPhoneStateListener = getPhoneStateListener(); mPhoneStateListener = getPhoneStateListener();
updateLatestAreaInfo(); updateLatestAreaInfo();
updateSubscriptionStatus(); updateSubscriptionStatus();

View File

@@ -136,7 +136,7 @@ public class SimStatusDialogControllerTest {
when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager); when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId( doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(
SubscriptionManager.DEFAULT_SUBSCRIPTION_ID); anyInt());
doReturn(2).when(mTelephonyManager).getCardIdForDefaultEuicc(); doReturn(2).when(mTelephonyManager).getCardIdForDefaultEuicc();
doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mTelephonyManager).getDataNetworkType(); doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mTelephonyManager).getDataNetworkType();