summaryrefslogtreecommitdiffstats
path: root/services/java/com/android/server/AttributeCache.java
diff options
context:
space:
mode:
Diffstat (limited to 'services/java/com/android/server/AttributeCache.java')
-rw-r--r--services/java/com/android/server/AttributeCache.java51
1 files changed, 18 insertions, 33 deletions
diff --git a/services/java/com/android/server/AttributeCache.java b/services/java/com/android/server/AttributeCache.java
index 81613c6..81378dc 100644
--- a/services/java/com/android/server/AttributeCache.java
+++ b/services/java/com/android/server/AttributeCache.java
@@ -23,7 +23,6 @@ import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
-import android.os.UserHandle;
import android.util.SparseArray;
import java.util.HashMap;
@@ -35,54 +34,52 @@ import java.util.WeakHashMap;
*/
public final class AttributeCache {
private static AttributeCache sInstance = null;
-
+
private final Context mContext;
- private final SparseArray<WeakHashMap<String, Package>> mPackages =
- new SparseArray<WeakHashMap<String, Package>>();
+ private final WeakHashMap<String, Package> mPackages =
+ new WeakHashMap<String, Package>();
private final Configuration mConfiguration = new Configuration();
-
+
public final static class Package {
public final Context context;
private final SparseArray<HashMap<int[], Entry>> mMap
= new SparseArray<HashMap<int[], Entry>>();
-
+
public Package(Context c) {
context = c;
}
}
-
+
public final static class Entry {
public final Context context;
public final TypedArray array;
-
+
public Entry(Context c, TypedArray ta) {
context = c;
array = ta;
}
}
-
+
public static void init(Context context) {
if (sInstance == null) {
sInstance = new AttributeCache(context);
}
}
-
+
public static AttributeCache instance() {
return sInstance;
}
-
+
public AttributeCache(Context context) {
mContext = context;
}
-
+
public void removePackage(String packageName) {
synchronized (this) {
- for (int i=0; i<mPackages.size(); i++) {
- mPackages.valueAt(i).remove(packageName);
- }
+ mPackages.remove(packageName);
}
}
-
+
public void updateConfiguration(Configuration config) {
synchronized (this) {
int changes = mConfiguration.updateFrom(config);
@@ -96,21 +93,10 @@ public final class AttributeCache {
}
}
}
-
- public void removeUser(int userId) {
- synchronized (this) {
- mPackages.remove(userId);
- }
- }
-
- public Entry get(int userId, String packageName, int resId, int[] styleable) {
+
+ public Entry get(String packageName, int resId, int[] styleable) {
synchronized (this) {
- WeakHashMap<String, Package> packages = mPackages.get(userId);
- if (packages == null) {
- packages = new WeakHashMap<String, Package>();
- mPackages.put(userId, packages);
- }
- Package pkg = packages.get(packageName);
+ Package pkg = mPackages.get(packageName);
HashMap<int[], Entry> map = null;
Entry ent = null;
if (pkg != null) {
@@ -124,8 +110,7 @@ public final class AttributeCache {
} else {
Context context;
try {
- context = mContext.createPackageContextAsUser(packageName, 0,
- new UserHandle(userId));
+ context = mContext.createPackageContext(packageName, 0);
if (context == null) {
return null;
}
@@ -133,7 +118,7 @@ public final class AttributeCache {
return null;
}
pkg = new Package(context);
- packages.put(packageName, pkg);
+ mPackages.put(packageName, pkg);
}
if (map == null) {