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

Commit abade65a authored by Lucas Silva's avatar Lucas Silva Committed by Android (Google) Code Review
Browse files

Merge "Allow dream to timeout in preview mode" into main

parents cb8302bf 39aa2a5c
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -263,6 +263,7 @@ public class DreamService extends Service implements Window.Callback {
    private boolean mCanDoze;
    private boolean mDozing;
    private boolean mWindowless;
    private boolean mPreviewMode;
    private int mDozeScreenState = Display.STATE_UNKNOWN;
    private int mDozeScreenBrightness = PowerManager.BRIGHTNESS_DEFAULT;

@@ -647,12 +648,13 @@ public class DreamService extends Service implements Window.Callback {
    }

    /**
     * Marks this dream as keeping the screen bright while dreaming.
     * Marks this dream as keeping the screen bright while dreaming. In preview mode, the screen
     * is always allowed to dim and overrides the value specified here.
     *
     * @param screenBright True to keep the screen bright while dreaming.
     */
    public void setScreenBright(boolean screenBright) {
        if (mScreenBright != screenBright) {
        if (mScreenBright != screenBright && !mPreviewMode) {
            mScreenBright = screenBright;
            int flag = WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
            applyWindowFlags(mScreenBright ? flag : 0, flag);
@@ -661,7 +663,7 @@ public class DreamService extends Service implements Window.Callback {

    /**
     * Returns whether this dream keeps the screen bright while dreaming.
     * Defaults to false, allowing the screen to dim if necessary.
     * Defaults to true, preventing the screen from dimming.
     *
     * @see #setScreenBright(boolean)
     */
@@ -1280,6 +1282,11 @@ public class DreamService extends Service implements Window.Callback {

        mDreamToken = dreamToken;
        mCanDoze = canDoze;
        mPreviewMode = isPreviewMode;
        if (mPreviewMode) {
            // Allow screen to dim when in preview mode.
            mScreenBright = false;
        }
        // This is not a security check to prevent malicious dreams but a guard rail to stop
        // third-party dreams from being windowless and not working well as a result.
        if (mWindowless && !mCanDoze && !isCallerSystemUi()) {