Search in sources :

Example 71 with ArraySet

use of android.util.ArraySet in project android_frameworks_base by DirtyUnicorns.

the class FullBackup method getBackupSchemeForTest.

public static BackupScheme getBackupSchemeForTest(Context context) {
    BackupScheme testing = new BackupScheme(context);
    testing.mExcludes = new ArraySet();
    testing.mIncludes = new ArrayMap();
    return testing;
}
Also used : ArraySet(android.util.ArraySet) ArrayMap(android.util.ArrayMap)

Example 72 with ArraySet

use of android.util.ArraySet in project android_frameworks_base by DirtyUnicorns.

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 73 with ArraySet

use of android.util.ArraySet in project android_frameworks_base by DirtyUnicorns.

the class KeySetManagerServiceTest method testAddDefinedKSToPackageThree.

/* add defined keyset, remove it, add again and make sure diff id. */
public void testAddDefinedKSToPackageThree() 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> keys1 = new ArraySet<PublicKey>();
    PublicKey keyA = PackageParser.parsePublicKey(KeySetStrings.ctsKeySetPublicKeyA);
    keys1.add(keyA);
    definedKS.put("aliasA", keys1);
    mKsms.addDefinedKeySetsToPackageLPw(ps, definedKS);
    /* now upgrade to different set */
    ArraySet<PublicKey> keys2 = new ArraySet<PublicKey>();
    PublicKey keyB = PackageParser.parsePublicKey(KeySetStrings.ctsKeySetPublicKeyB);
    keys2.add(keyB);
    definedKS.remove("aliasA");
    definedKS.put("aliasB", keys2);
    mKsms.addDefinedKeySetsToPackageLPw(ps, definedKS);
    /* upgrade back to original */
    definedKS.remove("aliasB");
    definedKS.put("aliasA", keys1);
    mKsms.addDefinedKeySetsToPackageLPw(ps, definedKS);
    assertEquals(0, KeySetUtils.getKeySetRefCount(mKsms, 1));
    assertEquals(0, KeySetUtils.getKeySetRefCount(mKsms, 2));
    assertEquals(1, KeySetUtils.getKeySetRefCount(mKsms, 3));
    assertEquals(0, KeySetUtils.getPubKeyRefCount(mKsms, 1));
    assertEquals(0, KeySetUtils.getPubKeyRefCount(mKsms, 2));
    assertEquals(1, KeySetUtils.getPubKeyRefCount(mKsms, 3));
    assertEquals(keyA, KeySetUtils.getPubKey(mKsms, 3));
    LongSparseArray<ArraySet<Long>> ksMapping = KeySetUtils.getKeySetMapping(mKsms);
    assertEquals(1, ksMapping.size());
    ArraySet<Long> mapping = ksMapping.get(3);
    assertEquals(1, mapping.size());
    assertTrue(mapping.contains(new Long(3)));
    assertEquals(new Long(3), ps.keySetData.getAliases().get("aliasA"));
}
Also used : ArraySet(android.util.ArraySet) PublicKey(java.security.PublicKey) ArrayMap(android.util.ArrayMap)

Example 74 with ArraySet

use of android.util.ArraySet in project android_frameworks_base by DirtyUnicorns.

the class KeySetManagerServiceTest method testRemoveAppKSDataUnique.

/* remove package and validate that keyset and public keys are removed */
public void testRemoveAppKSDataUnique() throws ReflectiveOperationException {
    /* create PackageSetting and add to Settings mPackages */
    PackageSetting ps = generateFakePackageSetting("packageA");
    mPackagesMap.put(ps.name, ps);
    /* collect signing key and add */
    ArraySet<PublicKey> signingKeys = new ArraySet<PublicKey>();
    PublicKey keyA = PackageParser.parsePublicKey(KeySetStrings.ctsKeySetPublicKeyA);
    signingKeys.add(keyA);
    mKsms.addSigningKeySetToPackageLPw(ps, signingKeys);
    /* remove its references */
    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());
}
Also used : ArraySet(android.util.ArraySet) PublicKey(java.security.PublicKey)

Example 75 with ArraySet

use of android.util.ArraySet in project android_frameworks_base by DirtyUnicorns.

the class KeySetManagerServiceTest method testAddSigningKSToPackageUpgradeSame.

/*
     * upgrade an app (same packagename) with same keyset and verify that
     * nothing changed.
     */
public void testAddSigningKSToPackageUpgradeSame() throws ReflectiveOperationException {
    /* create PackageSetting and add to Settings mPackages */
    PackageSetting ps = generateFakePackageSetting("packageA");
    mPackagesMap.put(ps.name, ps);
    /* collect signing key and add */
    ArraySet<PublicKey> signingKeys = new ArraySet<PublicKey>();
    PublicKey keyA = PackageParser.parsePublicKey(KeySetStrings.ctsKeySetPublicKeyA);
    signingKeys.add(keyA);
    mKsms.addSigningKeySetToPackageLPw(ps, signingKeys);
    /* add again, to represent upgrade of package */
    mKsms.addSigningKeySetToPackageLPw(ps, signingKeys);
    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)));
    assertEquals(1, ps.keySetData.getProperSigningKeySet());
}
Also used : ArraySet(android.util.ArraySet) PublicKey(java.security.PublicKey)

Aggregations

ArraySet (android.util.ArraySet)521 PublicKey (java.security.PublicKey)94 ArrayList (java.util.ArrayList)87 ComponentName (android.content.ComponentName)82 ArrayMap (android.util.ArrayMap)73 Pair (android.util.Pair)47 RemoteException (android.os.RemoteException)43 ResolveInfo (android.content.pm.ResolveInfo)39 Intent (android.content.Intent)38 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)35 File (java.io.File)33 SSLContext (javax.net.ssl.SSLContext)32 IOException (java.io.IOException)31 PackageManager (android.content.pm.PackageManager)29 UserInfo (android.content.pm.UserInfo)28 ApplicationInfo (android.content.pm.ApplicationInfo)24 Point (android.graphics.Point)24 X509Certificate (java.security.cert.X509Certificate)20 PackageInfo (android.content.pm.PackageInfo)19 Test (org.junit.Test)19