Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 51d639fe authored by Michał Brzeziński's avatar Michał Brzeziński Committed by Automerger Merge Worker
Browse files

Merge "Handling case when device returned from InputManager is null" into...

Merge "Handling case when device returned from InputManager is null" into udc-dev am: 6d956d2a am: 3a9a3448

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22715581



Change-Id: I190d670cfedec8912304d98387d35d8e9a05cb70
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 8dd274ca 3a9a3448
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -106,7 +106,7 @@ constructor(
    }

    private fun isPhysicalFullKeyboard(deviceId: Int): Boolean {
        val device = inputManager.getInputDevice(deviceId)
        val device = inputManager.getInputDevice(deviceId) ?: return false
        return !device.isVirtual && device.isFullKeyboard
    }

+11 −0
Original line number Diff line number Diff line
@@ -95,6 +95,16 @@ class KeyboardRepositoryTest : SysuiTestCase() {
            assertThat(isKeyboardConnected).isTrue()
        }

    @Test
    fun emitsDisconnected_whenDeviceWithIdDoesNotExist() =
        testScope.runTest {
            val deviceListener = captureDeviceListener()
            val isKeyboardConnected by collectLastValue(underTest.keyboardConnected)

            deviceListener.onInputDeviceAdded(NULL_DEVICE_ID)
            assertThat(isKeyboardConnected).isFalse()
        }

    @Test
    fun emitsDisconnected_whenKeyboardDisconnects() =
        testScope.runTest {
@@ -172,6 +182,7 @@ class KeyboardRepositoryTest : SysuiTestCase() {
        private const val VIRTUAL_FULL_KEYBOARD_ID = 2
        private const val PHYSICAL_NOT_FULL_KEYBOARD_ID = 3
        private const val ANOTHER_PHYSICAL_FULL_KEYBOARD_ID = 4
        private const val NULL_DEVICE_ID = 5

        private val INPUT_DEVICES_MAP: Map<Int, InputDevice> =
            mapOf(