summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Linnan Li <lilinnan@xiaomi.corp-partner.google.com> 2024-10-16 18:39:42 +0000
committer Cherrypicker Worker <android-build-cherrypicker-worker@google.com> 2024-10-16 18:39:42 +0000
commit72090cbd1c4484041a252a97c83cab48bc350464 (patch)
treeb0dc2e5fe4a0e89fccb2ba6aa67f0da30536c91f
parentc17f5671b3bf3faa1c547b44a4f57f1e5603791f (diff)
Move input event verify for publish to back of sendMessage
Currently, in InputTransport, we support verifying events intended to be published. This verification occurs before sendMessage. If the application processes events too slowly at this time, it can lead to an excessive number of events in the pipeline, preventing further sending. In such cases, we return a status to the dispatcher to allow it to send the event later. If the action of this event is DOWN or UP, the InputVerifier will receive multiple events with action DOWN or UP, which can cause problems with event verification, leading to abnormal device crashes. Here, we move the verification of the event to after sendMessage succeeds. This resolves the issue because we only verify events that have been successfully sent. Although this may cause the original logic to change (potentially sending an incorrect stream of events to the application), in reality, when an error occurs, the device has already rebooted, so there is no impact. Bug: 373764868 Flag: EXEMPT bugfix Test: presubmit Signed-off-by: Linnan Li <lilinnan@xiaomi.corp-partner.google.com> (cherry picked from https://partner-android-review.googlesource.com/q/commit:586c7ba1af39fd81190e977fd8ecc570144d37da) Merged-In: I74003e5d0eece9007db09cd98a60f616e0e7e22a Change-Id: I74003e5d0eece9007db09cd98a60f616e0e7e22a
-rw-r--r--libs/input/InputTransport.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/libs/input/InputTransport.cpp b/libs/input/InputTransport.cpp
index 77dcaa9ef2..6a55726db1 100644
--- a/libs/input/InputTransport.cpp
+++ b/libs/input/InputTransport.cpp
@@ -583,15 +583,6 @@ status_t InputPublisher::publishMotionEvent(
StringPrintf("publishMotionEvent(inputChannel=%s, action=%s)",
mChannel->getName().c_str(),
MotionEvent::actionToString(action).c_str()));
- if (verifyEvents()) {
- Result<void> result =
- mInputVerifier.processMovement(deviceId, source, action, pointerCount,
- pointerProperties, pointerCoords, flags);
- if (!result.ok()) {
- LOG(ERROR) << "Bad stream: " << result.error();
- return BAD_VALUE;
- }
- }
if (debugTransportPublisher()) {
std::string transformString;
transform.dump(transformString, "transform", " ");
@@ -657,8 +648,18 @@ status_t InputPublisher::publishMotionEvent(
msg.body.motion.pointers[i].properties = pointerProperties[i];
msg.body.motion.pointers[i].coords = pointerCoords[i];
}
+ const status_t status = mChannel->sendMessage(&msg);
- return mChannel->sendMessage(&msg);
+ if (status == OK && verifyEvents()) {
+ Result<void> result =
+ mInputVerifier.processMovement(deviceId, source, action, pointerCount,
+ pointerProperties, pointerCoords, flags);
+ if (!result.ok()) {
+ LOG(ERROR) << "Bad stream: " << result.error();
+ return BAD_VALUE;
+ }
+ }
+ return status;
}
status_t InputPublisher::publishFocusEvent(uint32_t seq, int32_t eventId, bool hasFocus) {