Search in sources :

Example 6 with GetEuiccProfileInfoListResult

use of android.service.euicc.GetEuiccProfileInfoListResult in project android_frameworks_opt_telephony by LineageOS.

the class SubscriptionInfoUpdaterTest method testUpdateEmbeddedSubscriptions_emptyToEmpty.

@Test
@SmallTest
public void testUpdateEmbeddedSubscriptions_emptyToEmpty() throws Exception {
    when(mEuiccManager.isEnabled()).thenReturn(true);
    when(mEuiccController.blockingGetEuiccProfileInfoList(FAKE_CARD_ID)).thenReturn(new GetEuiccProfileInfoListResult(42, null, /* subscriptions */
    true));
    List<SubscriptionInfo> subInfoList = new ArrayList<>();
    // 1: not embedded.
    subInfoList.add(new SubscriptionInfo(0, "1", 0, "", "", 0, 0, "", 0, null, "0", "0", "", false, /* isEmbedded */
    null, /* accessRules */
    null));
    when(mSubscriptionController.getSubscriptionInfoListForEmbeddedSubscriptionUpdate(new String[0], false)).thenReturn(subInfoList);
    ArrayList<Integer> cardIds = new ArrayList<>(1);
    cardIds.add(FAKE_CARD_ID);
    mUpdater.updateEmbeddedSubscriptions(cardIds, null);
    // No new entries should be created.
    verify(mSubscriptionController, never()).insertEmptySubInfoRecord(anyString(), anyInt());
    // No existing entries should have been updated.
    verify(mContentProvider, never()).update(eq(SubscriptionManager.CONTENT_URI), any(), any(), isNull());
}
Also used : GetEuiccProfileInfoListResult(android.service.euicc.GetEuiccProfileInfoListResult) ArrayList(java.util.ArrayList) SubscriptionInfo(android.telephony.SubscriptionInfo) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 7 with GetEuiccProfileInfoListResult

use of android.service.euicc.GetEuiccProfileInfoListResult in project android_frameworks_opt_telephony by LineageOS.

the class SubscriptionInfoUpdaterTest method testUpdateEmbeddedSubscriptions_listSuccess.

@Test
@SmallTest
public void testUpdateEmbeddedSubscriptions_listSuccess() throws Exception {
    when(mEuiccManager.isEnabled()).thenReturn(true);
    when(mEuiccManager.createForCardId(anyInt())).thenReturn(mEuiccManager);
    when(mEuiccManager.getEid()).thenReturn(FAKE_EID);
    EuiccProfileInfo[] euiccProfiles = new EuiccProfileInfo[] { new EuiccProfileInfo("1", null, /* accessRules */
    null), new EuiccProfileInfo("3", null, /* accessRules */
    null) };
    when(mEuiccController.blockingGetEuiccProfileInfoList(FAKE_CARD_ID)).thenReturn(new GetEuiccProfileInfoListResult(EuiccService.RESULT_OK, euiccProfiles, false));
    List<SubscriptionInfo> subInfoList = new ArrayList<>();
    // 1: not embedded, but has matching iccid with an embedded subscription.
    subInfoList.add(new SubscriptionInfo(0, "1", 0, "", "", 0, 0, "", 0, null, "0", "0", "", false, /* isEmbedded */
    null, /* accessRules */
    null));
    // 2: embedded but no longer present.
    subInfoList.add(new SubscriptionInfo(0, "2", 0, "", "", 0, 0, "", 0, null, "0", "0", "", true, /* isEmbedded */
    null, /* accessRules */
    null));
    when(mSubscriptionController.getSubscriptionInfoListForEmbeddedSubscriptionUpdate(new String[] { "1", "3" }, false)).thenReturn(subInfoList);
    List<Integer> cardIds = new ArrayList<>();
    cardIds.add(FAKE_CARD_ID);
    mUpdater.updateEmbeddedSubscriptions(cardIds, null);
    processAllMessages();
    // 3 is new and so a new entry should have been created.
    verify(mSubscriptionController).insertEmptySubInfoRecord("3", SubscriptionManager.SIM_NOT_INSERTED);
    // 1 already existed, so no new entries should be created for it.
    verify(mSubscriptionController, times(0)).clearSubInfo();
    verify(mSubscriptionController, never()).insertEmptySubInfoRecord(eq("1"), anyInt());
    // Info for 1 and 3 should be updated as active embedded subscriptions.
    ArgumentCaptor<ContentValues> iccid1Values = ArgumentCaptor.forClass(ContentValues.class);
    verify(mContentProvider).update(eq(SubscriptionManager.CONTENT_URI), iccid1Values.capture(), eq(SubscriptionManager.ICC_ID + "=\"1\""), isNull());
    assertEquals(1, iccid1Values.getValue().getAsInteger(SubscriptionManager.IS_EMBEDDED).intValue());
    ArgumentCaptor<ContentValues> iccid3Values = ArgumentCaptor.forClass(ContentValues.class);
    verify(mContentProvider).update(eq(SubscriptionManager.CONTENT_URI), iccid3Values.capture(), eq(SubscriptionManager.ICC_ID + "=\"3\""), isNull());
    assertEquals(1, iccid3Values.getValue().getAsInteger(SubscriptionManager.IS_EMBEDDED).intValue());
    // 2 should have been removed since it was returned from the cache but was not present
    // in the list provided by the LPA.
    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());
}
Also used : ContentValues(android.content.ContentValues) EuiccProfileInfo(android.service.euicc.EuiccProfileInfo) GetEuiccProfileInfoListResult(android.service.euicc.GetEuiccProfileInfoListResult) ArrayList(java.util.ArrayList) SubscriptionInfo(android.telephony.SubscriptionInfo) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

GetEuiccProfileInfoListResult (android.service.euicc.GetEuiccProfileInfoListResult)7 ArrayList (java.util.ArrayList)5 SubscriptionInfo (android.telephony.SubscriptionInfo)4 SmallTest (android.test.suitebuilder.annotation.SmallTest)3 Test (org.junit.Test)3 ContentValues (android.content.ContentValues)2 EuiccProfileInfo (android.service.euicc.EuiccProfileInfo)2 VisibleForTesting (com.android.internal.annotations.VisibleForTesting)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 ContentResolver (android.content.ContentResolver)1 Pair (android.util.Pair)1