From 5809a40f3ed091af74c5209a09a628fa2b5beb76 Mon Sep 17 00:00:00 2001 From: Hyunyoung Song Date: Tue, 2 Feb 2021 01:19:18 -0800 Subject: [PATCH] Fix issue of slice icon being rendered on non-UIthread Bug: 178989579 Test: Manual Change-Id: I23aa5055c8f07ee9877c1f3ce51cb280ac38a2b7 --- .../android/launcher3/search/SearchResultIconSlice.java | 3 ++- src/com/android/launcher3/BubbleTextView.java | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/launcher3/search/SearchResultIconSlice.java b/quickstep/src/com/android/launcher3/search/SearchResultIconSlice.java index 0ea2f8b86e..c441e2291b 100644 --- a/quickstep/src/com/android/launcher3/search/SearchResultIconSlice.java +++ b/quickstep/src/com/android/launcher3/search/SearchResultIconSlice.java @@ -15,6 +15,7 @@ */ package com.android.launcher3.search; +import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.launcher3.util.Executors.MODEL_EXECUTOR; import android.app.search.SearchTarget; @@ -104,7 +105,7 @@ public class SearchResultIconSlice extends LinearLayout implements SearchTargetH PackageItemInfo pkgItem = new PackageItemInfo(parentTarget.getPackageName()); pkgItem.user = parentTarget.getUserHandle(); appState.getIconCache().getTitleAndIconForApp(pkgItem, false); - mIcon.applyFromItemInfoWithIcon(pkgItem); + MAIN_EXECUTOR.post(() -> mIcon.applyFromItemInfoWithIcon(pkgItem)); }); } } diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index 140340af62..5007ffc7be 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -51,6 +51,7 @@ import android.view.ViewDebug; import android.widget.TextView; import androidx.annotation.Nullable; +import androidx.annotation.UiThread; import androidx.core.graphics.ColorUtils; import com.android.launcher3.Launcher.OnResumeCallback; @@ -271,6 +272,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, mDotScaleAnim.start(); } + @UiThread public void applyFromWorkspaceItem(WorkspaceItemInfo info) { applyFromWorkspaceItem(info, false); } @@ -287,6 +289,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, } } + @UiThread public void applyFromWorkspaceItem(WorkspaceItemInfo info, boolean promiseStateChanged) { applyIconAndLabel(info); setTag(info); @@ -295,6 +298,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, setDownloadStateContentDescription(info, info.getProgressLevel()); } + @UiThread public void applyFromApplicationInfo(AppInfo info) { applyIconAndLabel(info); @@ -314,6 +318,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, /** * Apply label and tag using a generic {@link ItemInfoWithIcon} */ + @UiThread public void applyFromItemInfoWithIcon(ItemInfoWithIcon info) { applyIconAndLabel(info); // We don't need to check the info since it's not a WorkspaceItemInfo @@ -328,11 +333,13 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, /** * Apply label and tag using a {@link SearchActionItemInfo} */ + @UiThread public void applyFromSearchActionItemInfo(SearchActionItemInfo searchActionItemInfo) { applyIconAndLabel(searchActionItemInfo); setTag(searchActionItemInfo); } + @UiThread protected void applyIconAndLabel(ItemInfoWithIcon info) { FastBitmapDrawable iconDrawable = newIcon(getContext(), info); mDotParams.color = IconPalette.getMutedColor(info.bitmap.color, 0.54f); @@ -341,6 +348,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, applyLabel(info); } + @UiThread private void applyLabel(ItemInfoWithIcon info) { setText(info.title); if (info.contentDescription != null) {