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
diff --git a/quickstep/src/com/android/quickstep/NormalizedIconLoader.java b/quickstep/src/com/android/quickstep/NormalizedIconLoader.java
index 6557761..bd6204a 100644
--- a/quickstep/src/com/android/quickstep/NormalizedIconLoader.java
+++ b/quickstep/src/com/android/quickstep/NormalizedIconLoader.java
@@ -43,7 +43,6 @@
private final SparseArray<BitmapInfo> mDefaultIcons = new SparseArray<>();
private final DrawableFactory mDrawableFactory;
private final boolean mDisableColorExtraction;
- private LauncherIcons mLauncherIcons;
public NormalizedIconLoader(Context context, TaskKeyLruCache<Drawable> iconCache,
LruCache<ComponentName, ActivityInfo> activityInfoCache,
@@ -73,19 +72,18 @@
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