Ensure TaskOrganizer works for newly created pinned stack
Steps to reproduce the bug:
- Restart the device
- Open Duo app and make a call
- When in call, try entering PiP
Duo application contains multiple activities and we create a new stack
from its top activity when moving it to pinned mode. This newly created
stack does not carry on the existing PictureInPictureParams, nor it is
marked as visible. Therefore, no onTaskAppeared would be sent to the
task organizer.
Also in this change:
- Removed aspectRatio and sourceHintBounds used to be passed into
RootWindowContainer#moveActivityToPinnedStack, they are used in
moveActivityToPinnedStack and one should refer to the
PictureInPictureParams set on ActivityRecord
- Added a null check for existing token when onTaskInfoChanged is
invoked in PipTaskOrganizer, it should be a fatal error that
onTaskInfoChanged is called ahead of onTaskAppeared
Bug: 152933995
Test: manually enter/exit PiP mode for Duo app
Test: atest RootActivityContainerTests
Test: atest ActivityRecordTests
Change-Id: Ifa9ad8768ba47ce043b8dd86cadc729931edcb14
diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
index c253cd2..08683ca 100644
--- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
+++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
@@ -4095,11 +4095,8 @@
r.setPictureInPictureParams(params);
final float aspectRatio = r.pictureInPictureArgs.getAspectRatio();
final List<RemoteAction> actions = r.pictureInPictureArgs.getActions();
- // Adjust the source bounds by the insets for the transition down
- final Rect sourceBounds = new Rect(
- r.pictureInPictureArgs.getSourceRectHint());
mRootWindowContainer.moveActivityToPinnedStack(
- r, sourceBounds, aspectRatio, "enterPictureInPictureMode");
+ r, "enterPictureInPictureMode");
final ActivityStack stack = r.getRootTask();
stack.setPictureInPictureAspectRatio(aspectRatio);
stack.setPictureInPictureActions(actions);