Loading libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/DesktopModeStatus.java +20 −2 Original line number Diff line number Diff line Loading @@ -67,6 +67,10 @@ public class DesktopModeStatus { private static final boolean ENFORCE_DEVICE_RESTRICTIONS = SystemProperties.getBoolean( "persist.wm.debug.desktop_mode_enforce_device_restrictions", true); /** Whether the desktop density override is enabled. */ public static final boolean DESKTOP_DENSITY_OVERRIDE_ENABLED = SystemProperties.getBoolean("persist.wm.debug.desktop_mode_density_enabled", false); /** Override density for tasks when they're inside the desktop. */ public static final int DESKTOP_DENSITY_OVERRIDE = SystemProperties.getInt("persist.wm.debug.desktop_mode_density", 284); Loading Loading @@ -157,9 +161,23 @@ public class DesktopModeStatus { } /** * Return {@code true} if the override desktop density is set. * Return {@code true} if the override desktop density is enabled and valid. */ public static boolean useDesktopOverrideDensity() { return isDesktopDensityOverrideEnabled() && isValidDesktopDensityOverrideSet(); } /** * Return {@code true} if the override desktop density is enabled. */ private static boolean isDesktopDensityOverrideEnabled() { return DESKTOP_DENSITY_OVERRIDE_ENABLED; } /** * Return {@code true} if the override desktop density is set and within a valid range. */ public static boolean isDesktopDensityOverrideSet() { private static boolean isValidDesktopDensityOverrideSet() { return DESKTOP_DENSITY_OVERRIDE >= DESKTOP_DENSITY_MIN && DESKTOP_DENSITY_OVERRIDE <= DESKTOP_DENSITY_MAX; } Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +5 −5 Original line number Diff line number Diff line Loading @@ -75,7 +75,7 @@ import com.android.wm.shell.recents.RecentsTransitionHandler import com.android.wm.shell.recents.RecentsTransitionStateListener import com.android.wm.shell.shared.DesktopModeStatus import com.android.wm.shell.shared.DesktopModeStatus.DESKTOP_DENSITY_OVERRIDE import com.android.wm.shell.shared.DesktopModeStatus.isDesktopDensityOverrideSet import com.android.wm.shell.shared.DesktopModeStatus.useDesktopOverrideDensity import com.android.wm.shell.shared.annotations.ExternalThread import com.android.wm.shell.shared.annotations.ShellMainThread import com.android.wm.shell.splitscreen.SplitScreenController Loading Loading @@ -960,8 +960,8 @@ class DesktopTasksController( } } val wct = WindowContainerTransaction() if (isDesktopDensityOverrideSet()) { // TODO(344599474) reintroduce density changes behind a disabled flag if (useDesktopOverrideDensity()) { wct.setDensityDpi(task.token, DESKTOP_DENSITY_OVERRIDE) } // Desktop Mode is showing and we're launching a new Task - we might need to minimize // a Task. Loading Loading @@ -1035,7 +1035,7 @@ class DesktopTasksController( } wct.setWindowingMode(taskInfo.token, targetWindowingMode) wct.reorder(taskInfo.token, true /* onTop */) if (isDesktopDensityOverrideSet()) { if (useDesktopOverrideDensity()) { wct.setDensityDpi(taskInfo.token, DESKTOP_DENSITY_OVERRIDE) } } Loading @@ -1055,7 +1055,7 @@ class DesktopTasksController( } wct.setWindowingMode(taskInfo.token, targetWindowingMode) wct.setBounds(taskInfo.token, Rect()) if (isDesktopDensityOverrideSet()) { if (useDesktopOverrideDensity()) { wct.setDensityDpi(taskInfo.token, getDefaultDensityDpi()) } } Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java +1 −1 Original line number Diff line number Diff line Loading @@ -386,7 +386,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin // Should match the density of the task. The task may have had its density overridden // to be different that SysUI's. windowDecorConfig.setTo(taskInfo.configuration); } else if (DesktopModeStatus.isDesktopDensityOverrideSet()) { } else if (DesktopModeStatus.useDesktopOverrideDensity()) { // The task has had its density overridden, but keep using the system's density to // layout the header. windowDecorConfig.setTo(context.getResources().getConfiguration()); Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +2 −6 Original line number Diff line number Diff line Loading @@ -1113,10 +1113,8 @@ class DesktopTasksControllerTest : ShellTestCase() { @Test fun handleRequest_freeformTask_alreadyInDesktop_noOverrideDensity_noConfigDensityChange() { // TODO(344599474) enable the test once the density change is behind a flag assumeTrue(false) assumeTrue(ENABLE_SHELL_TRANSITIONS) whenever(DesktopModeStatus.isDesktopDensityOverrideSet()).thenReturn(false) whenever(DesktopModeStatus.useDesktopOverrideDensity()).thenReturn(false) val freeformTask1 = setUpFreeformTask() markTaskVisible(freeformTask1) Loading @@ -1129,10 +1127,8 @@ class DesktopTasksControllerTest : ShellTestCase() { @Test fun handleRequest_freeformTask_alreadyInDesktop_overrideDensity_hasConfigDensityChange() { // TODO(344599474) enable the test once the density change is behind a flag assumeTrue(false) assumeTrue(ENABLE_SHELL_TRANSITIONS) whenever(DesktopModeStatus.isDesktopDensityOverrideSet()).thenReturn(true) whenever(DesktopModeStatus.useDesktopOverrideDensity()).thenReturn(true) val freeformTask1 = setUpFreeformTask() markTaskVisible(freeformTask1) Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorationTests.java +18 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW; import static android.platform.test.flag.junit.SetFlagsRule.DefaultInitValueType.DEVICE_DEFAULT; import static android.view.WindowInsetsController.APPEARANCE_TRANSPARENT_CAPTION_BAR_BACKGROUND; import static com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession; import static com.google.common.truth.Truth.assertThat; import static org.mockito.Mockito.any; Loading Loading @@ -54,6 +56,7 @@ import android.window.WindowContainerTransaction; import androidx.test.filters.SmallTest; import com.android.dx.mockito.inline.extended.StaticMockitoSession; import com.android.internal.R; import com.android.window.flags.Flags; import com.android.wm.shell.RootTaskDisplayAreaOrganizer; Loading @@ -62,14 +65,17 @@ import com.android.wm.shell.ShellTestCase; import com.android.wm.shell.TestRunningTaskInfoBuilder; import com.android.wm.shell.common.DisplayController; import com.android.wm.shell.common.SyncTransactionQueue; import com.android.wm.shell.shared.DesktopModeStatus; import com.android.wm.shell.windowdecor.WindowDecoration.RelayoutParams; import org.junit.After; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.quality.Strictness; import java.util.function.Supplier; Loading Loading @@ -118,6 +124,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { private final Configuration mConfiguration = new Configuration(); private StaticMockitoSession mMockitoSession; private TestableContext mTestableContext; /** Set up run before test class. */ Loading @@ -131,6 +138,11 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { @Before public void setUp() { mMockitoSession = mockitoSession() .strictness(Strictness.LENIENT) .spyStatic(DesktopModeStatus.class) .startMocking(); when(DesktopModeStatus.useDesktopOverrideDensity()).thenReturn(false); doReturn(mMockSurfaceControlViewHost).when(mMockSurfaceControlViewHostFactory).create( any(), any(), any()); doReturn(mMockTransaction).when(mMockTransactionSupplier).get(); Loading @@ -138,6 +150,11 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { mTestableContext.ensureTestableResources(); } @After public void tearDown() { mMockitoSession.finishMocking(); } @Test public void testMenusClosedWhenTaskIsInvisible() { doReturn(mMockTransaction).when(mMockTransaction).hide(any()); Loading Loading @@ -206,6 +223,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { @Test @DisableFlags(Flags.FLAG_ENABLE_APP_HEADER_WITH_TASK_DENSITY) public void updateRelayoutParams_appHeader_usesSystemDensity() { when(DesktopModeStatus.useDesktopOverrideDensity()).thenReturn(true); final int systemDensity = mTestableContext.getOrCreateTestableResources().getResources() .getConfiguration().densityDpi; final int customTaskDensity = systemDensity + 300; Loading Loading
libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/DesktopModeStatus.java +20 −2 Original line number Diff line number Diff line Loading @@ -67,6 +67,10 @@ public class DesktopModeStatus { private static final boolean ENFORCE_DEVICE_RESTRICTIONS = SystemProperties.getBoolean( "persist.wm.debug.desktop_mode_enforce_device_restrictions", true); /** Whether the desktop density override is enabled. */ public static final boolean DESKTOP_DENSITY_OVERRIDE_ENABLED = SystemProperties.getBoolean("persist.wm.debug.desktop_mode_density_enabled", false); /** Override density for tasks when they're inside the desktop. */ public static final int DESKTOP_DENSITY_OVERRIDE = SystemProperties.getInt("persist.wm.debug.desktop_mode_density", 284); Loading Loading @@ -157,9 +161,23 @@ public class DesktopModeStatus { } /** * Return {@code true} if the override desktop density is set. * Return {@code true} if the override desktop density is enabled and valid. */ public static boolean useDesktopOverrideDensity() { return isDesktopDensityOverrideEnabled() && isValidDesktopDensityOverrideSet(); } /** * Return {@code true} if the override desktop density is enabled. */ private static boolean isDesktopDensityOverrideEnabled() { return DESKTOP_DENSITY_OVERRIDE_ENABLED; } /** * Return {@code true} if the override desktop density is set and within a valid range. */ public static boolean isDesktopDensityOverrideSet() { private static boolean isValidDesktopDensityOverrideSet() { return DESKTOP_DENSITY_OVERRIDE >= DESKTOP_DENSITY_MIN && DESKTOP_DENSITY_OVERRIDE <= DESKTOP_DENSITY_MAX; } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +5 −5 Original line number Diff line number Diff line Loading @@ -75,7 +75,7 @@ import com.android.wm.shell.recents.RecentsTransitionHandler import com.android.wm.shell.recents.RecentsTransitionStateListener import com.android.wm.shell.shared.DesktopModeStatus import com.android.wm.shell.shared.DesktopModeStatus.DESKTOP_DENSITY_OVERRIDE import com.android.wm.shell.shared.DesktopModeStatus.isDesktopDensityOverrideSet import com.android.wm.shell.shared.DesktopModeStatus.useDesktopOverrideDensity import com.android.wm.shell.shared.annotations.ExternalThread import com.android.wm.shell.shared.annotations.ShellMainThread import com.android.wm.shell.splitscreen.SplitScreenController Loading Loading @@ -960,8 +960,8 @@ class DesktopTasksController( } } val wct = WindowContainerTransaction() if (isDesktopDensityOverrideSet()) { // TODO(344599474) reintroduce density changes behind a disabled flag if (useDesktopOverrideDensity()) { wct.setDensityDpi(task.token, DESKTOP_DENSITY_OVERRIDE) } // Desktop Mode is showing and we're launching a new Task - we might need to minimize // a Task. Loading Loading @@ -1035,7 +1035,7 @@ class DesktopTasksController( } wct.setWindowingMode(taskInfo.token, targetWindowingMode) wct.reorder(taskInfo.token, true /* onTop */) if (isDesktopDensityOverrideSet()) { if (useDesktopOverrideDensity()) { wct.setDensityDpi(taskInfo.token, DESKTOP_DENSITY_OVERRIDE) } } Loading @@ -1055,7 +1055,7 @@ class DesktopTasksController( } wct.setWindowingMode(taskInfo.token, targetWindowingMode) wct.setBounds(taskInfo.token, Rect()) if (isDesktopDensityOverrideSet()) { if (useDesktopOverrideDensity()) { wct.setDensityDpi(taskInfo.token, getDefaultDensityDpi()) } } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java +1 −1 Original line number Diff line number Diff line Loading @@ -386,7 +386,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin // Should match the density of the task. The task may have had its density overridden // to be different that SysUI's. windowDecorConfig.setTo(taskInfo.configuration); } else if (DesktopModeStatus.isDesktopDensityOverrideSet()) { } else if (DesktopModeStatus.useDesktopOverrideDensity()) { // The task has had its density overridden, but keep using the system's density to // layout the header. windowDecorConfig.setTo(context.getResources().getConfiguration()); Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +2 −6 Original line number Diff line number Diff line Loading @@ -1113,10 +1113,8 @@ class DesktopTasksControllerTest : ShellTestCase() { @Test fun handleRequest_freeformTask_alreadyInDesktop_noOverrideDensity_noConfigDensityChange() { // TODO(344599474) enable the test once the density change is behind a flag assumeTrue(false) assumeTrue(ENABLE_SHELL_TRANSITIONS) whenever(DesktopModeStatus.isDesktopDensityOverrideSet()).thenReturn(false) whenever(DesktopModeStatus.useDesktopOverrideDensity()).thenReturn(false) val freeformTask1 = setUpFreeformTask() markTaskVisible(freeformTask1) Loading @@ -1129,10 +1127,8 @@ class DesktopTasksControllerTest : ShellTestCase() { @Test fun handleRequest_freeformTask_alreadyInDesktop_overrideDensity_hasConfigDensityChange() { // TODO(344599474) enable the test once the density change is behind a flag assumeTrue(false) assumeTrue(ENABLE_SHELL_TRANSITIONS) whenever(DesktopModeStatus.isDesktopDensityOverrideSet()).thenReturn(true) whenever(DesktopModeStatus.useDesktopOverrideDensity()).thenReturn(true) val freeformTask1 = setUpFreeformTask() markTaskVisible(freeformTask1) Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorationTests.java +18 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW; import static android.platform.test.flag.junit.SetFlagsRule.DefaultInitValueType.DEVICE_DEFAULT; import static android.view.WindowInsetsController.APPEARANCE_TRANSPARENT_CAPTION_BAR_BACKGROUND; import static com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession; import static com.google.common.truth.Truth.assertThat; import static org.mockito.Mockito.any; Loading Loading @@ -54,6 +56,7 @@ import android.window.WindowContainerTransaction; import androidx.test.filters.SmallTest; import com.android.dx.mockito.inline.extended.StaticMockitoSession; import com.android.internal.R; import com.android.window.flags.Flags; import com.android.wm.shell.RootTaskDisplayAreaOrganizer; Loading @@ -62,14 +65,17 @@ import com.android.wm.shell.ShellTestCase; import com.android.wm.shell.TestRunningTaskInfoBuilder; import com.android.wm.shell.common.DisplayController; import com.android.wm.shell.common.SyncTransactionQueue; import com.android.wm.shell.shared.DesktopModeStatus; import com.android.wm.shell.windowdecor.WindowDecoration.RelayoutParams; import org.junit.After; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.quality.Strictness; import java.util.function.Supplier; Loading Loading @@ -118,6 +124,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { private final Configuration mConfiguration = new Configuration(); private StaticMockitoSession mMockitoSession; private TestableContext mTestableContext; /** Set up run before test class. */ Loading @@ -131,6 +138,11 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { @Before public void setUp() { mMockitoSession = mockitoSession() .strictness(Strictness.LENIENT) .spyStatic(DesktopModeStatus.class) .startMocking(); when(DesktopModeStatus.useDesktopOverrideDensity()).thenReturn(false); doReturn(mMockSurfaceControlViewHost).when(mMockSurfaceControlViewHostFactory).create( any(), any(), any()); doReturn(mMockTransaction).when(mMockTransactionSupplier).get(); Loading @@ -138,6 +150,11 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { mTestableContext.ensureTestableResources(); } @After public void tearDown() { mMockitoSession.finishMocking(); } @Test public void testMenusClosedWhenTaskIsInvisible() { doReturn(mMockTransaction).when(mMockTransaction).hide(any()); Loading Loading @@ -206,6 +223,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase { @Test @DisableFlags(Flags.FLAG_ENABLE_APP_HEADER_WITH_TASK_DENSITY) public void updateRelayoutParams_appHeader_usesSystemDensity() { when(DesktopModeStatus.useDesktopOverrideDensity()).thenReturn(true); final int systemDensity = mTestableContext.getOrCreateTestableResources().getResources() .getConfiguration().densityDpi; final int customTaskDensity = systemDensity + 300; Loading