Do not extract colors of live wallpapers.

Not extracting colors from live wallpaper thumbanils
since they might not represent the actual colors
being displayed.

Bug: 62019730
Test: Manual. Set live wallpaper, scrim is grey.
Change-Id: Ida652cab069beb1ee5fe36eb7862cc21e8edbc2e
diff --git a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
index 929f28d..dfcc166 100644
--- a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
+++ b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
@@ -379,54 +379,31 @@
 
     /**
      * We can easily extract colors from an ImageWallpaper since it's only a bitmap.
-     * In this case, using the crop is more than enough.
-     *
-     * In case of a live wallpaper, the best we can do is to extract colors from its
-     * preview image. Anyway, the live wallpaper can also implement the wallpaper colors API
-     * to report when colors change.
+     * In this case, using the crop is more than enough. Live wallpapers are just ignored.
      *
      * @param wallpaper a wallpaper representation
      */
     private void extractColors(WallpaperData wallpaper) {
         String cropFile = null;
-        Drawable thumbnail = null;
-        // This represents a maximum pixel count in an image.
-        // It prevents color extraction on big bitmaps.
-        int wallpaperId = -1;
+        int wallpaperId;
 
-        boolean imageWallpaper = false;
         synchronized (mLock) {
-            imageWallpaper = mImageWallpaper.equals(wallpaper.wallpaperComponent)
+            // Not having a wallpaperComponent means it's a lock screen wallpaper.
+            final boolean imageWallpaper = mImageWallpaper.equals(wallpaper.wallpaperComponent)
                     || wallpaper.wallpaperComponent == null;
-            if (imageWallpaper) {
-                if (wallpaper.cropFile != null && wallpaper.cropFile.exists()) {
-                    cropFile = wallpaper.cropFile.getAbsolutePath();
-                }
-            } else {
-                if (wallpaper.connection == null) {
-                    Slog.w(TAG, "Can't extract colors, wallpaper not connected. " +
-                            wallpaper.wallpaperId);
-                    return;
-                }
-                WallpaperInfo info = wallpaper.connection.mInfo;
-                if (info == null) {
-                    Slog.w(TAG, "Something is really wrong, live wallpaper doesn't have " +
-                           "a WallpaperInfo object! " + wallpaper.wallpaperId);
-                    return;
-                }
-                thumbnail = info.loadThumbnail(mContext.getPackageManager());
+            if (imageWallpaper && wallpaper.cropFile != null && wallpaper.cropFile.exists()) {
+                cropFile = wallpaper.cropFile.getAbsolutePath();
             }
-
             wallpaperId = wallpaper.wallpaperId;
         }
 
         WallpaperColors colors = null;
         if (cropFile != null) {
             Bitmap bitmap = BitmapFactory.decodeFile(cropFile);
-            colors = WallpaperColors.fromBitmap(bitmap);
-            bitmap.recycle();
-        } else if (thumbnail != null) {
-            colors = WallpaperColors.fromDrawable(thumbnail);
+            if (bitmap != null) {
+                colors = WallpaperColors.fromBitmap(bitmap);
+                bitmap.recycle();
+            }
         }
 
         if (colors == null) {
@@ -434,16 +411,6 @@
             return;
         }
 
-        // Even though we can extract colors from live wallpaper thumbnails,
-        // it's risky to assume that it might support dark text on top of it:
-        //    • Thumbnail might not be accurate.
-        //    • Colors might change over time.
-        if (!imageWallpaper) {
-            int colorHints = colors.getColorHints();
-            colorHints &= ~WallpaperColors.HINT_SUPPORTS_DARK_TEXT;
-            colors.setColorHints(colorHints);
-        }
-
         synchronized (mLock) {
             if (wallpaper.wallpaperId == wallpaperId) {
                 wallpaper.primaryColors = colors;