Search in sources :

Example 71 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 72 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 73 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 74 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)

Example 75 with ArrayMap

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

the class UserState method getPrintJobInfos.

public List<PrintJobInfo> getPrintJobInfos(int appId) {
    List<PrintJobInfo> cachedPrintJobs = mPrintJobForAppCache.getPrintJobs(appId);
    // Note that the print spooler is not storing print jobs that
    // are in a terminal state as it is non-trivial to properly update
    // the spooler state for when to forget print jobs in terminal state.
    // Therefore, we fuse the cached print jobs for running apps (some
    // jobs are in a terminal state) with the ones that the print
    // spooler knows about (some jobs are being processed).
    ArrayMap<PrintJobId, PrintJobInfo> result = new ArrayMap<PrintJobId, PrintJobInfo>();
    // Add the cached print jobs for running apps.
    final int cachedPrintJobCount = cachedPrintJobs.size();
    for (int i = 0; i < cachedPrintJobCount; i++) {
        PrintJobInfo cachedPrintJob = cachedPrintJobs.get(i);
        result.put(cachedPrintJob.getId(), cachedPrintJob);
        // Strip out the tag and the advanced print options.
        // They are visible only to print services.
        cachedPrintJob.setTag(null);
        cachedPrintJob.setAdvancedOptions(null);
    }
    // Add everything else the spooler knows about.
    List<PrintJobInfo> printJobs = mSpooler.getPrintJobInfos(null, PrintJobInfo.STATE_ANY, appId);
    if (printJobs != null) {
        final int printJobCount = printJobs.size();
        for (int i = 0; i < printJobCount; i++) {
            PrintJobInfo printJob = printJobs.get(i);
            result.put(printJob.getId(), printJob);
            // Strip out the tag and the advanced print options.
            // They are visible only to print services.
            printJob.setTag(null);
            printJob.setAdvancedOptions(null);
        }
    }
    return new ArrayList<PrintJobInfo>(result.values());
}
Also used : PrintJobId(android.print.PrintJobId) PrintJobInfo(android.print.PrintJobInfo) ArrayList(java.util.ArrayList) ArrayMap(android.util.ArrayMap)

Aggregations

ArrayMap (android.util.ArrayMap)365 ArraySet (android.util.ArraySet)77 ArrayList (java.util.ArrayList)75 PublicKey (java.security.PublicKey)49 HashMap (java.util.HashMap)32 Preference (android.support.v7.preference.Preference)30 IOException (java.io.IOException)30 Map (java.util.Map)29 HashSet (java.util.HashSet)28 Intent (android.content.Intent)24 Test (org.junit.Test)24 ComponentName (android.content.ComponentName)22 RemoteException (android.os.RemoteException)22 Field (java.lang.reflect.Field)21 Activity (android.app.Activity)20 SparseArray (android.util.SparseArray)18 List (java.util.List)18 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)18 Point (android.graphics.Point)17 Method (java.lang.reflect.Method)17