OSDN Git Service

ResourcesManager: Fix a cache issue
authorAdam Lesinski <adamlesinski@google.com>
Fri, 1 Apr 2016 18:48:10 +0000 (11:48 -0700)
committerAdam Lesinski <adamlesinski@google.com>
Fri, 1 Apr 2016 18:48:10 +0000 (11:48 -0700)
Forgot to cache the creating of ResourcesImpl during an Activity
override config update.

Bug:27644297
Change-Id: I65d9086f6d32f5adc7231aa3a1797d4f00c4b9a9

core/java/android/app/ResourcesManager.java

index 3f22385..4c4f128 100644 (file)
@@ -440,6 +440,11 @@ public class ResourcesManager {
                 compatInfo);
         classLoader = classLoader != null ? classLoader : ClassLoader.getSystemClassLoader();
 
+        if (DEBUG) {
+            Slog.d(TAG, "createBaseActivityResources activity=" + activityToken
+                    + " with key=" + key);
+        }
+
         synchronized (this) {
             final ActivityResources activityResources = getOrCreateActivityResourcesStructLocked(
                     activityToken);
@@ -651,6 +656,16 @@ public class ResourcesManager {
                 activityResources.overrideConfig.setToDefaults();
             }
 
+            if (DEBUG) {
+                Throwable here = new Throwable();
+                here.fillInStackTrace();
+                Slog.d(TAG, "updating resources override for activity=" + activityToken
+                        + " from oldConfig=" + Configuration.resourceQualifierString(oldConfig)
+                        + " to newConfig="
+                        + Configuration.resourceQualifierString(activityResources.overrideConfig),
+                        here);
+            }
+
             final boolean activityHasOverrideConfig =
                     !activityResources.overrideConfig.equals(Configuration.EMPTY);
 
@@ -692,9 +707,15 @@ public class ResourcesManager {
                         oldKey.mOverlayDirs, oldKey.mLibDirs, oldKey.mDisplayId,
                         rebasedOverrideConfig, oldKey.mCompatInfo);
 
+                if (DEBUG) {
+                    Slog.d(TAG, "rebasing ref=" + resources + " from oldKey=" + oldKey
+                            + " to newKey=" + newKey);
+                }
+
                 ResourcesImpl resourcesImpl = findResourcesImplForKeyLocked(newKey);
                 if (resourcesImpl == null) {
                     resourcesImpl = createResourcesImpl(newKey);
+                    mResourceImpls.put(newKey, new WeakReference<>(resourcesImpl));
                 }
 
                 if (resourcesImpl != resources.getImpl()) {