Let InputFlinger generate event IDs.
Also send event IDs via InputMessage and add some atrace calls to form a
complete chain of input event processing.
Bug: 144889238
Test: systrace shows correct event IDs.
Test: atest inputflinger_tests
Change-Id: I3c561b03b0ba75c22115ae020e6b41855686ab64
diff --git a/services/inputflinger/reader/InputReader.cpp b/services/inputflinger/reader/InputReader.cpp
index 2998cc9..657a134 100644
--- a/services/inputflinger/reader/InputReader.cpp
+++ b/services/inputflinger/reader/InputReader.cpp
@@ -46,7 +46,6 @@
: mContext(this),
mEventHub(eventHub),
mPolicy(policy),
- mNextId(1),
mGlobalMetaState(0),
mGeneration(1),
mNextInputDeviceId(END_RESERVED_ID),
@@ -697,7 +696,8 @@
// --- InputReader::ContextImpl ---
-InputReader::ContextImpl::ContextImpl(InputReader* reader) : mReader(reader) {}
+InputReader::ContextImpl::ContextImpl(InputReader* reader)
+ : mReader(reader), mIdGenerator(IdGenerator::Source::INPUT_READER) {}
void InputReader::ContextImpl::updateGlobalMetaState() {
// lock is already held by the input loop
@@ -762,7 +762,7 @@
}
int32_t InputReader::ContextImpl::getNextId() {
- return (mReader->mNextId)++;
+ return mIdGenerator.nextId();
}
} // namespace android
diff --git a/services/inputflinger/reader/include/InputReader.h b/services/inputflinger/reader/include/InputReader.h
index eaa105a..693ec30 100644
--- a/services/inputflinger/reader/include/InputReader.h
+++ b/services/inputflinger/reader/include/InputReader.h
@@ -94,6 +94,7 @@
class ContextImpl : public InputReaderContext {
InputReader* mReader;
+ IdGenerator mIdGenerator;
public:
explicit ContextImpl(InputReader* reader);
@@ -132,9 +133,6 @@
InputReaderConfiguration mConfig;
- // used by InputReaderContext::getNextId() as a counter for event sequence numbers
- uint32_t mNextId;
-
// The event queue.
static const int EVENT_BUFFER_SIZE = 256;
RawEvent mEventBuffer[EVENT_BUFFER_SIZE];