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

Commit 58752cac authored by Holly Jiuyu Sun's avatar Holly Jiuyu Sun Committed by Gerrit Code Review
Browse files

Merge "Only update subscription cache when profile list is not null."

parents e46ec0f3 db0b9edb
Loading
Loading
Loading
Loading
+15 −11
Original line number Diff line number Diff line
@@ -610,21 +610,25 @@ public class SubscriptionInfoUpdater extends Handler {
            return false;
        }

        // If the returned result is not RESULT_OK or the profile list is null, don't update cache.
        // Otherwise, update the cache.
        final EuiccProfileInfo[] embeddedProfiles;
        if (result.getResult() == EuiccService.RESULT_OK) {
        List<EuiccProfileInfo> list = result.getProfiles();
            if (list == null || list.size() == 0) {
                embeddedProfiles = new EuiccProfileInfo[0];
            } else {
        if (result.getResult() == EuiccService.RESULT_OK && list != null) {
            embeddedProfiles = list.toArray(new EuiccProfileInfo[list.size()]);
            if (DBG) {
                logd("blockingGetEuiccProfileInfoList: got " + result.getProfiles().size()
                        + " profiles");
            }
        } else {
            logd("updatedEmbeddedSubscriptions: error " + result.getResult() + " listing profiles");
            // If there's an error listing profiles, treat it equivalently to a successful
            // listing which returned no profiles under the assumption that none are currently
            // accessible.
            embeddedProfiles = new EuiccProfileInfo[0];
            if (DBG) {
                logd("blockingGetEuiccProfileInfoList returns an error. "
                        + "Result code=" + result.getResult()
                        + ". Null profile list=" + (result.getProfiles() == null));
            }
            return false;
        }

        final boolean isRemovable = result.getIsRemovable();

        final String[] embeddedIccids = new String[embeddedProfiles.length];
+3 −13
Original line number Diff line number Diff line
@@ -511,25 +511,15 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest {
        when(mSubscriptionController.getSubscriptionInfoListForEmbeddedSubscriptionUpdate(
                new String[0], false /* removable */)).thenReturn(subInfoList);

        assertTrue(mUpdater.updateEmbeddedSubscriptions(FAKE_CARD_ID));
        assertFalse(mUpdater.updateEmbeddedSubscriptions(FAKE_CARD_ID));

        // No new entries should be created.
        verify(mSubscriptionController, times(0)).clearSubInfo();
        verify(mSubscriptionController, never()).insertEmptySubInfoRecord(anyString(), anyInt());

        // 1 should not have been touched.
        verify(mContentProvider, never()).update(eq(SubscriptionManager.CONTENT_URI), any(),
                eq(SubscriptionManager.ICC_ID + "=\"1\""), isNull());
        // No existing entries should have been updated.
        verify(mContentProvider, never()).update(eq(SubscriptionManager.CONTENT_URI), any(),
                eq(SubscriptionManager.ICC_ID + "IN (\"1\")"), isNull());

        // 2 should have been removed since it was returned from the cache but the LPA had an
        // error when listing.
        ArgumentCaptor<ContentValues> iccid2Values = ArgumentCaptor.forClass(ContentValues.class);
        verify(mContentProvider).update(eq(SubscriptionManager.CONTENT_URI), iccid2Values.capture(),
                eq(SubscriptionManager.ICC_ID + " IN (\"2\")"), isNull());
        assertEquals(0,
                iccid2Values.getValue().getAsInteger(SubscriptionManager.IS_EMBEDDED).intValue());
                any(), isNull());
    }

    @Test