OSDN Git Service

Don't hold on to AssetManager instances
authorAdam Lesinski <adamlesinski@google.com>
Wed, 13 Jul 2016 19:09:24 +0000 (12:09 -0700)
committerAdam Lesinski <adamlesinski@google.com>
Thu, 14 Jul 2016 00:22:12 +0000 (00:22 +0000)
If we enter multi-window mode or load WebView
assets into a Resources object, then the underlying
AssetManager instance may change.

crbug.com/627586

Bug:30118654

Change-Id: I837637bdad5370809db7f060d7d8536b536cad9e

core/java/android/content/res/TypedArray.java

index 92134ee..1e44a5c 100644 (file)
@@ -49,6 +49,10 @@ public class TypedArray {
             attrs.mLength = len;
             attrs.mRecycled = false;
 
+            // Reset the assets, which may have changed due to configuration changes
+            // or further resource loading.
+            attrs.mAssets = res.getAssets();
+
             final int fullLen = len * AssetManager.STYLE_NUM_ENTRIES;
             if (attrs.mData.length >= fullLen) {
                 return attrs;
@@ -66,7 +70,7 @@ public class TypedArray {
 
     private final Resources mResources;
     private final DisplayMetrics mMetrics;
-    private final AssetManager mAssets;
+    private AssetManager mAssets;
 
     private boolean mRecycled;
 
@@ -1086,6 +1090,7 @@ public class TypedArray {
         // These may have been set by the client.
         mXml = null;
         mTheme = null;
+        mAssets = null;
 
         mResources.mTypedArrayPool.release(this);
     }