diff options
Diffstat (limited to 'libs')
3 files changed, 34 insertions, 8 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/freeform/FreeformTaskTransitionObserver.java b/libs/WindowManager/Shell/src/com/android/wm/shell/freeform/FreeformTaskTransitionObserver.java index f4888fbb2bb9..168f6d79a390 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/freeform/FreeformTaskTransitionObserver.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/freeform/FreeformTaskTransitionObserver.java @@ -98,9 +98,11 @@ public class FreeformTaskTransitionObserver implements Transitions.TransitionObs switch (change.getMode()) { case WindowManager.TRANSIT_OPEN: - case WindowManager.TRANSIT_TO_FRONT: onOpenTransitionReady(change, startT, finishT); break; + case WindowManager.TRANSIT_TO_FRONT: + onToFrontTransitionReady(change, startT, finishT); + break; case WindowManager.TRANSIT_CLOSE: { taskInfoList.add(change.getTaskInfo()); onCloseTransitionReady(change, startT, finishT); @@ -138,6 +140,21 @@ public class FreeformTaskTransitionObserver implements Transitions.TransitionObs change.getTaskInfo(), startT, finishT); } + private void onToFrontTransitionReady( + TransitionInfo.Change change, + SurfaceControl.Transaction startT, + SurfaceControl.Transaction finishT) { + boolean exists = mWindowDecorViewModel.setupWindowDecorationForTransition( + change.getTaskInfo(), + startT, + finishT); + if (!exists) { + // Window caption does not exist, create it + mWindowDecorViewModel.createWindowDecoration( + change.getTaskInfo(), change.getLeash(), startT, finishT); + } + } + @Override public void onTransitionStarting(@NonNull IBinder transition) {} diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecorViewModel.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecorViewModel.java index 36dd8edaa8b7..ca15f0002fac 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecorViewModel.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecorViewModel.java @@ -105,6 +105,11 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { SurfaceControl.Transaction startT, SurfaceControl.Transaction finishT) { if (!shouldShowWindowDecor(taskInfo)) return false; + CaptionWindowDecoration oldDecoration = mWindowDecorByTaskId.get(taskInfo.taskId); + if (oldDecoration != null) { + // close the old decoration if it exists to avoid two window decorations being added + oldDecoration.close(); + } final CaptionWindowDecoration windowDecoration = new CaptionWindowDecoration( mContext, mDisplayController, @@ -141,23 +146,25 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { } @Override - public void setupWindowDecorationForTransition( + public boolean setupWindowDecorationForTransition( RunningTaskInfo taskInfo, SurfaceControl.Transaction startT, SurfaceControl.Transaction finishT) { final CaptionWindowDecoration decoration = mWindowDecorByTaskId.get(taskInfo.taskId); - if (decoration == null) return; + if (decoration == null) return false; decoration.relayout(taskInfo, startT, finishT); + return true; } @Override - public void destroyWindowDecoration(RunningTaskInfo taskInfo) { + public boolean destroyWindowDecoration(RunningTaskInfo taskInfo) { final CaptionWindowDecoration decoration = mWindowDecorByTaskId.removeReturnOld(taskInfo.taskId); - if (decoration == null) return; + if (decoration == null) return false; decoration.close(); + return true; } private class CaptionTouchEventListener implements diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/WindowDecorViewModel.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/WindowDecorViewModel.java index d7f71c8235f1..2ce4d04377a1 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/WindowDecorViewModel.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/WindowDecorViewModel.java @@ -44,7 +44,7 @@ public interface WindowDecorViewModel { * @param taskSurface the surface of the task * @param startT the start transaction to be applied before the transition * @param finishT the finish transaction to restore states after the transition - * @return the window decoration object + * @return {@code true} if window decoration was created, {@code false} otherwise */ boolean createWindowDecoration( ActivityManager.RunningTaskInfo taskInfo, @@ -66,8 +66,9 @@ public interface WindowDecorViewModel { * * @param startT the start transaction to be applied before the transition * @param finishT the finish transaction to restore states after the transition + * @return {@code true} if window decoration exists, {@code false} otherwise */ - void setupWindowDecorationForTransition( + boolean setupWindowDecorationForTransition( ActivityManager.RunningTaskInfo taskInfo, SurfaceControl.Transaction startT, SurfaceControl.Transaction finishT); @@ -76,6 +77,7 @@ public interface WindowDecorViewModel { * Destroys the window decoration of the give task. * * @param taskInfo the info of the task + * @return {@code true} if window decoration was destroyed, {@code false} otherwise */ - void destroyWindowDecoration(ActivityManager.RunningTaskInfo taskInfo); + boolean destroyWindowDecoration(ActivityManager.RunningTaskInfo taskInfo); } |