Search in sources :

Example 1 with EuiccRulesAuthTable

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

the class EuiccRulesAuthTableTest method testFindIndex_AllowAllWithUserConsent.

@Test
public void testFindIndex_AllowAllWithUserConsent() {
    CarrierIdentifier opA = new CarrierIdentifier(new byte[] { 0x21, 0x63, 0x54 }, null, "4");
    CarrierIdentifier opB = new CarrierIdentifier(new byte[] { 0x78, (byte) 0xF4, 0x25 }, "4", null);
    EuiccRulesAuthTable rat = new EuiccRulesAuthTable.Builder(1).add(EuiccProfileInfo.POLICY_RULE_DO_NOT_DELETE | EuiccProfileInfo.POLICY_RULE_DO_NOT_DISABLE, Arrays.asList(// Matches none
    new CarrierIdentifier(new byte[] { (byte) 0xEE, (byte) 0xEE, (byte) 0xEE }, null, null)), EuiccRulesAuthTable.POLICY_RULE_FLAG_CONSENT_REQUIRED).build();
    assertEquals(0, rat.findIndex(EuiccProfileInfo.POLICY_RULE_DO_NOT_DELETE, opA));
    assertEquals(0, rat.findIndex(EuiccProfileInfo.POLICY_RULE_DO_NOT_DELETE, opB));
    assertEquals(0, rat.findIndex(EuiccProfileInfo.POLICY_RULE_DO_NOT_DISABLE, opA));
    assertEquals(0, rat.findIndex(EuiccProfileInfo.POLICY_RULE_DO_NOT_DISABLE, opB));
}
Also used : CarrierIdentifier(android.service.carrier.CarrierIdentifier) EuiccRulesAuthTable(android.telephony.euicc.EuiccRulesAuthTable) Test(org.junit.Test)

Example 2 with EuiccRulesAuthTable

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

the class EuiccRulesAuthTableTest method testEquals.

@Test
public void testEquals() {
    EuiccRulesAuthTable rat = new EuiccRulesAuthTable.Builder(4).add(EuiccProfileInfo.POLICY_RULE_DO_NOT_DELETE | EuiccProfileInfo.POLICY_RULE_DO_NOT_DISABLE, Arrays.asList(new CarrierIdentifier[] {}), EuiccRulesAuthTable.POLICY_RULE_FLAG_CONSENT_REQUIRED).add(EuiccProfileInfo.POLICY_RULE_DO_NOT_DELETE, Arrays.asList(new CarrierIdentifier(new byte[] { 0x21, (byte) 0xF3, 0x54 }, "4", null), new CarrierIdentifier(new byte[] { 0x21, 0x63, 0x54 }, null, "4")), EuiccRulesAuthTable.POLICY_RULE_FLAG_CONSENT_REQUIRED).add(EuiccProfileInfo.POLICY_RULE_DO_NOT_DISABLE, Arrays.asList(new CarrierIdentifier(new byte[] { 0x21, 0x63, 0x54 }, null, "5"), 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(new CarrierIdentifier(new byte[] { 0x21, 0x69, 0x54 }, "5", null), new CarrierIdentifier(new byte[] { 0x21, 0x6E, 0x54 }, "4", null), new CarrierIdentifier(new byte[] { 0x21, 0x6E, 0x54 }, null, "4")), EuiccRulesAuthTable.POLICY_RULE_FLAG_CONSENT_REQUIRED).build();
    // Same object.
    EuiccRulesAuthTable that = rat;
    assertTrue(rat.equals(that));
    // Same values with rat.
    that = new EuiccRulesAuthTable.Builder(4).add(EuiccProfileInfo.POLICY_RULE_DO_NOT_DELETE | EuiccProfileInfo.POLICY_RULE_DO_NOT_DISABLE, Arrays.asList(new CarrierIdentifier[] {}), EuiccRulesAuthTable.POLICY_RULE_FLAG_CONSENT_REQUIRED).add(EuiccProfileInfo.POLICY_RULE_DO_NOT_DELETE, Arrays.asList(new CarrierIdentifier(new byte[] { 0x21, (byte) 0xF3, 0x54 }, "4", null), new CarrierIdentifier(new byte[] { 0x21, 0x63, 0x54 }, null, "4")), EuiccRulesAuthTable.POLICY_RULE_FLAG_CONSENT_REQUIRED).add(EuiccProfileInfo.POLICY_RULE_DO_NOT_DISABLE, Arrays.asList(new CarrierIdentifier(new byte[] { 0x21, 0x63, 0x54 }, null, "5"), 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(new CarrierIdentifier(new byte[] { 0x21, 0x69, 0x54 }, "5", null), new CarrierIdentifier(new byte[] { 0x21, 0x6E, 0x54 }, "4", null), new CarrierIdentifier(new byte[] { 0x21, 0x6E, 0x54 }, null, "4")), EuiccRulesAuthTable.POLICY_RULE_FLAG_CONSENT_REQUIRED).build();
    assertTrue(rat.equals(that));
    // Null object.
    that = null;
    assertFalse(rat.equals(that));
    that = new EuiccRulesAuthTable.Builder(3).add(EuiccProfileInfo.POLICY_RULE_DO_NOT_DELETE | EuiccProfileInfo.POLICY_RULE_DO_NOT_DISABLE, Arrays.asList(new CarrierIdentifier[] {}), EuiccRulesAuthTable.POLICY_RULE_FLAG_CONSENT_REQUIRED).add(EuiccProfileInfo.POLICY_RULE_DO_NOT_DELETE, Arrays.asList(new CarrierIdentifier(new byte[] { 0x21, (byte) 0xF3, 0x54 }, "4", null), new CarrierIdentifier(new byte[] { 0x21, 0x63, 0x54 }, null, "4")), EuiccRulesAuthTable.POLICY_RULE_FLAG_CONSENT_REQUIRED).add(EuiccProfileInfo.POLICY_RULE_DO_NOT_DISABLE, Arrays.asList(new CarrierIdentifier(new byte[] { 0x21, 0x63, 0x54 }, null, "5"), new CarrierIdentifier(new byte[] { 0x21, 0x6E, 0x54 }, null, null)), 0).build();
    assertFalse(rat.equals(that));
    that = new EuiccRulesAuthTable.Builder(4).add(EuiccProfileInfo.POLICY_RULE_DO_NOT_DELETE | EuiccProfileInfo.POLICY_RULE_DO_NOT_DISABLE, Arrays.asList(new CarrierIdentifier[] {}), EuiccRulesAuthTable.POLICY_RULE_FLAG_CONSENT_REQUIRED).add(EuiccProfileInfo.POLICY_RULE_DO_NOT_DELETE, Arrays.asList(// Only one item
    new CarrierIdentifier(new byte[] { 0x21, (byte) 0xF3, 0x54 }, "4", null)), EuiccRulesAuthTable.POLICY_RULE_FLAG_CONSENT_REQUIRED).add(EuiccProfileInfo.POLICY_RULE_DO_NOT_DISABLE, Arrays.asList(new CarrierIdentifier(new byte[] { 0x21, 0x63, 0x54 }, null, "5"), 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(new CarrierIdentifier(new byte[] { 0x21, 0x69, 0x54 }, "5", null), new CarrierIdentifier(new byte[] { 0x21, 0x6E, 0x54 }, "4", null), new CarrierIdentifier(new byte[] { 0x21, 0x6E, 0x54 }, null, "4")), EuiccRulesAuthTable.POLICY_RULE_FLAG_CONSENT_REQUIRED).build();
    assertFalse(rat.equals(that));
    that = new EuiccRulesAuthTable.Builder(4).add(EuiccProfileInfo.POLICY_RULE_DO_NOT_DELETE | EuiccProfileInfo.POLICY_RULE_DO_NOT_DISABLE, Arrays.asList(new CarrierIdentifier[] {}), EuiccRulesAuthTable.POLICY_RULE_FLAG_CONSENT_REQUIRED).add(EuiccProfileInfo.POLICY_RULE_DO_NOT_DELETE, Arrays.asList(// Different value from rat
    new CarrierIdentifier(new byte[] { 0x22, (byte) 0xF3, 0x54 }, "4", null), new CarrierIdentifier(new byte[] { 0x21, 0x63, 0x54 }, null, "4")), EuiccRulesAuthTable.POLICY_RULE_FLAG_CONSENT_REQUIRED).add(EuiccProfileInfo.POLICY_RULE_DO_NOT_DISABLE, Arrays.asList(new CarrierIdentifier(new byte[] { 0x21, 0x63, 0x54 }, null, "5"), 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(new CarrierIdentifier(new byte[] { 0x21, 0x69, 0x54 }, "5", null), new CarrierIdentifier(new byte[] { 0x21, 0x6E, 0x54 }, "4", null), new CarrierIdentifier(new byte[] { 0x21, 0x6E, 0x54 }, null, "4")), EuiccRulesAuthTable.POLICY_RULE_FLAG_CONSENT_REQUIRED).build();
    assertFalse(rat.equals(that));
    that = new EuiccRulesAuthTable.Builder(4).add(EuiccProfileInfo.POLICY_RULE_DO_NOT_DELETE | EuiccProfileInfo.POLICY_RULE_DO_NOT_DISABLE, // Null here.
    null, EuiccRulesAuthTable.POLICY_RULE_FLAG_CONSENT_REQUIRED).add(EuiccProfileInfo.POLICY_RULE_DO_NOT_DELETE, Arrays.asList(new CarrierIdentifier(new byte[] { 0x21, (byte) 0xF3, 0x54 }, "4", null), new CarrierIdentifier(new byte[] { 0x21, 0x63, 0x54 }, null, "4")), EuiccRulesAuthTable.POLICY_RULE_FLAG_CONSENT_REQUIRED).add(EuiccProfileInfo.POLICY_RULE_DO_NOT_DISABLE, Arrays.asList(new CarrierIdentifier(new byte[] { 0x21, 0x63, 0x54 }, null, "5"), 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(new CarrierIdentifier(new byte[] { 0x21, 0x69, 0x54 }, "5", null), new CarrierIdentifier(new byte[] { 0x21, 0x6E, 0x54 }, "4", null), new CarrierIdentifier(new byte[] { 0x21, 0x6E, 0x54 }, null, "4")), EuiccRulesAuthTable.POLICY_RULE_FLAG_CONSENT_REQUIRED).build();
    assertTrue(rat.equals(that));
    that = new EuiccRulesAuthTable.Builder(4).add(// Different policy rules
    EuiccProfileInfo.POLICY_RULE_DO_NOT_DELETE, Arrays.asList(new CarrierIdentifier[] {}), EuiccRulesAuthTable.POLICY_RULE_FLAG_CONSENT_REQUIRED).add(EuiccProfileInfo.POLICY_RULE_DO_NOT_DELETE, Arrays.asList(new CarrierIdentifier(new byte[] { 0x21, (byte) 0xF3, 0x54 }, "4", null), new CarrierIdentifier(new byte[] { 0x21, 0x63, 0x54 }, null, "4")), EuiccRulesAuthTable.POLICY_RULE_FLAG_CONSENT_REQUIRED).add(EuiccProfileInfo.POLICY_RULE_DO_NOT_DISABLE, Arrays.asList(new CarrierIdentifier(new byte[] { 0x21, 0x63, 0x54 }, null, "5"), 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(new CarrierIdentifier(new byte[] { 0x21, 0x69, 0x54 }, "5", null), new CarrierIdentifier(new byte[] { 0x21, 0x6E, 0x54 }, "4", null), new CarrierIdentifier(new byte[] { 0x21, 0x6E, 0x54 }, null, "4")), EuiccRulesAuthTable.POLICY_RULE_FLAG_CONSENT_REQUIRED).build();
    assertFalse(rat.equals(that));
}
Also used : EuiccRulesAuthTable(android.telephony.euicc.EuiccRulesAuthTable) CarrierIdentifier(android.service.carrier.CarrierIdentifier) Test(org.junit.Test)

Example 3 with EuiccRulesAuthTable

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

the class EuiccRulesAuthTableTest method testFindIndex_DisallowAllWithEmptyRules.

@Test
public void testFindIndex_DisallowAllWithEmptyRules() {
    CarrierIdentifier opA = new CarrierIdentifier(new byte[] { 0x21, 0x63, 0x54 }, null, "4");
    CarrierIdentifier opB = new CarrierIdentifier(new byte[] { 0x78, 0x34, 0x25 }, "4", null);
    EuiccRulesAuthTable rat = new EuiccRulesAuthTable.Builder(0).build();
    assertEquals(-1, rat.findIndex(EuiccProfileInfo.POLICY_RULE_DO_NOT_DELETE, opA));
    assertEquals(-1, rat.findIndex(EuiccProfileInfo.POLICY_RULE_DO_NOT_DELETE, opB));
    assertEquals(-1, rat.findIndex(EuiccProfileInfo.POLICY_RULE_DO_NOT_DISABLE, opA));
    assertEquals(-1, rat.findIndex(EuiccProfileInfo.POLICY_RULE_DO_NOT_DISABLE, opB));
}
Also used : CarrierIdentifier(android.service.carrier.CarrierIdentifier) EuiccRulesAuthTable(android.telephony.euicc.EuiccRulesAuthTable) Test(org.junit.Test)

Example 4 with EuiccRulesAuthTable

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

the class EuiccRulesAuthTableTest method testFindIndex_DisallowAll.

@Test
public void testFindIndex_DisallowAll() {
    CarrierIdentifier opA = new CarrierIdentifier(new byte[] { 0x21, 0x63, 0x54 }, null, "4");
    CarrierIdentifier opB = new CarrierIdentifier(new byte[] { 0x78, (byte) 0xF4, 0x25 }, "4", null);
    EuiccRulesAuthTable rat = new EuiccRulesAuthTable.Builder(1).add(0, Arrays.asList(new CarrierIdentifier[] {}), 0).build();
    assertEquals(-1, rat.findIndex(EuiccProfileInfo.POLICY_RULE_DO_NOT_DELETE, opA));
    assertEquals(-1, rat.findIndex(EuiccProfileInfo.POLICY_RULE_DO_NOT_DELETE, opB));
    assertEquals(-1, rat.findIndex(EuiccProfileInfo.POLICY_RULE_DO_NOT_DISABLE, opA));
    assertEquals(-1, rat.findIndex(EuiccProfileInfo.POLICY_RULE_DO_NOT_DISABLE, opB));
}
Also used : CarrierIdentifier(android.service.carrier.CarrierIdentifier) EuiccRulesAuthTable(android.telephony.euicc.EuiccRulesAuthTable) Test(org.junit.Test)

Example 5 with EuiccRulesAuthTable

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

the class EuiccRulesAuthTableTest method testWriteToParcel.

@Test
public void testWriteToParcel() {
    EuiccRulesAuthTable rat = new EuiccRulesAuthTable.Builder(4).add(EuiccProfileInfo.POLICY_RULE_DO_NOT_DELETE | EuiccProfileInfo.POLICY_RULE_DO_NOT_DISABLE, Arrays.asList(new CarrierIdentifier[] {}), EuiccRulesAuthTable.POLICY_RULE_FLAG_CONSENT_REQUIRED).add(EuiccProfileInfo.POLICY_RULE_DO_NOT_DELETE, Arrays.asList(new CarrierIdentifier(new byte[] { 0x21, (byte) 0xF3, 0x54 }, "4", null), new CarrierIdentifier(new byte[] { 0x21, 0x63, 0x54 }, null, "4")), EuiccRulesAuthTable.POLICY_RULE_FLAG_CONSENT_REQUIRED).add(EuiccProfileInfo.POLICY_RULE_DO_NOT_DISABLE, Arrays.asList(new CarrierIdentifier(new byte[] { 0x21, 0x63, 0x54 }, null, "5"), 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(new CarrierIdentifier(new byte[] { 0x21, 0x69, 0x54 }, "5", null), new CarrierIdentifier(new byte[] { 0x21, 0x6E, 0x54 }, "4", null), new CarrierIdentifier(new byte[] { 0x21, 0x6E, 0x54 }, null, "4")), EuiccRulesAuthTable.POLICY_RULE_FLAG_CONSENT_REQUIRED).build();
    Parcel parcel = Parcel.obtain();
    assertTrue(parcel != null);
    rat.writeToParcel(parcel, 0);
    parcel.setDataPosition(0);
    EuiccRulesAuthTable fromParcel = EuiccRulesAuthTable.CREATOR.createFromParcel(parcel);
    assertEquals(rat, fromParcel);
    // Empty rules.
    rat = new EuiccRulesAuthTable.Builder(0).build();
    parcel = Parcel.obtain();
    rat.writeToParcel(parcel, 0);
    parcel.setDataPosition(0);
    fromParcel = EuiccRulesAuthTable.CREATOR.createFromParcel(parcel);
    assertEquals(rat, fromParcel);
    // Null carrier identifier.
    rat = new EuiccRulesAuthTable.Builder(1).add(EuiccProfileInfo.POLICY_RULE_DO_NOT_DELETE | EuiccProfileInfo.POLICY_RULE_DO_NOT_DISABLE, null, EuiccRulesAuthTable.POLICY_RULE_FLAG_CONSENT_REQUIRED).build();
    parcel = Parcel.obtain();
    rat.writeToParcel(parcel, 0);
    parcel.setDataPosition(0);
    fromParcel = EuiccRulesAuthTable.CREATOR.createFromParcel(parcel);
    assertEquals(rat, fromParcel);
}
Also used : Parcel(android.os.Parcel) EuiccRulesAuthTable(android.telephony.euicc.EuiccRulesAuthTable) CarrierIdentifier(android.service.carrier.CarrierIdentifier) 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