summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/app/WallpaperColors.java9
-rw-r--r--services/core/java/com/android/server/wallpaper/WallpaperManagerService.java2
-rw-r--r--services/tests/servicestests/src/com/android/server/wallpaper/WallpaperServiceTests.java15
3 files changed, 24 insertions, 2 deletions
diff --git a/core/java/android/app/WallpaperColors.java b/core/java/android/app/WallpaperColors.java
index a2864b9d83af..f780703b5786 100644
--- a/core/java/android/app/WallpaperColors.java
+++ b/core/java/android/app/WallpaperColors.java
@@ -137,6 +137,13 @@ 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");
}
@@ -186,7 +193,7 @@ public final class WallpaperColors implements Parcelable {
}
}
- int hints = calculateDarkHints(bitmap);
+ int hints = computeHints ? calculateDarkHints(bitmap) : 0;
if (shouldRecycle) {
bitmap.recycle();
diff --git a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
index 397c50f949b9..8901b044047c 100644
--- a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
+++ b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
@@ -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);
+ colors = WallpaperColors.fromBitmap(bitmap, true /* computeHints */);
bitmap.recycle();
}
}
diff --git a/services/tests/servicestests/src/com/android/server/wallpaper/WallpaperServiceTests.java b/services/tests/servicestests/src/com/android/server/wallpaper/WallpaperServiceTests.java
index 9c010a07135d..4d99b3208720 100644
--- a/services/tests/servicestests/src/com/android/server/wallpaper/WallpaperServiceTests.java
+++ b/services/tests/servicestests/src/com/android/server/wallpaper/WallpaperServiceTests.java
@@ -20,6 +20,8 @@ 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;
@@ -85,4 +87,17 @@ 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);
+ }
}