From 462e29da9ba854eb3651dd9664b09a2852a05141 Mon Sep 17 00:00:00 2001 From: Bryan Mawhinney Date: Thu, 22 Mar 2018 15:52:41 +0000 Subject: Add a SystemApi to control display saturation. Allows an app with the appropriate permission to reduce (make more gray) the saturation of colors on the display. Test: manual Bug: 77189882 Change-Id: I2b7b065d07bd2ca24730b2e8c52d161c22b307ab --- api/system-current.txt | 2 ++ .../android/hardware/display/DisplayManager.java | 13 +++++++++ .../hardware/display/DisplayManagerGlobal.java | 11 +++++++ .../android/hardware/display/IDisplayManager.aidl | 3 ++ core/res/AndroidManifest.xml | 6 ++++ .../server/display/DisplayManagerService.java | 34 ++++++++++++++++++++++ .../server/display/DisplayTransformManager.java | 6 ++-- 7 files changed, 73 insertions(+), 2 deletions(-) diff --git a/api/system-current.txt b/api/system-current.txt index a81afed5ecdb..ed763babb7ef 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -57,6 +57,7 @@ package android { field public static final java.lang.String CONFIGURE_DISPLAY_BRIGHTNESS = "android.permission.CONFIGURE_DISPLAY_BRIGHTNESS"; field public static final java.lang.String CONNECTIVITY_INTERNAL = "android.permission.CONNECTIVITY_INTERNAL"; field public static final java.lang.String CONNECTIVITY_USE_RESTRICTED_NETWORKS = "android.permission.CONNECTIVITY_USE_RESTRICTED_NETWORKS"; + field public static final java.lang.String CONTROL_DISPLAY_SATURATION = "android.permission.CONTROL_DISPLAY_SATURATION"; field public static final java.lang.String CONTROL_INCALL_EXPERIENCE = "android.permission.CONTROL_INCALL_EXPERIENCE"; field public static final java.lang.String CONTROL_LOCATION_UPDATES = "android.permission.CONTROL_LOCATION_UPDATES"; field public static final java.lang.String CONTROL_VPN = "android.permission.CONTROL_VPN"; @@ -1252,6 +1253,7 @@ package android.hardware.display { method public android.hardware.display.BrightnessConfiguration getDefaultBrightnessConfiguration(); method public android.graphics.Point getStableDisplaySize(); method public void setBrightnessConfiguration(android.hardware.display.BrightnessConfiguration); + method public void setSaturationLevel(float); } } diff --git a/core/java/android/hardware/display/DisplayManager.java b/core/java/android/hardware/display/DisplayManager.java index a3b2d22deccb..efb9517adc00 100644 --- a/core/java/android/hardware/display/DisplayManager.java +++ b/core/java/android/hardware/display/DisplayManager.java @@ -534,6 +534,19 @@ public final class DisplayManager { return mGlobal.getWifiDisplayStatus(); } + /** + * Set the level of color saturation to apply to the display. + * @param level The amount of saturation to apply, between 0 and 1 inclusive. + * 0 produces a grayscale image, 1 is normal. + * + * @hide + */ + @SystemApi + @RequiresPermission(Manifest.permission.CONTROL_DISPLAY_SATURATION) + public void setSaturationLevel(float level) { + mGlobal.setSaturationLevel(level); + } + /** * Creates a virtual display. * diff --git a/core/java/android/hardware/display/DisplayManagerGlobal.java b/core/java/android/hardware/display/DisplayManagerGlobal.java index 1f67a6bf71a7..2d0ef2f23432 100644 --- a/core/java/android/hardware/display/DisplayManagerGlobal.java +++ b/core/java/android/hardware/display/DisplayManagerGlobal.java @@ -384,6 +384,17 @@ public final class DisplayManagerGlobal { } } + /** + * Set the level of color saturation to apply to the display. + */ + public void setSaturationLevel(float level) { + try { + mDm.setSaturationLevel(level); + } catch (RemoteException ex) { + throw ex.rethrowFromSystemServer(); + } + } + public VirtualDisplay createVirtualDisplay(Context context, MediaProjection projection, String name, int width, int height, int densityDpi, Surface surface, int flags, VirtualDisplay.Callback callback, Handler handler, String uniqueId) { diff --git a/core/java/android/hardware/display/IDisplayManager.aidl b/core/java/android/hardware/display/IDisplayManager.aidl index 9fcb9d3fc265..b77de748a987 100644 --- a/core/java/android/hardware/display/IDisplayManager.aidl +++ b/core/java/android/hardware/display/IDisplayManager.aidl @@ -65,6 +65,9 @@ interface IDisplayManager { // Requires CONFIGURE_DISPLAY_COLOR_MODE void requestColorMode(int displayId, int colorMode); + // Requires CONTROL_DISPLAY_SATURATION + void setSaturationLevel(float level); + // Requires CAPTURE_VIDEO_OUTPUT, CAPTURE_SECURE_VIDEO_OUTPUT, or an appropriate // MediaProjection token for certain combinations of flags. int createVirtualDisplay(in IVirtualDisplayCallback callback, diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index cb375d5394fa..f4715fc7645d 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -3121,6 +3121,12 @@ + + +