Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java +6 −0 Original line number Diff line number Diff line Loading @@ -614,6 +614,12 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, } private void onEndOfSwipePipToHomeTransition() { if (Transitions.ENABLE_SHELL_TRANSITIONS) { mInSwipePipToHomeTransition = false; mSwipePipToHomeOverlay = null; return; } final Rect destinationBounds = mPipBoundsState.getBounds(); final SurfaceControl swipeToHomeOverlay = mSwipePipToHomeOverlay; final SurfaceControl.Transaction tx = mSurfaceControlTransactionFactory.getTransaction(); Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java +20 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import static com.android.wm.shell.transition.Transitions.TRANSIT_REMOVE_PIP; import android.app.TaskInfo; import android.content.Context; import android.graphics.Matrix; import android.graphics.Rect; import android.os.IBinder; import android.view.Surface; Loading Loading @@ -214,6 +215,25 @@ public class PipTransition extends PipTransitionController { final Rect currentBounds = taskInfo.configuration.windowConfiguration.getBounds(); PipAnimationController.PipTransitionAnimator animator; finishTransaction.setPosition(leash, destinationBounds.left, destinationBounds.top); if (taskInfo.pictureInPictureParams != null && taskInfo.pictureInPictureParams.isAutoEnterEnabled()) { mOneShotAnimationType = ANIM_TYPE_BOUNDS; // PiP menu is attached late in the process here to avoid any artifacts on the leash // caused by addShellRoot when in gesture navigation mode. mPipMenuController.attach(leash); SurfaceControl.Transaction tx = new SurfaceControl.Transaction(); tx.setMatrix(leash, Matrix.IDENTITY_MATRIX, new float[9]) .setPosition(leash, destinationBounds.left, destinationBounds.top) .setWindowCrop(leash, destinationBounds.width(), destinationBounds.height()); startTransaction.merge(tx); startTransaction.apply(); mPipBoundsState.setBounds(destinationBounds); onFinishResize(taskInfo, destinationBounds, TRANSITION_DIRECTION_TO_PIP, tx); sendOnPipTransitionFinished(TRANSITION_DIRECTION_TO_PIP); mFinishCallback = null; return true; } if (mOneShotAnimationType == ANIM_TYPE_BOUNDS) { final Rect sourceHintRect = PipBoundsAlgorithm.getValidSourceHintRect( Loading packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteTransitionCompat.java +27 −5 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import static android.window.TransitionFilter.CONTAINER_ORDER_TOP; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SuppressLint; import android.app.ActivityManager; import android.app.ActivityTaskManager; import android.graphics.Rect; import android.os.IBinder; Loading Loading @@ -122,15 +123,20 @@ public class RemoteTransitionCompat implements Parcelable { // This transition is for opening recents, so recents is on-top. We want to draw // the current going-away task on top of recents, though, so move it to front WindowContainerToken pausingTask = null; SurfaceControl pausingLeash = null; WindowContainerToken pipTask = null; for (int i = info.getChanges().size() - 1; i >= 0; --i) { final TransitionInfo.Change change = info.getChanges().get(i); if (change.getMode() == TRANSIT_CLOSE || change.getMode() == TRANSIT_TO_BACK) { t.setLayer(leashMap.get(change.getLeash()), info.getChanges().size() * 3 - i); if (change.getTaskInfo() != null) { final ActivityManager.RunningTaskInfo taskInfo = change.getTaskInfo(); if (taskInfo != null) { pausingTask = change.getTaskInfo().token; } if (taskInfo.pictureInPictureParams != null && taskInfo.pictureInPictureParams.isAutoEnterEnabled()) { pipTask = change.getTaskInfo().token; } } } // Also make all the wallpapers opaque since we want the visible from the start Loading @@ -138,7 +144,7 @@ public class RemoteTransitionCompat implements Parcelable { t.setAlpha(wallpapers[i].leash.mSurfaceControl, 1); } t.apply(); mRecentsSession.setup(controller, info, finishedCallback, pausingTask, mRecentsSession.setup(controller, info, finishedCallback, pausingTask, pipTask, leashMap, mToken); recents.onAnimationStart(mRecentsSession, apps, wallpapers, new Rect(0, 0, 0, 0), new Rect()); Loading Loading @@ -183,14 +189,17 @@ public class RemoteTransitionCompat implements Parcelable { private RecentsAnimationControllerCompat mWrapped = null; private IRemoteTransitionFinishedCallback mFinishCB = null; private WindowContainerToken mPausingTask = null; private WindowContainerToken mPipTask = null; private TransitionInfo mInfo = null; private SurfaceControl mOpeningLeash = null; private ArrayMap<SurfaceControl, SurfaceControl> mLeashMap = null; private PictureInPictureSurfaceTransaction mPipTransaction = null; private IBinder mTransition = null; void setup(RecentsAnimationControllerCompat wrapped, TransitionInfo info, IRemoteTransitionFinishedCallback finishCB, WindowContainerToken pausingTask, ArrayMap<SurfaceControl, SurfaceControl> leashMap, IBinder transition) { WindowContainerToken pipTask, ArrayMap<SurfaceControl, SurfaceControl> leashMap, IBinder transition) { if (mInfo != null) { throw new IllegalStateException("Trying to run a new recents animation while" + " recents is already active."); Loading @@ -199,6 +208,7 @@ public class RemoteTransitionCompat implements Parcelable { mInfo = info; mFinishCB = finishCB; mPausingTask = pausingTask; mPipTask = pipTask; mLeashMap = leashMap; mTransition = transition; } Loading Loading @@ -257,6 +267,7 @@ public class RemoteTransitionCompat implements Parcelable { @Override public void setFinishTaskTransaction(int taskId, PictureInPictureSurfaceTransaction finishTransaction, SurfaceControl overlay) { mPipTransaction = finishTransaction; if (mWrapped != null) { mWrapped.setFinishTaskTransaction(taskId, finishTransaction, overlay); } Loading Loading @@ -288,8 +299,19 @@ public class RemoteTransitionCompat implements Parcelable { t.setAlpha(mOpeningLeash, 1.f); t.apply(); } if (mPipTask != null && mPipTransaction != null) { final SurfaceControl.Transaction t = new SurfaceControl.Transaction(); t.show(mInfo.getChange(mPipTask).getLeash()); PictureInPictureSurfaceTransaction.apply(mPipTransaction, mInfo.getChange(mPipTask).getLeash(), t); mPipTask = null; mPipTransaction = null; mFinishCB.onTransitionFinished(null /* wct */, t); } else { mFinishCB.onTransitionFinished(null /* wct */, null /* sct */); } } } catch (RemoteException e) { Log.e("RemoteTransitionCompat", "Failed to call animation finish callback", e); } Loading services/core/java/com/android/server/wm/ActivityRecord.java +2 −1 Original line number Diff line number Diff line Loading @@ -5274,7 +5274,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A // returns. Just need to confirm this reasoning makes sense. final boolean deferHidingClient = canEnterPictureInPicture && !isState(STARTED, STOPPING, STOPPED, PAUSED); if (deferHidingClient && pictureInPictureArgs.isAutoEnterEnabled()) { if (!mAtmService.getTransitionController().isShellTransitionsEnabled() && deferHidingClient && pictureInPictureArgs.isAutoEnterEnabled()) { // Go ahead and just put the activity in pip if it supports auto-pip. mAtmService.enterPictureInPictureMode(this, pictureInPictureArgs); return; Loading services/core/java/com/android/server/wm/Task.java +3 −3 Original line number Diff line number Diff line Loading @@ -3365,9 +3365,9 @@ class Task extends TaskFragment { private @Nullable PictureInPictureParams getPictureInPictureParams(Task top) { if (top == null) return null; final ActivityRecord topVisibleActivity = top.getTopVisibleActivity(); return (topVisibleActivity == null || topVisibleActivity.pictureInPictureArgs.empty()) ? null : new PictureInPictureParams(topVisibleActivity.pictureInPictureArgs); final ActivityRecord topMostActivity = top.getTopMostActivity(); return (topMostActivity == null || topMostActivity.pictureInPictureArgs.empty()) ? null : new PictureInPictureParams(topMostActivity.pictureInPictureArgs); } /** Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java +6 −0 Original line number Diff line number Diff line Loading @@ -614,6 +614,12 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, } private void onEndOfSwipePipToHomeTransition() { if (Transitions.ENABLE_SHELL_TRANSITIONS) { mInSwipePipToHomeTransition = false; mSwipePipToHomeOverlay = null; return; } final Rect destinationBounds = mPipBoundsState.getBounds(); final SurfaceControl swipeToHomeOverlay = mSwipePipToHomeOverlay; final SurfaceControl.Transaction tx = mSurfaceControlTransactionFactory.getTransaction(); Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java +20 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import static com.android.wm.shell.transition.Transitions.TRANSIT_REMOVE_PIP; import android.app.TaskInfo; import android.content.Context; import android.graphics.Matrix; import android.graphics.Rect; import android.os.IBinder; import android.view.Surface; Loading Loading @@ -214,6 +215,25 @@ public class PipTransition extends PipTransitionController { final Rect currentBounds = taskInfo.configuration.windowConfiguration.getBounds(); PipAnimationController.PipTransitionAnimator animator; finishTransaction.setPosition(leash, destinationBounds.left, destinationBounds.top); if (taskInfo.pictureInPictureParams != null && taskInfo.pictureInPictureParams.isAutoEnterEnabled()) { mOneShotAnimationType = ANIM_TYPE_BOUNDS; // PiP menu is attached late in the process here to avoid any artifacts on the leash // caused by addShellRoot when in gesture navigation mode. mPipMenuController.attach(leash); SurfaceControl.Transaction tx = new SurfaceControl.Transaction(); tx.setMatrix(leash, Matrix.IDENTITY_MATRIX, new float[9]) .setPosition(leash, destinationBounds.left, destinationBounds.top) .setWindowCrop(leash, destinationBounds.width(), destinationBounds.height()); startTransaction.merge(tx); startTransaction.apply(); mPipBoundsState.setBounds(destinationBounds); onFinishResize(taskInfo, destinationBounds, TRANSITION_DIRECTION_TO_PIP, tx); sendOnPipTransitionFinished(TRANSITION_DIRECTION_TO_PIP); mFinishCallback = null; return true; } if (mOneShotAnimationType == ANIM_TYPE_BOUNDS) { final Rect sourceHintRect = PipBoundsAlgorithm.getValidSourceHintRect( Loading
packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteTransitionCompat.java +27 −5 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import static android.window.TransitionFilter.CONTAINER_ORDER_TOP; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SuppressLint; import android.app.ActivityManager; import android.app.ActivityTaskManager; import android.graphics.Rect; import android.os.IBinder; Loading Loading @@ -122,15 +123,20 @@ public class RemoteTransitionCompat implements Parcelable { // This transition is for opening recents, so recents is on-top. We want to draw // the current going-away task on top of recents, though, so move it to front WindowContainerToken pausingTask = null; SurfaceControl pausingLeash = null; WindowContainerToken pipTask = null; for (int i = info.getChanges().size() - 1; i >= 0; --i) { final TransitionInfo.Change change = info.getChanges().get(i); if (change.getMode() == TRANSIT_CLOSE || change.getMode() == TRANSIT_TO_BACK) { t.setLayer(leashMap.get(change.getLeash()), info.getChanges().size() * 3 - i); if (change.getTaskInfo() != null) { final ActivityManager.RunningTaskInfo taskInfo = change.getTaskInfo(); if (taskInfo != null) { pausingTask = change.getTaskInfo().token; } if (taskInfo.pictureInPictureParams != null && taskInfo.pictureInPictureParams.isAutoEnterEnabled()) { pipTask = change.getTaskInfo().token; } } } // Also make all the wallpapers opaque since we want the visible from the start Loading @@ -138,7 +144,7 @@ public class RemoteTransitionCompat implements Parcelable { t.setAlpha(wallpapers[i].leash.mSurfaceControl, 1); } t.apply(); mRecentsSession.setup(controller, info, finishedCallback, pausingTask, mRecentsSession.setup(controller, info, finishedCallback, pausingTask, pipTask, leashMap, mToken); recents.onAnimationStart(mRecentsSession, apps, wallpapers, new Rect(0, 0, 0, 0), new Rect()); Loading Loading @@ -183,14 +189,17 @@ public class RemoteTransitionCompat implements Parcelable { private RecentsAnimationControllerCompat mWrapped = null; private IRemoteTransitionFinishedCallback mFinishCB = null; private WindowContainerToken mPausingTask = null; private WindowContainerToken mPipTask = null; private TransitionInfo mInfo = null; private SurfaceControl mOpeningLeash = null; private ArrayMap<SurfaceControl, SurfaceControl> mLeashMap = null; private PictureInPictureSurfaceTransaction mPipTransaction = null; private IBinder mTransition = null; void setup(RecentsAnimationControllerCompat wrapped, TransitionInfo info, IRemoteTransitionFinishedCallback finishCB, WindowContainerToken pausingTask, ArrayMap<SurfaceControl, SurfaceControl> leashMap, IBinder transition) { WindowContainerToken pipTask, ArrayMap<SurfaceControl, SurfaceControl> leashMap, IBinder transition) { if (mInfo != null) { throw new IllegalStateException("Trying to run a new recents animation while" + " recents is already active."); Loading @@ -199,6 +208,7 @@ public class RemoteTransitionCompat implements Parcelable { mInfo = info; mFinishCB = finishCB; mPausingTask = pausingTask; mPipTask = pipTask; mLeashMap = leashMap; mTransition = transition; } Loading Loading @@ -257,6 +267,7 @@ public class RemoteTransitionCompat implements Parcelable { @Override public void setFinishTaskTransaction(int taskId, PictureInPictureSurfaceTransaction finishTransaction, SurfaceControl overlay) { mPipTransaction = finishTransaction; if (mWrapped != null) { mWrapped.setFinishTaskTransaction(taskId, finishTransaction, overlay); } Loading Loading @@ -288,8 +299,19 @@ public class RemoteTransitionCompat implements Parcelable { t.setAlpha(mOpeningLeash, 1.f); t.apply(); } if (mPipTask != null && mPipTransaction != null) { final SurfaceControl.Transaction t = new SurfaceControl.Transaction(); t.show(mInfo.getChange(mPipTask).getLeash()); PictureInPictureSurfaceTransaction.apply(mPipTransaction, mInfo.getChange(mPipTask).getLeash(), t); mPipTask = null; mPipTransaction = null; mFinishCB.onTransitionFinished(null /* wct */, t); } else { mFinishCB.onTransitionFinished(null /* wct */, null /* sct */); } } } catch (RemoteException e) { Log.e("RemoteTransitionCompat", "Failed to call animation finish callback", e); } Loading
services/core/java/com/android/server/wm/ActivityRecord.java +2 −1 Original line number Diff line number Diff line Loading @@ -5274,7 +5274,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A // returns. Just need to confirm this reasoning makes sense. final boolean deferHidingClient = canEnterPictureInPicture && !isState(STARTED, STOPPING, STOPPED, PAUSED); if (deferHidingClient && pictureInPictureArgs.isAutoEnterEnabled()) { if (!mAtmService.getTransitionController().isShellTransitionsEnabled() && deferHidingClient && pictureInPictureArgs.isAutoEnterEnabled()) { // Go ahead and just put the activity in pip if it supports auto-pip. mAtmService.enterPictureInPictureMode(this, pictureInPictureArgs); return; Loading
services/core/java/com/android/server/wm/Task.java +3 −3 Original line number Diff line number Diff line Loading @@ -3365,9 +3365,9 @@ class Task extends TaskFragment { private @Nullable PictureInPictureParams getPictureInPictureParams(Task top) { if (top == null) return null; final ActivityRecord topVisibleActivity = top.getTopVisibleActivity(); return (topVisibleActivity == null || topVisibleActivity.pictureInPictureArgs.empty()) ? null : new PictureInPictureParams(topVisibleActivity.pictureInPictureArgs); final ActivityRecord topMostActivity = top.getTopMostActivity(); return (topMostActivity == null || topMostActivity.pictureInPictureArgs.empty()) ? null : new PictureInPictureParams(topMostActivity.pictureInPictureArgs); } /** Loading