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

Commit 144da62e authored by Jack Yu's avatar Jack Yu
Browse files

Fixed crash when LPA is not available

The embedded subscription result could be null when LPA is not
available on AOSP devices.

Bug: 271349925
Test: v2/android-aosp-tests/device-boot-health-check-extra on aosp_panther-userdebug
Test: Basic phone functionality tests
Change-Id: I3a7cbcdadf30660b73611d13e1fdd8d2cc781f01
parent b61bb2ef
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -1025,7 +1025,7 @@ public class SubscriptionManagerService extends ISub.Stub {
        mBackgroundHandler.post(() -> {
            // Do nothing if eUICCs are disabled. (Previous entries may remain in the cache, but
            // they are filtered out of list calls as long as EuiccManager.isEnabled returns false).
            if (mEuiccManager == null || !mEuiccManager.isEnabled()) {
            if (mEuiccManager == null || !mEuiccManager.isEnabled() || mEuiccController == null) {
                loge("updateEmbeddedSubscriptions: eUICC not enabled");
                if (callback != null) {
                    callback.run();
@@ -1038,7 +1038,7 @@ public class SubscriptionManagerService extends ISub.Stub {

            for (UiccSlot slot : mUiccController.getUiccSlots()) {
                if (slot != null) {
                    log("  " + slot.toString());
                    log("  " + slot);
                }
            }

@@ -1046,6 +1046,11 @@ public class SubscriptionManagerService extends ISub.Stub {
                GetEuiccProfileInfoListResult result = mEuiccController
                        .blockingGetEuiccProfileInfoList(cardId);
                logl("updateEmbeddedSubscriptions: cardId=" + cardId + ", result=" + result);
                if (result == null) {
                    //TODO: Add back-off retry in the future if needed.
                    loge("Failed to get euicc profiles.");
                    continue;
                }

                if (result.getResult() != EuiccService.RESULT_OK) {
                    loge("Failed to get euicc profile info. result="
+15 −0
Original line number Diff line number Diff line
@@ -822,6 +822,21 @@ public class SubscriptionManagerServiceTest extends TelephonyTest {
        assertThat(subInfo.getNativeAccessRules()).isEqualTo(FAKE_NATIVE_ACCESS_RULES2);
    }

    @Test
    public void testUpdateEmbeddedSubscriptionsNullResult() {
        // Grant READ_PHONE_STATE permission.
        mContextFixture.addCallingOrSelfPermission(Manifest.permission.READ_PHONE_STATE);

        doReturn(null).when(mEuiccController).blockingGetEuiccProfileInfoList(anyInt());

        mSubscriptionManagerServiceUT.updateEmbeddedSubscriptions(List.of(1, 2), null);
        processAllMessages();

        List<SubscriptionInfo> subInfoList = mSubscriptionManagerServiceUT
                .getAllSubInfoList(CALLING_PACKAGE, CALLING_FEATURE);
        assertThat(subInfoList).isEmpty();
    }

    @Test
    public void testGetActiveSubscriptionInfo() {
        insertSubscription(FAKE_SUBSCRIPTION_INFO1);