summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Siarhei Vishniakou <svv@google.com> 2024-11-18 15:28:37 -0800
committer Siarhei Vishniakou <svv@google.com> 2024-11-20 05:56:09 +0000
commitf750aa8e275c1d335e6aba6394807b4c9e3df48c (patch)
tree0d63a58afbd73da971e906431cf4fa37dcbd40e5
parent20f9ecf04a4801a1a8866765c6bdc02ac117fd6e (diff)
InputDispatcher: Properly store values inside optional
Before this CL, we were storing values inside the optional incorrectly. The variable was first dereferenced (which is always valid, even if there's no value contained inside), and then the value was stored. However, the optional bool flag itself was not updated. As a result, the assertion ALOG_ASSERT was failing. This was not observed in our runs likely due to the behaviour of ALOG_ASSERT. The failure could be reproduced when this was switched to LOG_IF(FATAL locally. The test `PolicyNotifiedForUnhandledKey` was hitting that assertion and failing. The incorrect behaviour was introduced in ag/22679128: Use std::map for fallback keys. In this CL, the code is changed to properly update the optional and to crash always when the unexpected condition occurs. Bug: 377853843 Flag: EXEMPT bugfix Test: TEST=inputflinger_tests; m $TEST && $ANDROID_HOST_OUT/nativetest64/$TEST/$TEST Change-Id: I1f74ff11ac62fcf577ecd146067858d43adc0288
-rw-r--r--services/inputflinger/dispatcher/InputDispatcher.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 755995c15f..cd4ed5c55b 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -6805,14 +6805,15 @@ std::unique_ptr<const KeyEntry> InputDispatcher::afterKeyEventLockedInterruptabl
// The fallback keycode cannot change at any other point in the lifecycle.
if (initialDown) {
if (fallback) {
- *fallbackKeyCode = event.getKeyCode();
+ fallbackKeyCode = event.getKeyCode();
} else {
- *fallbackKeyCode = AKEYCODE_UNKNOWN;
+ fallbackKeyCode = AKEYCODE_UNKNOWN;
}
connection->inputState.setFallbackKey(originalKeyCode, *fallbackKeyCode);
}
- ALOG_ASSERT(fallbackKeyCode);
+ LOG_IF(FATAL, !fallbackKeyCode)
+ << "fallbackKeyCode is not initialized. initialDown = " << initialDown;
// Cancel the fallback key if the policy decides not to send it anymore.
// We will continue to dispatch the key to the policy but we will no