Search in sources :

Example 31 with ArrayMap

use of android.util.ArrayMap in project android_frameworks_base by ResurrectionRemix.

the class KeySetManagerServiceTest method testRemoveAppKSDataDefined.

/* remove package which used defined and upgrade keysets and ensure  removed */
public void testRemoveAppKSDataDefined() 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);
    /* removal requires signing keyset to be specified (since all apps are
         * assumed to have it).  We skipped this in the defined tests, but can't
         * here. */
    mKsms.addSigningKeySetToPackageLPw(ps, keys);
    definedKS.put("aliasA", keys);
    mKsms.addDefinedKeySetsToPackageLPw(ps, definedKS);
    ArraySet<String> upgradeKS = new ArraySet<String>();
    upgradeKS.add("aliasA");
    mKsms.addUpgradeKeySetsToPackageLPw(ps, upgradeKS);
    mKsms.removeAppKeySetDataLPw(ps.name);
    assertEquals(0, KeySetUtils.getKeySetRefCount(mKsms, 1));
    assertEquals(0, KeySetUtils.getPubKeyRefCount(mKsms, 1));
    LongSparseArray<ArraySet<Long>> ksMapping = KeySetUtils.getKeySetMapping(mKsms);
    assertEquals(0, ksMapping.size());
    assertEquals(PackageKeySetData.KEYSET_UNASSIGNED, ps.keySetData.getProperSigningKeySet());
    assertEquals(0, ps.keySetData.getAliases().size());
    assertNull(ps.keySetData.getUpgradeKeySets());
}
Also used : ArraySet(android.util.ArraySet) PublicKey(java.security.PublicKey) ArrayMap(android.util.ArrayMap)

Example 32 with ArrayMap

use of android.util.ArrayMap in project android_frameworks_base by ResurrectionRemix.

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 33 with ArrayMap

use of android.util.ArrayMap in project android_frameworks_base by ResurrectionRemix.

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 34 with ArrayMap

use of android.util.ArrayMap in project android_frameworks_base by ResurrectionRemix.

the class KeySetManagerServiceTest method testAddDefinedKSToPackageEmpty.

/* add a defined keyset make sure it shows up */
public void testAddDefinedKSToPackageEmpty() 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);
    assertEquals(1, 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"));
}
Also used : ArraySet(android.util.ArraySet) PublicKey(java.security.PublicKey) ArrayMap(android.util.ArrayMap)

Example 35 with ArrayMap

use of android.util.ArrayMap in project android_frameworks_base by ResurrectionRemix.

the class BackStackRecord method mapEnteringSharedElements.

/**
     * Maps shared elements to views in the entering fragment.
     *
     * @param state The transition State as returned from {@link #beginTransition(
     * android.util.SparseArray, android.util.SparseArray, boolean)}.
     * @param inFragment The last fragment to be added.
     * @param isBack true if this is popping the back stack or false if this is a
     *               forward operation.
     */
private ArrayMap<String, View> mapEnteringSharedElements(TransitionState state, Fragment inFragment, boolean isBack) {
    ArrayMap<String, View> namedViews = new ArrayMap<String, View>();
    View root = inFragment.getView();
    if (root != null) {
        if (mSharedElementSourceNames != null) {
            root.findNamedViews(namedViews);
            if (isBack) {
                namedViews = remapNames(mSharedElementSourceNames, mSharedElementTargetNames, namedViews);
            } else {
                namedViews.retainAll(mSharedElementTargetNames);
            }
        }
    }
    return namedViews;
}
Also used : ArrayMap(android.util.ArrayMap) View(android.view.View)

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