diff --git a/quickstep/src/com/android/launcher3/model/PredictionUpdateTask.java b/quickstep/src/com/android/launcher3/model/PredictionUpdateTask.java index 3544844bd2..a2c680a682 100644 --- a/quickstep/src/com/android/launcher3/model/PredictionUpdateTask.java +++ b/quickstep/src/com/android/launcher3/model/PredictionUpdateTask.java @@ -18,7 +18,6 @@ package com.android.launcher3.model; import static com.android.launcher3.EncryptionType.ENCRYPTED; import static com.android.launcher3.LauncherPrefs.nonRestorableItem; import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT; -import static com.android.launcher3.icons.cache.CacheLookupFlag.DEFAULT_LOOKUP_FLAG; import static com.android.quickstep.InstantAppResolverImpl.COMPONENT_CLASS_MARKER; import android.app.prediction.AppTarget; @@ -107,7 +106,7 @@ public class PredictionUpdateTask implements ModelUpdateTask { return null; } AppInfo ai = new AppInfo(context, lai, user); - iconCache.getTitleAndIcon(ai, lai, DEFAULT_LOOKUP_FLAG); + iconCache.getTitleAndIcon(ai, lai, mPredictorState.lookupFlag); return ai.makeWorkspaceItem(context); }); diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index 9a06f00973..efc887e417 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -31,6 +31,7 @@ import static com.android.launcher3.icons.BitmapInfo.FLAG_SKIP_USER_BADGE; import static com.android.launcher3.icons.BitmapInfo.FLAG_THEMED; import static com.android.launcher3.icons.GraphicsUtils.setColorAlphaBound; import static com.android.launcher3.icons.IconNormalizer.ICON_VISIBLE_AREA_FACTOR; +import static com.android.launcher3.icons.cache.CacheLookupFlag.DEFAULT_LOOKUP_FLAG; import static com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_INCREMENTAL_DOWNLOAD_ACTIVE; import static com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE; import static com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_SHOW_DOWNLOAD_PROGRESS_MASK; @@ -85,6 +86,7 @@ import com.android.launcher3.icons.DotRenderer; import com.android.launcher3.icons.FastBitmapDrawable; import com.android.launcher3.icons.IconCache.ItemInfoUpdateReceiver; import com.android.launcher3.icons.PlaceHolderIconDrawable; +import com.android.launcher3.icons.cache.CacheLookupFlag; import com.android.launcher3.model.data.AppInfo; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.ItemInfoWithIcon; @@ -1364,13 +1366,14 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, * Verifies that the current icon is high-res otherwise posts a request to load the icon. */ public void verifyHighRes() { + CacheLookupFlag expectedFlag = DEFAULT_LOOKUP_FLAG.withThemeIcon(shouldUseTheme()); if (getTag() instanceof ItemInfoWithIcon info && !mHighResUpdateInProgress - && info.getMatchingLookupFlag().useLowRes()) { + && info.getMatchingLookupFlag().isVisuallyLessThan(expectedFlag)) { if (mIconLoadRequest != null) { mIconLoadRequest.cancel(); } mIconLoadRequest = LauncherAppState.getInstance(getContext()).getIconCache() - .updateIconInBackground(BubbleTextView.this, info); + .updateIconInBackground(BubbleTextView.this, info, expectedFlag); } } diff --git a/src/com/android/launcher3/LauncherSettings.java b/src/com/android/launcher3/LauncherSettings.java index 5dc5d31ceb..b17f44f5ba 100644 --- a/src/com/android/launcher3/LauncherSettings.java +++ b/src/com/android/launcher3/LauncherSettings.java @@ -359,7 +359,7 @@ public class LauncherSettings { /** * Lookup flag to be used for items which are visible on the home screen */ - public static final CacheLookupFlag DESKTOP_ICON_FLAG = DEFAULT_LOOKUP_FLAG; + public static final CacheLookupFlag DESKTOP_ICON_FLAG = DEFAULT_LOOKUP_FLAG.withThemeIcon(); } /** diff --git a/src/com/android/launcher3/folder/PreviewItemManager.java b/src/com/android/launcher3/folder/PreviewItemManager.java index 4cf618d73d..a81dbe03a3 100644 --- a/src/com/android/launcher3/folder/PreviewItemManager.java +++ b/src/com/android/launcher3/folder/PreviewItemManager.java @@ -471,7 +471,7 @@ public class PreviewItemManager { setDrawable(p, newInfo); mIcon.invalidate(); } - }, info); + }, info, DESKTOP_ICON_FLAG); } } diff --git a/src/com/android/launcher3/icons/IconCache.java b/src/com/android/launcher3/icons/IconCache.java index 1e80d03727..59522998dc 100644 --- a/src/com/android/launcher3/icons/IconCache.java +++ b/src/com/android/launcher3/icons/IconCache.java @@ -66,6 +66,8 @@ import com.android.launcher3.model.data.PackageItemInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.pm.InstallSessionHelper; import com.android.launcher3.pm.UserCache; +import com.android.launcher3.shortcuts.ShortcutKey; +import com.android.launcher3.shortcuts.ShortcutRequest; import com.android.launcher3.util.CancellableTask; import com.android.launcher3.util.ComponentKey; import com.android.launcher3.util.DaggerSingletonTracker; @@ -189,16 +191,16 @@ public class IconCache extends BaseIconCache { */ @AnyThread public CancellableTask updateIconInBackground(final ItemInfoUpdateReceiver caller, - final ItemInfoWithIcon info) { + final ItemInfoWithIcon info, final CacheLookupFlag lookupFlag) { Supplier task; if (info instanceof AppInfo || info instanceof WorkspaceItemInfo) { task = () -> { - getTitleAndIcon(info, DEFAULT_LOOKUP_FLAG); + getTitleAndIcon(info, lookupFlag); return info; }; } else if (info instanceof PackageItemInfo pii) { task = () -> { - getTitleAndIconForApp(pii, DEFAULT_LOOKUP_FLAG); + getTitleAndIconForApp(pii, lookupFlag); return pii; }; } else { @@ -282,7 +284,7 @@ public class IconCache extends BaseIconCache { user, () -> si, CacheableShortcutCachingLogic.INSTANCE, - DEFAULT_LOOKUP_FLAG.withSkipAddToMemCache()).bitmap; + DEFAULT_LOOKUP_FLAG.withSkipAddToMemCache().withThemeIcon()).bitmap; if (bitmapInfo.isNullOrLowRes()) { bitmapInfo = getDefaultIcon(user); } @@ -342,6 +344,19 @@ public class IconCache extends BaseIconCache { info.bitmap = getDefaultIcon(info.user); info.title = ""; info.contentDescription = ""; + } else if (info.itemType == ITEM_TYPE_DEEP_SHORTCUT) { + ShortcutKey sk = ShortcutKey.fromItemInfo(info); + List sis = sk.buildRequest(context).query(ShortcutRequest.ALL); + if (sis.isEmpty()) { + return; + } + ShortcutInfo si = sis.getFirst(); + CacheEntry entry = cacheLocked(sk.componentName, sk.user, + () -> new CacheableShortcutInfo(si, context), + CacheableShortcutCachingLogic.INSTANCE, + lookupFlag.withSkipAddToMemCache()); + applyCacheEntry(entry, info); + info.bitmap = info.bitmap.withBadgeInfo(getShortcutInfoBadge(si)); } else { Intent intent = info.getIntent(); getTitleAndIcon(info, () -> mLauncherApps.resolveActivity(intent, info.user), @@ -404,7 +419,7 @@ public class IconCache extends BaseIconCache { */ public synchronized void getTitlesAndIconsInBulk( List> iconRequestInfos) { - Map, List>> iconLoadSubsectionsMap = + Map, List>> iconLoadSubsectionsMap = iconRequestInfos.stream() .filter(iconRequest -> { if (iconRequest.itemInfo.getTargetComponent() == null) { @@ -418,7 +433,7 @@ public class IconCache extends BaseIconCache { return true; }) .collect(groupingBy(iconRequest -> - Pair.create(iconRequest.itemInfo.user, iconRequest.useLowResIcon))); + Pair.create(iconRequest.itemInfo.user, iconRequest.lookupFlag))); Trace.beginSection("loadIconsInBulk"); iconLoadSubsectionsMap.forEach((sectionKey, filteredList) -> { @@ -446,15 +461,14 @@ public class IconCache extends BaseIconCache { } private void loadIconSubsection( - Pair sectionKey, + Pair sectionKey, List> filteredList, Map>> duplicateIconRequestsMap) { Trace.beginSection("loadIconSubsectionWithDatabase"); - CacheLookupFlag lookupFlag = DEFAULT_LOOKUP_FLAG.withUseLowRes(sectionKey.second); try (Cursor c = createBulkQueryCursor( filteredList, /* user = */ sectionKey.first, - lookupFlag)) { + /* lookupFlag = */ sectionKey.second)) { // Database title and icon loading int componentNameColumnIndex = c.getColumnIndexOrThrow(COLUMN_COMPONENT); while (c.moveToNext()) { @@ -470,7 +484,7 @@ public class IconCache extends BaseIconCache { /* user = */ sectionKey.first, () -> duplicateIconRequests.get(0).launcherActivityInfo, LauncherActivityCachingLogic.INSTANCE, - lookupFlag, + sectionKey.second, c); for (IconRequestInfo iconRequest : duplicateIconRequests) { @@ -519,7 +533,7 @@ public class IconCache extends BaseIconCache { lai, entry, LauncherActivityCachingLogic.INSTANCE, - /* usePackageIcon= */ false, + DEFAULT_LOOKUP_FLAG.withUsePackageIcon(false), /* usePackageTitle= */ loadFallbackTitle, cn, sectionKey.first); diff --git a/src/com/android/launcher3/model/LoaderCursor.java b/src/com/android/launcher3/model/LoaderCursor.java index fd8e2f7838..f009f72b82 100644 --- a/src/com/android/launcher3/model/LoaderCursor.java +++ b/src/com/android/launcher3/model/LoaderCursor.java @@ -18,6 +18,7 @@ package com.android.launcher3.model; import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_DESKTOP; import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT; +import static com.android.launcher3.LauncherSettings.Favorites.DESKTOP_ICON_FLAG; import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPLICATION; import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APP_PAIR; import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT; @@ -236,7 +237,8 @@ public class LoaderCursor extends CursorWrapper { byte[] iconBlob = itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT || restoreFlag != 0 || (wai.isInactiveArchive() && Flags.restoreArchivedAppIconsFromDb()) ? getIconBlob() : null; - return new IconRequestInfo<>(wai, mActivityInfo, iconBlob, useLowResIcon); + return new IconRequestInfo<>(wai, mActivityInfo, iconBlob, + DESKTOP_ICON_FLAG.withUseLowRes(useLowResIcon)); } /** diff --git a/src/com/android/launcher3/model/LoaderTask.java b/src/com/android/launcher3/model/LoaderTask.java index f54c56e83d..aa812535a3 100644 --- a/src/com/android/launcher3/model/LoaderTask.java +++ b/src/com/android/launcher3/model/LoaderTask.java @@ -776,7 +776,7 @@ public class LoaderTask implements Runnable { allAppsItemRequestInfos.add(new IconRequestInfo<>( promiseAppInfo, /* launcherActivityInfo= */ null, - promiseAppInfo.getMatchingLookupFlag().useLowRes())); + promiseAppInfo.getMatchingLookupFlag().withThemeIcon(false))); } } } @@ -843,7 +843,7 @@ public class LoaderTask implements Runnable { appInfo, activityInfo, workspaceIconRequest.get().iconBlob, - false /* useLowResIcon= */ + DEFAULT_LOOKUP_FLAG.withUseLowRes(false) ); if (!iconRequestInfo.loadIconFromDbBlob(mContext)) { Log.d(TAG, "AppInfo Icon failed to load from blob, using cache."); @@ -861,7 +861,8 @@ public class LoaderTask implements Runnable { + ", isArchived: " + activityInfo.getApplicationInfo().isArchived); } } - return new IconRequestInfo<>(appInfo, activityInfo, false /* useLowResIcon= */); + return new IconRequestInfo<>(appInfo, activityInfo, + DEFAULT_LOOKUP_FLAG.withUseLowRes(false)); } private List loadDeepShortcuts() { diff --git a/src/com/android/launcher3/model/data/IconRequestInfo.java b/src/com/android/launcher3/model/data/IconRequestInfo.java index 42af018b61..fbb042a38e 100644 --- a/src/com/android/launcher3/model/data/IconRequestInfo.java +++ b/src/com/android/launcher3/model/data/IconRequestInfo.java @@ -25,6 +25,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.android.launcher3.icons.LauncherIcons; +import com.android.launcher3.icons.cache.CacheLookupFlag; /** * Class representing one request for an icon to be queried in a sql database. @@ -39,28 +40,28 @@ public class IconRequestInfo { @NonNull public final T itemInfo; @Nullable public final LauncherActivityInfo launcherActivityInfo; @Nullable public final byte[] iconBlob; - public final boolean useLowResIcon; + public final CacheLookupFlag lookupFlag; public IconRequestInfo( @NonNull T itemInfo, @Nullable LauncherActivityInfo launcherActivityInfo, - boolean useLowResIcon) { + CacheLookupFlag lookupFlag) { this( itemInfo, launcherActivityInfo, /* iconBlob= */ null, - useLowResIcon); + lookupFlag); } public IconRequestInfo( @NonNull T itemInfo, @Nullable LauncherActivityInfo launcherActivityInfo, @Nullable byte[] iconBlob, - boolean useLowResIcon) { + CacheLookupFlag lookupFlag) { this.itemInfo = itemInfo; this.launcherActivityInfo = launcherActivityInfo; this.iconBlob = iconBlob; - this.useLowResIcon = useLowResIcon; + this.lookupFlag = lookupFlag; } /** diff --git a/src/com/android/launcher3/widget/PendingAppWidgetHostView.java b/src/com/android/launcher3/widget/PendingAppWidgetHostView.java index 1c29f8907f..8e9cf6f226 100644 --- a/src/com/android/launcher3/widget/PendingAppWidgetHostView.java +++ b/src/com/android/launcher3/widget/PendingAppWidgetHostView.java @@ -22,6 +22,7 @@ import static android.graphics.Paint.FILTER_BITMAP_FLAG; import static com.android.launcher3.graphics.PreloadIconDrawable.newPendingIcon; import static com.android.launcher3.model.data.LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY; +import static com.android.launcher3.icons.cache.CacheLookupFlag.DEFAULT_LOOKUP_FLAG; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import android.appwidget.AppWidgetProviderInfo; @@ -130,7 +131,7 @@ public class PendingAppWidgetHostView extends LauncherAppWidgetHostView info.pendingItemInfo = new PackageItemInfo(info.providerName.getPackageName(), info.user); LauncherAppState.getInstance(context).getIconCache() - .updateIconInBackground(this, info.pendingItemInfo); + .updateIconInBackground(this, info.pendingItemInfo, DEFAULT_LOOKUP_FLAG); } else { reapplyItemInfo(info.pendingItemInfo); } diff --git a/src/com/android/launcher3/widget/WidgetCell.java b/src/com/android/launcher3/widget/WidgetCell.java index 130843b1df..b592c32c37 100644 --- a/src/com/android/launcher3/widget/WidgetCell.java +++ b/src/com/android/launcher3/widget/WidgetCell.java @@ -19,6 +19,7 @@ package com.android.launcher3.widget; import static android.view.accessibility.AccessibilityNodeInfo.ACTION_CLICK; import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_WIDGETS_TRAY; +import static com.android.launcher3.icons.cache.CacheLookupFlag.DEFAULT_LOOKUP_FLAG; import static com.android.launcher3.widget.util.WidgetSizes.getWidgetItemSizePx; import android.animation.Animator; @@ -568,7 +569,8 @@ public class WidgetCell extends LinearLayout { mItem.componentName.getPackageName(), mItem.user); mIconLoadRequest = LauncherAppState.getInstance(getContext()).getIconCache() - .updateIconInBackground(this::reapplyIconInfo, tmpPackageItem); + .updateIconInBackground(this::reapplyIconInfo, tmpPackageItem, + DEFAULT_LOOKUP_FLAG); } } diff --git a/src/com/android/launcher3/widget/picker/WidgetsListHeader.java b/src/com/android/launcher3/widget/picker/WidgetsListHeader.java index 836675a1ee..806bef7a84 100644 --- a/src/com/android/launcher3/widget/picker/WidgetsListHeader.java +++ b/src/com/android/launcher3/widget/picker/WidgetsListHeader.java @@ -17,6 +17,8 @@ package com.android.launcher3.widget.picker; import static android.animation.ValueAnimator.areAnimatorsEnabled; +import static com.android.launcher3.icons.cache.CacheLookupFlag.DEFAULT_LOOKUP_FLAG; + import android.content.Context; import android.content.res.TypedArray; import android.graphics.drawable.Drawable; @@ -244,7 +246,7 @@ public final class WidgetsListHeader extends LinearLayout implements ItemInfoUpd } if (getTag() instanceof ItemInfoWithIcon info && info.getMatchingLookupFlag().useLowRes()) { mIconLoadRequest = LauncherAppState.getInstance(getContext()).getIconCache() - .updateIconInBackground(this, info); + .updateIconInBackground(this, info, DEFAULT_LOOKUP_FLAG); } } } diff --git a/tests/multivalentTests/src/com/android/launcher3/icons/IconCacheTest.java b/tests/multivalentTests/src/com/android/launcher3/icons/IconCacheTest.java index 0aaf4d7c40..86ea9fd5f1 100644 --- a/tests/multivalentTests/src/com/android/launcher3/icons/IconCacheTest.java +++ b/tests/multivalentTests/src/com/android/launcher3/icons/IconCacheTest.java @@ -50,12 +50,16 @@ import android.graphics.Bitmap.Config; import android.graphics.drawable.Icon; import android.os.PersistableBundle; import android.os.UserHandle; +import android.platform.test.annotations.DisableFlags; +import android.platform.test.annotations.EnableFlags; +import android.platform.test.flag.junit.SetFlagsRule; import android.text.TextUtils; import androidx.annotation.Nullable; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; +import com.android.launcher3.Flags; import com.android.launcher3.LauncherAppState; import com.android.launcher3.icons.cache.CachingLogic; import com.android.launcher3.icons.cache.IconCacheUpdateHandler; @@ -70,6 +74,7 @@ import com.android.launcher3.util.ApplicationInfoWrapper; import com.android.launcher3.util.ComponentKey; import com.android.launcher3.util.PackageUserKey; import com.android.launcher3.util.SandboxApplication; +import com.android.launcher3.util.TestUtil; import com.google.common.truth.Truth; @@ -88,6 +93,7 @@ import java.util.Set; public class IconCacheTest { @Rule public SandboxApplication mContext = new SandboxApplication(); + @Rule public SetFlagsRule mFlags = new SetFlagsRule(); private IconCache mIconCache; @@ -277,6 +283,60 @@ public class IconCacheTest { assertTrue(mIconCache.isItemInDb(new ComponentKey(cn2, user))); } + @Test + @EnableFlags(Flags.FLAG_EXTENDIBLE_THEME_MANAGER) + public void theme_icon_not_returned_if_not_requested() { + ComponentName cn = new ComponentName(TEST_PACKAGE, TEST_ACTIVITY); + UserHandle user = myUserHandle(); + LauncherActivityInfo lai = mContext.getSystemService(LauncherApps.class) + .resolveActivity(makeLaunchIntent(cn), user); + assertNotNull(lai); + executeIconUpdate(lai, LauncherActivityCachingLogic.INSTANCE); + + AppInfo info = new AppInfo(mContext, lai, user); + TestUtil.runOnExecutorSync(MODEL_EXECUTOR, () -> { + mIconCache.clearMemoryCache(); + mIconCache.getTitleAndIcon(info, () -> lai, DEFAULT_LOOKUP_FLAG); + }); + assertFalse(info.bitmap.getMatchingLookupFlag().hasThemeIcon()); + } + + @Test + @EnableFlags(Flags.FLAG_EXTENDIBLE_THEME_MANAGER) + public void theme_icon_returned_if_requested() { + ComponentName cn = new ComponentName(TEST_PACKAGE, TEST_ACTIVITY); + UserHandle user = myUserHandle(); + LauncherActivityInfo lai = mContext.getSystemService(LauncherApps.class) + .resolveActivity(makeLaunchIntent(cn), user); + assertNotNull(lai); + executeIconUpdate(lai, LauncherActivityCachingLogic.INSTANCE); + + AppInfo info = new AppInfo(mContext, lai, user); + TestUtil.runOnExecutorSync(MODEL_EXECUTOR, () -> { + mIconCache.clearMemoryCache(); + mIconCache.getTitleAndIcon(info, () -> lai, DEFAULT_LOOKUP_FLAG.withThemeIcon()); + }); + assertTrue(info.bitmap.getMatchingLookupFlag().hasThemeIcon()); + } + + @Test + @DisableFlags(Flags.FLAG_EXTENDIBLE_THEME_MANAGER) + public void theme_icon_returned_if_not_requested_with_flag_off() { + ComponentName cn = new ComponentName(TEST_PACKAGE, TEST_ACTIVITY); + UserHandle user = myUserHandle(); + LauncherActivityInfo lai = mContext.getSystemService(LauncherApps.class) + .resolveActivity(makeLaunchIntent(cn), user); + assertNotNull(lai); + executeIconUpdate(lai, LauncherActivityCachingLogic.INSTANCE); + + AppInfo info = new AppInfo(mContext, lai, user); + TestUtil.runOnExecutorSync(MODEL_EXECUTOR, () -> { + mIconCache.clearMemoryCache(); + mIconCache.getTitleAndIcon(info, () -> lai, DEFAULT_LOOKUP_FLAG); + }); + assertTrue(info.bitmap.getMatchingLookupFlag().hasThemeIcon()); + } + /** * Executes the icon update for the provided entry and returns the updated packages */ diff --git a/tests/multivalentTests/src/com/android/launcher3/icons/cache/CacheLookupFlagTest.kt b/tests/multivalentTests/src/com/android/launcher3/icons/cache/CacheLookupFlagTest.kt index 8218181468..1794c775dc 100644 --- a/tests/multivalentTests/src/com/android/launcher3/icons/cache/CacheLookupFlagTest.kt +++ b/tests/multivalentTests/src/com/android/launcher3/icons/cache/CacheLookupFlagTest.kt @@ -16,11 +16,16 @@ package com.android.launcher3.icons.cache +import android.platform.test.annotations.DisableFlags +import android.platform.test.annotations.EnableFlags +import android.platform.test.flag.junit.SetFlagsRule import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest +import com.android.launcher3.Flags import com.android.launcher3.icons.cache.CacheLookupFlag.Companion.DEFAULT_LOOKUP_FLAG import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith @@ -28,6 +33,8 @@ import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) class CacheLookupFlagTest { + @get:Rule val flags = SetFlagsRule() + @Test fun `useLowRes preserves lowRes values`() { assertFalse(DEFAULT_LOOKUP_FLAG.useLowRes()) @@ -99,4 +106,18 @@ class CacheLookupFlagTest { .isVisuallyLessThan(DEFAULT_LOOKUP_FLAG.withUsePackageIcon()) ) } + + @DisableFlags(Flags.FLAG_EXTENDIBLE_THEME_MANAGER) + @Test + fun `isVisuallyLessThan does not depend on theme with flag off`() { + assertFalse(DEFAULT_LOOKUP_FLAG.withThemeIcon().isVisuallyLessThan(DEFAULT_LOOKUP_FLAG)) + assertFalse(DEFAULT_LOOKUP_FLAG.isVisuallyLessThan(DEFAULT_LOOKUP_FLAG.withThemeIcon())) + } + + @EnableFlags(Flags.FLAG_EXTENDIBLE_THEME_MANAGER) + @Test + fun `isVisuallyLessThan depends on theme with flag on`() { + assertFalse(DEFAULT_LOOKUP_FLAG.withThemeIcon().isVisuallyLessThan(DEFAULT_LOOKUP_FLAG)) + assertTrue(DEFAULT_LOOKUP_FLAG.isVisuallyLessThan(DEFAULT_LOOKUP_FLAG.withThemeIcon())) + } } diff --git a/tests/multivalentTests/src/com/android/launcher3/icons/mono/MonoIconThemeControllerTest.kt b/tests/multivalentTests/src/com/android/launcher3/icons/mono/MonoIconThemeControllerTest.kt index 2c9cb2feb7..aca67d6b05 100644 --- a/tests/multivalentTests/src/com/android/launcher3/icons/mono/MonoIconThemeControllerTest.kt +++ b/tests/multivalentTests/src/com/android/launcher3/icons/mono/MonoIconThemeControllerTest.kt @@ -32,11 +32,14 @@ import com.android.launcher3.Flags import com.android.launcher3.icons.BaseIconFactory import com.android.launcher3.icons.BitmapInfo import com.android.launcher3.icons.SourceHint +import com.android.launcher3.icons.ThemedBitmap import com.android.launcher3.icons.cache.LauncherActivityCachingLogic import com.android.launcher3.util.ComponentKey import com.android.launcher3.util.LauncherMultivalentJUnit.Companion.isRunningInRobolectric import org.junit.Assert.assertNotNull +import org.junit.Assert.assertNotSame import org.junit.Assert.assertNull +import org.junit.Assert.assertSame import org.junit.Assume.assumeFalse import org.junit.Assume.assumeTrue import org.junit.Rule @@ -94,9 +97,10 @@ class MonoIconThemeControllerTest { val themeBitmap = MonoIconThemeController().createThemedBitmap(icon, iconInfo, iconFactory)!! - assertNotNull( + assertNotSame( + ThemedBitmap.NOT_SUPPORTED, MonoIconThemeController() - .decode(themeBitmap.serialize(), iconInfo, iconFactory, sourceHint) + .decode(themeBitmap.serialize(), iconInfo, iconFactory, sourceHint), ) } @@ -105,9 +109,10 @@ class MonoIconThemeControllerTest { ensureBitmapSerializationSupported() val icon = AdaptiveIconDrawable(ColorDrawable(Color.BLACK), null, ColorDrawable(Color.RED)) val iconInfo = iconFactory.createBadgedIconBitmap(icon) - assertNull( + assertSame( + ThemedBitmap.NOT_SUPPORTED, MonoIconThemeController() - .decode(byteArrayOf(1, 1, 1, 1), iconInfo, iconFactory, sourceHint) + .decode(byteArrayOf(1, 1, 1, 1), iconInfo, iconFactory, sourceHint), ) } diff --git a/tests/src/com/android/launcher3/folder/PreviewItemManagerTest.kt b/tests/src/com/android/launcher3/folder/PreviewItemManagerTest.kt index aa0326412c..a13c325fb2 100644 --- a/tests/src/com/android/launcher3/folder/PreviewItemManagerTest.kt +++ b/tests/src/com/android/launcher3/folder/PreviewItemManagerTest.kt @@ -99,7 +99,7 @@ class PreviewItemManagerTest { iconCache = LauncherAppState.INSTANCE[context].iconCache spyOn(iconCache) - doReturn(null).whenever(iconCache).updateIconInBackground(any(), any()) + doReturn(null).whenever(iconCache).updateIconInBackground(any(), any(), any()) previewItemManager = PreviewItemManager(folderIcon) @@ -249,7 +249,8 @@ class PreviewItemManagerTest { assertThat(drawingParams.drawable).isInstanceOf(PlaceHolderIconDrawable::class.java) val callbackCaptor = argumentCaptor() - verify(iconCache).updateIconInBackground(callbackCaptor.capture(), eq(folderItems[3])) + verify(iconCache) + .updateIconInBackground(callbackCaptor.capture(), eq(folderItems[3]), any()) // Restore high-res icon folderItems[3].bitmap = originalBitmap diff --git a/tests/src/com/android/launcher3/model/LoaderTaskTest.kt b/tests/src/com/android/launcher3/model/LoaderTaskTest.kt index b7688f08ae..f8516cc04b 100644 --- a/tests/src/com/android/launcher3/model/LoaderTaskTest.kt +++ b/tests/src/com/android/launcher3/model/LoaderTaskTest.kt @@ -30,6 +30,7 @@ import com.android.launcher3.LauncherSettings.Favorites.TABLE_NAME import com.android.launcher3.dagger.LauncherAppComponent import com.android.launcher3.dagger.LauncherAppSingleton import com.android.launcher3.icons.IconCache +import com.android.launcher3.icons.cache.CacheLookupFlag.Companion.DEFAULT_LOOKUP_FLAG import com.android.launcher3.icons.cache.CachingLogic import com.android.launcher3.icons.cache.IconCacheUpdateHandler import com.android.launcher3.model.LoaderTask.LoaderTaskFactory @@ -480,7 +481,7 @@ class LoaderTaskTest { }, activityInfo, expectedIconBlob, - false, /* useLowResIcon */ + DEFAULT_LOOKUP_FLAG.withUseLowRes(false), ) ) val expectedAppInfo = AppInfo().apply { componentName = expectedComponent } @@ -516,7 +517,7 @@ class LoaderTaskTest { }, activityInfo, expectedIconBlob, - false, /* useLowResIcon */ + DEFAULT_LOOKUP_FLAG.withUseLowRes(false), ) ) val expectedAppInfo = AppInfo().apply { componentName = expectedComponent } @@ -552,7 +553,7 @@ class LoaderTaskTest { }, activityInfo, expectedIconBlob, - false, /* useLowResIcon */ + DEFAULT_LOOKUP_FLAG.withUseLowRes(false), ) ) val expectedAppInfo = AppInfo().apply { componentName = expectedComponent } @@ -588,7 +589,7 @@ class LoaderTaskTest { }, activityInfo, expectedIconBlob, - false, /* useLowResIcon */ + DEFAULT_LOOKUP_FLAG.withUseLowRes(false), ) ) val expectedAppInfo = @@ -622,7 +623,7 @@ class LoaderTaskTest { WorkspaceItemInfo(), activityInfo, expectedIconBlob, - false, /* useLowResIcon */ + DEFAULT_LOOKUP_FLAG.withUseLowRes(false), ) ) val expectedAppInfo = AppInfo()