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

Commit c78176d9 authored by Yifei Zhang's avatar Yifei Zhang Committed by Android (Google) Code Review
Browse files

Merge "DisplayManagerInternal: add cancelBlockScreenOn for DisplayOffloadSession" into main

parents 1336fbab 453cbe82
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -740,6 +740,12 @@ public abstract class DisplayManagerInternal {
         */
        void onBlockingScreenOn(Runnable unblocker);

        /**
         * Called while display is turning to screen state other than state ON to notify that any
         * pending work from the previous blockScreenOn call should have been cancelled.
         */
        void cancelBlockScreenOn();

        /** Whether auto brightness update in doze is allowed */
        boolean allowAutoBrightnessInDoze();
    }
@@ -773,6 +779,12 @@ public abstract class DisplayManagerInternal {
         */
        boolean blockScreenOn(Runnable unblocker);

        /**
         * Called while display is turning to screen state other than state ON to notify that any
         * pending work from the previous blockScreenOn call should have been cancelled.
         */
        void cancelBlockScreenOn();

        /**
         * Get the brightness levels used to determine automatic brightness based on lux levels.
         * @param mode The auto-brightness mode
+8 −0
Original line number Diff line number Diff line
@@ -83,6 +83,14 @@ public class DisplayOffloadSessionImpl implements DisplayManagerInternal.Display
        return true;
    }

    @Override
    public void cancelBlockScreenOn() {
        if (mDisplayOffloader == null) {
            return;
        }
        mDisplayOffloader.cancelBlockScreenOn();
    }

    @Override
    public float[] getAutoBrightnessLevels(int mode) {
        if (mode < 0 || mode > AUTO_BRIGHTNESS_MODE_MAX) {
+14 −0
Original line number Diff line number Diff line
@@ -2110,6 +2110,17 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
                Trace.TRACE_TAG_POWER, SCREEN_ON_BLOCKED_BY_DISPLAYOFFLOAD_TRACE_NAME, 0);
    }

    private void cancelUnblockScreenOnByDisplayOffload() {
        if (mDisplayOffloadSession == null) {
            return;
        }
        if (mPendingScreenOnUnblockerByDisplayOffload != null) {
            // Already unblocked.
            return;
        }
        mDisplayOffloadSession.cancelBlockScreenOn();
    }

    private boolean setScreenState(int state, @Display.StateReason int reason) {
        return setScreenState(state, reason, false /*reportOnly*/);
    }
@@ -2126,6 +2137,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
            blockScreenOnByDisplayOffload(mDisplayOffloadSession);
        } else if (!isOn && mScreenTurningOnWasBlockedByDisplayOffload) {
            // No longer turning screen on, so unblock previous screen on blocking immediately.
            if (mFlags.isOffloadSessionCancelBlockScreenOnEnabled()) {
                cancelUnblockScreenOnByDisplayOffload();
            }
            unblockScreenOnByDisplayOffload();
            mScreenTurningOnWasBlockedByDisplayOffload = false;
        }
+10 −0
Original line number Diff line number Diff line
@@ -179,6 +179,11 @@ public class DisplayManagerFlags {
            Flags::offloadDozeOverrideHoldsWakelock
    );

    private final FlagState mOffloadSessionCancelBlockScreenOn =
            new FlagState(
                    Flags.FLAG_OFFLOAD_SESSION_CANCEL_BLOCK_SCREEN_ON,
                    Flags::offloadSessionCancelBlockScreenOn);

    /**
     * @return {@code true} if 'port' is allowed in display layout configuration file.
     */
@@ -352,6 +357,10 @@ public class DisplayManagerFlags {
        return mOffloadDozeOverrideHoldsWakelock.isEnabled();
    }

    public boolean isOffloadSessionCancelBlockScreenOnEnabled() {
        return mOffloadSessionCancelBlockScreenOn.isEnabled();
    }

    /**
     * @return Whether to ignore preferredRefreshRate app request conversion to display mode or not
     */
@@ -399,6 +408,7 @@ public class DisplayManagerFlags {
        pw.println(" " + mIgnoreAppPreferredRefreshRate);
        pw.println(" " + mSynthetic60hzModes);
        pw.println(" " + mOffloadDozeOverrideHoldsWakelock);
        pw.println(" " + mOffloadSessionCancelBlockScreenOn);
    }

    private static class FlagState {
+8 −0
Original line number Diff line number Diff line
@@ -299,3 +299,11 @@ flag {
      purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "offload_session_cancel_block_screen_on"
    namespace: "wear_frameworks"
    description: "Flag for DisplayPowerController to start notifying DisplayOffloadSession about cancelling screen on blocker."
    bug: "331725519"
    is_fixed_read_only: true
}
Loading