summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Julius D'souza <jdsouza@google.com> 2017-06-06 21:29:39 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2017-06-06 21:29:49 +0000
commit9fd3076fe6929ae423693115fe64aa6bbc8448ef (patch)
tree6976674181ec2db6a3178f359767b5cbc3eb1c08
parentc742b8ab2d5b6e4a3f168eef40024c7e95de2fbd (diff)
parentd5105dddbe983794ee8709b5cd6ad07a9a7fe095 (diff)
Merge "Add state machine model for skipping initial brightness ramps." into oc-dev
-rw-r--r--core/res/res/values/config.xml5
-rw-r--r--core/res/res/values/symbols.xml1
-rw-r--r--services/core/java/com/android/server/display/DisplayPowerController.java45
3 files changed, 50 insertions, 1 deletions
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 8e6c40294e2c..ec0b0493c8d3 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -1099,6 +1099,11 @@
that can be set by the user. -->
<integer name="config_screenBrightnessDoze">1</integer>
+ <!-- Whether or not to skip the initial brightness ramps when the display transitions to
+ STATE_ON. Setting this to true will skip the brightness ramp to the last stored active
+ brightness value and will repeat for the following ramp if autobrightness is enabled. -->
+ <bool name="config_skipScreenOnBrightnessRamp">false</bool>
+
<!-- Allow automatic adjusting of the screen brightness while dozing in low power state. -->
<bool name="config_allowAutoBrightnessWhileDozing">false</bool>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index cd29c64df4d8..8678a3e68fa0 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -1755,6 +1755,7 @@
<java-symbol type="bool" name="config_sf_limitedAlpha" />
<java-symbol type="bool" name="config_unplugTurnsOnScreen" />
<java-symbol type="bool" name="config_usbChargingMessage" />
+ <java-symbol type="bool" name="config_skipScreenOnBrightnessRamp" />
<java-symbol type="bool" name="config_allowAutoBrightnessWhileDozing" />
<java-symbol type="bool" name="config_allowTheaterModeWakeFromUnplug" />
<java-symbol type="bool" name="config_allowTheaterModeWakeFromGesture" />
diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java
index 9dc317ad38ac..e82724db27f7 100644
--- a/services/core/java/com/android/server/display/DisplayPowerController.java
+++ b/services/core/java/com/android/server/display/DisplayPowerController.java
@@ -104,6 +104,11 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
// Trigger proximity if distance is less than 5 cm.
private static final float TYPICAL_PROXIMITY_THRESHOLD = 5.0f;
+ // State machine constants for tracking initial brightness ramp skipping when enabled.
+ private static final int RAMP_STATE_SKIP_NONE = 0;
+ private static final int RAMP_STATE_SKIP_INITIAL = 1;
+ private static final int RAMP_STATE_SKIP_AUTOBRIGHT = 2;
+
private static final int REPORTED_TO_POLICY_SCREEN_OFF = 0;
private static final int REPORTED_TO_POLICY_SCREEN_TURNING_ON = 1;
private static final int REPORTED_TO_POLICY_SCREEN_ON = 2;
@@ -239,6 +244,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
// Screen state we reported to policy. Must be one of REPORTED_TO_POLICY_SCREEN_* fields.
private int mReportedScreenStateToPolicy;
+ // If the last recorded screen state was dozing or not.
+ private boolean mDozing;
+
// Remembers whether certain kinds of brightness adjustments
// were recently applied so that we can decide how to transition.
private boolean mAppliedAutoBrightness;
@@ -249,6 +257,15 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
private final int mBrightnessRampRateFast;
private final int mBrightnessRampRateSlow;
+ // Whether or not to skip the initial brightness ramps into STATE_ON.
+ private final boolean mSkipScreenOnBrightnessRamp;
+
+ // A record of state for skipping brightness ramps.
+ private int mSkipRampState = RAMP_STATE_SKIP_NONE;
+
+ // The first autobrightness value set when entering RAMP_STATE_SKIP_INITIAL.
+ private int mInitialAutoBrightness;
+
// The controller for the automatic brightness level.
private AutomaticBrightnessController mAutomaticBrightnessController;
@@ -312,6 +329,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
com.android.internal.R.integer.config_brightness_ramp_rate_fast);
mBrightnessRampRateSlow = resources.getInteger(
com.android.internal.R.integer.config_brightness_ramp_rate_slow);
+ mSkipScreenOnBrightnessRamp = resources.getBoolean(
+ com.android.internal.R.bool.config_skipScreenOnBrightnessRamp);
int lightSensorRate = resources.getInteger(
com.android.internal.R.integer.config_autoBrightnessLightSensorRate);
@@ -731,8 +750,29 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
// Animate the screen brightness when the screen is on or dozing.
// Skip the animation when the screen is off or suspended or transition to/from VR.
if (!mPendingScreenOff) {
+ if (mSkipScreenOnBrightnessRamp) {
+
+ if (state == Display.STATE_ON) {
+ if (mSkipRampState == RAMP_STATE_SKIP_NONE && mDozing) {
+ mInitialAutoBrightness = brightness;
+ mSkipRampState = RAMP_STATE_SKIP_INITIAL;
+ } else if (mSkipRampState == RAMP_STATE_SKIP_INITIAL
+ && mUseSoftwareAutoBrightnessConfig
+ && brightness != mInitialAutoBrightness) {
+ mSkipRampState = RAMP_STATE_SKIP_AUTOBRIGHT;
+ } else if (mSkipRampState == RAMP_STATE_SKIP_AUTOBRIGHT) {
+ mSkipRampState = RAMP_STATE_SKIP_NONE;
+ }
+ } else {
+ mSkipRampState = RAMP_STATE_SKIP_NONE;
+ }
+ }
+
boolean wasOrWillBeInVr = (state == Display.STATE_VR || oldState == Display.STATE_VR);
- if ((state == Display.STATE_ON || state == Display.STATE_DOZE) && !wasOrWillBeInVr) {
+ if ((state == Display.STATE_ON
+ && mSkipRampState == RAMP_STATE_SKIP_NONE
+ || state == Display.STATE_DOZE)
+ && !wasOrWillBeInVr) {
animateScreenBrightness(brightness,
slowChange ? mBrightnessRampRateSlow : mBrightnessRampRateFast);
} else {
@@ -790,6 +830,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
mUnfinishedBusiness = false;
mCallbacks.releaseSuspendBlocker();
}
+
+ // Record if dozing for future comparison.
+ mDozing = state != Display.STATE_ON;
}
@Override