Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b1cf4dd7 authored by Jack Yu's avatar Jack Yu Committed by Automerger Merge Worker
Browse files

Fixed incorrect phone number from inactive subscription am: 71898cc5

parents 9912352a 71898cc5
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1390,7 +1390,7 @@ public class SubscriptionManagerService extends ISub.Stub {
                        loge("updateSubscription: sim country iso is null");
                    }

                    String msisdn = mTelephonyManager.getLine1Number(subId);
                    String msisdn = PhoneFactory.getPhone(phoneId).getLine1Number();
                    if (!TextUtils.isEmpty(msisdn)) {
                        setDisplayNumber(msisdn, subId);
                    }
@@ -3390,7 +3390,7 @@ public class SubscriptionManagerService extends ISub.Stub {
        try {
            switch(source) {
                case SubscriptionManager.PHONE_NUMBER_SOURCE_UICC:
                    Phone phone = PhoneFactory.getPhone(getPhoneId(subId));
                    Phone phone = PhoneFactory.getPhone(getSlotIndex(subId));
                    if (phone != null) {
                        return TextUtils.emptyIfNull(phone.getLine1Number());
                    } else {
+20 −1
Original line number Diff line number Diff line
@@ -166,6 +166,7 @@ public class SubscriptionManagerServiceTest extends TelephonyTest {
        // Dual-SIM configuration
        mPhones = new Phone[] {mPhone, mPhone2};
        replaceInstance(PhoneFactory.class, "sPhones", null, mPhones);
        doReturn(FAKE_PHONE_NUMBER1).when(mPhone).getLine1Number();
        doReturn(2).when(mTelephonyManager).getActiveModemCount();
        doReturn(2).when(mTelephonyManager).getSupportedModemCount();
        doReturn(mUiccProfile).when(mPhone2).getIccCard();
@@ -1851,7 +1852,6 @@ public class SubscriptionManagerServiceTest extends TelephonyTest {

        doReturn(FAKE_IMSI1).when(mTelephonyManager).getSubscriberId();
        doReturn(FAKE_MCC1 + FAKE_MNC1).when(mTelephonyManager).getSimOperatorNumeric(anyInt());
        doReturn(FAKE_PHONE_NUMBER1).when(mTelephonyManager).getLine1Number(anyInt());
        doReturn(FAKE_EHPLMNS1.split(",")).when(mSimRecords).getEhplmns();
        doReturn(FAKE_HPLMNS1.split(",")).when(mSimRecords).getPlmnsFromHplmnActRecord();
        doReturn(0).when(mUiccSlot).getPortIndexFromIccId(anyString());
@@ -1925,6 +1925,24 @@ public class SubscriptionManagerServiceTest extends TelephonyTest {
                .isEmpty();
    }

    @Test
    public void testGetPhoneNumberFromInactiveSubscription() {
        mContextFixture.addCallingOrSelfPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE);
        testInactiveSimRemoval();

        int subId = insertSubscription(FAKE_SUBSCRIPTION_INFO1);
        assertThat(subId).isEqualTo(2);
        assertThat(mSubscriptionManagerServiceUT.getActiveSubIdList(false)).hasLength(1);
        assertThat(mSubscriptionManagerServiceUT.getAllSubInfoList(CALLING_PACKAGE,
                CALLING_FEATURE)).hasSize(2);

        assertThat(mSubscriptionManagerServiceUT.getPhoneNumberFromFirstAvailableSource(1,
                CALLING_PACKAGE, CALLING_FEATURE)).isEqualTo(FAKE_PHONE_NUMBER2);
        assertThat(mSubscriptionManagerServiceUT.getPhoneNumber(1,
                SubscriptionManager.PHONE_NUMBER_SOURCE_UICC, CALLING_PACKAGE, CALLING_FEATURE))
                .isEqualTo(FAKE_PHONE_NUMBER2);
    }

    @Test
    public void testDeleteEsim() {
        mContextFixture.addCallingOrSelfPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE);
@@ -2013,6 +2031,7 @@ public class SubscriptionManagerServiceTest extends TelephonyTest {
                0, TelephonyManager.SIM_STATE_READY, null, null);
        processAllMessages();

        mContextFixture.addCallingOrSelfPermission(Manifest.permission.MODIFY_PHONE_STATE);
        mSubscriptionManagerServiceUT.updateSimState(
                0, TelephonyManager.SIM_STATE_LOADED, null, null);
        processAllMessages();