Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 106f1443 authored by Julius D'souza's avatar Julius D'souza
Browse files

DO NOT MERGE: Add the option to skip the initial brightness

ramp when the screen turns on.

Bug: 35389235

Change-Id: I0bd94c927708c23985f2888d6fa2a1d11c28487e
parent 89bb32fb
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1028,6 +1028,9 @@
    -->
    <integer name="config_doubleTapOnHomeBehavior">0</integer>

    <!-- Whether or not to skip the brightness ramp when the display transitions to STATE_ON. -->
    <bool name="config_skipScreenOnBrightnessRamp">false</bool>

    <!-- Minimum screen brightness setting allowed by the power manager.
         The user is forbidden from setting the brightness below this level. -->
    <integer name="config_screenBrightnessSettingMinimum">10</integer>
+1 −0
Original line number Diff line number Diff line
@@ -1682,6 +1682,7 @@
  <java-symbol type="bool" name="config_enableGeofenceOverlay" />
  <java-symbol type="bool" name="config_enableNetworkLocationOverlay" />
  <java-symbol type="bool" name="config_sf_limitedAlpha" />
  <java-symbol type="bool" name="config_skipScreenOnBrightnessRamp" />
  <java-symbol type="bool" name="config_unplugTurnsOnScreen" />
  <java-symbol type="bool" name="config_usbChargingMessage" />
  <java-symbol type="bool" name="config_allowAutoBrightnessWhileDozing" />
+15 −2
Original line number Diff line number Diff line
@@ -237,6 +237,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;
@@ -247,6 +250,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
    private final int mBrightnessRampRateFast;
    private final int mBrightnessRampRateSlow;

    // Brightness animation ramp flags
    private final boolean mSkipScreenOnBrightnessRamp;

    // The controller for the automatic brightness level.
    private AutomaticBrightnessController mAutomaticBrightnessController;

@@ -310,6 +316,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);
@@ -738,9 +746,11 @@ 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.
        // Skip the animation when the screen is off, suspended, or if configs say otherwise.
        if (!mPendingScreenOff) {
            if (state == Display.STATE_ON || state == Display.STATE_DOZE) {
            boolean skipScreenRamp = mSkipScreenOnBrightnessRamp && mDozing
                    && state == Display.STATE_ON;
            if (state == Display.STATE_ON && !skipScreenRamp || state == Display.STATE_DOZE) {
                animateScreenBrightness(brightness,
                        slowChange ? mBrightnessRampRateSlow : mBrightnessRampRateFast);
            } else {
@@ -798,6 +808,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
            mUnfinishedBusiness = false;
            mCallbacks.releaseSuspendBlocker();
        }

        // Record if dozing for future comparison.
        mDozing = state != Display.STATE_ON;
    }

    @Override