OSDN Git Service

Revert "WallpaperColors hint computation"
authorLucas Dupin <dupin@google.com>
Thu, 24 May 2018 16:33:14 +0000 (16:33 +0000)
committerLucas Dupin <dupin@google.com>
Thu, 24 May 2018 16:33:14 +0000 (16:33 +0000)
This reverts commit c50f47d970b474371938f33e46b13ae2dd040df0.

Fixes: 79465234
Reason for revert: Google still does it using private APIs and apps were relying on this behavior, not good for the ecosystem.

Change-Id: I62e2b4cd1e6e562fcdd89c97e599bcdade83381a

core/java/android/app/WallpaperColors.java
services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
services/tests/servicestests/src/com/android/server/wallpaper/WallpaperServiceTests.java

index f780703..a2864b9 100644 (file)
@@ -137,13 +137,6 @@ public final class WallpaperColors implements Parcelable {
      * @param bitmap Source where to extract from.
      */
     public static WallpaperColors fromBitmap(@NonNull Bitmap bitmap) {
-        return fromBitmap(bitmap, false /* computeHints */);
-    }
-
-    /**
-     * @hide
-     */
-    public static WallpaperColors fromBitmap(@NonNull Bitmap bitmap, boolean computeHints) {
         if (bitmap == null) {
             throw new IllegalArgumentException("Bitmap can't be null");
         }
@@ -193,7 +186,7 @@ public final class WallpaperColors implements Parcelable {
             }
         }
 
-        int hints = computeHints ? calculateDarkHints(bitmap) : 0;
+        int hints = calculateDarkHints(bitmap);
 
         if (shouldRecycle) {
             bitmap.recycle();
index 8901b04..397c50f 100644 (file)
@@ -458,7 +458,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
         if (cropFile != null) {
             Bitmap bitmap = BitmapFactory.decodeFile(cropFile);
             if (bitmap != null) {
-                colors = WallpaperColors.fromBitmap(bitmap, true /* computeHints */);
+                colors = WallpaperColors.fromBitmap(bitmap);
                 bitmap.recycle();
             }
         }
index 4d99b32..9c010a0 100644 (file)
@@ -20,8 +20,6 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
 import android.app.WallpaperColors;
-import android.graphics.Color;
-import android.graphics.drawable.ColorDrawable;
 import android.os.Handler;
 import android.os.Message;
 import android.os.SystemClock;
@@ -87,17 +85,4 @@ public class WallpaperServiceTests {
         assertEquals("OnComputeColors should have been deferred.",
                 0, eventCountdown.getCount());
     }
-
-    @Test
-    public void testFromDrawableTest_doesntComputeHints() {
-        WallpaperColors wallpaperColors = WallpaperColors.fromDrawable(
-                new ColorDrawable(Color.BLACK));
-        assertEquals("WallpaperColors should not support dark theme.", 0,
-                wallpaperColors.getColorHints() & WallpaperColors.HINT_SUPPORTS_DARK_THEME);
-
-        wallpaperColors = WallpaperColors.fromDrawable(
-                new ColorDrawable(Color.WHITE));
-        assertEquals("WallpaperColors should not support dark text.", 0,
-                wallpaperColors.getColorHints() & WallpaperColors.HINT_SUPPORTS_DARK_TEXT);
-    }
 }