Merge "Slider always represents absolute brightness"
This commit is contained in:
committed by
Android (Google) Code Review
commit
8b4e2ddc41
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -1001,24 +1001,6 @@ public final class PowerManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the brightness of the backlights (screen, keyboard, button).
|
||||
* <p>
|
||||
* Requires the {@link android.Manifest.permission#DEVICE_POWER} permission.
|
||||
* </p>
|
||||
*
|
||||
* @param brightness The brightness value from 0 to 255.
|
||||
*
|
||||
* @hide Requires signature permission.
|
||||
*/
|
||||
public void setBacklightBrightness(int brightness) {
|
||||
try {
|
||||
mService.setTemporaryScreenBrightnessSettingOverride(brightness);
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the specified wake lock level is supported.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user