Skip to content

Commit 521e071

Browse files
Treehugger RobotAndroid (Google) Code Review
authored andcommitted
Merge "inputflinger: Check for KeyCharacterMap before use" into main
2 parents 12fb1d2 + 8cb62fe commit 521e071

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

services/inputflinger/reader/EventHub.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,8 +662,12 @@ bool EventHub::Device::hasKeycodeLocked(int keycode) const {
662662
if (hasKeycodeInternalLocked(keycode)) {
663663
return true;
664664
}
665-
666-
for (auto& fromKey : getKeyCharacterMap()->findKeyCodesMappedToKeyCode(keycode)) {
665+
// Check the key character map first. Not all input devices will have one.
666+
const std::shared_ptr<KeyCharacterMap> kcm = getKeyCharacterMap();
667+
if (kcm == nullptr) {
668+
return false;
669+
}
670+
for (auto& fromKey : kcm->findKeyCodesMappedToKeyCode(keycode)) {
667671
if (hasKeycodeInternalLocked(fromKey)) {
668672
return true;
669673
}

0 commit comments

Comments
 (0)