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

Commit 9d914c47 authored by Beverly's avatar Beverly
Browse files

DOZE instead of DOZE_AOD when batterySaver=active

So we don't mistakenly briefly show the AOD UI
when entering AOD with battery saver active.

Test: manual
Fixes: 219030172
Change-Id: Ida3b52a3a091736b8ba2d3ad614662a0ac4724e1
parent b78bf4e4
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -319,9 +319,10 @@ public class DozeLog implements Dumpable {
    /**
     * Appends the doze state that was suppressed to the doze event log
     * @param suppressedState The {@link DozeMachine.State} that was suppressed
     * @param reason what suppressed always on
     */
    public void traceAlwaysOnSuppressed(DozeMachine.State suppressedState) {
        mLogger.logAlwaysOnSuppressed(suppressedState);
    public void traceAlwaysOnSuppressed(DozeMachine.State suppressedState, String reason) {
        mLogger.logAlwaysOnSuppressed(suppressedState, reason);
    }

    /**
+3 −2
Original line number Diff line number Diff line
@@ -267,11 +267,12 @@ class DozeLogger @Inject constructor(
        })
    }

    fun logAlwaysOnSuppressed(state: DozeMachine.State) {
    fun logAlwaysOnSuppressed(state: DozeMachine.State, reason: String) {
        buffer.log(TAG, INFO, {
            str1 = state.name
            str2 = reason
        }, {
            "Always-on state suppressed, suppressed state=$str1"
            "Always-on state suppressed, suppressed state=$str1 reason=$str2"
        })
    }

+7 −2
Original line number Diff line number Diff line
@@ -358,8 +358,13 @@ public class DozeMachine {
            return State.FINISH;
        }
        if (mDozeHost.isAlwaysOnSuppressed() && requestedState.isAlwaysOn()) {
            Log.i(TAG, "Doze is suppressed. Suppressing state: " + requestedState);
            mDozeLog.traceAlwaysOnSuppressed(requestedState);
            Log.i(TAG, "Doze is suppressed by an app. Suppressing state: " + requestedState);
            mDozeLog.traceAlwaysOnSuppressed(requestedState, "app");
            return State.DOZE;
        }
        if (mDozeHost.isPowerSaveActive() && requestedState.isAlwaysOn()) {
            Log.i(TAG, "Doze is suppressed by battery saver. Suppressing state: " + requestedState);
            mDozeLog.traceAlwaysOnSuppressed(requestedState, "batterySaver");
            return State.DOZE;
        }
        if ((mState == State.DOZE_AOD_PAUSED || mState == State.DOZE_AOD_PAUSING
+3 −1
Original line number Diff line number Diff line
@@ -136,6 +136,8 @@ public class DozeService extends DreamService
    @Override
    public void setDozeScreenState(int state) {
        super.setDozeScreenState(state);
        if (mDozeMachine != null) {
            mDozeMachine.onScreenState(state);
        }
    }
}
+4 −0
Original line number Diff line number Diff line
@@ -166,6 +166,8 @@ public class DozeSuppressor implements DozeMachine.Part {
    private DozeHost.Callback mHostCallback = new DozeHost.Callback() {
        @Override
        public void onPowerSaveChanged(boolean active) {
            // handles suppression changes, while DozeMachine#transitionPolicy handles gating
            // transitions to DOZE_AOD
            DozeMachine.State nextState = null;
            if (mDozeHost.isPowerSaveActive()) {
                nextState = DozeMachine.State.DOZE;
@@ -182,6 +184,8 @@ public class DozeSuppressor implements DozeMachine.Part {

        @Override
        public void onAlwaysOnSuppressedChanged(boolean suppressed) {
            // handles suppression changes, while DozeMachine#transitionPolicy handles gating
            // transitions to DOZE_AOD
            final DozeMachine.State nextState;
            if (mConfig.alwaysOnEnabled(UserHandle.USER_CURRENT) && !suppressed) {
                nextState = DozeMachine.State.DOZE_AOD;