Loading libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java +19 −3 Original line number Diff line number Diff line Loading @@ -16,7 +16,9 @@ package com.android.wm.shell.compatui; import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.window.DesktopExperienceFlags.ENABLE_COMPAT_UI_DESKTOP_MODE_SYNCHRONIZATION_BUGFIX; import static com.android.wm.shell.compatui.impl.CompatUIRequestsKt.DISPLAY_COMPAT_SHOW_RESTART_DIALOG; Loading Loading @@ -921,12 +923,26 @@ public class CompatUIController implements OnDisplaysChangedListener, boolean mHasShownUserAspectRatioSettingsButtonHint; } /** * Returns {@code true} if the given task is considered to be in desktop mode for the purpose * of showing compat UI. */ private boolean isInDesktopMode(@Nullable TaskInfo taskInfo) { if (mDesktopUserRepositories.isEmpty() || taskInfo == null) { if (taskInfo == null) { return false; } boolean isDesktopModeShowing = mDesktopUserRepositories.get().getCurrent() final boolean isDesktopModeShowing; if (ENABLE_COMPAT_UI_DESKTOP_MODE_SYNCHRONIZATION_BUGFIX.isTrue()) { // CompatUI is based on TaskListener and may not be synchronized with shell // transitions. Checking the windowing mode in addition to desktop eligibility // provides a more reliable state. isDesktopModeShowing = taskInfo.getWindowingMode() == WINDOWING_MODE_FREEFORM && mDesktopState.isDesktopModeSupportedOnDisplay(taskInfo.displayId); } else { isDesktopModeShowing = mDesktopUserRepositories.isPresent() && mDesktopUserRepositories.get().getCurrent() .isAnyDeskActive(taskInfo.displayId); } return DesktopModeFlags.ENABLE_DESKTOP_SKIP_COMPAT_UI_EDUCATION_IN_DESKTOP_MODE_BUGFIX .isTrue() && isDesktopModeShowing; } Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIControllerTest.java +10 −10 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.wm.shell.compatui; import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; import static android.view.WindowInsets.Type.navigationBars; import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn; Loading @@ -30,7 +31,6 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.app.ActivityManager.RunningTaskInfo; import android.app.TaskInfo; Loading Loading @@ -146,6 +146,7 @@ public class CompatUIControllerTest extends ShellTestCase { MockitoAnnotations.initMocks(this); mDesktopState = new FakeDesktopState(); mDesktopState.getOverrideDesktopModeSupportPerDisplay().put(DISPLAY_ID, true); doReturn(mMockDisplayLayout).when(mMockDisplayController).getDisplayLayout(anyInt()); doReturn(DISPLAY_ID).when(mMockCompatLayout).getDisplayId(); doReturn(TASK_ID).when(mMockCompatLayout).getTaskId(); Loading Loading @@ -712,16 +713,16 @@ public class CompatUIControllerTest extends ShellTestCase { @Test @RequiresFlagsDisabled(Flags.FLAG_APP_COMPAT_UI_FRAMEWORK) @EnableFlags(Flags.FLAG_SKIP_COMPAT_UI_EDUCATION_IN_DESKTOP_MODE) @EnableFlags({Flags.FLAG_SKIP_COMPAT_UI_EDUCATION_IN_DESKTOP_MODE, Flags.FLAG_ENABLE_COMPAT_UI_DESKTOP_MODE_SYNCHRONIZATION_BUGFIX}) public void testUpdateActiveTaskInfo_removeAllComponentWhenInDesktopModeFlagEnabled() { TaskInfo taskInfo = createTaskInfo(DISPLAY_ID, TASK_ID, /* hasSizeCompat= */ true); when(mDesktopUserRepositories.getCurrent().isAnyDeskActive(DISPLAY_ID)).thenReturn(false); mController.onCompatInfoChanged(new CompatUIInfo(taskInfo, mMockTaskListener)); verify(mController, never()).removeLayouts(taskInfo.taskId); when(mDesktopUserRepositories.getCurrent().isAnyDeskActive(DISPLAY_ID)).thenReturn(true); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FREEFORM); mController.onCompatInfoChanged(new CompatUIInfo(taskInfo, mMockTaskListener)); Loading @@ -730,14 +731,13 @@ public class CompatUIControllerTest extends ShellTestCase { @Test @RequiresFlagsDisabled(Flags.FLAG_APP_COMPAT_UI_FRAMEWORK) @EnableFlags(Flags.FLAG_SKIP_COMPAT_UI_EDUCATION_IN_DESKTOP_MODE) @EnableFlags({Flags.FLAG_SKIP_COMPAT_UI_EDUCATION_IN_DESKTOP_MODE, Flags.FLAG_ENABLE_COMPAT_UI_DESKTOP_MODE_SYNCHRONIZATION_BUGFIX}) public void testUpdateActiveTaskInfo_alwaysRemoveLetterboxEdu() { TaskInfo taskInfo = createTaskInfo(DISPLAY_ID, TASK_ID, /* hasSizeCompat= */ true); // When not in Desktop Mode the LetterboxEdu is removed only if the taskId is the one used // when created. when(mDesktopUserRepositories.getCurrent().isAnyDeskActive(DISPLAY_ID)).thenReturn(false); mController.onCompatInfoChanged(new CompatUIInfo(taskInfo, mMockTaskListener)); mController.removeLetterboxEdu(TASK_ID_2); verify(mMockLetterboxEduLayout, never()).release(); Loading @@ -747,7 +747,7 @@ public class CompatUIControllerTest extends ShellTestCase { verify(mMockLetterboxEduLayout).release(); // When in Desktop Mode the LetterboxEdu is always removed when(mDesktopUserRepositories.getCurrent().isAnyDeskActive(DISPLAY_ID)).thenReturn(true); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FREEFORM); mController.onCompatInfoChanged(new CompatUIInfo(taskInfo, mMockTaskListener)); mController.removeLetterboxEdu(TASK_ID); Loading @@ -761,15 +761,15 @@ public class CompatUIControllerTest extends ShellTestCase { @Test @RequiresFlagsDisabled(Flags.FLAG_APP_COMPAT_UI_FRAMEWORK) @DisableFlags(Flags.FLAG_SKIP_COMPAT_UI_EDUCATION_IN_DESKTOP_MODE) @EnableFlags(Flags.FLAG_ENABLE_COMPAT_UI_DESKTOP_MODE_SYNCHRONIZATION_BUGFIX) public void testUpdateActiveTaskInfo_removeAllComponentWhenInDesktopModeFlagDisabled() { when(mDesktopUserRepositories.getCurrent().isAnyDeskActive(DISPLAY_ID)).thenReturn(false); TaskInfo taskInfo = createTaskInfo(DISPLAY_ID, TASK_ID, /* hasSizeCompat= */ true); mController.onCompatInfoChanged(new CompatUIInfo(taskInfo, mMockTaskListener)); verify(mController, never()).removeLayouts(taskInfo.taskId); when(mDesktopUserRepositories.getCurrent().isAnyDeskActive(DISPLAY_ID)).thenReturn(true); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FREEFORM); mController.onCompatInfoChanged(new CompatUIInfo(taskInfo, mMockTaskListener)); Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java +19 −3 Original line number Diff line number Diff line Loading @@ -16,7 +16,9 @@ package com.android.wm.shell.compatui; import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.window.DesktopExperienceFlags.ENABLE_COMPAT_UI_DESKTOP_MODE_SYNCHRONIZATION_BUGFIX; import static com.android.wm.shell.compatui.impl.CompatUIRequestsKt.DISPLAY_COMPAT_SHOW_RESTART_DIALOG; Loading Loading @@ -921,12 +923,26 @@ public class CompatUIController implements OnDisplaysChangedListener, boolean mHasShownUserAspectRatioSettingsButtonHint; } /** * Returns {@code true} if the given task is considered to be in desktop mode for the purpose * of showing compat UI. */ private boolean isInDesktopMode(@Nullable TaskInfo taskInfo) { if (mDesktopUserRepositories.isEmpty() || taskInfo == null) { if (taskInfo == null) { return false; } boolean isDesktopModeShowing = mDesktopUserRepositories.get().getCurrent() final boolean isDesktopModeShowing; if (ENABLE_COMPAT_UI_DESKTOP_MODE_SYNCHRONIZATION_BUGFIX.isTrue()) { // CompatUI is based on TaskListener and may not be synchronized with shell // transitions. Checking the windowing mode in addition to desktop eligibility // provides a more reliable state. isDesktopModeShowing = taskInfo.getWindowingMode() == WINDOWING_MODE_FREEFORM && mDesktopState.isDesktopModeSupportedOnDisplay(taskInfo.displayId); } else { isDesktopModeShowing = mDesktopUserRepositories.isPresent() && mDesktopUserRepositories.get().getCurrent() .isAnyDeskActive(taskInfo.displayId); } return DesktopModeFlags.ENABLE_DESKTOP_SKIP_COMPAT_UI_EDUCATION_IN_DESKTOP_MODE_BUGFIX .isTrue() && isDesktopModeShowing; } Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIControllerTest.java +10 −10 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.wm.shell.compatui; import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; import static android.view.WindowInsets.Type.navigationBars; import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn; Loading @@ -30,7 +31,6 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.app.ActivityManager.RunningTaskInfo; import android.app.TaskInfo; Loading Loading @@ -146,6 +146,7 @@ public class CompatUIControllerTest extends ShellTestCase { MockitoAnnotations.initMocks(this); mDesktopState = new FakeDesktopState(); mDesktopState.getOverrideDesktopModeSupportPerDisplay().put(DISPLAY_ID, true); doReturn(mMockDisplayLayout).when(mMockDisplayController).getDisplayLayout(anyInt()); doReturn(DISPLAY_ID).when(mMockCompatLayout).getDisplayId(); doReturn(TASK_ID).when(mMockCompatLayout).getTaskId(); Loading Loading @@ -712,16 +713,16 @@ public class CompatUIControllerTest extends ShellTestCase { @Test @RequiresFlagsDisabled(Flags.FLAG_APP_COMPAT_UI_FRAMEWORK) @EnableFlags(Flags.FLAG_SKIP_COMPAT_UI_EDUCATION_IN_DESKTOP_MODE) @EnableFlags({Flags.FLAG_SKIP_COMPAT_UI_EDUCATION_IN_DESKTOP_MODE, Flags.FLAG_ENABLE_COMPAT_UI_DESKTOP_MODE_SYNCHRONIZATION_BUGFIX}) public void testUpdateActiveTaskInfo_removeAllComponentWhenInDesktopModeFlagEnabled() { TaskInfo taskInfo = createTaskInfo(DISPLAY_ID, TASK_ID, /* hasSizeCompat= */ true); when(mDesktopUserRepositories.getCurrent().isAnyDeskActive(DISPLAY_ID)).thenReturn(false); mController.onCompatInfoChanged(new CompatUIInfo(taskInfo, mMockTaskListener)); verify(mController, never()).removeLayouts(taskInfo.taskId); when(mDesktopUserRepositories.getCurrent().isAnyDeskActive(DISPLAY_ID)).thenReturn(true); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FREEFORM); mController.onCompatInfoChanged(new CompatUIInfo(taskInfo, mMockTaskListener)); Loading @@ -730,14 +731,13 @@ public class CompatUIControllerTest extends ShellTestCase { @Test @RequiresFlagsDisabled(Flags.FLAG_APP_COMPAT_UI_FRAMEWORK) @EnableFlags(Flags.FLAG_SKIP_COMPAT_UI_EDUCATION_IN_DESKTOP_MODE) @EnableFlags({Flags.FLAG_SKIP_COMPAT_UI_EDUCATION_IN_DESKTOP_MODE, Flags.FLAG_ENABLE_COMPAT_UI_DESKTOP_MODE_SYNCHRONIZATION_BUGFIX}) public void testUpdateActiveTaskInfo_alwaysRemoveLetterboxEdu() { TaskInfo taskInfo = createTaskInfo(DISPLAY_ID, TASK_ID, /* hasSizeCompat= */ true); // When not in Desktop Mode the LetterboxEdu is removed only if the taskId is the one used // when created. when(mDesktopUserRepositories.getCurrent().isAnyDeskActive(DISPLAY_ID)).thenReturn(false); mController.onCompatInfoChanged(new CompatUIInfo(taskInfo, mMockTaskListener)); mController.removeLetterboxEdu(TASK_ID_2); verify(mMockLetterboxEduLayout, never()).release(); Loading @@ -747,7 +747,7 @@ public class CompatUIControllerTest extends ShellTestCase { verify(mMockLetterboxEduLayout).release(); // When in Desktop Mode the LetterboxEdu is always removed when(mDesktopUserRepositories.getCurrent().isAnyDeskActive(DISPLAY_ID)).thenReturn(true); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FREEFORM); mController.onCompatInfoChanged(new CompatUIInfo(taskInfo, mMockTaskListener)); mController.removeLetterboxEdu(TASK_ID); Loading @@ -761,15 +761,15 @@ public class CompatUIControllerTest extends ShellTestCase { @Test @RequiresFlagsDisabled(Flags.FLAG_APP_COMPAT_UI_FRAMEWORK) @DisableFlags(Flags.FLAG_SKIP_COMPAT_UI_EDUCATION_IN_DESKTOP_MODE) @EnableFlags(Flags.FLAG_ENABLE_COMPAT_UI_DESKTOP_MODE_SYNCHRONIZATION_BUGFIX) public void testUpdateActiveTaskInfo_removeAllComponentWhenInDesktopModeFlagDisabled() { when(mDesktopUserRepositories.getCurrent().isAnyDeskActive(DISPLAY_ID)).thenReturn(false); TaskInfo taskInfo = createTaskInfo(DISPLAY_ID, TASK_ID, /* hasSizeCompat= */ true); mController.onCompatInfoChanged(new CompatUIInfo(taskInfo, mMockTaskListener)); verify(mController, never()).removeLayouts(taskInfo.taskId); when(mDesktopUserRepositories.getCurrent().isAnyDeskActive(DISPLAY_ID)).thenReturn(true); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FREEFORM); mController.onCompatInfoChanged(new CompatUIInfo(taskInfo, mMockTaskListener)); Loading