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

Commit 7adc4773 authored by Yogisha Dixit's avatar Yogisha Dixit Committed by Android (Google) Code Review
Browse files

Merge "Add a content observer for DOZE_SUPPRESSED."

parents c62ab875 b6594def
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -194,6 +194,11 @@ public class AmbientDisplayConfiguration {
        return !TextUtils.isEmpty(ambientDisplayComponent());
    }

    /** {@hide} */
    public boolean dozeSuppressed(int user) {
        return boolSettingDefaultOff(Settings.Secure.SUPPRESS_DOZE, user);
    }

    private boolean alwaysOnDisplayAvailable() {
        return mContext.getResources().getBoolean(R.bool.config_dozeAlwaysOnDisplayAvailable);
    }
+1 −0
Original line number Diff line number Diff line
@@ -118,6 +118,7 @@ public class DozeFactory {
                new DozeWallpaperState(mWallpaperManager, mBiometricUnlockController,
                        mDozeParameters),
                new DozeDockHandler(config, machine, mDockManager),
                new DozeSuppressedHandler(dozeService, config, machine),
                new DozeAuthRemover(dozeService)
        });

+8 −0
Original line number Diff line number Diff line
@@ -266,6 +266,14 @@ public class DozeLog implements Dumpable {
        mLogger.logSensorTriggered(reason);
    }

    /**
     * Appends doze suppressed event to the logs
     * @param suppressedState The {@link DozeMachine.State} that was suppressed
     */
    public void traceDozeSuppressed(DozeMachine.State suppressedState) {
        mLogger.logDozeSuppressed(suppressedState);
    }

    private class SummaryStats {
        private int mCount;

+8 −0
Original line number Diff line number Diff line
@@ -194,6 +194,14 @@ class DozeLogger @Inject constructor(
            "Sensor triggered, type=${reasonToString(int1)}"
        })
    }

    fun logDozeSuppressed(state: DozeMachine.State) {
        buffer.log(TAG, INFO, {
            str1 = state.name
        }, {
            "Doze state suppressed, state=$str1"
        })
    }
}

private const val TAG = "DozeLog"
+9 −0
Original line number Diff line number Diff line
@@ -102,6 +102,10 @@ public class DozeMachine {
            }
        }

        boolean isAlwaysOn() {
            return this == DOZE_AOD || this == DOZE_AOD_DOCKED;
        }

        int screenState(DozeParameters parameters) {
            switch (this) {
                case UNINITIALIZED:
@@ -324,6 +328,11 @@ public class DozeMachine {
        if (mState == State.FINISH) {
            return State.FINISH;
        }
        if (mConfig.dozeSuppressed(UserHandle.USER_CURRENT) && requestedState.isAlwaysOn()) {
            Log.i(TAG, "Doze is suppressed. Suppressing state: " + requestedState);
            mDozeLog.traceDozeSuppressed(requestedState);
            return State.DOZE;
        }
        if ((mState == State.DOZE_AOD_PAUSED || mState == State.DOZE_AOD_PAUSING
                || mState == State.DOZE_AOD || mState == State.DOZE)
                && requestedState == State.DOZE_PULSE_DONE) {
Loading