diff options
6 files changed, 59 insertions, 59 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipScheduler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipScheduler.java index 9bb383f0b61a..0448d94669ce 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipScheduler.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipScheduler.java @@ -57,11 +57,6 @@ public class PipScheduler { @Nullable private SurfaceControl mPinnedTaskLeash; - // the leash of the original task of the PiP activity; - // used to synchronize app drawings in the multi-activity case - @Nullable - private SurfaceControl mOriginalTaskLeash; - /** * A temporary broadcast receiver to initiate exit PiP via expand. * This will later be modified to be triggered by the PiP menu. @@ -95,10 +90,6 @@ public class PipScheduler { mPinnedTaskLeash = pinnedTaskLeash; } - void setOriginalTaskLeash(SurfaceControl originalTaskLeash) { - mOriginalTaskLeash = originalTaskLeash; - } - void setPipTaskToken(@Nullable WindowContainerToken pipTaskToken) { mPipTaskToken = pipTaskToken; } @@ -133,6 +124,5 @@ public class PipScheduler { void onExitPip() { mPipTaskToken = null; mPinnedTaskLeash = null; - mOriginalTaskLeash = null; } } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTransition.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTransition.java index 7d3bd658d126..6200ea583a48 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTransition.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTransition.java @@ -16,7 +16,6 @@ package com.android.wm.shell.pip2.phone; -import static android.app.ActivityTaskManager.INVALID_TASK_ID; import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; import static android.view.WindowManager.TRANSIT_OPEN; @@ -50,7 +49,7 @@ import com.android.wm.shell.transition.Transitions; public class PipTransition extends PipTransitionController { private static final String TAG = PipTransition.class.getSimpleName(); - private PipScheduler mPipScheduler; + private final PipScheduler mPipScheduler; @Nullable private WindowContainerToken mPipTaskToken; @Nullable @@ -168,14 +167,9 @@ public class PipTransition extends PipTransitionController { } mPipTaskToken = pipChange.getContainer(); - // cache the PiP task token and the relevant leashes + // cache the PiP task token and leash mPipScheduler.setPipTaskToken(mPipTaskToken); mPipScheduler.setPinnedTaskLeash(pipChange.getLeash()); - // check if we entered PiP from a multi-activity task and set the original task leash - final int lastParentTaskId = pipChange.getTaskInfo().lastParentTaskIdBeforePip; - final boolean isSingleActivity = lastParentTaskId == INVALID_TASK_ID; - mPipScheduler.setOriginalTaskLeash(isSingleActivity ? null : - findChangeByTaskId(info, lastParentTaskId).getLeash()); startTransaction.apply(); finishCallback.onTransitionFinished(null); @@ -201,17 +195,6 @@ public class PipTransition extends PipTransitionController { return null; } - @Nullable - private TransitionInfo.Change findChangeByTaskId(TransitionInfo info, int taskId) { - for (TransitionInfo.Change change : info.getChanges()) { - if (change.getTaskInfo() != null - && change.getTaskInfo().taskId == taskId) { - return change; - } - } - return null; - } - private void onExitPip() { mPipTaskToken = null; mPipScheduler.onExitPip(); diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index 24d99387d63c..44b9b8bf9c83 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -1556,9 +1556,15 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A return false; } - // Transition change for the activity moving into a TaskFragment of different bounds. - return newParent.isOrganizedTaskFragment() - && !newParent.getBounds().equals(oldParent.getBounds()); + final boolean isInPip2 = ActivityTaskManagerService.isPip2ExperimentEnabled() + && inPinnedWindowingMode(); + if (!newParent.isOrganizedTaskFragment() && !isInPip2) { + // Parent TaskFragment isn't associated with a TF organizer and we are not in PiP2, + // so do not allow for initializeChangeTransition() on parent changes + return false; + } + // Transition change for the activity moving into TaskFragment of different bounds. + return !newParent.getBounds().equals(oldParent.getBounds()); } @Override diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index 267d148b1ce8..33f61fe9d3e8 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -4625,7 +4625,12 @@ class Task extends TaskFragment { if (topActivity != null) { mTaskSupervisor.mNoAnimActivities.add(topActivity); } - super.setWindowingMode(windowingMode); + + final boolean isPip2ExperimentEnabled = + ActivityTaskManagerService.isPip2ExperimentEnabled(); + if (!isPip2ExperimentEnabled) { + super.setWindowingMode(windowingMode); + } if (currentMode == WINDOWING_MODE_PINNED && topActivity != null) { // Try reparent pinned activity back to its original task after @@ -4634,32 +4639,37 @@ class Task extends TaskFragment { // PiP, we set final windowing mode on the ActivityRecord first and then on its // Task when the exit PiP transition finishes. Meanwhile, the exit transition is // always performed on its original task, reparent immediately in ActivityRecord - // breaks it. - if (topActivity.getLastParentBeforePip() != null) { - // Do not reparent if the pinned task is in removal, indicated by the - // force hidden flag. - if (!isForceHidden()) { - final Task lastParentBeforePip = topActivity.getLastParentBeforePip(); - if (lastParentBeforePip.isAttached()) { - topActivity.reparent(lastParentBeforePip, - lastParentBeforePip.getChildCount() /* top */, - "movePinnedActivityToOriginalTask"); - final DisplayContent dc = topActivity.getDisplayContent(); - if (dc != null && dc.isFixedRotationLaunchingApp(topActivity)) { - // Expanding pip into new rotation, so create a rotation leash - // until the display is rotated. - topActivity.getOrCreateFixedRotationLeash( - topActivity.getPendingTransaction()); - } - lastParentBeforePip.moveToFront("movePinnedActivityToOriginalTask"); - } + // breaks it. Do not reparent if the pinned task is in removal, indicated by the + // force hidden flag. + if (topActivity.getLastParentBeforePip() != null && !isForceHidden() + && topActivity.getLastParentBeforePip().isAttached()) { + // We need to collect the pip activity to allow for screenshots + // to be taken as a part of reparenting. + mTransitionController.collect(topActivity); + + final Task lastParentBeforePip = topActivity.getLastParentBeforePip(); + topActivity.reparent(lastParentBeforePip, + lastParentBeforePip.getChildCount() /* top */, + "movePinnedActivityToOriginalTask"); + final DisplayContent dc = topActivity.getDisplayContent(); + if (dc != null && dc.isFixedRotationLaunchingApp(topActivity)) { + // Expanding pip into new rotation, so create a rotation leash + // until the display is rotated. + topActivity.getOrCreateFixedRotationLeash( + topActivity.getSyncTransaction()); } + lastParentBeforePip.moveToFront("movePinnedActivityToOriginalTask"); + } + if (isPip2ExperimentEnabled) { + super.setWindowingMode(windowingMode); } // Resume app-switches-allowed flag when exiting from pinned mode since // it does not follow the ActivityStarter path. if (topActivity.shouldBeVisible()) { mAtmService.resumeAppSwitches(); } + } else if (isPip2ExperimentEnabled) { + super.setWindowingMode(windowingMode); } if (creating) { diff --git a/services/core/java/com/android/server/wm/TaskOrganizerController.java b/services/core/java/com/android/server/wm/TaskOrganizerController.java index f1481760a5e7..17ab00d64924 100644 --- a/services/core/java/com/android/server/wm/TaskOrganizerController.java +++ b/services/core/java/com/android/server/wm/TaskOrganizerController.java @@ -394,7 +394,7 @@ class TaskOrganizerController extends ITaskOrganizerController.Stub { boolean taskAppearedSent = t.mTaskAppearedSent; if (taskAppearedSent) { if (t.getSurfaceControl() != null) { - t.migrateToNewSurfaceControl(t.getPendingTransaction()); + t.migrateToNewSurfaceControl(t.getSyncTransaction()); } t.mTaskAppearedSent = false; } diff --git a/services/core/java/com/android/server/wm/WindowContainer.java b/services/core/java/com/android/server/wm/WindowContainer.java index 2b77ffffece0..e28262dfbe2f 100644 --- a/services/core/java/com/android/server/wm/WindowContainer.java +++ b/services/core/java/com/android/server/wm/WindowContainer.java @@ -2988,12 +2988,23 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< /** Whether we can start change transition with this window and current display status. */ boolean canStartChangeTransition() { - return !mWmService.mDisableTransitionAnimation && mDisplayContent != null - && getSurfaceControl() != null && !mDisplayContent.inTransition() - && isVisible() && isVisibleRequested() && okToAnimate() - // Pip animation will be handled by PipTaskOrganizer. - && !inPinnedWindowingMode() && getParent() != null - && !getParent().inPinnedWindowingMode(); + if (mWmService.mDisableTransitionAnimation || !okToAnimate()) return false; + + // Change transition only make sense as we go from "visible" to "visible". + if (mDisplayContent == null || getSurfaceControl() == null + || !isVisible() || !isVisibleRequested()) { + return false; + } + + // Make sure display isn't a part of the transition already - needed for legacy transitions. + if (mDisplayContent.inTransition()) return false; + + if (!ActivityTaskManagerService.isPip2ExperimentEnabled()) { + // Screenshots are turned off when PiP is undergoing changes. + return !inPinnedWindowingMode() && getParent() != null + && !getParent().inPinnedWindowingMode(); + } + return true; } /** |