Search in sources :

Example 11 with ArrayMap

use of android.util.ArrayMap in project platform_frameworks_base by android.

the class KeySetManagerServiceTest method testAddDefinedKSToPackageOrthoUpgr.

/* upgrd defined keyset ortho (make sure previous is removed for pkg) */
public void testAddDefinedKSToPackageOrthoUpgr() throws ReflectiveOperationException {
    /* create PackageSetting and add to Settings mPackages */
    PackageSetting ps = generateFakePackageSetting("packageA");
    mPackagesMap.put(ps.name, ps);
    /* collect key and add */
    ArrayMap<String, ArraySet<PublicKey>> definedKS = new ArrayMap<String, ArraySet<PublicKey>>();
    ArraySet<PublicKey> keys = new ArraySet<PublicKey>();
    PublicKey keyA = PackageParser.parsePublicKey(KeySetStrings.ctsKeySetPublicKeyA);
    keys.add(keyA);
    definedKS.put("aliasA", keys);
    mKsms.addDefinedKeySetsToPackageLPw(ps, definedKS);
    /* now upgrade to different defined key-set */
    keys = new ArraySet<PublicKey>();
    PublicKey keyB = PackageParser.parsePublicKey(KeySetStrings.ctsKeySetPublicKeyB);
    keys.add(keyB);
    definedKS.remove("aliasA");
    definedKS.put("aliasB", keys);
    mKsms.addDefinedKeySetsToPackageLPw(ps, definedKS);
    assertEquals(0, KeySetUtils.getKeySetRefCount(mKsms, 1));
    assertEquals(0, KeySetUtils.getPubKeyRefCount(mKsms, 1));
    assertEquals(1, KeySetUtils.getKeySetRefCount(mKsms, 2));
    assertEquals(1, KeySetUtils.getPubKeyRefCount(mKsms, 2));
    assertEquals(keyB, KeySetUtils.getPubKey(mKsms, 2));
    LongSparseArray<ArraySet<Long>> ksMapping = KeySetUtils.getKeySetMapping(mKsms);
    assertEquals(1, ksMapping.size());
    ArraySet<Long> mapping = ksMapping.get(2);
    assertEquals(1, mapping.size());
    assertTrue(mapping.contains(new Long(2)));
    assertNull(ps.keySetData.getAliases().get("aliasA"));
    assertNotNull(ps.keySetData.getAliases().get("aliasB"));
    assertEquals(new Long(2), ps.keySetData.getAliases().get("aliasB"));
}
Also used : ArraySet(android.util.ArraySet) PublicKey(java.security.PublicKey) ArrayMap(android.util.ArrayMap)

Example 12 with ArrayMap

use of android.util.ArrayMap in project platform_frameworks_base by android.

the class KeySetManagerServiceTest method testAddUpgradeKSToPackageWrong.

/* add upgrade keyset for non-existing defined and check that it compains */
public void testAddUpgradeKSToPackageWrong() {
    /* create PackageSetting and add to Settings mPackages */
    PackageSetting ps = generateFakePackageSetting("packageA");
    mPackagesMap.put(ps.name, ps);
    /* collect key and add and try to specify bogus upgrade keyset */
    ArrayMap<String, ArraySet<PublicKey>> definedKS = new ArrayMap<String, ArraySet<PublicKey>>();
    ArraySet<PublicKey> keys = new ArraySet<PublicKey>();
    PublicKey keyA = PackageParser.parsePublicKey(KeySetStrings.ctsKeySetPublicKeyA);
    keys.add(keyA);
    definedKS.put("aliasA", keys);
    mKsms.addDefinedKeySetsToPackageLPw(ps, definedKS);
    ArraySet<String> upgradeKS = new ArraySet<String>();
    upgradeKS.add("aliasB");
    try {
        mKsms.addUpgradeKeySetsToPackageLPw(ps, upgradeKS);
    } catch (IllegalArgumentException e) {
        /* should have been caught in packagemanager, so exception thrown */
        return;
    }
    fail("Expected IllegalArgumentException when adding undefined upgrade keyset!!");
}
Also used : ArraySet(android.util.ArraySet) PublicKey(java.security.PublicKey) ArrayMap(android.util.ArrayMap)

Example 13 with ArrayMap

use of android.util.ArrayMap in project platform_frameworks_base by android.

the class KeySetManagerServiceTest method testAddUpgradeKSToPackageDisappear.

/* upgrade from defined keysets w/upgrade to different defined keysets and
     * make sure the previously specified upgrade keyset has been removed. */
public void testAddUpgradeKSToPackageDisappear() {
    /* create PackageSetting and add to Settings mPackages */
    PackageSetting ps = generateFakePackageSetting("packageA");
    mPackagesMap.put(ps.name, ps);
    /* collect key and add */
    ArrayMap<String, ArraySet<PublicKey>> definedKS = new ArrayMap<String, ArraySet<PublicKey>>();
    ArraySet<PublicKey> keys = new ArraySet<PublicKey>();
    PublicKey keyA = PackageParser.parsePublicKey(KeySetStrings.ctsKeySetPublicKeyA);
    keys.add(keyA);
    definedKS.put("aliasA", keys);
    mKsms.addDefinedKeySetsToPackageLPw(ps, definedKS);
    ArraySet<String> upgradeKS = new ArraySet<String>();
    upgradeKS.add("aliasA");
    mKsms.addUpgradeKeySetsToPackageLPw(ps, upgradeKS);
    keys = new ArraySet<PublicKey>();
    PublicKey keyB = PackageParser.parsePublicKey(KeySetStrings.ctsKeySetPublicKeyB);
    keys.add(keyB);
    definedKS.remove("aliasA");
    definedKS.put("aliasB", keys);
    mKsms.addDefinedKeySetsToPackageLPw(ps, definedKS);
    assertNull(ps.keySetData.getUpgradeKeySets());
}
Also used : ArraySet(android.util.ArraySet) PublicKey(java.security.PublicKey) ArrayMap(android.util.ArrayMap)

Example 14 with ArrayMap

use of android.util.ArrayMap in project platform_frameworks_base by android.

the class KeySetManagerServiceTest method testAddDefinedKSToPackageDoubleAlias.

/* add 2 defined keysets which refer to same keyset and make sure ref-ct is 2 */
public void testAddDefinedKSToPackageDoubleAlias() throws ReflectiveOperationException {
    /* create PackageSetting and add to Settings mPackages */
    PackageSetting ps = generateFakePackageSetting("packageA");
    mPackagesMap.put(ps.name, ps);
    /* collect key and add */
    ArrayMap<String, ArraySet<PublicKey>> definedKS = new ArrayMap<String, ArraySet<PublicKey>>();
    ArraySet<PublicKey> keys = new ArraySet<PublicKey>();
    PublicKey keyA = PackageParser.parsePublicKey(KeySetStrings.ctsKeySetPublicKeyA);
    keys.add(keyA);
    definedKS.put("aliasA", keys);
    definedKS.put("aliasA2", keys);
    mKsms.addDefinedKeySetsToPackageLPw(ps, definedKS);
    assertEquals(2, KeySetUtils.getKeySetRefCount(mKsms, 1));
    assertEquals(1, KeySetUtils.getPubKeyRefCount(mKsms, 1));
    assertEquals(keyA, KeySetUtils.getPubKey(mKsms, 1));
    LongSparseArray<ArraySet<Long>> ksMapping = KeySetUtils.getKeySetMapping(mKsms);
    assertEquals(1, ksMapping.size());
    ArraySet<Long> mapping = ksMapping.get(1);
    assertEquals(1, mapping.size());
    assertTrue(mapping.contains(new Long(1)));
    assertNotNull(ps.keySetData.getAliases().get("aliasA"));
    assertEquals(new Long(1), ps.keySetData.getAliases().get("aliasA"));
    assertNotNull(ps.keySetData.getAliases().get("aliasA2"));
    assertEquals(new Long(1), ps.keySetData.getAliases().get("aliasA2"));
}
Also used : ArraySet(android.util.ArraySet) PublicKey(java.security.PublicKey) ArrayMap(android.util.ArrayMap)

Example 15 with ArrayMap

use of android.util.ArrayMap in project platform_frameworks_base by android.

the class CarrierAppUtils method getDefaultCarrierAssociatedAppsHelper.

private static Map<String, List<ApplicationInfo>> getDefaultCarrierAssociatedAppsHelper(IPackageManager packageManager, int userId, ArrayMap<String, List<String>> systemCarrierAssociatedAppsDisabledUntilUsed) {
    int size = systemCarrierAssociatedAppsDisabledUntilUsed.size();
    Map<String, List<ApplicationInfo>> associatedApps = new ArrayMap<>(size);
    for (int i = 0; i < size; i++) {
        String carrierAppPackage = systemCarrierAssociatedAppsDisabledUntilUsed.keyAt(i);
        List<String> associatedAppPackages = systemCarrierAssociatedAppsDisabledUntilUsed.valueAt(i);
        for (int j = 0; j < associatedAppPackages.size(); j++) {
            ApplicationInfo ai = getApplicationInfoIfSystemApp(packageManager, userId, associatedAppPackages.get(j));
            // shouldn't touch it.
            if (ai != null && !ai.isUpdatedSystemApp()) {
                List<ApplicationInfo> appList = associatedApps.get(carrierAppPackage);
                if (appList == null) {
                    appList = new ArrayList<>();
                    associatedApps.put(carrierAppPackage, appList);
                }
                appList.add(ai);
            }
        }
    }
    return associatedApps;
}
Also used : ApplicationInfo(android.content.pm.ApplicationInfo) ArrayMap(android.util.ArrayMap) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ArrayMap (android.util.ArrayMap)242 ArraySet (android.util.ArraySet)77 ArrayList (java.util.ArrayList)58 PublicKey (java.security.PublicKey)49 IOException (java.io.IOException)27 HashMap (java.util.HashMap)26 Map (java.util.Map)19 Point (android.graphics.Point)17 X509Certificate (java.security.cert.X509Certificate)15 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)15 RemoteException (android.os.RemoteException)14 List (java.util.List)14 ComponentName (android.content.ComponentName)13 SparseArray (android.util.SparseArray)12 Field (java.lang.reflect.Field)12 Method (java.lang.reflect.Method)11 NonNull (android.annotation.NonNull)10 Paint (android.graphics.Paint)10 BatterySipper (com.android.internal.os.BatterySipper)10 BatteryStatsHelper (com.android.internal.os.BatteryStatsHelper)10