Search in sources :

Example 1 with RequestBuilder

use of com.android.internal.telephony.uicc.euicc.apdu.RequestBuilder in project android_frameworks_opt_telephony by LineageOS.

the class EuiccCard method getProfile.

/**
 * Gets a profile.
 *
 * @param callback The callback to get the result.
 * @param handler The handler to run the callback.
 * @since 1.1.0 [GSMA SGP.22]
 */
public final void getProfile(String iccid, AsyncResultCallback<EuiccProfileInfo> callback, Handler handler) {
    sendApdu(newRequestProvider((RequestBuilder requestBuilder) -> requestBuilder.addStoreData(Asn1Node.newBuilder(Tags.TAG_GET_PROFILES).addChild(Asn1Node.newBuilder(Tags.TAG_CTX_COMP_0).addChildAsBytes(Tags.TAG_ICCID, IccUtils.bcdToBytes(padTrailingFs(iccid))).build()).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);
        if (profileNodes.isEmpty()) {
            return null;
        }
        Asn1Node profileNode = profileNodes.get(0);
        String strippedIccIdString = stripTrailingFs(profileNode.getChild(Tags.TAG_ICCID).asBytes());
        EuiccProfileInfo.Builder profileBuilder = new EuiccProfileInfo.Builder(strippedIccIdString);
        buildProfile(profileNode, profileBuilder);
        return profileBuilder.build();
    }, callback, handler);
}
Also used : Asn1Node(com.android.internal.telephony.uicc.asn1.Asn1Node) RequestBuilder(com.android.internal.telephony.uicc.euicc.apdu.RequestBuilder) EuiccProfileInfo(android.service.euicc.EuiccProfileInfo) Asn1Decoder(com.android.internal.telephony.uicc.asn1.Asn1Decoder) RequestBuilder(com.android.internal.telephony.uicc.euicc.apdu.RequestBuilder)

Example 2 with RequestBuilder

use of com.android.internal.telephony.uicc.euicc.apdu.RequestBuilder 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);
}
Also used : Asn1Node(com.android.internal.telephony.uicc.asn1.Asn1Node) RequestBuilder(com.android.internal.telephony.uicc.euicc.apdu.RequestBuilder)

Example 3 with RequestBuilder

use of com.android.internal.telephony.uicc.euicc.apdu.RequestBuilder 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);
}
Also used : Asn1Node(com.android.internal.telephony.uicc.asn1.Asn1Node) RequestBuilder(com.android.internal.telephony.uicc.euicc.apdu.RequestBuilder) RequestBuilder(com.android.internal.telephony.uicc.euicc.apdu.RequestBuilder) EuiccRulesAuthTable(android.telephony.euicc.EuiccRulesAuthTable) CarrierIdentifier(android.service.carrier.CarrierIdentifier)

Example 4 with RequestBuilder

use of com.android.internal.telephony.uicc.euicc.apdu.RequestBuilder 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);
}
Also used : Asn1Node(com.android.internal.telephony.uicc.asn1.Asn1Node) RequestBuilder(com.android.internal.telephony.uicc.euicc.apdu.RequestBuilder) EuiccProfileInfo(android.service.euicc.EuiccProfileInfo) Asn1Decoder(com.android.internal.telephony.uicc.asn1.Asn1Decoder) RequestBuilder(com.android.internal.telephony.uicc.euicc.apdu.RequestBuilder)

Example 5 with RequestBuilder

use of com.android.internal.telephony.uicc.euicc.apdu.RequestBuilder 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);
}
Also used : Asn1Node(com.android.internal.telephony.uicc.asn1.Asn1Node) RequestBuilder(com.android.internal.telephony.uicc.euicc.apdu.RequestBuilder) EuiccNotification(android.telephony.euicc.EuiccNotification)

Aggregations

Asn1Node (com.android.internal.telephony.uicc.asn1.Asn1Node)6 RequestBuilder (com.android.internal.telephony.uicc.euicc.apdu.RequestBuilder)6 EuiccProfileInfo (android.service.euicc.EuiccProfileInfo)2 EuiccNotification (android.telephony.euicc.EuiccNotification)2 Asn1Decoder (com.android.internal.telephony.uicc.asn1.Asn1Decoder)2 CarrierIdentifier (android.service.carrier.CarrierIdentifier)1 EuiccRulesAuthTable (android.telephony.euicc.EuiccRulesAuthTable)1