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

Commit 115bfefd authored by Nick Chameyev's avatar Nick Chameyev
Browse files

Pass screen turning on reason to KeyguardService

Pass a reason int to onScreenTurningOn
callback of KeyguardService, so we can force
SHOW_WALLPAPER flag to true if the display
is switching.

Bug: 395612286
Flag: EXEMPT trivial change
Test: atest PhoneWindowManagerTests
Change-Id: I3e754282076459cbd9792ef06d35b408000f52eb
parent fc0658ab
Loading
Loading
Loading
Loading
+16 −1
Original line number Original line Diff line number Diff line
@@ -74,10 +74,25 @@ oneway interface IKeyguardService {
     */
     */
    void onFinishedWakingUp();
    void onFinishedWakingUp();


    /**
    * Screen turning on reason: unknown
    */
    const int SCREEN_TURNING_ON_REASON_UNKNOWN = 0;

    /**
     * Screen turning on reason: the screen is turning on because of a display switch,
     * e.g. turning on the opposite screen when unfolding a foldable device
     */
    const int SCREEN_TURNING_ON_REASON_DISPLAY_SWITCH = 1;

    /**
    /**
     * Called when the device screen is turning on.
     * Called when the device screen is turning on.
     * @param reason the reason for the screen turning on, must be one of
     *        IKeyguardService.SCREEN_TURNING_ON_REASON_*
     * @param callback the callback that should executed when SystemUI has finished preparations
     *        for turning on the screen
     */
     */
    void onScreenTurningOn(IKeyguardDrawnCallback callback);
    void onScreenTurningOn(int reason, IKeyguardDrawnCallback callback);


    /**
    /**
     * Called when the screen has actually turned on.
     * Called when the screen has actually turned on.
+8 −7
Original line number Original line Diff line number Diff line
@@ -21,6 +21,7 @@ import android.platform.test.flag.junit.SetFlagsRule
import android.platform.test.flag.junit.SetFlagsRule.DefaultInitValueType.DEVICE_DEFAULT
import android.platform.test.flag.junit.SetFlagsRule.DefaultInitValueType.DEVICE_DEFAULT
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import androidx.test.filters.SmallTest
import com.android.internal.policy.IKeyguardService.SCREEN_TURNING_ON_REASON_UNKNOWN
import com.android.systemui.Flags
import com.android.systemui.Flags
import com.android.systemui.SysuiTestCase
import com.android.systemui.SysuiTestCase
import com.android.systemui.unfold.FoldAodAnimationController
import com.android.systemui.unfold.FoldAodAnimationController
@@ -36,9 +37,9 @@ import org.junit.runner.RunWith
import org.mockito.ArgumentCaptor
import org.mockito.ArgumentCaptor
import org.mockito.Captor
import org.mockito.Captor
import org.mockito.Mock
import org.mockito.Mock
import org.mockito.Mockito.`when`
import org.mockito.Mockito.never
import org.mockito.Mockito.never
import org.mockito.Mockito.verify
import org.mockito.Mockito.verify
import org.mockito.Mockito.`when`
import org.mockito.MockitoAnnotations
import org.mockito.MockitoAnnotations
import java.util.Optional
import java.util.Optional


@@ -83,7 +84,7 @@ class ScreenOnCoordinatorTest : SysuiTestCase() {


    @Test
    @Test
    fun testUnfoldTransitionEnabledDrawnTasksReady_onScreenTurningOn_callsDrawnCallback() {
    fun testUnfoldTransitionEnabledDrawnTasksReady_onScreenTurningOn_callsDrawnCallback() {
        screenOnCoordinator.onScreenTurningOn(runnable)
        screenOnCoordinator.onScreenTurningOn(reason = SCREEN_TURNING_ON_REASON_UNKNOWN, runnable)


        onUnfoldOverlayReady()
        onUnfoldOverlayReady()
        onFoldAodReady()
        onFoldAodReady()
@@ -95,7 +96,7 @@ class ScreenOnCoordinatorTest : SysuiTestCase() {


    @Test
    @Test
    fun testTasksReady_onScreenTurningOnAndTurnedOnEventsCalledTogether_callsDrawnCallback() {
    fun testTasksReady_onScreenTurningOnAndTurnedOnEventsCalledTogether_callsDrawnCallback() {
        screenOnCoordinator.onScreenTurningOn(runnable)
        screenOnCoordinator.onScreenTurningOn(reason = SCREEN_TURNING_ON_REASON_UNKNOWN, runnable)
        screenOnCoordinator.onScreenTurnedOn()
        screenOnCoordinator.onScreenTurnedOn()


        onUnfoldOverlayReady()
        onUnfoldOverlayReady()
@@ -108,7 +109,7 @@ class ScreenOnCoordinatorTest : SysuiTestCase() {


    @Test
    @Test
    fun testTasksReady_onScreenTurnedOnAndTurnedOffBeforeCompletion_doesNotCallDrawnCallback() {
    fun testTasksReady_onScreenTurnedOnAndTurnedOffBeforeCompletion_doesNotCallDrawnCallback() {
        screenOnCoordinator.onScreenTurningOn(runnable)
        screenOnCoordinator.onScreenTurningOn(reason = SCREEN_TURNING_ON_REASON_UNKNOWN, runnable)
        screenOnCoordinator.onScreenTurnedOn()
        screenOnCoordinator.onScreenTurnedOn()
        screenOnCoordinator.onScreenTurnedOff()
        screenOnCoordinator.onScreenTurnedOff()


@@ -129,7 +130,7 @@ class ScreenOnCoordinatorTest : SysuiTestCase() {
            Optional.empty(),
            Optional.empty(),
            testHandler
            testHandler
        )
        )
        screenOnCoordinator.onScreenTurningOn(runnable)
        screenOnCoordinator.onScreenTurningOn(reason = SCREEN_TURNING_ON_REASON_UNKNOWN, runnable)
        waitHandlerIdle()
        waitHandlerIdle()


        // Should be called when only keyguard drawn
        // Should be called when only keyguard drawn
@@ -143,7 +144,7 @@ class ScreenOnCoordinatorTest : SysuiTestCase() {
                Optional.empty(),
                Optional.empty(),
                testHandler
                testHandler
        )
        )
        screenOnCoordinator.onScreenTurningOn(runnable)
        screenOnCoordinator.onScreenTurningOn(reason = SCREEN_TURNING_ON_REASON_UNKNOWN, runnable)


        // Never called as the main handler didn't schedule it yet.
        // Never called as the main handler didn't schedule it yet.
        verify(runnable, never()).run()
        verify(runnable, never()).run()
@@ -157,7 +158,7 @@ class ScreenOnCoordinatorTest : SysuiTestCase() {
                Optional.empty(),
                Optional.empty(),
                testHandler
                testHandler
        )
        )
        screenOnCoordinator.onScreenTurningOn(runnable)
        screenOnCoordinator.onScreenTurningOn(reason = SCREEN_TURNING_ON_REASON_UNKNOWN, runnable)
        // No need to wait for the handler to be idle, as it shouldn't be used
        // No need to wait for the handler to be idle, as it shouldn't be used
        // waitHandlerIdle()
        // waitHandlerIdle()


+1 −1
Original line number Original line Diff line number Diff line
@@ -53,7 +53,7 @@ constructor(
     * called on a binder thread from [com.android.systemui.keyguard.KeyguardService].
     * called on a binder thread from [com.android.systemui.keyguard.KeyguardService].
     */
     */
    @BinderThread
    @BinderThread
    fun onScreenTurningOn(onDrawn: Runnable) {
    fun onScreenTurningOn(reason: Int, onDrawn: Runnable) {
        Trace.beginSection("ScreenOnCoordinator#onScreenTurningOn")
        Trace.beginSection("ScreenOnCoordinator#onScreenTurningOn")


        pendingTasks.reset()
        pendingTasks.reset()
+2 −2
Original line number Original line Diff line number Diff line
@@ -549,7 +549,7 @@ public class KeyguardService extends Service {
        }
        }


        @Override // Binder interface
        @Override // Binder interface
        public void onScreenTurningOn(IKeyguardDrawnCallback callback) {
        public void onScreenTurningOn(int reason, IKeyguardDrawnCallback callback) {
            trace("onScreenTurningOn");
            trace("onScreenTurningOn");
            Trace.beginSection("KeyguardService.mBinder#onScreenTurningOn");
            Trace.beginSection("KeyguardService.mBinder#onScreenTurningOn");
            checkPermission();
            checkPermission();
@@ -563,7 +563,7 @@ public class KeyguardService extends Service {
            Trace.beginAsyncSection(onDrawWaitingTraceTag, traceCookie);
            Trace.beginAsyncSection(onDrawWaitingTraceTag, traceCookie);


            // Ensure the drawn callback is only ever called once
            // Ensure the drawn callback is only ever called once
            mScreenOnCoordinator.onScreenTurningOn(new Runnable() {
            mScreenOnCoordinator.onScreenTurningOn(reason, new Runnable() {
                boolean mInvoked;
                boolean mInvoked;
                @Override
                @Override
                public void run() {
                public void run() {
+6 −1
Original line number Original line Diff line number Diff line
@@ -89,6 +89,8 @@ import static android.view.WindowManager.LayoutParams.isSystemAlertWindowType;
import static android.view.WindowManagerGlobal.ADD_OKAY;
import static android.view.WindowManagerGlobal.ADD_OKAY;
import static android.view.WindowManagerGlobal.ADD_PERMISSION_DENIED;
import static android.view.WindowManagerGlobal.ADD_PERMISSION_DENIED;
import static android.view.contentprotection.flags.Flags.createAccessibilityOverlayAppOpEnabled;
import static android.view.contentprotection.flags.Flags.createAccessibilityOverlayAppOpEnabled;
import static com.android.internal.policy.IKeyguardService.SCREEN_TURNING_ON_REASON_UNKNOWN;
import static com.android.internal.policy.IKeyguardService.SCREEN_TURNING_ON_REASON_DISPLAY_SWITCH;


import static com.android.hardware.input.Flags.enableNew25q2Keycodes;
import static com.android.hardware.input.Flags.enableNew25q2Keycodes;
import static com.android.server.policy.SingleKeyGestureEvent.ACTION_CANCEL;
import static com.android.server.policy.SingleKeyGestureEvent.ACTION_CANCEL;
@@ -5636,7 +5638,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    mHandler.removeMessages(MSG_KEYGUARD_DRAWN_TIMEOUT);
                    mHandler.removeMessages(MSG_KEYGUARD_DRAWN_TIMEOUT);
                    mHandler.sendEmptyMessageDelayed(MSG_KEYGUARD_DRAWN_TIMEOUT,
                    mHandler.sendEmptyMessageDelayed(MSG_KEYGUARD_DRAWN_TIMEOUT,
                            getKeyguardDrawnTimeout());
                            getKeyguardDrawnTimeout());
                    mKeyguardDelegate.onScreenTurningOn(mKeyguardDrawnCallback);
                    final int reason = mDefaultDisplayPolicy.isDisplaySwitching()
                            ? SCREEN_TURNING_ON_REASON_DISPLAY_SWITCH
                            : SCREEN_TURNING_ON_REASON_UNKNOWN;
                    mKeyguardDelegate.onScreenTurningOn(reason, mKeyguardDrawnCallback);
                } else {
                } else {
                    if (DEBUG_WAKEUP) Slog.d(TAG,
                    if (DEBUG_WAKEUP) Slog.d(TAG,
                            "null mKeyguardDelegate: setting mKeyguardDrawComplete.");
                            "null mKeyguardDelegate: setting mKeyguardDrawComplete.");
Loading