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));
}
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));
}
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));
}
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));
}
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);
}
Aggregations