From e4a9f826067b8c9f0aa2795bdc994566992c9027 Mon Sep 17 00:00:00 2001 From: mattsziklay Date: Thu, 1 Sep 2022 13:11:33 -0700 Subject: Show captions on tablets even when display windowing mode is fullscreen. Changes the criteria for showing caption on fullscreen tasks to check if the device is a tablet based on screen size rather than using display windowing mode. Bug: 243671025 Test: Manual testing; launched fullscreen tasks on multiple devices with and without desktop mode flag enabled. Change-Id: I4550f040daef9c55edaaf42bcfc2004a23e6924f --- .../shell/fullscreen/FullscreenTaskListener.java | 31 +++++++++------------- .../windowdecor/CaptionWindowDecorViewModel.java | 18 ++++++++++--- .../wm/shell/windowdecor/WindowDecorViewModel.java | 6 +++-- 3 files changed, 32 insertions(+), 23 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/fullscreen/FullscreenTaskListener.java b/libs/WindowManager/Shell/src/com/android/wm/shell/fullscreen/FullscreenTaskListener.java index e9f9bb5d7327..3740a1b1c335 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/fullscreen/FullscreenTaskListener.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/fullscreen/FullscreenTaskListener.java @@ -16,8 +16,6 @@ package com.android.wm.shell.fullscreen; -import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; - import static com.android.wm.shell.ShellTaskOrganizer.TASK_LISTENER_TYPE_FULLSCREEN; import static com.android.wm.shell.ShellTaskOrganizer.taskListenerTypeToString; @@ -107,13 +105,14 @@ public class FullscreenTaskListener if (Transitions.ENABLE_SHELL_TRANSITIONS) return; updateRecentsForVisibleFullscreenTask(taskInfo); - if (shouldShowWindowDecor(taskInfo) && mWindowDecorViewModelOptional.isPresent()) { + if (mWindowDecorViewModelOptional.isPresent()) { SurfaceControl.Transaction t = new SurfaceControl.Transaction(); state.mWindowDecoration = mWindowDecorViewModelOptional.get().createWindowDecoration(taskInfo, leash, t, t); t.apply(); - } else { + } + if (state.mWindowDecoration == null) { mSyncQueue.runInSync(t -> { // Reset several properties back to fullscreen (PiP, for example, leaves all these // properties in a bad state). @@ -178,13 +177,12 @@ public class FullscreenTaskListener public void createWindowDecoration(TransitionInfo.Change change, SurfaceControl.Transaction startT, SurfaceControl.Transaction finishT) { final State state = createOrUpdateTaskState(change.getTaskInfo(), change.getLeash()); - if (!mWindowDecorViewModelOptional.isPresent() - || !shouldShowWindowDecor(state.mTaskInfo)) { - return; - } - - state.mWindowDecoration = mWindowDecorViewModelOptional.get().createWindowDecoration( + if (!mWindowDecorViewModelOptional.isPresent()) return; + T newWindowDecor = mWindowDecorViewModelOptional.get().createWindowDecoration( state.mTaskInfo, state.mLeash, startT, finishT); + if (newWindowDecor != null) { + state.mWindowDecoration = newWindowDecor; + } } /** @@ -202,8 +200,7 @@ public class FullscreenTaskListener SurfaceControl.Transaction startT, SurfaceControl.Transaction finishT, @Nullable AutoCloseable windowDecor) { - if (!mWindowDecorViewModelOptional.isPresent() - || !shouldShowWindowDecor(change.getTaskInfo())) { + if (!mWindowDecorViewModelOptional.isPresent()) { return false; } final State state = createOrUpdateTaskState(change.getTaskInfo(), change.getLeash()); @@ -214,8 +211,11 @@ public class FullscreenTaskListener state.mTaskInfo, startT, finishT, state.mWindowDecoration); return true; } else { - state.mWindowDecoration = mWindowDecorViewModelOptional.get().createWindowDecoration( + T newWindowDecor = mWindowDecorViewModelOptional.get().createWindowDecoration( state.mTaskInfo, state.mLeash, startT, finishT); + if (newWindowDecor != null) { + state.mWindowDecoration = newWindowDecor; + } return false; } } @@ -336,10 +336,5 @@ public class FullscreenTaskListener return TAG + ":" + taskListenerTypeToString(TASK_LISTENER_TYPE_FULLSCREEN); } - private static boolean shouldShowWindowDecor(RunningTaskInfo taskInfo) { - return taskInfo.getConfiguration().windowConfiguration.getDisplayWindowingMode() - == WINDOWING_MODE_FREEFORM; - } - } 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 83aa539d24d6..e8a2cb160880 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 @@ -36,6 +36,7 @@ import com.android.wm.shell.R; import com.android.wm.shell.ShellTaskOrganizer; import com.android.wm.shell.common.DisplayController; import com.android.wm.shell.common.SyncTransactionQueue; +import com.android.wm.shell.desktopmode.DesktopMode; import com.android.wm.shell.freeform.FreeformTaskTransitionStarter; import com.android.wm.shell.transition.Transitions; @@ -80,6 +81,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel= 600; + } } 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 c234949572bf..d9697d288ab6 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 @@ -42,6 +42,7 @@ public interface WindowDecorViewModel { /** * Creates a window decoration for the given task. + * Can be {@code null} for Fullscreen tasks but not Freeform ones. * * @param taskInfo the initial task info of the task * @param taskSurface the surface of the task @@ -49,7 +50,7 @@ public interface WindowDecorViewModel { * @param finishT the finish transaction to restore states after the transition * @return the window decoration object */ - T createWindowDecoration( + @Nullable T createWindowDecoration( ActivityManager.RunningTaskInfo taskInfo, SurfaceControl taskSurface, SurfaceControl.Transaction startT, @@ -57,11 +58,12 @@ public interface WindowDecorViewModel { /** * Adopts the window decoration if possible. + * May be {@code null} if a window decor is not needed or the given one is incompatible. * * @param windowDecor the potential window decoration to adopt * @return the window decoration if it can be adopted, or {@code null} otherwise. */ - T adoptWindowDecoration(@Nullable AutoCloseable windowDecor); + @Nullable T adoptWindowDecoration(@Nullable AutoCloseable windowDecor); /** * Notifies a task info update on the given task, with the window decoration created previously -- cgit v1.2.3-59-g8ed1b