Apply BitmapCachingAsset for WallpaperColorsLoader to use the catched bitmap
The catch map: https://source.corp.google.com/android/packages/apps/WallpaperPicker2/src/com/android/wallpaper/asset/BitmapCachingAsset.java;l=65?q=package:%5E(android)$%20file:(%2F%7C%5E)com%2Fandroid%2Fwallpaper%2Fasset%2FBitmapCachingAsset%5C.java$
Test: Manually
Bug: 146475648
Change-Id: I8427838d186c4e48b53e721d6cdcc72d0384eb5e
diff --git a/src/com/android/wallpaper/picker/CategoryFragment.java b/src/com/android/wallpaper/picker/CategoryFragment.java
index a17263e..5cb858d 100755
--- a/src/com/android/wallpaper/picker/CategoryFragment.java
+++ b/src/com/android/wallpaper/picker/CategoryFragment.java
@@ -687,6 +687,7 @@
}
WallpaperColorsLoader.getWallpaperColors(
+ getContext(),
wallpaperInfo.getThumbAsset(getContext()),
thumbnailView.getMeasuredWidth(),
thumbnailView.getMeasuredHeight(),
diff --git a/src/com/android/wallpaper/widget/WallpaperColorsLoader.java b/src/com/android/wallpaper/widget/WallpaperColorsLoader.java
index 5ea5c15..22d1ab2 100644
--- a/src/com/android/wallpaper/widget/WallpaperColorsLoader.java
+++ b/src/com/android/wallpaper/widget/WallpaperColorsLoader.java
@@ -16,12 +16,14 @@
package com.android.wallpaper.widget;
import android.app.WallpaperColors;
+import android.content.Context;
import android.graphics.Bitmap;
import android.util.Log;
import androidx.annotation.NonNull;
import com.android.wallpaper.asset.Asset;
+import com.android.wallpaper.asset.BitmapCachingAsset;
/** A class to load the {@link WallpaperColors} from wallpaper {@link Asset}. */
public class WallpaperColorsLoader {
@@ -39,9 +41,10 @@
}
/** Gets the {@link WallpaperColors} from the wallpaper {@link Asset}. */
- public static void getWallpaperColors(@NonNull Asset asset, int targetWidth, int targetHeight,
+ public static void getWallpaperColors(Context context, @NonNull Asset asset,
+ int targetWidth, int targetHeight,
@NonNull Callback callback) {
- asset.decodeBitmap(targetWidth, targetHeight, bitmap -> {
+ new BitmapCachingAsset(context, asset).decodeBitmap(targetWidth, targetHeight, bitmap -> {
if (bitmap != null) {
boolean shouldRecycle = false;
if (bitmap.getConfig() == Bitmap.Config.HARDWARE) {