use of com.android.internal.telephony.uicc.asn1.Asn1Node in project android_frameworks_opt_telephony by LineageOS.
the class EuiccCard method retrieveNotification.
/**
* Retrieves the content of a notification of the given {@code seqNumber}.
*
* @param seqNumber The sequence number of the notification.
* @param callback The callback to get the result.
* @param handler The handler to run the callback.
* @since 2.0.0 [GSMA SGP.22]
*/
public void retrieveNotification(int seqNumber, AsyncResultCallback<EuiccNotification> callback, Handler handler) {
sendApdu(newRequestProvider((RequestBuilder requestBuilder) -> requestBuilder.addStoreData(Asn1Node.newBuilder(Tags.TAG_RETRIEVE_NOTIFICATIONS_LIST).addChild(Asn1Node.newBuilder(Tags.TAG_CTX_COMP_0).addChildAsInteger(Tags.TAG_CTX_0, seqNumber)).build().toHex())), response -> {
Asn1Node root = parseResponseAndCheckSimpleError(response, EuiccCardErrorException.OPERATION_RETRIEVE_NOTIFICATION);
List<Asn1Node> nodes = root.getChild(Tags.TAG_CTX_COMP_0).getChildren();
if (nodes.size() > 0) {
return createNotification(nodes.get(0));
}
return null;
}, callback, handler);
}
use of com.android.internal.telephony.uicc.asn1.Asn1Node in project android_frameworks_opt_telephony by LineageOS.
the class EuiccCard method getRulesAuthTable.
/**
* Gets Rules Authorisation Table.
*
* @param callback The callback to get the result.
* @param handler The handler to run the callback.
* @since 2.0.0 [GSMA SGP.22]
*/
public void getRulesAuthTable(AsyncResultCallback<EuiccRulesAuthTable> callback, Handler handler) {
sendApdu(newRequestProvider((RequestBuilder requestBuilder) -> requestBuilder.addStoreData(Asn1Node.newBuilder(Tags.TAG_GET_RAT).build().toHex())), response -> {
Asn1Node root = parseResponse(response);
List<Asn1Node> nodes = root.getChildren(Tags.TAG_CTX_COMP_0);
EuiccRulesAuthTable.Builder builder = new EuiccRulesAuthTable.Builder(nodes.size());
int size = nodes.size();
for (int i = 0; i < size; i++) {
Asn1Node node = nodes.get(i);
List<Asn1Node> opIdNodes = node.getChild(Tags.TAG_SEQUENCE, Tags.TAG_CTX_COMP_1).getChildren();
int opIdSize = opIdNodes.size();
CarrierIdentifier[] opIds = new CarrierIdentifier[opIdSize];
for (int j = 0; j < opIdSize; j++) {
opIds[j] = buildCarrierIdentifier(opIdNodes.get(j));
}
builder.add(node.getChild(Tags.TAG_SEQUENCE, Tags.TAG_CTX_0).asBits(), Arrays.asList(opIds), node.getChild(Tags.TAG_SEQUENCE, Tags.TAG_CTX_2).asBits());
}
return builder.build();
}, callback, handler);
}
use of com.android.internal.telephony.uicc.asn1.Asn1Node in project android_frameworks_opt_telephony by LineageOS.
the class EuiccSpecVersion method fromOpenChannelResponse.
/**
* Parses the response of opening a logical channel to get spec version of the eUICC card.
*
* @return Parsed spec version. If any error is encountered, null will be returned.
*/
public static EuiccSpecVersion fromOpenChannelResponse(byte[] response) {
Asn1Node node;
try {
Asn1Decoder decoder = new Asn1Decoder(response);
if (!decoder.hasNextNode()) {
return null;
}
node = decoder.nextNode();
} catch (InvalidAsn1DataException e) {
Rlog.e(LOG_TAG, "Cannot parse the select response of ISD-R.", e);
return null;
}
try {
byte[] versionType;
if (node.getTag() == TAG_ISD_R_APP_TEMPLATE) {
versionType = node.getChild(TAG_VERSION).asBytes();
} else {
versionType = node.getChild(TAG_ISD_R_APP_TEMPLATE, TAG_VERSION).asBytes();
}
if (versionType.length == 3) {
return new EuiccSpecVersion(versionType);
} else {
Rlog.e(LOG_TAG, "Cannot parse select response of ISD-R: " + node.toHex());
}
} catch (InvalidAsn1DataException | TagNotFoundException e) {
Rlog.e(LOG_TAG, "Cannot parse select response of ISD-R: " + node.toHex());
}
return null;
}
use of com.android.internal.telephony.uicc.asn1.Asn1Node 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 com.android.internal.telephony.uicc.asn1.Asn1Node in project android_frameworks_opt_telephony by LineageOS.
the class EuiccCard method retrieveNotificationList.
/**
* Retrieves contents of all notification of the given {@code events}.
*
* @param events Bits of the event types ({@link EuiccNotification.Event}) to list.
* @param callback The callback to get the result.
* @param handler The handler to run the callback.
* @since 2.0.0 [GSMA SGP.22]
*/
public void retrieveNotificationList(@EuiccNotification.Event int events, AsyncResultCallback<EuiccNotification[]> callback, Handler handler) {
sendApdu(newRequestProvider((RequestBuilder requestBuilder) -> requestBuilder.addStoreData(Asn1Node.newBuilder(Tags.TAG_RETRIEVE_NOTIFICATIONS_LIST).addChild(Asn1Node.newBuilder(Tags.TAG_CTX_COMP_0).addChildAsBits(Tags.TAG_CTX_1, events)).build().toHex())), response -> {
Asn1Node root = parseResponse(response);
if (root.hasChild(Tags.TAG_CTX_1)) {
// SGP.22 v2.0 RetrieveNotificationsListResponse
int error = root.getChild(Tags.TAG_CTX_1).asInteger();
switch(error) {
case CODE_NO_RESULT_AVAILABLE:
return new EuiccNotification[0];
default:
throw new EuiccCardErrorException(EuiccCardErrorException.OPERATION_RETRIEVE_NOTIFICATION, error);
}
}
List<Asn1Node> nodes = root.getChild(Tags.TAG_CTX_COMP_0).getChildren();
EuiccNotification[] notifications = new EuiccNotification[nodes.size()];
for (int i = 0; i < notifications.length; ++i) {
notifications[i] = createNotification(nodes.get(i));
}
return notifications;
}, callback, handler);
}
Aggregations