Loading core/java/android/app/ResourcesManager.java +16 −15 Original line number Diff line number Diff line Loading @@ -214,11 +214,10 @@ public class ResourcesManager { for (int i = mCachedApkAssets.size() - 1; i >= 0; i--) { final ApkKey key = mCachedApkAssets.keyAt(i); if (key.path.equals(path)) { WeakReference<ApkAssets> apkAssetsRef = mCachedApkAssets.remove(key); WeakReference<ApkAssets> apkAssetsRef = mCachedApkAssets.removeAt(i); if (apkAssetsRef != null && apkAssetsRef.get() != null) { apkAssetsRef.get().close(); } mCachedApkAssets.remove(key); } } } Loading Loading @@ -774,6 +773,7 @@ public class ResourcesManager { * Rebases a key's override config on top of the Activity's base override. */ private void rebaseKeyForActivity(IBinder activityToken, ResourcesKey key) { synchronized (this) { final ActivityResources activityResources = getOrCreateActivityResourcesStructLocked(activityToken); Loading @@ -789,6 +789,7 @@ public class ResourcesManager { key.mOverrideConfiguration.setTo(temp); } } } /** * Check WeakReferences and remove any dead references so they don't pile up. Loading core/java/android/content/res/ResourcesImpl.java +2 −29 Original line number Diff line number Diff line Loading @@ -57,8 +57,6 @@ import android.view.DisplayAdjustments; import com.android.internal.util.GrowingArrayUtils; import libcore.io.IoUtils; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; Loading Loading @@ -817,27 +815,6 @@ public class ResourcesImpl { } } /** * Loads a Drawable from an encoded image stream, or null. * * This call will handle closing the {@link InputStream}. */ @Nullable private Drawable decodeImageDrawable(@NonNull InputStream inputStream, @NonNull Resources wrapper, @NonNull TypedValue value) { ImageDecoder.Source src = ImageDecoder.createSource(wrapper, inputStream, value.density); try { return ImageDecoder.decodeDrawable(src, (decoder, info, s) -> decoder.setAllocator(ImageDecoder.ALLOCATOR_SOFTWARE)); } catch (IOException ignored) { // This is okay. This may be something that ImageDecoder does not // support, like SVG. return null; } finally { IoUtils.closeQuietly(inputStream); } } /** * Loads a drawable from XML or resources stream. * Loading Loading @@ -902,12 +879,8 @@ public class ResourcesImpl { } else { final InputStream is = mAssets.openNonAsset( value.assetCookie, file, AssetManager.ACCESS_STREAMING); if (is instanceof AssetInputStream) { AssetInputStream ais = (AssetInputStream) is; final AssetInputStream ais = (AssetInputStream) is; dr = decodeImageDrawable(ais, wrapper, value); } else { dr = decodeImageDrawable(is, wrapper, value); } } } finally { stack.pop(); Loading Loading
core/java/android/app/ResourcesManager.java +16 −15 Original line number Diff line number Diff line Loading @@ -214,11 +214,10 @@ public class ResourcesManager { for (int i = mCachedApkAssets.size() - 1; i >= 0; i--) { final ApkKey key = mCachedApkAssets.keyAt(i); if (key.path.equals(path)) { WeakReference<ApkAssets> apkAssetsRef = mCachedApkAssets.remove(key); WeakReference<ApkAssets> apkAssetsRef = mCachedApkAssets.removeAt(i); if (apkAssetsRef != null && apkAssetsRef.get() != null) { apkAssetsRef.get().close(); } mCachedApkAssets.remove(key); } } } Loading Loading @@ -774,6 +773,7 @@ public class ResourcesManager { * Rebases a key's override config on top of the Activity's base override. */ private void rebaseKeyForActivity(IBinder activityToken, ResourcesKey key) { synchronized (this) { final ActivityResources activityResources = getOrCreateActivityResourcesStructLocked(activityToken); Loading @@ -789,6 +789,7 @@ public class ResourcesManager { key.mOverrideConfiguration.setTo(temp); } } } /** * Check WeakReferences and remove any dead references so they don't pile up. Loading
core/java/android/content/res/ResourcesImpl.java +2 −29 Original line number Diff line number Diff line Loading @@ -57,8 +57,6 @@ import android.view.DisplayAdjustments; import com.android.internal.util.GrowingArrayUtils; import libcore.io.IoUtils; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; Loading Loading @@ -817,27 +815,6 @@ public class ResourcesImpl { } } /** * Loads a Drawable from an encoded image stream, or null. * * This call will handle closing the {@link InputStream}. */ @Nullable private Drawable decodeImageDrawable(@NonNull InputStream inputStream, @NonNull Resources wrapper, @NonNull TypedValue value) { ImageDecoder.Source src = ImageDecoder.createSource(wrapper, inputStream, value.density); try { return ImageDecoder.decodeDrawable(src, (decoder, info, s) -> decoder.setAllocator(ImageDecoder.ALLOCATOR_SOFTWARE)); } catch (IOException ignored) { // This is okay. This may be something that ImageDecoder does not // support, like SVG. return null; } finally { IoUtils.closeQuietly(inputStream); } } /** * Loads a drawable from XML or resources stream. * Loading Loading @@ -902,12 +879,8 @@ public class ResourcesImpl { } else { final InputStream is = mAssets.openNonAsset( value.assetCookie, file, AssetManager.ACCESS_STREAMING); if (is instanceof AssetInputStream) { AssetInputStream ais = (AssetInputStream) is; final AssetInputStream ais = (AssetInputStream) is; dr = decodeImageDrawable(ais, wrapper, value); } else { dr = decodeImageDrawable(is, wrapper, value); } } } finally { stack.pop(); Loading