Merge "Synchronize before calling unstableRemoveIf" into rvc-dev am: ad5a070a87 am: 84e64c26ee
Change-Id: I9c4f61837abdd364de698376619c5369deb00d2e
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -774,19 +773,21 @@ public class ResourcesManager {
|
||||
* Rebases a key's override config on top of the Activity's base override.
|
||||
*/
|
||||
private void rebaseKeyForActivity(IBinder activityToken, ResourcesKey key) {
|
||||
final ActivityResources activityResources =
|
||||
getOrCreateActivityResourcesStructLocked(activityToken);
|
||||
synchronized (this) {
|
||||
final ActivityResources activityResources =
|
||||
getOrCreateActivityResourcesStructLocked(activityToken);
|
||||
|
||||
// Clean up any dead references so they don't pile up.
|
||||
ArrayUtils.unstableRemoveIf(activityResources.activityResources,
|
||||
sEmptyReferencePredicate);
|
||||
// Clean up any dead references so they don't pile up.
|
||||
ArrayUtils.unstableRemoveIf(activityResources.activityResources,
|
||||
sEmptyReferencePredicate);
|
||||
|
||||
// Rebase the key's override config on top of the Activity's base override.
|
||||
if (key.hasOverrideConfiguration()
|
||||
&& !activityResources.overrideConfig.equals(Configuration.EMPTY)) {
|
||||
final Configuration temp = new Configuration(activityResources.overrideConfig);
|
||||
temp.updateFrom(key.mOverrideConfiguration);
|
||||
key.mOverrideConfiguration.setTo(temp);
|
||||
// Rebase the key's override config on top of the Activity's base override.
|
||||
if (key.hasOverrideConfiguration()
|
||||
&& !activityResources.overrideConfig.equals(Configuration.EMPTY)) {
|
||||
final Configuration temp = new Configuration(activityResources.overrideConfig);
|
||||
temp.updateFrom(key.mOverrideConfiguration);
|
||||
key.mOverrideConfiguration.setTo(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
@@ -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;
|
||||
dr = decodeImageDrawable(ais, wrapper, value);
|
||||
} else {
|
||||
dr = decodeImageDrawable(is, wrapper, value);
|
||||
}
|
||||
final AssetInputStream ais = (AssetInputStream) is;
|
||||
dr = decodeImageDrawable(ais, wrapper, value);
|
||||
}
|
||||
} finally {
|
||||
stack.pop();
|
||||
|
||||
Reference in New Issue
Block a user