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

Commit 06485d38 authored by Joonhun Shin's avatar Joonhun Shin Committed by Android (Google) Code Review
Browse files

Merge "Clear cached IMS phone number when device lost IMS registration." into main

parents 02c70b23 24f42b03
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -2527,6 +2527,10 @@ public class ImsPhone extends ImsPhoneBase {
            }
            updateImsRegistrationInfo(REGISTRATION_STATE_NOT_REGISTERED,
                    imsRadioTech, suggestedModemAction);

            // Clear the phone number from P-Associated-Uri
            setCurrentSubscriberUris(null);
            clearPhoneNumberForSourceIms();
        }

        @Override
@@ -2537,6 +2541,18 @@ public class ImsPhone extends ImsPhoneBase {
        }
    };

    /** Clear the IMS phone number from IMS associated Uris when IMS registration is lost. */
    @VisibleForTesting
    public void clearPhoneNumberForSourceIms() {
        int subId = getSubId();
        if (!SubscriptionManager.isValidSubscriptionId(subId)) {
            return;
        }

        if (DBG) logd("clearPhoneNumberForSourceIms");
        mSubscriptionManagerService.setNumberFromIms(subId, new String(""));
    }

    /** Sets the IMS phone number from IMS associated URIs, if any found. */
    @VisibleForTesting
    public void setPhoneNumberForSourceIms(Uri[] uris) {
+3 −0
Original line number Diff line number Diff line
@@ -1424,6 +1424,9 @@ public class SubscriptionManagerService extends ISub.Stub {
                        loge("updateSubscription: ICC card is not available.");
                    }

                    // Clear the cached Ims phone number before proceeding with Ims Registration
                    setNumberFromIms(subId, new String(""));

                    // Attempt to restore SIM specific settings when SIM is loaded.
                    Bundle result = mContext.getContentResolver().call(
                            SubscriptionManager.SIM_INFO_BACKUP_AND_RESTORE_CONTENT_URI,
+28 −0
Original line number Diff line number Diff line
@@ -1111,6 +1111,34 @@ public class ImsPhoneTest extends TelephonyTest {
        mContextFixture.addCallingOrSelfPermission("");
    }

    @Test
    @SmallTest
    public void testClearPhoneNumberForSourceIms() {
        // In reality the method under test runs in phone process so has MODIFY_PHONE_STATE
        mContextFixture.addCallingOrSelfPermission(MODIFY_PHONE_STATE);
        int subId = 1;
        doReturn(subId).when(mPhone).getSubId();
        doReturn(new SubscriptionInfoInternal.Builder().setId(subId).setSimSlotIndex(0)
                .setCountryIso("gb").build()).when(mSubscriptionManagerService)
                .getSubscriptionInfoInternal(subId);

        // 1. Two valid phone number; 1st is set.
        Uri[] associatedUris = new Uri[] {
                Uri.parse("sip:+447539447777@ims.x.com"),
                Uri.parse("tel:+447539446666")
        };
        mImsPhoneUT.setPhoneNumberForSourceIms(associatedUris);

        verify(mSubscriptionManagerService).setNumberFromIms(subId, "+447539447777");

        mImsPhoneUT.clearPhoneNumberForSourceIms();

        verify(mSubscriptionManagerService).setNumberFromIms(subId, "");

        // Clean up
        mContextFixture.addCallingOrSelfPermission("");
    }

    /**
     * Verifies that valid radio technology is passed to RIL
     * when IMS registration state changes to registered.