From 719f58b23f90f9316546679dba790ca49effe2cb Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Thu, 11 Oct 2018 13:56:08 -0700 Subject: [PATCH] Fixing dead lock in loading icon for recents > getBitmapInfo() is called on background thead which blocks on the main thread to get InvariantDeviceProfile > getDefaultIcon() can be called on the main thread, which would get blocked on a previous call of getBitmapInfo() Bug: 117588621 Change-Id: I6549398c7e0a49284fe59950965495074ab8cdd0 --- .../quickstep/NormalizedIconLoader.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/quickstep/src/com/android/quickstep/NormalizedIconLoader.java b/quickstep/src/com/android/quickstep/NormalizedIconLoader.java index 655776194f..bd6204aab1 100644 --- a/quickstep/src/com/android/quickstep/NormalizedIconLoader.java +++ b/quickstep/src/com/android/quickstep/NormalizedIconLoader.java @@ -43,7 +43,6 @@ public class NormalizedIconLoader extends IconLoader { private final SparseArray mDefaultIcons = new SparseArray<>(); private final DrawableFactory mDrawableFactory; private final boolean mDisableColorExtraction; - private LauncherIcons mLauncherIcons; public NormalizedIconLoader(Context context, TaskKeyLruCache iconCache, LruCache activityInfoCache, @@ -73,19 +72,18 @@ public class NormalizedIconLoader extends IconLoader { false)); } - private synchronized BitmapInfo getBitmapInfo(Drawable drawable, int userId, + private BitmapInfo getBitmapInfo(Drawable drawable, int userId, int primaryColor, boolean isInstantApp) { - if (mLauncherIcons == null) { - mLauncherIcons = LauncherIcons.obtain(mContext); + try (LauncherIcons la = LauncherIcons.obtain(mContext)) { if (mDisableColorExtraction) { - mLauncherIcons.disableColorExtraction(); + la.disableColorExtraction(); } - } + la.setWrapperBackgroundColor(primaryColor); - mLauncherIcons.setWrapperBackgroundColor(primaryColor); - // User version code O, so that the icon is always wrapped in an adaptive icon container. - return mLauncherIcons.createBadgedIconBitmap(drawable, UserHandle.of(userId), - Build.VERSION_CODES.O, isInstantApp); + // User version code O, so that the icon is always wrapped in an adaptive icon container + return la.createBadgedIconBitmap(drawable, UserHandle.of(userId), + Build.VERSION_CODES.O, isInstantApp); + } } @Override