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

Commit f0613cda authored by Michael Wright's avatar Michael Wright Committed by android-build-merger
Browse files

Merge "Add config to force display to transition to off after doze" into oc-dr1-dev

am: cb423e42

Change-Id: Ie643ec6a1c917aa2d9364dbc431121f19a8a7e31
parents 4c535d55 cb423e42
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -1132,6 +1132,15 @@ public final class Display {
        return state == STATE_OFF || state == STATE_DOZE_SUSPEND;
    }

    /**
     * Returns true if the display may be in a reduced operating mode while in the
     * specified display power state.
     * @hide
     */
    public static boolean isDozeState(int state) {
        return state == STATE_DOZE || state == STATE_DOZE_SUSPEND;
    }

    /**
     * A mode supported by a given display.
     *
+5 −0
Original line number Diff line number Diff line
@@ -1897,6 +1897,11 @@
         states. -->
    <bool name="config_dozeAlwaysOnDisplayAvailable">false</bool>

    <!-- Whether the display hardware requires we go to the off state before transitioning
         out of any doze states. -->
    <bool name="config_displayTransitionOffAfterDoze">false</bool>


    <!-- Power Management: Specifies whether to decouple the auto-suspend state of the
         device from the display on/off state.

+1 −0
Original line number Diff line number Diff line
@@ -3051,6 +3051,7 @@
  <java-symbol type="bool" name="config_handleVolumeKeysInWindowManager" />
  <java-symbol type="integer" name="config_inCallNotificationVolumeRelative" />
  <java-symbol type="bool" name="config_dozeAlwaysOnDisplayAvailable" />
  <java-symbol type="bool" name="config_displayTransitionOffAfterDoze" />
  <java-symbol type="integer" name="config_storageManagerDaystoRetainDefault" />
  <java-symbol type="string" name="config_headlineFontFamily" />
  <java-symbol type="string" name="config_headlineFontFamilyLight" />
+34 −2
Original line number Diff line number Diff line
@@ -169,6 +169,12 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
    // a stylish color fade animation instead.
    private boolean mColorFadeFadesConfig;

    // True if we need to transition to the off state when coming out of a doze state.
    // Some display hardware will show artifacts (flickers, etc) when transitioning from a doze
    // to a fully on state. In order to hide these, we first transition to off to let the system
    // animate the screen on as it normally would, which is a much smoother experience.
    private boolean mTransitionOffAfterDozeConfig;

    // The pending power request.
    // Initially null until the first call to requestPowerState.
    // Guarded by mLock.
@@ -416,6 +422,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
        mColorFadeFadesConfig = resources.getBoolean(
                com.android.internal.R.bool.config_animateScreenLights);

        mTransitionOffAfterDozeConfig = resources.getBoolean(
                com.android.internal.R.bool.config_displayTransitionOffAfterDoze);

        if (!DEBUG_PRETEND_PROXIMITY_SENSOR_ABSENT) {
            mProximitySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
            if (mProximitySensor != null) {
@@ -885,6 +894,10 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
    }

    private boolean setScreenState(int state) {
        return setScreenState(state, false /*force*/);
    }

    private boolean setScreenState(int state, boolean force) {
        final boolean isOff = (state == Display.STATE_OFF);
        if (mPowerState.getScreenState() != state) {

@@ -895,9 +908,17 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
                    mReportedScreenStateToPolicy = REPORTED_TO_POLICY_SCREEN_TURNING_OFF;
                    blockScreenOff();
                    mWindowManagerPolicy.screenTurningOff(mPendingScreenOffUnblocker);
                    if (force) {
                        // If we're forcing the power state transition then immediately
                        // unblock the screen off event. This keeps the lifecycle consistent,
                        // so WindowManagerPolicy will always see screenTurningOff before
                        // screenTurnedOff, but we don't actually block on them for the state
                        // change.
                        unblockScreenOff();
                    } else {
                        return false;
                    }
                } else if (mPendingScreenOffUnblocker != null) {

                    // Abort doing the state change until screen off is unblocked.
                    return false;
                }
@@ -976,6 +997,17 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
            mPendingScreenOff = false;
        }

        if (mTransitionOffAfterDozeConfig &&
                Display.isDozeState(mPowerState.getScreenState())
                && !Display.isDozeState(target)) {
            setScreenState(Display.STATE_OFF, true /*force*/);
            // Skip the screen off animation and add a black surface to hide the
            // contents of the screen. This will also trigger another power state update so that we
            // end up converging on the target state.
            mColorFadeOffAnimator.end();
            return;
        }

        // If we were in the process of turning off the screen but didn't quite
        // finish.  Then finish up now to prevent a jarring transition back
        // to screen on if we skipped blocking screen on as usual.