Search in sources :

Example 6 with EuiccNotification

use of android.telephony.euicc.EuiccNotification in project android_frameworks_opt_telephony by LineageOS.

the class EuiccCardController method retrieveNotificationList.

@Override
public void retrieveNotificationList(String callingPackage, String cardId, @EuiccNotification.Event int events, IRetrieveNotificationListCallback 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("retrieveNotificationList callback failure.", exception);
        }
        return;
    }
    AsyncResultCallback<EuiccNotification[]> cardCb = new AsyncResultCallback<EuiccNotification[]>() {

        @Override
        public void onResult(EuiccNotification[] result) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_OK, result);
            } catch (RemoteException exception) {
                loge("retrieveNotificationList callback failure.", exception);
            }
        }

        @Override
        public void onException(Throwable e) {
            try {
                loge("retrieveNotificationList callback onException: ", e);
                callback.onComplete(getResultCode(e), null);
            } catch (RemoteException exception) {
                loge("retrieveNotificationList callback failure.", exception);
            }
        }
    };
    card.retrieveNotificationList(events, cardCb, mEuiccMainThreadHandler);
}
Also used : EuiccCard(com.android.internal.telephony.uicc.euicc.EuiccCard) RemoteException(android.os.RemoteException) EuiccNotification(android.telephony.euicc.EuiccNotification) AsyncResultCallback(com.android.internal.telephony.uicc.euicc.async.AsyncResultCallback)

Example 7 with EuiccNotification

use of android.telephony.euicc.EuiccNotification 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)

Example 8 with EuiccNotification

use of android.telephony.euicc.EuiccNotification in project android_frameworks_opt_telephony by LineageOS.

the class EuiccCard method listNotifications.

/**
 * Lists all notifications of the given {@code notificationEvents}.
 *
 * @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 listNotifications(@EuiccNotification.Event int events, AsyncResultCallback<EuiccNotification[]> callback, Handler handler) {
    sendApdu(newRequestProvider((RequestBuilder requestBuilder) -> requestBuilder.addStoreData(Asn1Node.newBuilder(Tags.TAG_LIST_NOTIFICATION).addChildAsBits(Tags.TAG_CTX_1, events).build().toHex())), response -> {
        Asn1Node root = parseResponseAndCheckSimpleError(response, EuiccCardErrorException.OPERATION_LIST_NOTIFICATIONS);
        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)

Example 9 with EuiccNotification

use of android.telephony.euicc.EuiccNotification in project android_frameworks_opt_telephony by LineageOS.

the class EuiccNotificationTest method testEqualsHashCode.

@Test
public void testEqualsHashCode() {
    EuiccNotification n = new EuiccNotification(1, "g.co", EuiccNotification.EVENT_DELETE, new byte[] { 1 });
    assertTrue(n.equals(n));
    assertFalse(n.equals(new Object()));
    EuiccNotification t = null;
    assertFalse(n.equals(t));
    t = new EuiccNotification(1, "g.co", EuiccNotification.EVENT_DELETE, new byte[] { 1 });
    assertTrue(n.equals(t));
    assertEquals(n.hashCode(), t.hashCode());
    t = new EuiccNotification(2, "g.co", EuiccNotification.EVENT_DELETE, new byte[] { 1 });
    assertFalse(n.equals(t));
    assertNotEquals(n.hashCode(), t.hashCode());
    t = new EuiccNotification(1, "x.co", EuiccNotification.EVENT_DELETE, new byte[] { 1 });
    assertFalse(n.equals(t));
    assertNotEquals(n.hashCode(), t.hashCode());
    t = new EuiccNotification(1, "g.co", 0, new byte[] { 1 });
    assertFalse(n.equals(t));
    assertNotEquals(n.hashCode(), t.hashCode());
    t = new EuiccNotification(1, "g.co", EuiccNotification.EVENT_DELETE, null);
    assertFalse(n.equals(t));
    assertNotEquals(n.hashCode(), t.hashCode());
}
Also used : EuiccNotification(android.telephony.euicc.EuiccNotification) Test(org.junit.Test)

Aggregations

EuiccNotification (android.telephony.euicc.EuiccNotification)9 Test (org.junit.Test)4 RemoteException (android.os.RemoteException)3 TelephonyTest (com.android.internal.telephony.TelephonyTest)3 EuiccCard (com.android.internal.telephony.uicc.euicc.EuiccCard)3 AsyncResultCallback (com.android.internal.telephony.uicc.euicc.async.AsyncResultCallback)3 Asn1Node (com.android.internal.telephony.uicc.asn1.Asn1Node)2 RequestBuilder (com.android.internal.telephony.uicc.euicc.apdu.RequestBuilder)2