Fix loading thumbnail with destroyed Activity
Check and bypass loading thumbnail if Activity is destroyed. This
prevents exception in loading thumbnail without considering Activity's
lifecycle.
Bug: 177446199
Test: Manual
Change-Id: I8afd3946d194162cf9ee89aa55cff1ae685f827e
diff --git a/src/com/android/customization/picker/WallpaperPreviewer.java b/src/com/android/customization/picker/WallpaperPreviewer.java
index 50010c5..064ece6 100644
--- a/src/com/android/customization/picker/WallpaperPreviewer.java
+++ b/src/com/android/customization/picker/WallpaperPreviewer.java
@@ -149,6 +149,9 @@
ImageView homeImageWallpaper = mWallpaperSurfaceCallback.getHomeImageWallpaper();
if (mWallpaper != null && homeImageWallpaper != null) {
homeImageWallpaper.post(() -> {
+ if (mActivity == null || mActivity.isDestroyed()) {
+ return;
+ }
boolean renderInImageWallpaperSurface = !(mWallpaper instanceof LiveWallpaperInfo);
mWallpaper.getThumbAsset(mActivity.getApplicationContext())
.loadPreviewImage(mActivity,