Merge "Reduce PackageManager RAM usage: ArrayMap/Set." into lmp-mr1-dev
This commit is contained in:
@@ -74,7 +74,6 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -380,7 +379,7 @@ public class PackageParser {
|
||||
*/
|
||||
public static PackageInfo generatePackageInfo(PackageParser.Package p,
|
||||
int gids[], int flags, long firstInstallTime, long lastUpdateTime,
|
||||
HashSet<String> grantedPermissions, PackageUserState state) {
|
||||
ArraySet<String> grantedPermissions, PackageUserState state) {
|
||||
|
||||
return generatePackageInfo(p, gids, flags, firstInstallTime, lastUpdateTime,
|
||||
grantedPermissions, state, UserHandle.getCallingUserId());
|
||||
@@ -401,7 +400,7 @@ public class PackageParser {
|
||||
|
||||
public static PackageInfo generatePackageInfo(PackageParser.Package p,
|
||||
int gids[], int flags, long firstInstallTime, long lastUpdateTime,
|
||||
HashSet<String> grantedPermissions, PackageUserState state, int userId) {
|
||||
ArraySet<String> grantedPermissions, PackageUserState state, int userId) {
|
||||
|
||||
if (!checkUseInstalledOrHidden(flags, state)) {
|
||||
return null;
|
||||
|
||||
@@ -18,7 +18,7 @@ package android.content.pm;
|
||||
|
||||
import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
|
||||
|
||||
import java.util.HashSet;
|
||||
import android.util.ArraySet;
|
||||
|
||||
/**
|
||||
* Per-user state information about a package.
|
||||
@@ -34,8 +34,8 @@ public class PackageUserState {
|
||||
|
||||
public String lastDisableAppCaller;
|
||||
|
||||
public HashSet<String> disabledComponents;
|
||||
public HashSet<String> enabledComponents;
|
||||
public ArraySet<String> disabledComponents;
|
||||
public ArraySet<String> enabledComponents;
|
||||
|
||||
public PackageUserState() {
|
||||
installed = true;
|
||||
@@ -51,9 +51,9 @@ public class PackageUserState {
|
||||
hidden = o.hidden;
|
||||
lastDisableAppCaller = o.lastDisableAppCaller;
|
||||
disabledComponents = o.disabledComponents != null
|
||||
? new HashSet<String>(o.disabledComponents) : null;
|
||||
? new ArraySet<String>(o.disabledComponents) : null;
|
||||
enabledComponents = o.enabledComponents != null
|
||||
? new HashSet<String>(o.enabledComponents) : null;
|
||||
? new ArraySet<String>(o.enabledComponents) : null;
|
||||
blockUninstall = o.blockUninstall;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,13 +245,20 @@ public final class ArraySet<E> implements Collection<E>, Set<E> {
|
||||
/**
|
||||
* Create a new ArraySet with the mappings from the given ArraySet.
|
||||
*/
|
||||
public ArraySet(ArraySet set) {
|
||||
public ArraySet(ArraySet<E> set) {
|
||||
this();
|
||||
if (set != null) {
|
||||
addAll(set);
|
||||
}
|
||||
}
|
||||
|
||||
/** {@hide} */
|
||||
public ArraySet(Collection<E> set) {
|
||||
this();
|
||||
if (set != null) {
|
||||
addAll(set);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Make the array map empty. All storage is released.
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -30,6 +29,7 @@ import java.util.Set;
|
||||
import android.net.Uri;
|
||||
import android.util.FastImmutableArraySet;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.ArraySet;
|
||||
import android.util.Log;
|
||||
import android.util.PrintWriterPrinter;
|
||||
import android.util.Slog;
|
||||
@@ -736,7 +736,7 @@ public abstract class IntentResolver<F extends IntentFilter, R extends Object> {
|
||||
/**
|
||||
* All filters that have been registered.
|
||||
*/
|
||||
private final HashSet<F> mFilters = new HashSet<F>();
|
||||
private final ArraySet<F> mFilters = new ArraySet<F>();
|
||||
|
||||
/**
|
||||
* All of the MIME types that have been registered, such as "image/jpeg",
|
||||
|
||||
@@ -32,8 +32,6 @@ import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
import static com.android.internal.util.ArrayUtils.appendInt;
|
||||
|
||||
@@ -50,7 +48,7 @@ public class SystemConfig {
|
||||
|
||||
// These are the built-in uid -> permission mappings that were read from the
|
||||
// system configuration files.
|
||||
final SparseArray<HashSet<String>> mSystemPermissions = new SparseArray<>();
|
||||
final SparseArray<ArraySet<String>> mSystemPermissions = new SparseArray<>();
|
||||
|
||||
// These are the built-in shared libraries that were read from the
|
||||
// system configuration files. Keys are the library names; strings are the
|
||||
@@ -59,7 +57,7 @@ public class SystemConfig {
|
||||
|
||||
// These are the features this devices supports that were read from the
|
||||
// system configuration files.
|
||||
final HashMap<String, FeatureInfo> mAvailableFeatures = new HashMap<>();
|
||||
final ArrayMap<String, FeatureInfo> mAvailableFeatures = new ArrayMap<>();
|
||||
|
||||
public static final class PermissionEntry {
|
||||
public final String name;
|
||||
@@ -94,7 +92,7 @@ public class SystemConfig {
|
||||
return mGlobalGids;
|
||||
}
|
||||
|
||||
public SparseArray<HashSet<String>> getSystemPermissions() {
|
||||
public SparseArray<ArraySet<String>> getSystemPermissions() {
|
||||
return mSystemPermissions;
|
||||
}
|
||||
|
||||
@@ -102,7 +100,7 @@ public class SystemConfig {
|
||||
return mSharedLibraries;
|
||||
}
|
||||
|
||||
public HashMap<String, FeatureInfo> getAvailableFeatures() {
|
||||
public ArrayMap<String, FeatureInfo> getAvailableFeatures() {
|
||||
return mAvailableFeatures;
|
||||
}
|
||||
|
||||
@@ -252,9 +250,9 @@ public class SystemConfig {
|
||||
continue;
|
||||
}
|
||||
perm = perm.intern();
|
||||
HashSet<String> perms = mSystemPermissions.get(uid);
|
||||
ArraySet<String> perms = mSystemPermissions.get(uid);
|
||||
if (perms == null) {
|
||||
perms = new HashSet<String>();
|
||||
perms = new ArraySet<String>();
|
||||
mSystemPermissions.put(uid, perms);
|
||||
}
|
||||
perms.add(perm);
|
||||
|
||||
@@ -23,9 +23,9 @@ import android.app.job.JobService;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.os.ServiceManager;
|
||||
import android.util.ArraySet;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
@@ -59,7 +59,7 @@ public class BackgroundDexOptService extends JobService {
|
||||
if (pm.isStorageLow()) {
|
||||
return false;
|
||||
}
|
||||
final HashSet<String> pkgs = pm.getPackagesThatNeedDexOpt();
|
||||
final ArraySet<String> pkgs = pm.getPackagesThatNeedDexOpt();
|
||||
if (pkgs == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -17,13 +17,12 @@
|
||||
package com.android.server.pm;
|
||||
|
||||
import android.content.pm.ApplicationInfo;
|
||||
|
||||
import java.util.HashSet;
|
||||
import android.util.ArraySet;
|
||||
|
||||
class GrantedPermissions {
|
||||
int pkgFlags;
|
||||
|
||||
HashSet<String> grantedPermissions = new HashSet<String>();
|
||||
ArraySet<String> grantedPermissions = new ArraySet<String>();
|
||||
|
||||
int[] gids;
|
||||
|
||||
@@ -34,7 +33,7 @@ class GrantedPermissions {
|
||||
@SuppressWarnings("unchecked")
|
||||
GrantedPermissions(GrantedPermissions base) {
|
||||
pkgFlags = base.pkgFlags;
|
||||
grantedPermissions = (HashSet<String>) base.grantedPermissions.clone();
|
||||
grantedPermissions = new ArraySet<>(base.grantedPermissions);
|
||||
|
||||
if (base.gids != null) {
|
||||
gids = base.gids.clone();
|
||||
|
||||
@@ -16,10 +16,9 @@
|
||||
|
||||
package com.android.server.pm;
|
||||
|
||||
import com.android.internal.util.ArrayUtils;
|
||||
import android.util.ArrayMap;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import com.android.internal.util.ArrayUtils;
|
||||
|
||||
public class PackageKeySetData {
|
||||
|
||||
@@ -34,7 +33,7 @@ public class PackageKeySetData {
|
||||
|
||||
private long[] mDefinedKeySets;
|
||||
|
||||
private final Map<String, Long> mKeySetAliases = new HashMap<String, Long>();
|
||||
private final ArrayMap<String, Long> mKeySetAliases = new ArrayMap<String, Long>();
|
||||
|
||||
PackageKeySetData() {
|
||||
mProperSigningKeySet = KEYSET_UNASSIGNED;
|
||||
@@ -132,7 +131,7 @@ public class PackageKeySetData {
|
||||
return mDefinedKeySets;
|
||||
}
|
||||
|
||||
protected Map<String, Long> getAliases() {
|
||||
protected ArrayMap<String, Long> getAliases() {
|
||||
return mKeySetAliases;
|
||||
}
|
||||
|
||||
|
||||
@@ -201,8 +201,6 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -374,20 +372,20 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
// Keys are String (package name), values are Package. This also serves
|
||||
// as the lock for the global state. Methods that must be called with
|
||||
// this lock held have the prefix "LP".
|
||||
final HashMap<String, PackageParser.Package> mPackages =
|
||||
new HashMap<String, PackageParser.Package>();
|
||||
final ArrayMap<String, PackageParser.Package> mPackages =
|
||||
new ArrayMap<String, PackageParser.Package>();
|
||||
|
||||
// Tracks available target package names -> overlay package paths.
|
||||
final HashMap<String, HashMap<String, PackageParser.Package>> mOverlays =
|
||||
new HashMap<String, HashMap<String, PackageParser.Package>>();
|
||||
final ArrayMap<String, ArrayMap<String, PackageParser.Package>> mOverlays =
|
||||
new ArrayMap<String, ArrayMap<String, PackageParser.Package>>();
|
||||
|
||||
final Settings mSettings;
|
||||
boolean mRestoredSettings;
|
||||
|
||||
// System configuration read by SystemConfig.
|
||||
final int[] mGlobalGids;
|
||||
final SparseArray<HashSet<String>> mSystemPermissions;
|
||||
final HashMap<String, FeatureInfo> mAvailableFeatures;
|
||||
final SparseArray<ArraySet<String>> mSystemPermissions;
|
||||
final ArrayMap<String, FeatureInfo> mAvailableFeatures;
|
||||
|
||||
// If mac_permissions.xml was found for seinfo labeling.
|
||||
boolean mFoundPolicyFile;
|
||||
@@ -406,8 +404,8 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
}
|
||||
|
||||
// Currently known shared libraries.
|
||||
final HashMap<String, SharedLibraryEntry> mSharedLibraries =
|
||||
new HashMap<String, SharedLibraryEntry>();
|
||||
final ArrayMap<String, SharedLibraryEntry> mSharedLibraries =
|
||||
new ArrayMap<String, SharedLibraryEntry>();
|
||||
|
||||
// All available activities, for your resolving pleasure.
|
||||
final ActivityIntentResolver mActivities =
|
||||
@@ -425,23 +423,23 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
|
||||
// Mapping from provider base names (first directory in content URI codePath)
|
||||
// to the provider information.
|
||||
final HashMap<String, PackageParser.Provider> mProvidersByAuthority =
|
||||
new HashMap<String, PackageParser.Provider>();
|
||||
final ArrayMap<String, PackageParser.Provider> mProvidersByAuthority =
|
||||
new ArrayMap<String, PackageParser.Provider>();
|
||||
|
||||
// Mapping from instrumentation class names to info about them.
|
||||
final HashMap<ComponentName, PackageParser.Instrumentation> mInstrumentation =
|
||||
new HashMap<ComponentName, PackageParser.Instrumentation>();
|
||||
final ArrayMap<ComponentName, PackageParser.Instrumentation> mInstrumentation =
|
||||
new ArrayMap<ComponentName, PackageParser.Instrumentation>();
|
||||
|
||||
// Mapping from permission names to info about them.
|
||||
final HashMap<String, PackageParser.PermissionGroup> mPermissionGroups =
|
||||
new HashMap<String, PackageParser.PermissionGroup>();
|
||||
final ArrayMap<String, PackageParser.PermissionGroup> mPermissionGroups =
|
||||
new ArrayMap<String, PackageParser.PermissionGroup>();
|
||||
|
||||
// Packages whose data we have transfered into another package, thus
|
||||
// should no longer exist.
|
||||
final HashSet<String> mTransferedPackages = new HashSet<String>();
|
||||
final ArraySet<String> mTransferedPackages = new ArraySet<String>();
|
||||
|
||||
// Broadcast actions that are only available to the system.
|
||||
final HashSet<String> mProtectedBroadcasts = new HashSet<String>();
|
||||
final ArraySet<String> mProtectedBroadcasts = new ArraySet<String>();
|
||||
|
||||
/** List of packages waiting for verification. */
|
||||
final SparseArray<PackageVerificationState> mPendingVerification
|
||||
@@ -452,7 +450,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
|
||||
final PackageInstallerService mInstallerService;
|
||||
|
||||
HashSet<PackageParser.Package> mDeferredDexOpt = null;
|
||||
ArraySet<PackageParser.Package> mDeferredDexOpt = null;
|
||||
|
||||
// Cache of users who need badging.
|
||||
SparseBooleanArray mUserNeedsBadging = new SparseBooleanArray();
|
||||
@@ -476,24 +474,24 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
// Set of pending broadcasts for aggregating enable/disable of components.
|
||||
static class PendingPackageBroadcasts {
|
||||
// for each user id, a map of <package name -> components within that package>
|
||||
final SparseArray<HashMap<String, ArrayList<String>>> mUidMap;
|
||||
final SparseArray<ArrayMap<String, ArrayList<String>>> mUidMap;
|
||||
|
||||
public PendingPackageBroadcasts() {
|
||||
mUidMap = new SparseArray<HashMap<String, ArrayList<String>>>(2);
|
||||
mUidMap = new SparseArray<ArrayMap<String, ArrayList<String>>>(2);
|
||||
}
|
||||
|
||||
public ArrayList<String> get(int userId, String packageName) {
|
||||
HashMap<String, ArrayList<String>> packages = getOrAllocate(userId);
|
||||
ArrayMap<String, ArrayList<String>> packages = getOrAllocate(userId);
|
||||
return packages.get(packageName);
|
||||
}
|
||||
|
||||
public void put(int userId, String packageName, ArrayList<String> components) {
|
||||
HashMap<String, ArrayList<String>> packages = getOrAllocate(userId);
|
||||
ArrayMap<String, ArrayList<String>> packages = getOrAllocate(userId);
|
||||
packages.put(packageName, components);
|
||||
}
|
||||
|
||||
public void remove(int userId, String packageName) {
|
||||
HashMap<String, ArrayList<String>> packages = mUidMap.get(userId);
|
||||
ArrayMap<String, ArrayList<String>> packages = mUidMap.get(userId);
|
||||
if (packages != null) {
|
||||
packages.remove(packageName);
|
||||
}
|
||||
@@ -511,7 +509,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
return mUidMap.keyAt(n);
|
||||
}
|
||||
|
||||
public HashMap<String, ArrayList<String>> packagesForUserId(int userId) {
|
||||
public ArrayMap<String, ArrayList<String>> packagesForUserId(int userId) {
|
||||
return mUidMap.get(userId);
|
||||
}
|
||||
|
||||
@@ -528,10 +526,10 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
mUidMap.clear();
|
||||
}
|
||||
|
||||
private HashMap<String, ArrayList<String>> getOrAllocate(int userId) {
|
||||
HashMap<String, ArrayList<String>> map = mUidMap.get(userId);
|
||||
private ArrayMap<String, ArrayList<String>> getOrAllocate(int userId) {
|
||||
ArrayMap<String, ArrayList<String>> map = mUidMap.get(userId);
|
||||
if (map == null) {
|
||||
map = new HashMap<String, ArrayList<String>>();
|
||||
map = new ArrayMap<String, ArrayList<String>>();
|
||||
mUidMap.put(userId, map);
|
||||
}
|
||||
return map;
|
||||
@@ -568,7 +566,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
static UserManagerService sUserManager;
|
||||
|
||||
// Stores a list of users whose package restrictions file needs to be updated
|
||||
private HashSet<Integer> mDirtyUsers = new HashSet<Integer>();
|
||||
private ArraySet<Integer> mDirtyUsers = new ArraySet<Integer>();
|
||||
|
||||
final private DefaultContainerConnection mDefContainerConn =
|
||||
new DefaultContainerConnection();
|
||||
@@ -1396,7 +1394,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
// scanning install directories.
|
||||
final int scanFlags = SCAN_NO_PATHS | SCAN_DEFER_DEX | SCAN_BOOTING;
|
||||
|
||||
final HashSet<String> alreadyDexOpted = new HashSet<String>();
|
||||
final ArraySet<String> alreadyDexOpted = new ArraySet<String>();
|
||||
|
||||
/**
|
||||
* Add everything in the in the boot class path to the
|
||||
@@ -2381,7 +2379,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
return PackageManager.PERMISSION_GRANTED;
|
||||
}
|
||||
} else {
|
||||
HashSet<String> perms = mSystemPermissions.get(uid);
|
||||
ArraySet<String> perms = mSystemPermissions.get(uid);
|
||||
if (perms != null && perms.contains(permName)) {
|
||||
return PackageManager.PERMISSION_GRANTED;
|
||||
}
|
||||
@@ -2802,11 +2800,11 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
PackageManager.SIGNATURE_NO_MATCH;
|
||||
}
|
||||
|
||||
HashSet<Signature> set1 = new HashSet<Signature>();
|
||||
ArraySet<Signature> set1 = new ArraySet<Signature>();
|
||||
for (Signature sig : s1) {
|
||||
set1.add(sig);
|
||||
}
|
||||
HashSet<Signature> set2 = new HashSet<Signature>();
|
||||
ArraySet<Signature> set2 = new ArraySet<Signature>();
|
||||
for (Signature sig : s2) {
|
||||
set2.add(sig);
|
||||
}
|
||||
@@ -2841,11 +2839,11 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
return PackageManager.SIGNATURE_NO_MATCH;
|
||||
}
|
||||
|
||||
HashSet<Signature> existingSet = new HashSet<Signature>();
|
||||
ArraySet<Signature> existingSet = new ArraySet<Signature>();
|
||||
for (Signature sig : existingSigs.mSignatures) {
|
||||
existingSet.add(sig);
|
||||
}
|
||||
HashSet<Signature> scannedCompatSet = new HashSet<Signature>();
|
||||
ArraySet<Signature> scannedCompatSet = new ArraySet<Signature>();
|
||||
for (Signature sig : scannedPkg.mSignatures) {
|
||||
try {
|
||||
Signature[] chainSignatures = sig.getChainSignatures();
|
||||
@@ -4035,7 +4033,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
}
|
||||
|
||||
private void createIdmapsForPackageLI(PackageParser.Package pkg) {
|
||||
HashMap<String, PackageParser.Package> overlays = mOverlays.get(pkg.packageName);
|
||||
ArrayMap<String, PackageParser.Package> overlays = mOverlays.get(pkg.packageName);
|
||||
if (overlays == null) {
|
||||
Slog.w(TAG, "Unable to create idmap for " + pkg.packageName + ": no overlay packages");
|
||||
return;
|
||||
@@ -4056,7 +4054,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
opkg.baseCodePath + ": overlay not trusted");
|
||||
return false;
|
||||
}
|
||||
HashMap<String, PackageParser.Package> overlaySet = mOverlays.get(pkg.packageName);
|
||||
ArrayMap<String, PackageParser.Package> overlaySet = mOverlays.get(pkg.packageName);
|
||||
if (overlaySet == null) {
|
||||
Slog.e(TAG, "was about to create idmap for " + pkg.baseCodePath + " and " +
|
||||
opkg.baseCodePath + " but target package has no known overlays");
|
||||
@@ -4477,7 +4475,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
public void performBootDexOpt() {
|
||||
enforceSystemOrRoot("Only the system can request dexopt be performed");
|
||||
|
||||
final HashSet<PackageParser.Package> pkgs;
|
||||
final ArraySet<PackageParser.Package> pkgs;
|
||||
synchronized (mPackages) {
|
||||
pkgs = mDeferredDexOpt;
|
||||
mDeferredDexOpt = null;
|
||||
@@ -4500,7 +4498,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
}
|
||||
// Give priority to system apps that listen for pre boot complete.
|
||||
Intent intent = new Intent(Intent.ACTION_PRE_BOOT_COMPLETED);
|
||||
HashSet<String> pkgNames = getPackageNamesForIntent(intent);
|
||||
ArraySet<String> pkgNames = getPackageNamesForIntent(intent);
|
||||
for (Iterator<PackageParser.Package> it = pkgs.iterator(); it.hasNext();) {
|
||||
PackageParser.Package pkg = it.next();
|
||||
if (pkgNames.contains(pkg.packageName)) {
|
||||
@@ -4574,7 +4572,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
private void filterRecentlyUsedApps(HashSet<PackageParser.Package> pkgs) {
|
||||
private void filterRecentlyUsedApps(ArraySet<PackageParser.Package> pkgs) {
|
||||
// Filter out packages that aren't recently used.
|
||||
//
|
||||
// The exception is first boot of a non-eng device (aka !mLazyDexOpt), which
|
||||
@@ -4601,14 +4599,14 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
private HashSet<String> getPackageNamesForIntent(Intent intent) {
|
||||
private ArraySet<String> getPackageNamesForIntent(Intent intent) {
|
||||
List<ResolveInfo> ris = null;
|
||||
try {
|
||||
ris = AppGlobals.getPackageManager().queryIntentReceivers(
|
||||
intent, null, 0, UserHandle.USER_OWNER);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
HashSet<String> pkgNames = new HashSet<String>();
|
||||
ArraySet<String> pkgNames = new ArraySet<String>();
|
||||
if (ris != null) {
|
||||
for (ResolveInfo ri : ris) {
|
||||
pkgNames.add(ri.activityInfo.packageName);
|
||||
@@ -4686,8 +4684,8 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
public HashSet<String> getPackagesThatNeedDexOpt() {
|
||||
HashSet<String> pkgs = null;
|
||||
public ArraySet<String> getPackagesThatNeedDexOpt() {
|
||||
ArraySet<String> pkgs = null;
|
||||
synchronized (mPackages) {
|
||||
for (PackageParser.Package p : mPackages.values()) {
|
||||
if (DEBUG_DEXOPT) {
|
||||
@@ -4697,7 +4695,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
continue;
|
||||
}
|
||||
if (pkgs == null) {
|
||||
pkgs = new HashSet<String>();
|
||||
pkgs = new ArraySet<String>();
|
||||
}
|
||||
pkgs.add(p.packageName);
|
||||
}
|
||||
@@ -4710,7 +4708,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
}
|
||||
|
||||
private void performDexOptLibsLI(ArrayList<String> libs, String[] instructionSets,
|
||||
boolean forceDex, boolean defer, HashSet<String> done) {
|
||||
boolean forceDex, boolean defer, ArraySet<String> done) {
|
||||
for (int i=0; i<libs.size(); i++) {
|
||||
PackageParser.Package libPkg;
|
||||
String libName;
|
||||
@@ -4735,7 +4733,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
static final int DEX_OPT_FAILED = -1;
|
||||
|
||||
private int performDexOptLI(PackageParser.Package pkg, String[] targetInstructionSets,
|
||||
boolean forceDex, boolean defer, HashSet<String> done) {
|
||||
boolean forceDex, boolean defer, ArraySet<String> done) {
|
||||
final String[] instructionSets = targetInstructionSets != null ?
|
||||
targetInstructionSets : getAppDexInstructionSets(pkg.applicationInfo);
|
||||
|
||||
@@ -4813,7 +4811,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
// our list of deferred dexopts.
|
||||
if (defer && isDexOptNeeded != DexFile.UP_TO_DATE) {
|
||||
if (mDeferredDexOpt == null) {
|
||||
mDeferredDexOpt = new HashSet<PackageParser.Package>();
|
||||
mDeferredDexOpt = new ArraySet<PackageParser.Package>();
|
||||
}
|
||||
mDeferredDexOpt.add(pkg);
|
||||
return DEX_OPT_DEFERRED;
|
||||
@@ -4910,7 +4908,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
}
|
||||
|
||||
private static String[] getDexCodeInstructionSets(String[] instructionSets) {
|
||||
HashSet<String> dexCodeInstructionSets = new HashSet<String>(instructionSets.length);
|
||||
ArraySet<String> dexCodeInstructionSets = new ArraySet<String>(instructionSets.length);
|
||||
for (String instructionSet : instructionSets) {
|
||||
dexCodeInstructionSets.add(getDexCodeInstructionSet(instructionSet));
|
||||
}
|
||||
@@ -4953,9 +4951,9 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
|
||||
private int performDexOptLI(PackageParser.Package pkg, String[] instructionSets,
|
||||
boolean forceDex, boolean defer, boolean inclDependencies) {
|
||||
HashSet<String> done;
|
||||
ArraySet<String> done;
|
||||
if (inclDependencies && (pkg.usesLibraries != null || pkg.usesOptionalLibraries != null)) {
|
||||
done = new HashSet<String>();
|
||||
done = new ArraySet<String>();
|
||||
done.add(pkg.packageName);
|
||||
} else {
|
||||
done = null;
|
||||
@@ -6140,7 +6138,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
r = null;
|
||||
for (i=0; i<N; i++) {
|
||||
PackageParser.Permission p = pkg.permissions.get(i);
|
||||
HashMap<String, BasePermission> permissionMap =
|
||||
ArrayMap<String, BasePermission> permissionMap =
|
||||
p.tree ? mSettings.mPermissionTrees
|
||||
: mSettings.mPermissions;
|
||||
p.group = mPermissionGroups.get(p.info.group);
|
||||
@@ -6268,9 +6266,9 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
if (pkg.mOverlayTarget != null && !pkg.mOverlayTarget.equals("android")) {
|
||||
if (!mOverlays.containsKey(pkg.mOverlayTarget)) {
|
||||
mOverlays.put(pkg.mOverlayTarget,
|
||||
new HashMap<String, PackageParser.Package>());
|
||||
new ArrayMap<String, PackageParser.Package>());
|
||||
}
|
||||
HashMap<String, PackageParser.Package> map = mOverlays.get(pkg.mOverlayTarget);
|
||||
ArrayMap<String, PackageParser.Package> map = mOverlays.get(pkg.mOverlayTarget);
|
||||
map.put(pkg.packageName, pkg);
|
||||
PackageParser.Package orig = mPackages.get(pkg.mOverlayTarget);
|
||||
if (orig != null && !createIdmapForPackagePairLI(orig, pkg)) {
|
||||
@@ -6931,13 +6929,13 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
return;
|
||||
}
|
||||
final GrantedPermissions gp = ps.sharedUser != null ? ps.sharedUser : ps;
|
||||
HashSet<String> origPermissions = gp.grantedPermissions;
|
||||
ArraySet<String> origPermissions = gp.grantedPermissions;
|
||||
boolean changedPermission = false;
|
||||
|
||||
if (replace) {
|
||||
ps.permissionsFixed = false;
|
||||
if (gp == ps) {
|
||||
origPermissions = new HashSet<String>(gp.grantedPermissions);
|
||||
origPermissions = new ArraySet<String>(gp.grantedPermissions);
|
||||
gp.grantedPermissions.clear();
|
||||
gp.gids = mGlobalGids;
|
||||
}
|
||||
@@ -7084,7 +7082,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
}
|
||||
|
||||
private boolean grantSignaturePermission(String perm, PackageParser.Package pkg,
|
||||
BasePermission bp, HashSet<String> origPermissions) {
|
||||
BasePermission bp, ArraySet<String> origPermissions) {
|
||||
boolean allowed;
|
||||
allowed = (compareSignatures(
|
||||
bp.packageSetting.signatures.mSignatures, pkg.mSignatures)
|
||||
@@ -7342,8 +7340,8 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
// }
|
||||
|
||||
// Keys are String (activity class name), values are Activity.
|
||||
private final HashMap<ComponentName, PackageParser.Activity> mActivities
|
||||
= new HashMap<ComponentName, PackageParser.Activity>();
|
||||
private final ArrayMap<ComponentName, PackageParser.Activity> mActivities
|
||||
= new ArrayMap<ComponentName, PackageParser.Activity>();
|
||||
private int mFlags;
|
||||
}
|
||||
|
||||
@@ -7541,8 +7539,8 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
// }
|
||||
|
||||
// Keys are String (activity class name), values are Activity.
|
||||
private final HashMap<ComponentName, PackageParser.Service> mServices
|
||||
= new HashMap<ComponentName, PackageParser.Service>();
|
||||
private final ArrayMap<ComponentName, PackageParser.Service> mServices
|
||||
= new ArrayMap<ComponentName, PackageParser.Service>();
|
||||
private int mFlags;
|
||||
};
|
||||
|
||||
@@ -7735,8 +7733,8 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
out.println(Integer.toHexString(System.identityHashCode(filter)));
|
||||
}
|
||||
|
||||
private final HashMap<ComponentName, PackageParser.Provider> mProviders
|
||||
= new HashMap<ComponentName, PackageParser.Provider>();
|
||||
private final ArrayMap<ComponentName, PackageParser.Provider> mProviders
|
||||
= new ArrayMap<ComponentName, PackageParser.Provider>();
|
||||
private int mFlags;
|
||||
};
|
||||
|
||||
@@ -11838,8 +11836,8 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
synchronized (mPackages) {
|
||||
CrossProfileIntentResolver resolver =
|
||||
mSettings.editCrossProfileIntentResolverLPw(sourceUserId);
|
||||
HashSet<CrossProfileIntentFilter> set =
|
||||
new HashSet<CrossProfileIntentFilter>(resolver.filterSet());
|
||||
ArraySet<CrossProfileIntentFilter> set =
|
||||
new ArraySet<CrossProfileIntentFilter>(resolver.filterSet());
|
||||
for (CrossProfileIntentFilter filter : set) {
|
||||
if (filter.getOwnerPackage().equals(ownerPackage)
|
||||
&& filter.getOwnerUserId() == callingUserId) {
|
||||
|
||||
@@ -21,10 +21,10 @@ import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED
|
||||
import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
|
||||
|
||||
import android.content.pm.PackageUserState;
|
||||
import android.util.ArraySet;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* Settings base class for pending and resolved classes.
|
||||
@@ -321,8 +321,8 @@ class PackageSettingBase extends GrantedPermissions {
|
||||
|
||||
void setUserState(int userId, int enabled, boolean installed, boolean stopped,
|
||||
boolean notLaunched, boolean hidden,
|
||||
String lastDisableAppCaller, HashSet<String> enabledComponents,
|
||||
HashSet<String> disabledComponents, boolean blockUninstall) {
|
||||
String lastDisableAppCaller, ArraySet<String> enabledComponents,
|
||||
ArraySet<String> disabledComponents, boolean blockUninstall) {
|
||||
PackageUserState state = modifyUserState(userId);
|
||||
state.enabled = enabled;
|
||||
state.installed = installed;
|
||||
@@ -335,39 +335,39 @@ class PackageSettingBase extends GrantedPermissions {
|
||||
state.blockUninstall = blockUninstall;
|
||||
}
|
||||
|
||||
HashSet<String> getEnabledComponents(int userId) {
|
||||
ArraySet<String> getEnabledComponents(int userId) {
|
||||
return readUserState(userId).enabledComponents;
|
||||
}
|
||||
|
||||
HashSet<String> getDisabledComponents(int userId) {
|
||||
ArraySet<String> getDisabledComponents(int userId) {
|
||||
return readUserState(userId).disabledComponents;
|
||||
}
|
||||
|
||||
void setEnabledComponents(HashSet<String> components, int userId) {
|
||||
void setEnabledComponents(ArraySet<String> components, int userId) {
|
||||
modifyUserState(userId).enabledComponents = components;
|
||||
}
|
||||
|
||||
void setDisabledComponents(HashSet<String> components, int userId) {
|
||||
void setDisabledComponents(ArraySet<String> components, int userId) {
|
||||
modifyUserState(userId).disabledComponents = components;
|
||||
}
|
||||
|
||||
void setEnabledComponentsCopy(HashSet<String> components, int userId) {
|
||||
void setEnabledComponentsCopy(ArraySet<String> components, int userId) {
|
||||
modifyUserState(userId).enabledComponents = components != null
|
||||
? new HashSet<String>(components) : null;
|
||||
? new ArraySet<String>(components) : null;
|
||||
}
|
||||
|
||||
void setDisabledComponentsCopy(HashSet<String> components, int userId) {
|
||||
void setDisabledComponentsCopy(ArraySet<String> components, int userId) {
|
||||
modifyUserState(userId).disabledComponents = components != null
|
||||
? new HashSet<String>(components) : null;
|
||||
? new ArraySet<String>(components) : null;
|
||||
}
|
||||
|
||||
PackageUserState modifyUserStateComponents(int userId, boolean disabled, boolean enabled) {
|
||||
PackageUserState state = modifyUserState(userId);
|
||||
if (disabled && state.disabledComponents == null) {
|
||||
state.disabledComponents = new HashSet<String>(1);
|
||||
state.disabledComponents = new ArraySet<String>(1);
|
||||
}
|
||||
if (enabled && state.enabledComponents == null) {
|
||||
state.enabledComponents = new HashSet<String>(1);
|
||||
state.enabledComponents = new ArraySet<String>(1);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -63,6 +63,8 @@ import android.content.pm.Signature;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.content.pm.PackageUserState;
|
||||
import android.content.pm.VerifierDeviceIdentity;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.ArraySet;
|
||||
import android.util.Log;
|
||||
import android.util.Slog;
|
||||
import android.util.SparseArray;
|
||||
@@ -78,8 +80,6 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -159,11 +159,11 @@ final class Settings {
|
||||
private final File mStoppedPackagesFilename;
|
||||
private final File mBackupStoppedPackagesFilename;
|
||||
|
||||
final HashMap<String, PackageSetting> mPackages =
|
||||
new HashMap<String, PackageSetting>();
|
||||
final ArrayMap<String, PackageSetting> mPackages =
|
||||
new ArrayMap<String, PackageSetting>();
|
||||
// List of replaced system applications
|
||||
private final HashMap<String, PackageSetting> mDisabledSysPackages =
|
||||
new HashMap<String, PackageSetting>();
|
||||
private final ArrayMap<String, PackageSetting> mDisabledSysPackages =
|
||||
new ArrayMap<String, PackageSetting>();
|
||||
|
||||
private static int mFirstAvailableUid = 0;
|
||||
|
||||
@@ -206,8 +206,8 @@ final class Settings {
|
||||
final SparseArray<CrossProfileIntentResolver> mCrossProfileIntentResolvers =
|
||||
new SparseArray<CrossProfileIntentResolver>();
|
||||
|
||||
final HashMap<String, SharedUserSetting> mSharedUsers =
|
||||
new HashMap<String, SharedUserSetting>();
|
||||
final ArrayMap<String, SharedUserSetting> mSharedUsers =
|
||||
new ArrayMap<String, SharedUserSetting>();
|
||||
private final ArrayList<Object> mUserIds = new ArrayList<Object>();
|
||||
private final SparseArray<Object> mOtherUserIds =
|
||||
new SparseArray<Object>();
|
||||
@@ -217,12 +217,12 @@ final class Settings {
|
||||
new ArrayList<Signature>();
|
||||
|
||||
// Mapping from permission names to info about them.
|
||||
final HashMap<String, BasePermission> mPermissions =
|
||||
new HashMap<String, BasePermission>();
|
||||
final ArrayMap<String, BasePermission> mPermissions =
|
||||
new ArrayMap<String, BasePermission>();
|
||||
|
||||
// Mapping from permission tree names to info about them.
|
||||
final HashMap<String, BasePermission> mPermissionTrees =
|
||||
new HashMap<String, BasePermission>();
|
||||
final ArrayMap<String, BasePermission> mPermissionTrees =
|
||||
new ArrayMap<String, BasePermission>();
|
||||
|
||||
// Packages that have been uninstalled and still need their external
|
||||
// storage data deleted.
|
||||
@@ -232,7 +232,7 @@ final class Settings {
|
||||
// Keys are the new names of the packages, values are the original
|
||||
// names. The packages appear everwhere else under their original
|
||||
// names.
|
||||
final HashMap<String, String> mRenamedPackages = new HashMap<String, String>();
|
||||
final ArrayMap<String, String> mRenamedPackages = new ArrayMap<String, String>();
|
||||
|
||||
final StringBuilder mReadMessages = new StringBuilder();
|
||||
|
||||
@@ -437,7 +437,7 @@ final class Settings {
|
||||
void transferPermissionsLPw(String origPkg, String newPkg) {
|
||||
// Transfer ownership of permissions to the new package.
|
||||
for (int i=0; i<2; i++) {
|
||||
HashMap<String, BasePermission> permissions =
|
||||
ArrayMap<String, BasePermission> permissions =
|
||||
i == 0 ? mPermissionTrees : mPermissions;
|
||||
for (BasePermission bp : permissions.values()) {
|
||||
if (origPkg.equals(bp.sourcePackage)) {
|
||||
@@ -582,7 +582,7 @@ final class Settings {
|
||||
}
|
||||
p.appId = dis.appId;
|
||||
// Clone permissions
|
||||
p.grantedPermissions = new HashSet<String>(dis.grantedPermissions);
|
||||
p.grantedPermissions = new ArraySet<String>(dis.grantedPermissions);
|
||||
// Clone component info
|
||||
List<UserInfo> users = getAllUsers();
|
||||
if (users != null) {
|
||||
@@ -1138,8 +1138,8 @@ final class Settings {
|
||||
final boolean blockUninstall = blockUninstallStr == null
|
||||
? false : Boolean.parseBoolean(blockUninstallStr);
|
||||
|
||||
HashSet<String> enabledComponents = null;
|
||||
HashSet<String> disabledComponents = null;
|
||||
ArraySet<String> enabledComponents = null;
|
||||
ArraySet<String> disabledComponents = null;
|
||||
|
||||
int packageDepth = parser.getDepth();
|
||||
while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
|
||||
@@ -1189,9 +1189,9 @@ final class Settings {
|
||||
}
|
||||
}
|
||||
|
||||
private HashSet<String> readComponentsLPr(XmlPullParser parser)
|
||||
private ArraySet<String> readComponentsLPr(XmlPullParser parser)
|
||||
throws IOException, XmlPullParserException {
|
||||
HashSet<String> components = null;
|
||||
ArraySet<String> components = null;
|
||||
int type;
|
||||
int outerDepth = parser.getDepth();
|
||||
String tagName;
|
||||
@@ -1207,7 +1207,7 @@ final class Settings {
|
||||
String componentName = parser.getAttributeValue(null, ATTR_NAME);
|
||||
if (componentName != null) {
|
||||
if (components == null) {
|
||||
components = new HashSet<String>();
|
||||
components = new ArraySet<String>();
|
||||
}
|
||||
components.add(componentName);
|
||||
}
|
||||
@@ -1921,7 +1921,7 @@ final class Settings {
|
||||
}
|
||||
|
||||
ArrayList<PackageSetting> getListOfIncompleteInstallPackagesLPr() {
|
||||
final HashSet<String> kList = new HashSet<String>(mPackages.keySet());
|
||||
final ArraySet<String> kList = new ArraySet<String>(mPackages.keySet());
|
||||
final Iterator<String> its = kList.iterator();
|
||||
final ArrayList<PackageSetting> ret = new ArrayList<PackageSetting>();
|
||||
while (its.hasNext()) {
|
||||
@@ -2511,7 +2511,7 @@ final class Settings {
|
||||
return defValue;
|
||||
}
|
||||
|
||||
private void readPermissionsLPw(HashMap<String, BasePermission> out, XmlPullParser parser)
|
||||
private void readPermissionsLPw(ArrayMap<String, BasePermission> out, XmlPullParser parser)
|
||||
throws IOException, XmlPullParserException {
|
||||
int outerDepth = parser.getDepth();
|
||||
int type;
|
||||
@@ -3016,7 +3016,7 @@ final class Settings {
|
||||
}
|
||||
}
|
||||
|
||||
private void readGrantedPermissionsLPw(XmlPullParser parser, HashSet<String> outPerms)
|
||||
private void readGrantedPermissionsLPw(XmlPullParser parser, ArraySet<String> outPerms)
|
||||
throws IOException, XmlPullParserException {
|
||||
int outerDepth = parser.getDepth();
|
||||
int type;
|
||||
@@ -3090,8 +3090,8 @@ final class Settings {
|
||||
int sourceUserId = mCrossProfileIntentResolvers.keyAt(i);
|
||||
CrossProfileIntentResolver cpir = mCrossProfileIntentResolvers.get(sourceUserId);
|
||||
boolean needsWriting = false;
|
||||
HashSet<CrossProfileIntentFilter> cpifs =
|
||||
new HashSet<CrossProfileIntentFilter>(cpir.filterSet());
|
||||
ArraySet<CrossProfileIntentFilter> cpifs =
|
||||
new ArraySet<CrossProfileIntentFilter>(cpir.filterSet());
|
||||
for (CrossProfileIntentFilter cpif : cpifs) {
|
||||
if (cpif.getTargetUserId() == userId) {
|
||||
needsWriting = true;
|
||||
@@ -3147,7 +3147,7 @@ final class Settings {
|
||||
return ps;
|
||||
}
|
||||
|
||||
private String compToString(HashSet<String> cmp) {
|
||||
private String compToString(ArraySet<String> cmp) {
|
||||
return cmp != null ? Arrays.toString(cmp.toArray()) : "[]";
|
||||
}
|
||||
|
||||
@@ -3477,7 +3477,7 @@ final class Settings {
|
||||
pw.print(prefix); pw.print(" lastDisabledCaller: ");
|
||||
pw.println(lastDisabledAppCaller);
|
||||
}
|
||||
HashSet<String> cmp = ps.getDisabledComponents(user.id);
|
||||
ArraySet<String> cmp = ps.getDisabledComponents(user.id);
|
||||
if (cmp != null && cmp.size() > 0) {
|
||||
pw.print(prefix); pw.println(" disabledComponents:");
|
||||
for (String s : cmp) {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.android.server.pm;
|
||||
|
||||
import java.util.HashSet;
|
||||
import android.util.ArraySet;
|
||||
|
||||
/**
|
||||
* Settings data for a particular shared user ID we know about.
|
||||
@@ -29,7 +29,7 @@ final class SharedUserSetting extends GrantedPermissions {
|
||||
// flags that are associated with this uid, regardless of any package flags
|
||||
int uidFlags;
|
||||
|
||||
final HashSet<PackageSetting> packages = new HashSet<PackageSetting>();
|
||||
final ArraySet<PackageSetting> packages = new ArraySet<PackageSetting>();
|
||||
|
||||
final PackageSignatures signatures = new PackageSignatures();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user