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

Commit 26994f4d authored by Evan Rosky's avatar Evan Rosky Committed by Android (Google) Code Review
Browse files

Merge "Always report keyguard-going-away even if empty" into udc-dev

parents f5a5d248 e6b3aa3d
Loading
Loading
Loading
Loading
+19 −3
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.wm.shell.transition;
import static android.view.WindowManager.TRANSIT_CHANGE;
import static android.view.WindowManager.TRANSIT_CLOSE;
import static android.view.WindowManager.TRANSIT_FIRST_CUSTOM;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY;
import static android.view.WindowManager.TRANSIT_KEYGUARD_UNOCCLUDE;
import static android.view.WindowManager.TRANSIT_OPEN;
import static android.view.WindowManager.TRANSIT_SLEEP;
@@ -541,9 +542,7 @@ public class Transitions implements RemoteCallable<Transitions> {
            }
        }

        // Allow to notify keyguard un-occluding state to KeyguardService, which can happen while
        // screen-off, so there might no visibility change involved.
        if (info.getRootCount() == 0 && info.getType() != TRANSIT_KEYGUARD_UNOCCLUDE) {
        if (info.getRootCount() == 0 && !alwaysReportToKeyguard(info)) {
            // No root-leashes implies that the transition is empty/no-op, so just do
            // housekeeping and return.
            ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, "No transition roots (%s): %s",
@@ -589,6 +588,23 @@ public class Transitions implements RemoteCallable<Transitions> {
        processReadyQueue();
    }

    /**
     * Some transitions we always need to report to keyguard even if they are empty.
     * TODO (b/274954192): Remove this once keyguard dispatching moves to Shell.
     */
    private static boolean alwaysReportToKeyguard(TransitionInfo info) {
        // occlusion status of activities can change while screen is off so there will be no
        // visibility change but we still need keyguardservice to be notified.
        if (info.getType() == TRANSIT_KEYGUARD_UNOCCLUDE) return true;

        // It's possible for some activities to stop with bad timing (esp. since we can't yet
        // queue activity transitions initiated by apps) that results in an empty transition for
        // keyguard going-away. In general, we should should always report Keyguard-going-away.
        if ((info.getFlags() & TRANSIT_FLAG_KEYGUARD_GOING_AWAY) != 0) return true;

        return false;
    }

    void processReadyQueue() {
        if (mReadyTransitions.isEmpty()) {
            // Check if idle.
+8 −1
Original line number Diff line number Diff line
@@ -38,9 +38,16 @@ public class TransitionInfoBuilder {

    public TransitionInfoBuilder(@WindowManager.TransitionType int type,
            @WindowManager.TransitionFlags int flags) {
        this(type, flags, false /* asNoOp */);
    }

    public TransitionInfoBuilder(@WindowManager.TransitionType int type,
            @WindowManager.TransitionFlags int flags, boolean asNoOp) {
        mInfo = new TransitionInfo(type, flags);
        if (!asNoOp) {
            mInfo.addRootLeash(DISPLAY_ID, createMockSurface(true /* valid */), 0, 0);
        }
    }

    public TransitionInfoBuilder addChange(@WindowManager.TransitionType int mode,
            @TransitionInfo.ChangeFlags int flags, ActivityManager.RunningTaskInfo taskInfo) {
+19 −0
Original line number Diff line number Diff line
@@ -1039,6 +1039,25 @@ public class ShellTransitionTests extends ShellTestCase {
        verify(observer, times(0)).onTransitionFinished(eq(transitToken3), anyBoolean());
    }

    @Test
    public void testEmptyTransitionStillReportsKeyguardGoingAway() {
        Transitions transitions = createTestTransitions();
        transitions.replaceDefaultHandlerForTest(mDefaultHandler);

        IBinder transitToken = new Binder();
        transitions.requestStartTransition(transitToken,
                new TransitionRequestInfo(TRANSIT_OPEN, null /* trigger */, null /* remote */));

        // Make a no-op transition
        TransitionInfo info = new TransitionInfoBuilder(
                TRANSIT_OPEN, TRANSIT_FLAG_KEYGUARD_GOING_AWAY, true /* noOp */).build();
        transitions.onTransitionReady(transitToken, info, mock(SurfaceControl.Transaction.class),
                mock(SurfaceControl.Transaction.class));

        // If keyguard-going-away flag set, then it shouldn't be aborted.
        assertEquals(1, mDefaultHandler.activeCount());
    }

    class ChangeBuilder {
        final TransitionInfo.Change mChange;

+11 −0
Original line number Diff line number Diff line
@@ -2690,6 +2690,17 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
                        mInteractionJankMonitor.end(CUJ_LOCKSCREEN_UNLOCK_ANIMATION);
                        return;
                    }
                    if (apps == null || apps.length == 0) {
                        Slog.e(TAG, "Keyguard exit without a corresponding app to show.");
                        try {
                            finishedCallback.onAnimationFinished();
                        } catch (RemoteException e) {
                            Slog.e(TAG, "RemoteException");
                        } finally {
                            mInteractionJankMonitor.end(CUJ_LOCKSCREEN_UNLOCK_ANIMATION);
                        }
                        return;
                    }

                    // TODO(bc-unlock): Sample animation, just to apply alpha animation on the app.
                    final SyncRtSurfaceTransactionApplier applier =