Snap for 9919854 from 999c15e9ed7e6728a253cf10f14c80c2f7d75cb6 to tm-qpr3-release
Change-Id: I18d8a9f4e9b30ed514f8dda09902912189c8118b
diff --git a/src/com/android/wallpaper/asset/LiveWallpaperThumbAsset.java b/src/com/android/wallpaper/asset/LiveWallpaperThumbAsset.java
index 1f4fb67..08486a1 100755
--- a/src/com/android/wallpaper/asset/LiveWallpaperThumbAsset.java
+++ b/src/com/android/wallpaper/asset/LiveWallpaperThumbAsset.java
@@ -21,16 +21,23 @@
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
+import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
+import android.graphics.drawable.LayerDrawable;
import android.net.Uri;
+import android.os.Handler;
+import android.os.Looper;
import android.util.Log;
import android.widget.ImageView;
import androidx.annotation.WorkerThread;
+import com.android.wallpaper.module.DrawableLayerResolver;
+import com.android.wallpaper.module.InjectorProvider;
+
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.Key;
import com.bumptech.glide.load.MultiTransformation;
@@ -59,6 +66,7 @@
protected final Context mContext;
protected final android.app.WallpaperInfo mInfo;
+ protected final DrawableLayerResolver mLayerResolver;
// The content Uri of thumbnail
protected Uri mUri;
private Drawable mThumbnailDrawable;
@@ -66,6 +74,7 @@
public LiveWallpaperThumbAsset(Context context, android.app.WallpaperInfo info) {
mContext = context.getApplicationContext();
mInfo = info;
+ mLayerResolver = InjectorProvider.getInjector().getDrawableLayerResolver();
}
public LiveWallpaperThumbAsset(Context context, android.app.WallpaperInfo info, Uri uri) {
@@ -114,7 +123,25 @@
@Override
public void decodeRawDimensions(Activity unused, DimensionsReceiver receiver) {
- receiver.onDimensionsDecoded(null);
+ // TODO(b/277166654): Reuse the logic for all thumb asset decoding
+ sExecutorService.execute(() -> {
+ Bitmap result = null;
+ Drawable thumb = mInfo.loadThumbnail(mContext.getPackageManager());
+ if (thumb instanceof BitmapDrawable) {
+ result = ((BitmapDrawable) thumb).getBitmap();
+ } else if (thumb instanceof LayerDrawable) {
+ Drawable layer = mLayerResolver.resolveLayer((LayerDrawable) thumb);
+ if (layer instanceof BitmapDrawable) {
+ result = ((BitmapDrawable) layer).getBitmap();
+ }
+ }
+ final Bitmap lr = result;
+ new Handler(Looper.getMainLooper()).post(
+ () ->
+ receiver.onDimensionsDecoded(
+ lr == null ? null : new Point(lr.getWidth(), lr.getHeight()))
+ );
+ });
}
@Override