Merge "Do not use pool of SimpleIconFactory objects in Chooser/ResolverActivity" into tm-qpr-dev am: cbb45c6814
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19952284 Change-Id: Ied1239518758bd583218ccbb6f59dc22ac7ae789 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -51,6 +51,7 @@ import android.util.Pools.SynchronizedPool;
|
|||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
|
|
||||||
import com.android.internal.R;
|
import com.android.internal.R;
|
||||||
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
|
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
|
|
||||||
@@ -69,6 +70,7 @@ public class SimpleIconFactory {
|
|||||||
|
|
||||||
private static final SynchronizedPool<SimpleIconFactory> sPool =
|
private static final SynchronizedPool<SimpleIconFactory> sPool =
|
||||||
new SynchronizedPool<>(Runtime.getRuntime().availableProcessors());
|
new SynchronizedPool<>(Runtime.getRuntime().availableProcessors());
|
||||||
|
private static boolean sPoolEnabled = true;
|
||||||
|
|
||||||
private static final int DEFAULT_WRAPPER_BACKGROUND = Color.WHITE;
|
private static final int DEFAULT_WRAPPER_BACKGROUND = Color.WHITE;
|
||||||
private static final float BLUR_FACTOR = 1.5f / 48;
|
private static final float BLUR_FACTOR = 1.5f / 48;
|
||||||
@@ -92,7 +94,7 @@ public class SimpleIconFactory {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static SimpleIconFactory obtain(Context ctx) {
|
public static SimpleIconFactory obtain(Context ctx) {
|
||||||
SimpleIconFactory instance = sPool.acquire();
|
SimpleIconFactory instance = sPoolEnabled ? sPool.acquire() : null;
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
final ActivityManager am = (ActivityManager) ctx.getSystemService(ACTIVITY_SERVICE);
|
final ActivityManager am = (ActivityManager) ctx.getSystemService(ACTIVITY_SERVICE);
|
||||||
final int iconDpi = (am == null) ? 0 : am.getLauncherLargeIconDensity();
|
final int iconDpi = (am == null) ? 0 : am.getLauncherLargeIconDensity();
|
||||||
@@ -106,6 +108,17 @@ public class SimpleIconFactory {
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables or disables SimpleIconFactory objects pooling. It is enabled in production, you
|
||||||
|
* could use this method in tests and disable the pooling to make the icon rendering more
|
||||||
|
* deterministic because some sizing parameters will not be cached. Please ensure that you
|
||||||
|
* reset this value back after finishing the test.
|
||||||
|
*/
|
||||||
|
@VisibleForTesting
|
||||||
|
public static void setPoolEnabled(boolean poolEnabled) {
|
||||||
|
sPoolEnabled = poolEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
private static int getAttrDimFromContext(Context ctx, @AttrRes int attrId, String errorMsg) {
|
private static int getAttrDimFromContext(Context ctx, @AttrRes int attrId, String errorMsg) {
|
||||||
final Resources res = ctx.getResources();
|
final Resources res = ctx.getResources();
|
||||||
TypedValue outVal = new TypedValue();
|
TypedValue outVal = new TypedValue();
|
||||||
|
|||||||
Reference in New Issue
Block a user