Search in sources :

Example 6 with EuiccRulesAuthTable

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

the class EuiccRulesAuthTableTest method testHasPolicyRuleFlag_OutOfBounds.

@Test(expected = ArrayIndexOutOfBoundsException.class)
public void testHasPolicyRuleFlag_OutOfBounds() {
    EuiccRulesAuthTable rat = new EuiccRulesAuthTable.Builder(1).add(0, Arrays.asList(new CarrierIdentifier[] {}), 0).build();
    rat.hasPolicyRuleFlag(1, EuiccRulesAuthTable.POLICY_RULE_FLAG_CONSENT_REQUIRED);
}
Also used : EuiccRulesAuthTable(android.telephony.euicc.EuiccRulesAuthTable) Test(org.junit.Test)

Example 7 with EuiccRulesAuthTable

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

the class EuiccCardController method getRulesAuthTable.

@Override
public void getRulesAuthTable(String callingPackage, String cardId, IGetRulesAuthTableCallback 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("getRulesAuthTable callback failure.", exception);
        }
        return;
    }
    AsyncResultCallback<EuiccRulesAuthTable> cardCb = new AsyncResultCallback<EuiccRulesAuthTable>() {

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

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

Example 8 with EuiccRulesAuthTable

use of android.telephony.euicc.EuiccRulesAuthTable 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 9 with EuiccRulesAuthTable

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

the class EuiccCardTest method testGetRulesAuthTable.

@Test
public void testGetRulesAuthTable() {
    int channel = mockLogicalChannelResponses("BF434B" + // Rule #1
    "A0233021" + // Policy rules: DO_NOT_DELETE | DO_NOT_DISABLE
    "800206C0" + // Operator IDs
    "A118" + // ID #1: 213, 54, [1,2,3], null
    "B70A800312F3458103010203" + // ID #2: 213, 54, null, [4,5,6]
    "B70A800312F3458203040506" + // Flag (no user consent)
    "820108" + // Rule #2
    "A0243022" + // Policy rules: DO_NOT_DISABLE
    "80020780" + // Operator IDs
    "A118" + // ID #1: 213, 54E, [1,2,3], null
    "B70A800312E3458103010203" + // ID #2: EEE, 54E, null, [4,5,6]
    "B70A8003EEEE458203040506" + // Flag (user consent)
    "82020780" + "9000");
    ResultCaptor<EuiccRulesAuthTable> resultCaptor = new ResultCaptor<>();
    mEuiccCard.getRulesAuthTable(resultCaptor, mHandler);
    processAllMessages();
    EuiccRulesAuthTable rat = resultCaptor.result;
    assertEquals(-1, rat.findIndex(EuiccProfileInfo.POLICY_RULE_DO_NOT_DELETE, new CarrierIdentifier(new byte[] { 0x12, (byte) 0xF3, 0x45 }, null, null)));
    assertEquals(1, rat.findIndex(EuiccProfileInfo.POLICY_RULE_DO_NOT_DISABLE, new CarrierIdentifier(new byte[] { 0x23, 0x67, 0x45 }, null, "040506")));
    assertFalse(rat.hasPolicyRuleFlag(0, EuiccRulesAuthTable.POLICY_RULE_FLAG_CONSENT_REQUIRED));
    assertTrue(rat.hasPolicyRuleFlag(1, EuiccRulesAuthTable.POLICY_RULE_FLAG_CONSENT_REQUIRED));
    verifyStoreData(channel, "BF4300");
}
Also used : EuiccRulesAuthTable(android.telephony.euicc.EuiccRulesAuthTable) CarrierIdentifier(android.service.carrier.CarrierIdentifier) TelephonyTest(com.android.internal.telephony.TelephonyTest) Test(org.junit.Test)

Example 10 with EuiccRulesAuthTable

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

the class EuiccRulesAuthTableTest method testFindIndex.

@Test
public void testFindIndex() {
    CarrierIdentifier opA = new CarrierIdentifier(new byte[] { 0x21, 0x63, 0x54 }, null, "4");
    CarrierIdentifier opB = new CarrierIdentifier(new byte[] { 0x21, 0x69, 0x54 }, "4", null);
    EuiccRulesAuthTable rat = new EuiccRulesAuthTable.Builder(4).add(EuiccProfileInfo.POLICY_RULE_DO_NOT_DELETE | EuiccProfileInfo.POLICY_RULE_DO_NOT_DISABLE, // Matches none
    Arrays.asList(new CarrierIdentifier[] {}), EuiccRulesAuthTable.POLICY_RULE_FLAG_CONSENT_REQUIRED).add(EuiccProfileInfo.POLICY_RULE_DO_NOT_DELETE, Arrays.asList(// Matches none
    new CarrierIdentifier(new byte[] { 0x21, (byte) 0xF3, 0x54 }, "4", null), // Matches opA
    new CarrierIdentifier(new byte[] { 0x21, 0x63, 0x54 }, null, "4")), EuiccRulesAuthTable.POLICY_RULE_FLAG_CONSENT_REQUIRED).add(EuiccProfileInfo.POLICY_RULE_DO_NOT_DISABLE, Arrays.asList(// Matches none
    new CarrierIdentifier(new byte[] { 0x21, 0x63, 0x54 }, null, "5"), // Matches opA and opB
    new CarrierIdentifier(new byte[] { 0x21, 0x6E, 0x54 }, null, null)), 0).add(EuiccProfileInfo.POLICY_RULE_DO_NOT_DELETE | EuiccProfileInfo.POLICY_RULE_DO_NOT_DISABLE, Arrays.asList(// Matches none
    new CarrierIdentifier(new byte[] { 0x21, 0x69, 0x54 }, "5", null), // Matches opB
    new CarrierIdentifier(new byte[] { 0x21, 0x6E, 0x54 }, "4", null), // Matches opA
    new CarrierIdentifier(new byte[] { 0x21, 0x6E, 0x54 }, null, "4")), EuiccRulesAuthTable.POLICY_RULE_FLAG_CONSENT_REQUIRED).build();
    assertEquals(1, rat.findIndex(EuiccProfileInfo.POLICY_RULE_DO_NOT_DELETE, opA));
    assertEquals(3, rat.findIndex(EuiccProfileInfo.POLICY_RULE_DO_NOT_DELETE, opB));
    assertEquals(2, rat.findIndex(EuiccProfileInfo.POLICY_RULE_DO_NOT_DISABLE, opA));
    assertEquals(2, rat.findIndex(EuiccProfileInfo.POLICY_RULE_DO_NOT_DISABLE, opB));
    assertTrue(rat.hasPolicyRuleFlag(1, EuiccRulesAuthTable.POLICY_RULE_FLAG_CONSENT_REQUIRED));
    assertFalse(rat.hasPolicyRuleFlag(2, EuiccRulesAuthTable.POLICY_RULE_FLAG_CONSENT_REQUIRED));
    assertTrue(rat.hasPolicyRuleFlag(3, EuiccRulesAuthTable.POLICY_RULE_FLAG_CONSENT_REQUIRED));
}
Also used : CarrierIdentifier(android.service.carrier.CarrierIdentifier) EuiccRulesAuthTable(android.telephony.euicc.EuiccRulesAuthTable) Test(org.junit.Test)

Aggregations

EuiccRulesAuthTable (android.telephony.euicc.EuiccRulesAuthTable)10 CarrierIdentifier (android.service.carrier.CarrierIdentifier)8 Test (org.junit.Test)8 Parcel (android.os.Parcel)1 RemoteException (android.os.RemoteException)1 TelephonyTest (com.android.internal.telephony.TelephonyTest)1 Asn1Node (com.android.internal.telephony.uicc.asn1.Asn1Node)1 EuiccCard (com.android.internal.telephony.uicc.euicc.EuiccCard)1 RequestBuilder (com.android.internal.telephony.uicc.euicc.apdu.RequestBuilder)1 AsyncResultCallback (com.android.internal.telephony.uicc.euicc.async.AsyncResultCallback)1