Skip to content

Commit 72090cb

Browse files
Linnan LiCherrypicker Worker
authored andcommitted
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
1 parent c17f567 commit 72090cb

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

libs/input/InputTransport.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -583,15 +583,6 @@ status_t InputPublisher::publishMotionEvent(
583583
StringPrintf("publishMotionEvent(inputChannel=%s, action=%s)",
584584
mChannel->getName().c_str(),
585585
MotionEvent::actionToString(action).c_str()));
586-
if (verifyEvents()) {
587-
Result<void> result =
588-
mInputVerifier.processMovement(deviceId, source, action, pointerCount,
589-
pointerProperties, pointerCoords, flags);
590-
if (!result.ok()) {
591-
LOG(ERROR) << "Bad stream: " << result.error();
592-
return BAD_VALUE;
593-
}
594-
}
595586
if (debugTransportPublisher()) {
596587
std::string transformString;
597588
transform.dump(transformString, "transform", " ");
@@ -657,8 +648,18 @@ status_t InputPublisher::publishMotionEvent(
657648
msg.body.motion.pointers[i].properties = pointerProperties[i];
658649
msg.body.motion.pointers[i].coords = pointerCoords[i];
659650
}
651+
const status_t status = mChannel->sendMessage(&msg);
660652

661-
return mChannel->sendMessage(&msg);
653+
if (status == OK && verifyEvents()) {
654+
Result<void> result =
655+
mInputVerifier.processMovement(deviceId, source, action, pointerCount,
656+
pointerProperties, pointerCoords, flags);
657+
if (!result.ok()) {
658+
LOG(ERROR) << "Bad stream: " << result.error();
659+
return BAD_VALUE;
660+
}
661+
}
662+
return status;
662663
}
663664

664665
status_t InputPublisher::publishFocusEvent(uint32_t seq, int32_t eventId, bool hasFocus) {

0 commit comments

Comments
 (0)