use of android.service.euicc.EuiccProfileInfo in project android_frameworks_opt_telephony by LineageOS.
the class EuiccCardController method getAllProfiles.
@Override
public void getAllProfiles(String callingPackage, String cardId, IGetAllProfilesCallback callback) {
try {
checkCallingPackage(callingPackage);
} catch (SecurityException se) {
try {
callback.onComplete(EuiccCardManager.RESULT_CALLER_NOT_ALLOWED, null);
} catch (RemoteException re) {
loge("callback onComplete failure after checkCallingPackage.", re);
}
return;
}
EuiccCard card = getEuiccCard(cardId);
if (card == null) {
try {
callback.onComplete(EuiccCardManager.RESULT_EUICC_NOT_FOUND, null);
} catch (RemoteException exception) {
loge("getAllProfiles callback failure.", exception);
}
return;
}
AsyncResultCallback<EuiccProfileInfo[]> cardCb = new AsyncResultCallback<EuiccProfileInfo[]>() {
@Override
public void onResult(EuiccProfileInfo[] result) {
try {
callback.onComplete(EuiccCardManager.RESULT_OK, result);
} catch (RemoteException exception) {
loge("getAllProfiles callback failure.", exception);
}
}
@Override
public void onException(Throwable e) {
try {
loge("getAllProfiles callback onException: ", e);
callback.onComplete(getResultCode(e), null);
} catch (RemoteException exception) {
loge("getAllProfiles callback failure.", exception);
}
}
};
card.getAllProfiles(cardCb, mEuiccMainThreadHandler);
}
use of android.service.euicc.EuiccProfileInfo in project android_frameworks_opt_telephony by LineageOS.
the class EuiccCardController method switchToProfile.
@Override
public void switchToProfile(String callingPackage, String cardId, String iccid, boolean refresh, ISwitchToProfileCallback callback) {
try {
checkCallingPackage(callingPackage);
} catch (SecurityException se) {
try {
callback.onComplete(EuiccCardManager.RESULT_CALLER_NOT_ALLOWED, null);
} catch (RemoteException re) {
loge("callback onComplete failure after checkCallingPackage.", re);
}
return;
}
EuiccCard card = getEuiccCard(cardId);
if (card == null) {
try {
callback.onComplete(EuiccCardManager.RESULT_EUICC_NOT_FOUND, null);
} catch (RemoteException exception) {
loge("switchToProfile callback failure.", exception);
}
return;
}
AsyncResultCallback<EuiccProfileInfo> profileCb = new AsyncResultCallback<EuiccProfileInfo>() {
@Override
public void onResult(EuiccProfileInfo profile) {
AsyncResultCallback<Void> switchCb = new AsyncResultCallback<Void>() {
@Override
public void onResult(Void result) {
try {
callback.onComplete(EuiccCardManager.RESULT_OK, profile);
} catch (RemoteException exception) {
loge("switchToProfile callback failure.", exception);
}
}
@Override
public void onException(Throwable e) {
try {
loge("switchToProfile callback onException: ", e);
callback.onComplete(getResultCode(e), profile);
} catch (RemoteException exception) {
loge("switchToProfile callback failure.", exception);
}
}
};
card.switchToProfile(iccid, refresh, switchCb, mEuiccMainThreadHandler);
}
@Override
public void onException(Throwable e) {
try {
loge("getProfile in switchToProfile callback onException: ", e);
callback.onComplete(getResultCode(e), null);
} catch (RemoteException exception) {
loge("switchToProfile callback failure.", exception);
}
}
};
card.getProfile(iccid, profileCb, mEuiccMainThreadHandler);
}
use of android.service.euicc.EuiccProfileInfo in project android_frameworks_opt_telephony by LineageOS.
the class EuiccCard method getAllProfiles.
/**
* Gets a list of user-visible profiles.
*
* @param callback The callback to get the result.
* @param handler The handler to run the callback.
* @since 1.1.0 [GSMA SGP.22]
*/
public void getAllProfiles(AsyncResultCallback<EuiccProfileInfo[]> callback, Handler handler) {
sendApdu(newRequestProvider((RequestBuilder requestBuilder) -> requestBuilder.addStoreData(Asn1Node.newBuilder(Tags.TAG_GET_PROFILES).addChildAsBytes(Tags.TAG_TAG_LIST, Tags.EUICC_PROFILE_TAGS).build().toHex())), response -> {
List<Asn1Node> profileNodes = new Asn1Decoder(response).nextNode().getChild(Tags.TAG_CTX_COMP_0).getChildren(Tags.TAG_PROFILE_INFO);
int size = profileNodes.size();
EuiccProfileInfo[] profiles = new EuiccProfileInfo[size];
int profileCount = 0;
for (int i = 0; i < size; i++) {
Asn1Node profileNode = profileNodes.get(i);
if (!profileNode.hasChild(Tags.TAG_ICCID)) {
loge("Profile must have an ICCID.");
continue;
}
String strippedIccIdString = stripTrailingFs(profileNode.getChild(Tags.TAG_ICCID).asBytes());
EuiccProfileInfo.Builder profileBuilder = new EuiccProfileInfo.Builder(strippedIccIdString);
buildProfile(profileNode, profileBuilder);
EuiccProfileInfo profile = profileBuilder.build();
profiles[profileCount++] = profile;
}
return profiles;
}, callback, handler);
}
use of android.service.euicc.EuiccProfileInfo 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());
}
Aggregations