Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopDisplayModeController.kt +16 −19 Original line number Diff line number Diff line Loading @@ -56,13 +56,6 @@ class DesktopDisplayModeController( @ShellMainThread private val mainHandler: Handler, ) { private val onTabletModeChangedListener = object : InputManager.OnTabletModeChangedListener { override fun onTabletModeChanged(whenNanos: Long, inTabletMode: Boolean) { refreshDisplayWindowingMode() } } private val inputDeviceListener = object : InputManager.InputDeviceListener { override fun onInputDeviceAdded(deviceId: Int) { Loading @@ -80,10 +73,6 @@ class DesktopDisplayModeController( init { if (DesktopExperienceFlags.FORM_FACTOR_BASED_DESKTOP_FIRST_SWITCH.isTrue) { inputManager.registerOnTabletModeChangedListener( onTabletModeChangedListener, mainHandler, ) inputManager.registerInputDeviceListener(inputDeviceListener, mainHandler) } } Loading Loading @@ -139,7 +128,7 @@ class DesktopDisplayModeController( return true } if (DesktopExperienceFlags.FORM_FACTOR_BASED_DESKTOP_FIRST_SWITCH.isTrue) { if (isInClamshellMode() || hasAnyMouseDevice()) { if (hasAnyTouchpadDevice() && hasAnyPhysicalKeyboardDevice()) { return true } } Loading Loading @@ -186,15 +175,23 @@ class DesktopDisplayModeController( private fun hasExternalDisplay() = rootTaskDisplayAreaOrganizer.getDisplayIds().any { it != DEFAULT_DISPLAY } private fun hasAnyMouseDevice() = inputManager.inputDeviceIds.any { inputManager.getInputDevice(it)?.supportsSource(InputDevice.SOURCE_MOUSE) == true private fun hasAnyTouchpadDevice() = inputManager.inputDeviceIds.any { deviceId -> inputManager.getInputDevice(deviceId)?.let { device -> device.supportsSource(InputDevice.SOURCE_TOUCHPAD) && device.isEnabled() } ?: false } private fun isInClamshellMode() = inputManager.isInTabletMode() == InputManager.SWITCH_STATE_OFF private fun hasAnyPhysicalKeyboardDevice() = inputManager.inputDeviceIds.any { deviceId -> inputManager.getInputDevice(deviceId)?.let { device -> !device.isVirtual() && device.isFullKeyboard() && device.isEnabled() } ?: false } private fun isDefaultDisplayDesktopEligible(): Boolean { val display = requireNotNull(displayController.getDisplay(DEFAULT_DISPLAY)) { val display = requireNotNull(displayController.getDisplay(DEFAULT_DISPLAY)) { "Display object of DEFAULT_DISPLAY must be non-null." } return DesktopModeStatus.isDesktopModeSupportedOnDisplay(context, display) Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopDisplayModeControllerTest.kt +154 −288 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopDisplayModeController.kt +16 −19 Original line number Diff line number Diff line Loading @@ -56,13 +56,6 @@ class DesktopDisplayModeController( @ShellMainThread private val mainHandler: Handler, ) { private val onTabletModeChangedListener = object : InputManager.OnTabletModeChangedListener { override fun onTabletModeChanged(whenNanos: Long, inTabletMode: Boolean) { refreshDisplayWindowingMode() } } private val inputDeviceListener = object : InputManager.InputDeviceListener { override fun onInputDeviceAdded(deviceId: Int) { Loading @@ -80,10 +73,6 @@ class DesktopDisplayModeController( init { if (DesktopExperienceFlags.FORM_FACTOR_BASED_DESKTOP_FIRST_SWITCH.isTrue) { inputManager.registerOnTabletModeChangedListener( onTabletModeChangedListener, mainHandler, ) inputManager.registerInputDeviceListener(inputDeviceListener, mainHandler) } } Loading Loading @@ -139,7 +128,7 @@ class DesktopDisplayModeController( return true } if (DesktopExperienceFlags.FORM_FACTOR_BASED_DESKTOP_FIRST_SWITCH.isTrue) { if (isInClamshellMode() || hasAnyMouseDevice()) { if (hasAnyTouchpadDevice() && hasAnyPhysicalKeyboardDevice()) { return true } } Loading Loading @@ -186,15 +175,23 @@ class DesktopDisplayModeController( private fun hasExternalDisplay() = rootTaskDisplayAreaOrganizer.getDisplayIds().any { it != DEFAULT_DISPLAY } private fun hasAnyMouseDevice() = inputManager.inputDeviceIds.any { inputManager.getInputDevice(it)?.supportsSource(InputDevice.SOURCE_MOUSE) == true private fun hasAnyTouchpadDevice() = inputManager.inputDeviceIds.any { deviceId -> inputManager.getInputDevice(deviceId)?.let { device -> device.supportsSource(InputDevice.SOURCE_TOUCHPAD) && device.isEnabled() } ?: false } private fun isInClamshellMode() = inputManager.isInTabletMode() == InputManager.SWITCH_STATE_OFF private fun hasAnyPhysicalKeyboardDevice() = inputManager.inputDeviceIds.any { deviceId -> inputManager.getInputDevice(deviceId)?.let { device -> !device.isVirtual() && device.isFullKeyboard() && device.isEnabled() } ?: false } private fun isDefaultDisplayDesktopEligible(): Boolean { val display = requireNotNull(displayController.getDisplay(DEFAULT_DISPLAY)) { val display = requireNotNull(displayController.getDisplay(DEFAULT_DISPLAY)) { "Display object of DEFAULT_DISPLAY must be non-null." } return DesktopModeStatus.isDesktopModeSupportedOnDisplay(context, display) Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopDisplayModeControllerTest.kt +154 −288 File changed.Preview size limit exceeded, changes collapsed. Show changes