Pass source to dispatchBatchedInputEventPending (2/2)
The API requestUnbufferedDispatch allow View could receive the event in
unbuffered way. But doing processUnbufferedRequest in onInputEvent is
too late for the first event. Instead, we should pass the source of
the input event up to dispatchBatchedInputEventPending, and then we can
use that to determine whether we could consume event immediately or not.
Bug: 149715123
Test: atest ViewUnbufferedTest
Change-Id: I9cd6f76cc3ba74647b57036b3f4979efa8751b95
diff --git a/libs/input/InputTransport.cpp b/libs/input/InputTransport.cpp
index 7335b30..ef7cc7d 100644
--- a/libs/input/InputTransport.cpp
+++ b/libs/input/InputTransport.cpp
@@ -1130,6 +1130,16 @@
return !mBatches.isEmpty();
}
+int32_t InputConsumer::getPendingBatchSource() const {
+ if (mBatches.isEmpty()) {
+ return AINPUT_SOURCE_CLASS_NONE;
+ }
+
+ const Batch& batch = mBatches.itemAt(0);
+ const InputMessage& head = batch.samples.itemAt(0);
+ return head.body.motion.source;
+}
+
ssize_t InputConsumer::findBatch(int32_t deviceId, int32_t source) const {
for (size_t i = 0; i < mBatches.size(); i++) {
const Batch& batch = mBatches.itemAt(i);