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

Commit 5181a70b authored by Hongwei Wang's avatar Hongwei Wang
Browse files

Dismiss keyguard if entering PiP from lock screen

If Activity claims showWhenLocked ability and tries to enter PiP from
lock screen, we should start the entering PiP process after the keyguard
is dismissed. This is to align with the behavior in PiP1.

Flag: com.android.wm.shell.enable_pip2
Bug: 379758804
Test: atest --iteration 10 KeyguardLockedTests#testEnterPipOverKeyguard
Change-Id: I4bf6280f04dba06a22c8a71fab9037d484bf83a0
parent 542b26c3
Loading
Loading
Loading
Loading
+37 −24
Original line number Diff line number Diff line
@@ -3853,8 +3853,9 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        }

        if (isPip2ExperimentEnabled()) {
            // If PiP2 flag is on and request to enter PiP comes in,
            // we request a direct transition TRANSIT_PIP from Shell to get the right entry bounds.
            final Runnable enterPipRunnable = () -> {
                // If PiP2 flag is on and request to enter PiP comes in, we request a direct
                // transition TRANSIT_PIP from Shell to get the right entry bounds.
                // So PiP activity isn't moved to a pinned task until after
                // Shell calls back into Core with the entry bounds to be applied with startWCT.
                final Transition enterPipTransition = new Transition(TRANSIT_PIP,
@@ -3863,20 +3864,32 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
                enterPipTransition.setPipActivity(r);
                r.mAutoEnteringPip = isAutoEnter;

            if (r.getTaskFragment() != null && r.getTaskFragment().isEmbeddedWithBoundsOverride()
                    && enterPipTransition != null) {
                if (r.getTaskFragment() != null
                        && r.getTaskFragment().isEmbeddedWithBoundsOverride()) {
                    enterPipTransition.addFlag(FLAG_IN_TASK_WITH_EMBEDDED_ACTIVITY);
                }

                getTransitionController().startCollectOrQueue(enterPipTransition, (deferred) -> {
                    mChainTracker.start("enterPip2", enterPipTransition);
                // Collecting PiP activity explicitly to avoid stopping PiP activity while Shell
                // handles the request; see task supervisor's processStoppingAndFinishingActivities.
                    // Collecting PiP activity explicitly to avoid stopping PiP activity while
                    // Shell handles the request; see task supervisor's
                    // processStoppingAndFinishingActivities.
                    enterPipTransition.collect(r);
                    getTransitionController().requestStartTransition(enterPipTransition,
                            r.getTask(), null /* remoteTransition */, null /* displayChange */);
                    mChainTracker.end();
                });
            };
            if (r.isKeyguardLocked()) {
                mActivityClientController.dismissKeyguard(r.token, new KeyguardDismissCallback() {
                    @Override
                    public void onDismissSucceeded() {
                        enterPipRunnable.run();
                    }
                }, null /* message */);
            } else {
                enterPipRunnable.run();
            }
            return true;
        }