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