Loading core/java/android/hardware/display/DisplayManager.java +28 −0 Original line number Diff line number Diff line Loading @@ -655,6 +655,34 @@ public final class DisplayManager { mGlobal.setBrightnessConfigurationForUser(c, userId, packageName); } /** * Temporarily sets the brightness of the display. * <p> * Requires the {@link android.Manifest.permission#CONTROL_DISPLAY_BRIGHTNESS} permission. * </p> * * @param brightness The brightness value from 0 to 255. * * @hide Requires signature permission. */ public void setTemporaryBrightness(int brightness) { mGlobal.setTemporaryBrightness(brightness); } /** * Temporarily sets the auto brightness adjustment factor. * <p> * Requires the {@link android.Manifest.permission#CONTROL_DISPLAY_BRIGHTNESS} permission. * </p> * * @param adjustment The adjustment factor from -1.0 to 1.0. * * @hide Requires signature permission. */ public void setTemporaryAutoBrightnessAdjustment(float adjustment) { mGlobal.setTemporaryAutoBrightnessAdjustment(adjustment); } /** * Listens for changes in available display devices. */ Loading core/java/android/hardware/display/DisplayManagerGlobal.java +36 −0 Original line number Diff line number Diff line Loading @@ -489,6 +489,42 @@ public final class DisplayManagerGlobal { } } /** * Temporarily sets the brightness of the display. * <p> * Requires the {@link android.Manifest.permission#CONTROL_DISPLAY_BRIGHTNESS} permission. * </p> * * @param brightness The brightness value from 0 to 255. * * @hide Requires signature permission. */ public void setTemporaryBrightness(int brightness) { try { mDm.setTemporaryBrightness(brightness); } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); } } /** * Temporarily sets the auto brightness adjustment factor. * <p> * Requires the {@link android.Manifest.permission#CONTROL_DISPLAY_BRIGHTNESS} permission. * </p> * * @param adjustment The adjustment factor from -1.0 to 1.0. * * @hide Requires signature permission. */ public void setTemporaryAutoBrightnessAdjustment(float adjustment) { try { mDm.setTemporaryAutoBrightnessAdjustment(adjustment); } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); } } private final class DisplayManagerCallback extends IDisplayManagerCallback.Stub { @Override public void onDisplayEvent(int displayId, int event) { Loading core/java/android/hardware/display/DisplayManagerInternal.java +23 −34 Original line number Diff line number Diff line Loading @@ -214,23 +214,12 @@ public abstract class DisplayManagerInternal { // nearby, turning it off temporarily until the object is moved away. public boolean useProximitySensor; // The desired screen brightness in the range 0 (minimum / off) to 255 (brightest). // The display power controller may choose to clamp the brightness. // When auto-brightness is enabled, this field should specify a nominal default // value to use while waiting for the light sensor to report enough data. public int screenBrightness; // An override of the screen brightness. Set to -1 is used if there's no override. public int screenBrightnessOverride; // The screen auto-brightness adjustment factor in the range -1 (dimmer) to 1 (brighter). public float screenAutoBrightnessAdjustment; // Set to true if screenBrightness and screenAutoBrightnessAdjustment were both // set by the user as opposed to being programmatically controlled by apps. public boolean brightnessSetByUser; // Set to true if screenBrightness or screenAutoBrightnessAdjustment are being set // temporarily. This is typically set while the user has their finger on the brightness // control, before they've selected the final brightness value. public boolean brightnessIsTemporary; // An override of the screen auto-brightness adjustment factor in the range -1 (dimmer) to // 1 (brighter). Set to Float.NaN if there's no override. public float screenAutoBrightnessAdjustmentOverride; // If true, enables automatic brightness control. public boolean useAutoBrightness; Loading Loading @@ -262,10 +251,10 @@ public abstract class DisplayManagerInternal { public DisplayPowerRequest() { policy = POLICY_BRIGHT; useProximitySensor = false; screenBrightness = PowerManager.BRIGHTNESS_ON; screenAutoBrightnessAdjustment = 0.0f; screenLowPowerBrightnessFactor = 0.5f; screenBrightnessOverride = -1; useAutoBrightness = false; screenAutoBrightnessAdjustmentOverride = Float.NaN; screenLowPowerBrightnessFactor = 0.5f; blockScreenOn = false; dozeScreenBrightness = PowerManager.BRIGHTNESS_DEFAULT; dozeScreenState = Display.STATE_UNKNOWN; Loading @@ -286,12 +275,10 @@ public abstract class DisplayManagerInternal { public void copyFrom(DisplayPowerRequest other) { policy = other.policy; useProximitySensor = other.useProximitySensor; screenBrightness = other.screenBrightness; screenAutoBrightnessAdjustment = other.screenAutoBrightnessAdjustment; screenLowPowerBrightnessFactor = other.screenLowPowerBrightnessFactor; brightnessSetByUser = other.brightnessSetByUser; brightnessIsTemporary = other.brightnessIsTemporary; screenBrightnessOverride = other.screenBrightnessOverride; useAutoBrightness = other.useAutoBrightness; screenAutoBrightnessAdjustmentOverride = other.screenAutoBrightnessAdjustmentOverride; screenLowPowerBrightnessFactor = other.screenLowPowerBrightnessFactor; blockScreenOn = other.blockScreenOn; lowPowerMode = other.lowPowerMode; boostScreenBrightness = other.boostScreenBrightness; Loading @@ -309,13 +296,12 @@ public abstract class DisplayManagerInternal { return other != null && policy == other.policy && useProximitySensor == other.useProximitySensor && screenBrightness == other.screenBrightness && screenAutoBrightnessAdjustment == other.screenAutoBrightnessAdjustment && screenBrightnessOverride == other.screenBrightnessOverride && useAutoBrightness == other.useAutoBrightness && floatEquals(screenAutoBrightnessAdjustmentOverride, other.screenAutoBrightnessAdjustmentOverride) && screenLowPowerBrightnessFactor == other.screenLowPowerBrightnessFactor && brightnessSetByUser == other.brightnessSetByUser && brightnessIsTemporary == other.brightnessIsTemporary && useAutoBrightness == other.useAutoBrightness && blockScreenOn == other.blockScreenOn && lowPowerMode == other.lowPowerMode && boostScreenBrightness == other.boostScreenBrightness Loading @@ -323,6 +309,10 @@ public abstract class DisplayManagerInternal { && dozeScreenState == other.dozeScreenState; } private boolean floatEquals(float f1, float f2) { return f1 == f2 || Float.isNaN(f1) && Float.isNaN(f2); } @Override public int hashCode() { return 0; // don't care Loading @@ -332,12 +322,11 @@ public abstract class DisplayManagerInternal { public String toString() { return "policy=" + policyToString(policy) + ", useProximitySensor=" + useProximitySensor + ", screenBrightness=" + screenBrightness + ", screenAutoBrightnessAdjustment=" + screenAutoBrightnessAdjustment + ", screenLowPowerBrightnessFactor=" + screenLowPowerBrightnessFactor + ", brightnessSetByUser=" + brightnessSetByUser + ", brightnessIsTemporary=" + brightnessIsTemporary + ", screenBrightnessOverride=" + screenBrightnessOverride + ", useAutoBrightness=" + useAutoBrightness + ", screenAutoBrightnessAdjustmentOverride=" + screenAutoBrightnessAdjustmentOverride + ", screenLowPowerBrightnessFactor=" + screenLowPowerBrightnessFactor + ", blockScreenOn=" + blockScreenOn + ", lowPowerMode=" + lowPowerMode + ", boostScreenBrightness=" + boostScreenBrightness Loading core/java/android/hardware/display/IDisplayManager.aidl +6 −0 Original line number Diff line number Diff line Loading @@ -92,4 +92,10 @@ interface IDisplayManager { // the same as the calling user. void setBrightnessConfigurationForUser(in BrightnessConfiguration c, int userId, String packageName); // Temporarily sets the display brightness. void setTemporaryBrightness(int brightness); // Temporarily sets the auto brightness adjustment factor. void setTemporaryAutoBrightnessAdjustment(float adjustment); } core/java/android/os/IPowerManager.aidl +0 −5 Original line number Diff line number Diff line Loading @@ -63,11 +63,6 @@ interface IPowerManager // --- deprecated --- boolean isScreenBrightnessBoosted(); // temporarily overrides the screen brightness settings to allow the user to // see the effect of a settings change without applying it immediately void setTemporaryScreenBrightnessSettingOverride(int brightness); void setTemporaryScreenAutoBrightnessAdjustmentSettingOverride(float adj); // sets the attention light (used by phone app only) void setAttentionLight(boolean on, int color); } Loading
core/java/android/hardware/display/DisplayManager.java +28 −0 Original line number Diff line number Diff line Loading @@ -655,6 +655,34 @@ public final class DisplayManager { mGlobal.setBrightnessConfigurationForUser(c, userId, packageName); } /** * Temporarily sets the brightness of the display. * <p> * Requires the {@link android.Manifest.permission#CONTROL_DISPLAY_BRIGHTNESS} permission. * </p> * * @param brightness The brightness value from 0 to 255. * * @hide Requires signature permission. */ public void setTemporaryBrightness(int brightness) { mGlobal.setTemporaryBrightness(brightness); } /** * Temporarily sets the auto brightness adjustment factor. * <p> * Requires the {@link android.Manifest.permission#CONTROL_DISPLAY_BRIGHTNESS} permission. * </p> * * @param adjustment The adjustment factor from -1.0 to 1.0. * * @hide Requires signature permission. */ public void setTemporaryAutoBrightnessAdjustment(float adjustment) { mGlobal.setTemporaryAutoBrightnessAdjustment(adjustment); } /** * Listens for changes in available display devices. */ Loading
core/java/android/hardware/display/DisplayManagerGlobal.java +36 −0 Original line number Diff line number Diff line Loading @@ -489,6 +489,42 @@ public final class DisplayManagerGlobal { } } /** * Temporarily sets the brightness of the display. * <p> * Requires the {@link android.Manifest.permission#CONTROL_DISPLAY_BRIGHTNESS} permission. * </p> * * @param brightness The brightness value from 0 to 255. * * @hide Requires signature permission. */ public void setTemporaryBrightness(int brightness) { try { mDm.setTemporaryBrightness(brightness); } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); } } /** * Temporarily sets the auto brightness adjustment factor. * <p> * Requires the {@link android.Manifest.permission#CONTROL_DISPLAY_BRIGHTNESS} permission. * </p> * * @param adjustment The adjustment factor from -1.0 to 1.0. * * @hide Requires signature permission. */ public void setTemporaryAutoBrightnessAdjustment(float adjustment) { try { mDm.setTemporaryAutoBrightnessAdjustment(adjustment); } catch (RemoteException ex) { throw ex.rethrowFromSystemServer(); } } private final class DisplayManagerCallback extends IDisplayManagerCallback.Stub { @Override public void onDisplayEvent(int displayId, int event) { Loading
core/java/android/hardware/display/DisplayManagerInternal.java +23 −34 Original line number Diff line number Diff line Loading @@ -214,23 +214,12 @@ public abstract class DisplayManagerInternal { // nearby, turning it off temporarily until the object is moved away. public boolean useProximitySensor; // The desired screen brightness in the range 0 (minimum / off) to 255 (brightest). // The display power controller may choose to clamp the brightness. // When auto-brightness is enabled, this field should specify a nominal default // value to use while waiting for the light sensor to report enough data. public int screenBrightness; // An override of the screen brightness. Set to -1 is used if there's no override. public int screenBrightnessOverride; // The screen auto-brightness adjustment factor in the range -1 (dimmer) to 1 (brighter). public float screenAutoBrightnessAdjustment; // Set to true if screenBrightness and screenAutoBrightnessAdjustment were both // set by the user as opposed to being programmatically controlled by apps. public boolean brightnessSetByUser; // Set to true if screenBrightness or screenAutoBrightnessAdjustment are being set // temporarily. This is typically set while the user has their finger on the brightness // control, before they've selected the final brightness value. public boolean brightnessIsTemporary; // An override of the screen auto-brightness adjustment factor in the range -1 (dimmer) to // 1 (brighter). Set to Float.NaN if there's no override. public float screenAutoBrightnessAdjustmentOverride; // If true, enables automatic brightness control. public boolean useAutoBrightness; Loading Loading @@ -262,10 +251,10 @@ public abstract class DisplayManagerInternal { public DisplayPowerRequest() { policy = POLICY_BRIGHT; useProximitySensor = false; screenBrightness = PowerManager.BRIGHTNESS_ON; screenAutoBrightnessAdjustment = 0.0f; screenLowPowerBrightnessFactor = 0.5f; screenBrightnessOverride = -1; useAutoBrightness = false; screenAutoBrightnessAdjustmentOverride = Float.NaN; screenLowPowerBrightnessFactor = 0.5f; blockScreenOn = false; dozeScreenBrightness = PowerManager.BRIGHTNESS_DEFAULT; dozeScreenState = Display.STATE_UNKNOWN; Loading @@ -286,12 +275,10 @@ public abstract class DisplayManagerInternal { public void copyFrom(DisplayPowerRequest other) { policy = other.policy; useProximitySensor = other.useProximitySensor; screenBrightness = other.screenBrightness; screenAutoBrightnessAdjustment = other.screenAutoBrightnessAdjustment; screenLowPowerBrightnessFactor = other.screenLowPowerBrightnessFactor; brightnessSetByUser = other.brightnessSetByUser; brightnessIsTemporary = other.brightnessIsTemporary; screenBrightnessOverride = other.screenBrightnessOverride; useAutoBrightness = other.useAutoBrightness; screenAutoBrightnessAdjustmentOverride = other.screenAutoBrightnessAdjustmentOverride; screenLowPowerBrightnessFactor = other.screenLowPowerBrightnessFactor; blockScreenOn = other.blockScreenOn; lowPowerMode = other.lowPowerMode; boostScreenBrightness = other.boostScreenBrightness; Loading @@ -309,13 +296,12 @@ public abstract class DisplayManagerInternal { return other != null && policy == other.policy && useProximitySensor == other.useProximitySensor && screenBrightness == other.screenBrightness && screenAutoBrightnessAdjustment == other.screenAutoBrightnessAdjustment && screenBrightnessOverride == other.screenBrightnessOverride && useAutoBrightness == other.useAutoBrightness && floatEquals(screenAutoBrightnessAdjustmentOverride, other.screenAutoBrightnessAdjustmentOverride) && screenLowPowerBrightnessFactor == other.screenLowPowerBrightnessFactor && brightnessSetByUser == other.brightnessSetByUser && brightnessIsTemporary == other.brightnessIsTemporary && useAutoBrightness == other.useAutoBrightness && blockScreenOn == other.blockScreenOn && lowPowerMode == other.lowPowerMode && boostScreenBrightness == other.boostScreenBrightness Loading @@ -323,6 +309,10 @@ public abstract class DisplayManagerInternal { && dozeScreenState == other.dozeScreenState; } private boolean floatEquals(float f1, float f2) { return f1 == f2 || Float.isNaN(f1) && Float.isNaN(f2); } @Override public int hashCode() { return 0; // don't care Loading @@ -332,12 +322,11 @@ public abstract class DisplayManagerInternal { public String toString() { return "policy=" + policyToString(policy) + ", useProximitySensor=" + useProximitySensor + ", screenBrightness=" + screenBrightness + ", screenAutoBrightnessAdjustment=" + screenAutoBrightnessAdjustment + ", screenLowPowerBrightnessFactor=" + screenLowPowerBrightnessFactor + ", brightnessSetByUser=" + brightnessSetByUser + ", brightnessIsTemporary=" + brightnessIsTemporary + ", screenBrightnessOverride=" + screenBrightnessOverride + ", useAutoBrightness=" + useAutoBrightness + ", screenAutoBrightnessAdjustmentOverride=" + screenAutoBrightnessAdjustmentOverride + ", screenLowPowerBrightnessFactor=" + screenLowPowerBrightnessFactor + ", blockScreenOn=" + blockScreenOn + ", lowPowerMode=" + lowPowerMode + ", boostScreenBrightness=" + boostScreenBrightness Loading
core/java/android/hardware/display/IDisplayManager.aidl +6 −0 Original line number Diff line number Diff line Loading @@ -92,4 +92,10 @@ interface IDisplayManager { // the same as the calling user. void setBrightnessConfigurationForUser(in BrightnessConfiguration c, int userId, String packageName); // Temporarily sets the display brightness. void setTemporaryBrightness(int brightness); // Temporarily sets the auto brightness adjustment factor. void setTemporaryAutoBrightnessAdjustment(float adjustment); }
core/java/android/os/IPowerManager.aidl +0 −5 Original line number Diff line number Diff line Loading @@ -63,11 +63,6 @@ interface IPowerManager // --- deprecated --- boolean isScreenBrightnessBoosted(); // temporarily overrides the screen brightness settings to allow the user to // see the effect of a settings change without applying it immediately void setTemporaryScreenBrightnessSettingOverride(int brightness); void setTemporaryScreenAutoBrightnessAdjustmentSettingOverride(float adj); // sets the attention light (used by phone app only) void setAttentionLight(boolean on, int color); }