Allow toggle caps lock even if device doesn't a have caps lock key
For Alphabetic keyboards without CapsLock key, we should allow system
to toggle CapsLock modifier state.
Test: atest CtsInputTestCases
Bug: 368397939
Flag: EXEMPT bugfix
Change-Id: I57cfe94bf5ab7804a9a1579dae769c18684776cb
diff --git a/services/inputflinger/reader/InputReader.cpp b/services/inputflinger/reader/InputReader.cpp
index 8b664d5..ab27042 100644
--- a/services/inputflinger/reader/InputReader.cpp
+++ b/services/inputflinger/reader/InputReader.cpp
@@ -584,18 +584,9 @@
void InputReader::toggleCapsLockState(int32_t deviceId) {
std::scoped_lock _l(mLock);
- InputDevice* device = findInputDeviceLocked(deviceId);
- if (!device) {
- ALOGW("Ignoring toggleCapsLock for unknown deviceId %" PRId32 ".", deviceId);
- return;
+ if (mKeyboardClassifier->getKeyboardType(deviceId) == KeyboardType::ALPHABETIC) {
+ updateLedMetaStateLocked(mLedMetaState ^ AMETA_CAPS_LOCK_ON);
}
-
- if (device->isIgnored()) {
- ALOGW("Ignoring toggleCapsLock for ignored deviceId %" PRId32 ".", deviceId);
- return;
- }
-
- device->updateMetaState(AKEYCODE_CAPS_LOCK);
}
bool InputReader::hasKeys(int32_t deviceId, uint32_t sourceMask,