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