Merge "Fix: Cache key should include Layout type" into udc-dev am: 9ae95fb783
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22960760 Change-Id: I08a783cef0288c86443cb25637b37aa7d273ad5e Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -562,7 +562,7 @@ final class KeyboardLayoutManager implements InputManager.InputDeviceListener {
|
|||||||
key.append(",languageTag:").append(inputDevice.getKeyboardLanguageTag());
|
key.append(",languageTag:").append(inputDevice.getKeyboardLanguageTag());
|
||||||
}
|
}
|
||||||
if (!TextUtils.isEmpty(inputDevice.getKeyboardLayoutType())) {
|
if (!TextUtils.isEmpty(inputDevice.getKeyboardLayoutType())) {
|
||||||
key.append(",layoutType:").append(inputDevice.getKeyboardLanguageTag());
|
key.append(",layoutType:").append(inputDevice.getKeyboardLayoutType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return key.toString();
|
return key.toString();
|
||||||
|
|||||||
@@ -85,6 +85,9 @@ class KeyboardLayoutManagerTests {
|
|||||||
const val DEVICE_ID = 1
|
const val DEVICE_ID = 1
|
||||||
const val VENDOR_SPECIFIC_DEVICE_ID = 2
|
const val VENDOR_SPECIFIC_DEVICE_ID = 2
|
||||||
const val ENGLISH_DVORAK_DEVICE_ID = 3
|
const val ENGLISH_DVORAK_DEVICE_ID = 3
|
||||||
|
const val ENGLISH_QWERTY_DEVICE_ID = 4
|
||||||
|
const val DEFAULT_VENDOR_ID = 123
|
||||||
|
const val DEFAULT_PRODUCT_ID = 456
|
||||||
const val USER_ID = 4
|
const val USER_ID = 4
|
||||||
const val IME_ID = "ime_id"
|
const val IME_ID = "ime_id"
|
||||||
const val PACKAGE_NAME = "KeyboardLayoutManagerTests"
|
const val PACKAGE_NAME = "KeyboardLayoutManagerTests"
|
||||||
@@ -122,6 +125,7 @@ class KeyboardLayoutManagerTests {
|
|||||||
private lateinit var keyboardDevice: InputDevice
|
private lateinit var keyboardDevice: InputDevice
|
||||||
private lateinit var vendorSpecificKeyboardDevice: InputDevice
|
private lateinit var vendorSpecificKeyboardDevice: InputDevice
|
||||||
private lateinit var englishDvorakKeyboardDevice: InputDevice
|
private lateinit var englishDvorakKeyboardDevice: InputDevice
|
||||||
|
private lateinit var englishQwertyKeyboardDevice: InputDevice
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
@@ -150,17 +154,26 @@ class KeyboardLayoutManagerTests {
|
|||||||
Mockito.`when`(context.getSystemService(Mockito.eq(Context.INPUT_SERVICE)))
|
Mockito.`when`(context.getSystemService(Mockito.eq(Context.INPUT_SERVICE)))
|
||||||
.thenReturn(inputManager)
|
.thenReturn(inputManager)
|
||||||
|
|
||||||
keyboardDevice = createKeyboard(DEVICE_ID, 0, 0, "", "")
|
keyboardDevice = createKeyboard(DEVICE_ID, DEFAULT_VENDOR_ID, DEFAULT_PRODUCT_ID, "", "")
|
||||||
vendorSpecificKeyboardDevice = createKeyboard(VENDOR_SPECIFIC_DEVICE_ID, 1, 1, "", "")
|
vendorSpecificKeyboardDevice = createKeyboard(VENDOR_SPECIFIC_DEVICE_ID, 1, 1, "", "")
|
||||||
englishDvorakKeyboardDevice =
|
englishDvorakKeyboardDevice = createKeyboard(ENGLISH_DVORAK_DEVICE_ID, DEFAULT_VENDOR_ID,
|
||||||
createKeyboard(ENGLISH_DVORAK_DEVICE_ID, 0, 0, "en", "dvorak")
|
DEFAULT_PRODUCT_ID, "en", "dvorak")
|
||||||
|
englishQwertyKeyboardDevice = createKeyboard(ENGLISH_QWERTY_DEVICE_ID, DEFAULT_VENDOR_ID,
|
||||||
|
DEFAULT_PRODUCT_ID, "en", "qwerty")
|
||||||
Mockito.`when`(iInputManager.inputDeviceIds)
|
Mockito.`when`(iInputManager.inputDeviceIds)
|
||||||
.thenReturn(intArrayOf(DEVICE_ID, VENDOR_SPECIFIC_DEVICE_ID, ENGLISH_DVORAK_DEVICE_ID))
|
.thenReturn(intArrayOf(
|
||||||
|
DEVICE_ID,
|
||||||
|
VENDOR_SPECIFIC_DEVICE_ID,
|
||||||
|
ENGLISH_DVORAK_DEVICE_ID,
|
||||||
|
ENGLISH_QWERTY_DEVICE_ID
|
||||||
|
))
|
||||||
Mockito.`when`(iInputManager.getInputDevice(DEVICE_ID)).thenReturn(keyboardDevice)
|
Mockito.`when`(iInputManager.getInputDevice(DEVICE_ID)).thenReturn(keyboardDevice)
|
||||||
Mockito.`when`(iInputManager.getInputDevice(VENDOR_SPECIFIC_DEVICE_ID))
|
Mockito.`when`(iInputManager.getInputDevice(VENDOR_SPECIFIC_DEVICE_ID))
|
||||||
.thenReturn(vendorSpecificKeyboardDevice)
|
.thenReturn(vendorSpecificKeyboardDevice)
|
||||||
Mockito.`when`(iInputManager.getInputDevice(ENGLISH_DVORAK_DEVICE_ID))
|
Mockito.`when`(iInputManager.getInputDevice(ENGLISH_DVORAK_DEVICE_ID))
|
||||||
.thenReturn(englishDvorakKeyboardDevice)
|
.thenReturn(englishDvorakKeyboardDevice)
|
||||||
|
Mockito.`when`(iInputManager.getInputDevice(ENGLISH_QWERTY_DEVICE_ID))
|
||||||
|
.thenReturn(englishQwertyKeyboardDevice)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupBroadcastReceiver() {
|
private fun setupBroadcastReceiver() {
|
||||||
@@ -778,14 +791,23 @@ class KeyboardLayoutManagerTests {
|
|||||||
@Test
|
@Test
|
||||||
fun testNewUi_getDefaultKeyboardLayoutForInputDevice_withHwLanguageTagAndLayoutType() {
|
fun testNewUi_getDefaultKeyboardLayoutForInputDevice_withHwLanguageTagAndLayoutType() {
|
||||||
NewSettingsApiFlag(true).use {
|
NewSettingsApiFlag(true).use {
|
||||||
// Should return English dvorak even if IME current layout is qwerty, since HW says the
|
val frenchSubtype = createImeSubtypeForLanguageTagAndLayoutType("fr", "azerty")
|
||||||
|
// Should return English dvorak even if IME current layout is French, since HW says the
|
||||||
// keyboard is a Dvorak keyboard
|
// keyboard is a Dvorak keyboard
|
||||||
assertCorrectLayout(
|
assertCorrectLayout(
|
||||||
englishDvorakKeyboardDevice,
|
englishDvorakKeyboardDevice,
|
||||||
createImeSubtypeForLanguageTagAndLayoutType("en", "qwerty"),
|
frenchSubtype,
|
||||||
createLayoutDescriptor("keyboard_layout_english_us_dvorak")
|
createLayoutDescriptor("keyboard_layout_english_us_dvorak")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Back to back changing HW keyboards with same product and vendor ID but different
|
||||||
|
// language and layout type should configure the layouts correctly.
|
||||||
|
assertCorrectLayout(
|
||||||
|
englishQwertyKeyboardDevice,
|
||||||
|
frenchSubtype,
|
||||||
|
createLayoutDescriptor("keyboard_layout_english_us")
|
||||||
|
)
|
||||||
|
|
||||||
// Fallback to IME information if the HW provided layout script is incompatible with the
|
// Fallback to IME information if the HW provided layout script is incompatible with the
|
||||||
// provided IME subtype
|
// provided IME subtype
|
||||||
assertCorrectLayout(
|
assertCorrectLayout(
|
||||||
|
|||||||
Reference in New Issue
Block a user