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

Commit d6cde7b8 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

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

parents 6c0e524d 69e439f2
Loading
Loading
Loading
Loading
+15 −12
Original line number Diff line number Diff line
@@ -741,22 +741,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];
                if (DBG) logd("blockingGetEuiccProfileInfoList list is empty.");
            } 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
@@ -517,25 +517,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