From 95c307f8adbb8f9c261ae8b5d44dcc78808b6c94 Mon Sep 17 00:00:00 2001 From: Hongwei Wang Date: Wed, 27 May 2020 11:31:40 -0700 Subject: [PATCH] No onMultiWindowModeChanged callback from split to PiP When entering PiP from split-screen, there should be exact one onPictureInPictureModeChanged callback with zero onMultiWindowModeChanged since the multi-window mode is not changed. When the stack is nested, we reparent the to-be-pinned stack to the display area and later on set the stack windowing mode onto ActivityRecord, which ends up WINDOWING_MODE_FULLSCREEN in this case. Therefore, the windowing mode changes from split-screen-secondary to fullscreen and then pinned. And client receives onMultiWindowModeChanged(false), onPictureInPictureModeChanged(true), onMultiWindowModeChanged(true) in sequence. Fixes this by setting the windowing mode prior to re-parenting within RootWindowContainer#moveActivityToPinnedStack Bug: 157172491 Test: manually enter PiP from split screen and verifies lifecycle Change-Id: Idf57235349ed6b78db96a632af9665b6e39edb78 --- .../java/com/android/server/wm/RootWindowContainer.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/RootWindowContainer.java b/services/core/java/com/android/server/wm/RootWindowContainer.java index 0ecde72cc5667..ae5adcae5b9bf 100644 --- a/services/core/java/com/android/server/wm/RootWindowContainer.java +++ b/services/core/java/com/android/server/wm/RootWindowContainer.java @@ -2187,6 +2187,10 @@ class RootWindowContainer extends WindowContainer // up-to-dated pinned stack information on this newly created stack. r.reparent(stack, MAX_VALUE, reason); } + // The intermediate windowing mode to be set on the ActivityRecord later. + // This needs to happen before the re-parenting, otherwise we will always set the + // ActivityRecord to be fullscreen. + final int intermediateWindowingMode = stack.getWindowingMode(); if (stack.getParent() != taskDisplayArea) { // stack is nested, but pinned tasks need to be direct children of their // display area, so reparent. @@ -2195,7 +2199,7 @@ class RootWindowContainer extends WindowContainer // Defer the windowing mode change until after the transition to prevent the activity // from doing work and changing the activity visuals while animating // TODO(task-org): Figure-out more structured way to do this long term. - r.setWindowingMode(stack.getWindowingMode()); + r.setWindowingMode(intermediateWindowingMode); stack.setWindowingMode(WINDOWING_MODE_PINNED); // Reset the state that indicates it can enter PiP while pausing after we've moved it