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

Commit 87f95c5f authored by Nick Chameyev's avatar Nick Chameyev Committed by Android (Google) Code Review
Browse files

Merge "Pass screen turning on reason to KeyguardService" into main

parents f049b97c 115bfefd
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -74,10 +74,25 @@ oneway interface IKeyguardService {
     */
    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.
     * @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.
+8 −7
Original line number 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 androidx.test.ext.junit.runners.AndroidJUnit4
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.SysuiTestCase
import com.android.systemui.unfold.FoldAodAnimationController
@@ -36,9 +37,9 @@ import org.junit.runner.RunWith
import org.mockito.ArgumentCaptor
import org.mockito.Captor
import org.mockito.Mock
import org.mockito.Mockito.`when`
import org.mockito.Mockito.never
import org.mockito.Mockito.verify
import org.mockito.Mockito.`when`
import org.mockito.MockitoAnnotations
import java.util.Optional

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

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

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

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

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

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

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

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

        // Never called as the main handler didn't schedule it yet.
        verify(runnable, never()).run()
@@ -157,7 +158,7 @@ class ScreenOnCoordinatorTest : SysuiTestCase() {
                Optional.empty(),
                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
        // waitHandlerIdle()

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

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

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

            // Ensure the drawn callback is only ever called once
            mScreenOnCoordinator.onScreenTurningOn(new Runnable() {
            mScreenOnCoordinator.onScreenTurningOn(reason, new Runnable() {
                boolean mInvoked;
                @Override
                public void run() {
+6 −1
Original line number 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_PERMISSION_DENIED;
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.server.policy.SingleKeyGestureEvent.ACTION_CANCEL;
@@ -5644,7 +5646,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    mHandler.removeMessages(MSG_KEYGUARD_DRAWN_TIMEOUT);
                    mHandler.sendEmptyMessageDelayed(MSG_KEYGUARD_DRAWN_TIMEOUT,
                            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 {
                    if (DEBUG_WAKEUP) Slog.d(TAG,
                            "null mKeyguardDelegate: setting mKeyguardDrawComplete.");
Loading