Allow other app enter PiP when exiting current one

When there is an PiP window and another app supports PiP being present,
exiting PiP from one app should trigger the other one entering PiP.

Video: http://recall/-/aaaaaabFQoRHlzixHdtY/cSpUhLRkoyTUP73M5sXXWJ
Bug: 235877477
Test: Follow the reproduce step in bug, see video
Change-Id: Ic6c9f64885b53368b79060aa76894ea6685630c9
This commit is contained in:
Hongwei Wang
2022-07-28 15:57:57 -07:00
parent 57f5c6bcf1
commit c6ec2bf886
2 changed files with 9 additions and 1 deletions

View File

@@ -949,7 +949,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
// Re-set the PIP bounds to none.
mPipBoundsState.setBounds(new Rect());
mPipUiEventLoggerLogger.setTaskInfo(null);
mMainExecutor.executeDelayed(() -> mPipMenuController.detach(), 0);
mPipMenuController.detach();
mLeash = null;
if (info.displayId != Display.DEFAULT_DISPLAY && mOnDisplayIdChangeCallback != null) {

View File

@@ -4440,6 +4440,14 @@ class Task extends TaskFragment {
// transferring the transform on the leash to the task, reset this state once we're
// moving out of pip
setCanAffectSystemUiFlags(true);
// Turn on userLeaveHint so other app can enter PiP mode.
mTaskSupervisor.mUserLeaving = true;
// Allow entering PiP from current top most activity when we are leaving PiP.
final Task topFocused = mRootWindowContainer.getTopDisplayFocusedRootTask();
if (topFocused != null) {
final ActivityRecord ar = topFocused.getTopResumedActivity();
enableEnterPipOnTaskSwitch(ar, null /* toFrontTask */, ar, null /* opts */);
}
mRootWindowContainer.notifyActivityPipModeChanged(this, null);
}
if (likelyResolvedMode == WINDOWING_MODE_PINNED) {