Rename sequenceNum to ID.
This is for consistency with ID in other places. Change it to signed
type to match Java int type.
Bug: 144889238
Test: atest inputflinger_tests
Change-Id: I8b6782a67f28aa13f7feaed2c97b8e87105019db
Merged-In: I8b6782a67f28aa13f7feaed2c97b8e87105019db
(cherry picked from commit 6a5a14e75b1a0fb377c670cb9a1e9ace60c5da74)
diff --git a/services/inputflinger/dispatcher/Entry.cpp b/services/inputflinger/dispatcher/Entry.cpp
index c4b3789..49630ad 100644
--- a/services/inputflinger/dispatcher/Entry.cpp
+++ b/services/inputflinger/dispatcher/Entry.cpp
@@ -86,8 +86,8 @@
// --- EventEntry ---
-EventEntry::EventEntry(uint32_t sequenceNum, Type type, nsecs_t eventTime, uint32_t policyFlags)
- : sequenceNum(sequenceNum),
+EventEntry::EventEntry(int32_t id, Type type, nsecs_t eventTime, uint32_t policyFlags)
+ : id(id),
refCount(1),
type(type),
eventTime(eventTime),
@@ -117,8 +117,8 @@
// --- ConfigurationChangedEntry ---
-ConfigurationChangedEntry::ConfigurationChangedEntry(uint32_t sequenceNum, nsecs_t eventTime)
- : EventEntry(sequenceNum, Type::CONFIGURATION_CHANGED, eventTime, 0) {}
+ConfigurationChangedEntry::ConfigurationChangedEntry(int32_t id, nsecs_t eventTime)
+ : EventEntry(id, Type::CONFIGURATION_CHANGED, eventTime, 0) {}
ConfigurationChangedEntry::~ConfigurationChangedEntry() {}
@@ -128,8 +128,8 @@
// --- DeviceResetEntry ---
-DeviceResetEntry::DeviceResetEntry(uint32_t sequenceNum, nsecs_t eventTime, int32_t deviceId)
- : EventEntry(sequenceNum, Type::DEVICE_RESET, eventTime, 0), deviceId(deviceId) {}
+DeviceResetEntry::DeviceResetEntry(int32_t id, nsecs_t eventTime, int32_t deviceId)
+ : EventEntry(id, Type::DEVICE_RESET, eventTime, 0), deviceId(deviceId) {}
DeviceResetEntry::~DeviceResetEntry() {}
@@ -140,9 +140,8 @@
// --- FocusEntry ---
// Focus notifications always go to apps, so set the flag POLICY_FLAG_PASS_TO_USER for all entries
-FocusEntry::FocusEntry(uint32_t sequenceNum, nsecs_t eventTime, sp<IBinder> connectionToken,
- bool hasFocus)
- : EventEntry(sequenceNum, Type::FOCUS, eventTime, POLICY_FLAG_PASS_TO_USER),
+FocusEntry::FocusEntry(int32_t id, nsecs_t eventTime, sp<IBinder> connectionToken, bool hasFocus)
+ : EventEntry(id, Type::FOCUS, eventTime, POLICY_FLAG_PASS_TO_USER),
connectionToken(connectionToken),
hasFocus(hasFocus) {}
@@ -154,11 +153,11 @@
// --- KeyEntry ---
-KeyEntry::KeyEntry(uint32_t sequenceNum, nsecs_t eventTime, int32_t deviceId, uint32_t source,
+KeyEntry::KeyEntry(int32_t id, nsecs_t eventTime, int32_t deviceId, uint32_t source,
int32_t displayId, uint32_t policyFlags, int32_t action, int32_t flags,
int32_t keyCode, int32_t scanCode, int32_t metaState, int32_t repeatCount,
nsecs_t downTime)
- : EventEntry(sequenceNum, Type::KEY, eventTime, policyFlags),
+ : EventEntry(id, Type::KEY, eventTime, policyFlags),
deviceId(deviceId),
source(source),
displayId(displayId),
@@ -198,7 +197,7 @@
// --- MotionEntry ---
-MotionEntry::MotionEntry(uint32_t sequenceNum, nsecs_t eventTime, int32_t deviceId, uint32_t source,
+MotionEntry::MotionEntry(int32_t id, nsecs_t eventTime, int32_t deviceId, uint32_t source,
int32_t displayId, uint32_t policyFlags, int32_t action,
int32_t actionButton, int32_t flags, int32_t metaState,
int32_t buttonState, MotionClassification classification,
@@ -206,7 +205,7 @@
float xCursorPosition, float yCursorPosition, nsecs_t downTime,
uint32_t pointerCount, const PointerProperties* pointerProperties,
const PointerCoords* pointerCoords, float xOffset, float yOffset)
- : EventEntry(sequenceNum, Type::MOTION, eventTime, policyFlags),
+ : EventEntry(id, Type::MOTION, eventTime, policyFlags),
eventTime(eventTime),
deviceId(deviceId),
source(source),
diff --git a/services/inputflinger/dispatcher/Entry.h b/services/inputflinger/dispatcher/Entry.h
index b5b61cc..c58ae23 100644
--- a/services/inputflinger/dispatcher/Entry.h
+++ b/services/inputflinger/dispatcher/Entry.h
@@ -30,7 +30,7 @@
namespace android::inputdispatcher {
// Sequence number for synthesized or injected events.
-constexpr uint32_t SYNTHESIZED_EVENT_SEQUENCE_NUM = 0;
+constexpr int32_t SYNTHESIZED_EVENT_ID = 0;
struct EventEntry {
enum class Type {
@@ -56,7 +56,7 @@
}
}
- uint32_t sequenceNum;
+ int32_t id;
mutable int32_t refCount;
Type type;
nsecs_t eventTime;
@@ -78,22 +78,20 @@
* Key repeat is a synthesized event, because it is related to an actual hardware state
* (a key is currently pressed), but the repeat itself is generated by the framework.
*/
- inline bool isSynthesized() const {
- return isInjected() || sequenceNum == SYNTHESIZED_EVENT_SEQUENCE_NUM;
- }
+ inline bool isSynthesized() const { return isInjected() || id == SYNTHESIZED_EVENT_ID; }
void release();
virtual void appendDescription(std::string& msg) const = 0;
protected:
- EventEntry(uint32_t sequenceNum, Type type, nsecs_t eventTime, uint32_t policyFlags);
+ EventEntry(int32_t id, Type type, nsecs_t eventTime, uint32_t policyFlags);
virtual ~EventEntry();
void releaseInjectionState();
};
struct ConfigurationChangedEntry : EventEntry {
- explicit ConfigurationChangedEntry(uint32_t sequenceNum, nsecs_t eventTime);
+ explicit ConfigurationChangedEntry(int32_t id, nsecs_t eventTime);
virtual void appendDescription(std::string& msg) const;
protected:
@@ -103,7 +101,7 @@
struct DeviceResetEntry : EventEntry {
int32_t deviceId;
- DeviceResetEntry(uint32_t sequenceNum, nsecs_t eventTime, int32_t deviceId);
+ DeviceResetEntry(int32_t id, nsecs_t eventTime, int32_t deviceId);
virtual void appendDescription(std::string& msg) const;
protected:
@@ -114,7 +112,7 @@
sp<IBinder> connectionToken;
bool hasFocus;
- FocusEntry(uint32_t sequenceNum, nsecs_t eventTime, sp<IBinder> connectionToken, bool hasFocus);
+ FocusEntry(int32_t id, nsecs_t eventTime, sp<IBinder> connectionToken, bool hasFocus);
virtual void appendDescription(std::string& msg) const;
protected:
@@ -144,10 +142,9 @@
InterceptKeyResult interceptKeyResult; // set based on the interception result
nsecs_t interceptKeyWakeupTime; // used with INTERCEPT_KEY_RESULT_TRY_AGAIN_LATER
- KeyEntry(uint32_t sequenceNum, nsecs_t eventTime, int32_t deviceId, uint32_t source,
- int32_t displayId, uint32_t policyFlags, int32_t action, int32_t flags,
- int32_t keyCode, int32_t scanCode, int32_t metaState, int32_t repeatCount,
- nsecs_t downTime);
+ KeyEntry(int32_t id, nsecs_t eventTime, int32_t deviceId, uint32_t source, int32_t displayId,
+ uint32_t policyFlags, int32_t action, int32_t flags, int32_t keyCode, int32_t scanCode,
+ int32_t metaState, int32_t repeatCount, nsecs_t downTime);
virtual void appendDescription(std::string& msg) const;
void recycle();
@@ -176,13 +173,13 @@
PointerProperties pointerProperties[MAX_POINTERS];
PointerCoords pointerCoords[MAX_POINTERS];
- MotionEntry(uint32_t sequenceNum, nsecs_t eventTime, int32_t deviceId, uint32_t source,
- int32_t displayId, uint32_t policyFlags, int32_t action, int32_t actionButton,
- int32_t flags, int32_t metaState, int32_t buttonState,
- MotionClassification classification, int32_t edgeFlags, float xPrecision,
- float yPrecision, float xCursorPosition, float yCursorPosition, nsecs_t downTime,
- uint32_t pointerCount, const PointerProperties* pointerProperties,
- const PointerCoords* pointerCoords, float xOffset, float yOffset);
+ MotionEntry(int32_t id, nsecs_t eventTime, int32_t deviceId, uint32_t source, int32_t displayId,
+ uint32_t policyFlags, int32_t action, int32_t actionButton, int32_t flags,
+ int32_t metaState, int32_t buttonState, MotionClassification classification,
+ int32_t edgeFlags, float xPrecision, float yPrecision, float xCursorPosition,
+ float yCursorPosition, nsecs_t downTime, uint32_t pointerCount,
+ const PointerProperties* pointerProperties, const PointerCoords* pointerCoords,
+ float xOffset, float yOffset);
virtual void appendDescription(std::string& msg) const;
protected:
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 70cee18..2f7b5ad 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -302,7 +302,7 @@
}
MotionEntry* combinedMotionEntry =
- new MotionEntry(motionEntry.sequenceNum, motionEntry.eventTime, motionEntry.deviceId,
+ new MotionEntry(motionEntry.id, motionEntry.eventTime, motionEntry.deviceId,
motionEntry.source, motionEntry.displayId, motionEntry.policyFlags,
motionEntry.action, motionEntry.actionButton, motionEntry.flags,
motionEntry.metaState, motionEntry.buttonState,
@@ -930,9 +930,9 @@
entry->repeatCount += 1;
} else {
KeyEntry* newEntry =
- new KeyEntry(SYNTHESIZED_EVENT_SEQUENCE_NUM, currentTime, entry->deviceId,
- entry->source, entry->displayId, policyFlags, entry->action,
- entry->flags, entry->keyCode, entry->scanCode, entry->metaState,
+ new KeyEntry(SYNTHESIZED_EVENT_ID, currentTime, entry->deviceId, entry->source,
+ entry->displayId, policyFlags, entry->action, entry->flags,
+ entry->keyCode, entry->scanCode, entry->metaState,
entry->repeatCount + 1, entry->downTime);
mKeyRepeatState.lastKeyEntry = newEntry;
@@ -981,7 +981,7 @@
void InputDispatcher::enqueueFocusEventLocked(const InputWindowHandle& window, bool hasFocus) {
FocusEntry* focusEntry =
- new FocusEntry(SYNTHESIZED_EVENT_SEQUENCE_NUM, now(), window.getToken(), hasFocus);
+ new FocusEntry(SYNTHESIZED_EVENT_ID, now(), window.getToken(), hasFocus);
enqueueInboundEventLocked(focusEntry);
}
@@ -1076,7 +1076,7 @@
setInjectionResult(entry,
*dropReason == DropReason::POLICY ? INPUT_EVENT_INJECTION_SUCCEEDED
: INPUT_EVENT_INJECTION_FAILED);
- mReporter->reportDroppedKey(entry->sequenceNum);
+ mReporter->reportDroppedKey(entry->id);
return true;
}
@@ -2188,8 +2188,8 @@
const InputTarget& inputTarget) {
if (ATRACE_ENABLED()) {
std::string message =
- StringPrintf("prepareDispatchCycleLocked(inputChannel=%s, sequenceNum=%" PRIu32 ")",
- connection->getInputChannelName().c_str(), eventEntry->sequenceNum);
+ StringPrintf("prepareDispatchCycleLocked(inputChannel=%s, id=%" PRIx32 ")",
+ connection->getInputChannelName().c_str(), eventEntry->id);
ATRACE_NAME(message.c_str());
}
#if DEBUG_DISPATCH_CYCLE
@@ -2244,9 +2244,8 @@
const InputTarget& inputTarget) {
if (ATRACE_ENABLED()) {
std::string message =
- StringPrintf("enqueueDispatchEntriesLocked(inputChannel=%s, sequenceNum=%" PRIu32
- ")",
- connection->getInputChannelName().c_str(), eventEntry->sequenceNum);
+ StringPrintf("enqueueDispatchEntriesLocked(inputChannel=%s, id=%" PRIx32 ")",
+ connection->getInputChannelName().c_str(), eventEntry->id);
ATRACE_NAME(message.c_str());
}
@@ -2922,7 +2921,7 @@
}
MotionEntry* splitMotionEntry =
- new MotionEntry(originalMotionEntry.sequenceNum, originalMotionEntry.eventTime,
+ new MotionEntry(originalMotionEntry.id, originalMotionEntry.eventTime,
originalMotionEntry.deviceId, originalMotionEntry.source,
originalMotionEntry.displayId, originalMotionEntry.policyFlags, action,
originalMotionEntry.actionButton, originalMotionEntry.flags,
@@ -2951,7 +2950,7 @@
std::scoped_lock _l(mLock);
ConfigurationChangedEntry* newEntry =
- new ConfigurationChangedEntry(args->sequenceNum, args->eventTime);
+ new ConfigurationChangedEntry(args->id, args->eventTime);
needWake = enqueueInboundEventLocked(newEntry);
} // release lock
@@ -3030,7 +3029,7 @@
accelerateMetaShortcuts(args->deviceId, args->action, keyCode, metaState);
KeyEvent event;
- event.initialize(args->sequenceNum, args->deviceId, args->source, args->displayId, INVALID_HMAC,
+ event.initialize(args->id, args->deviceId, args->source, args->displayId, INVALID_HMAC,
args->action, flags, keyCode, args->scanCode, metaState, repeatCount,
args->downTime, args->eventTime);
@@ -3057,7 +3056,7 @@
}
KeyEntry* newEntry =
- new KeyEntry(args->sequenceNum, args->eventTime, args->deviceId, args->source,
+ new KeyEntry(args->id, args->eventTime, args->deviceId, args->source,
args->displayId, policyFlags, args->action, flags, keyCode,
args->scanCode, metaState, repeatCount, args->downTime);
@@ -3076,15 +3075,15 @@
void InputDispatcher::notifyMotion(const NotifyMotionArgs* args) {
#if DEBUG_INBOUND_EVENT_DETAILS
- ALOGD("notifyMotion - eventTime=%" PRId64 ", deviceId=%d, source=0x%x, displayId=%" PRId32
- ", policyFlags=0x%x, "
+ ALOGD("notifyMotion - id=%" PRIx32 " eventTime=%" PRId64 ", deviceId=%d, source=0x%x, "
+ "displayId=%" PRId32 ", policyFlags=0x%x, "
"action=0x%x, actionButton=0x%x, flags=0x%x, metaState=0x%x, buttonState=0x%x, "
"edgeFlags=0x%x, xPrecision=%f, yPrecision=%f, xCursorPosition=%f, "
"yCursorPosition=%f, downTime=%" PRId64,
- args->eventTime, args->deviceId, args->source, args->displayId, args->policyFlags,
- args->action, args->actionButton, args->flags, args->metaState, args->buttonState,
- args->edgeFlags, args->xPrecision, args->yPrecision, args->xCursorPosition,
- args->yCursorPosition, args->downTime);
+ args->id, args->eventTime, args->deviceId, args->source, args->displayId,
+ args->policyFlags, args->action, args->actionButton, args->flags, args->metaState,
+ args->buttonState, args->edgeFlags, args->xPrecision, args->yPrecision,
+ args->xCursorPosition, args->yCursorPosition, args->downTime);
for (uint32_t i = 0; i < args->pointerCount; i++) {
ALOGD(" Pointer %d: id=%d, toolType=%d, "
"x=%f, y=%f, pressure=%f, size=%f, "
@@ -3125,14 +3124,13 @@
mLock.unlock();
MotionEvent event;
- event.initialize(args->sequenceNum, args->deviceId, args->source, args->displayId,
- INVALID_HMAC, args->action, args->actionButton, args->flags,
- args->edgeFlags, args->metaState, args->buttonState,
- args->classification, 1 /*xScale*/, 1 /*yScale*/, 0 /* xOffset */,
- 0 /* yOffset */, args->xPrecision, args->yPrecision,
- args->xCursorPosition, args->yCursorPosition, args->downTime,
- args->eventTime, args->pointerCount, args->pointerProperties,
- args->pointerCoords);
+ event.initialize(args->id, args->deviceId, args->source, args->displayId, INVALID_HMAC,
+ args->action, args->actionButton, args->flags, args->edgeFlags,
+ args->metaState, args->buttonState, args->classification, 1 /*xScale*/,
+ 1 /*yScale*/, 0 /* xOffset */, 0 /* yOffset */, args->xPrecision,
+ args->yPrecision, args->xCursorPosition, args->yCursorPosition,
+ args->downTime, args->eventTime, args->pointerCount,
+ args->pointerProperties, args->pointerCoords);
policyFlags |= POLICY_FLAG_FILTERED;
if (!mPolicy->filterInputEvent(&event, policyFlags)) {
@@ -3144,7 +3142,7 @@
// Just enqueue a new motion event.
MotionEntry* newEntry =
- new MotionEntry(args->sequenceNum, args->eventTime, args->deviceId, args->source,
+ new MotionEntry(args->id, args->eventTime, args->deviceId, args->source,
args->displayId, policyFlags, args->action, args->actionButton,
args->flags, args->metaState, args->buttonState,
args->classification, args->edgeFlags, args->xPrecision,
@@ -3188,7 +3186,7 @@
std::scoped_lock _l(mLock);
DeviceResetEntry* newEntry =
- new DeviceResetEntry(args->sequenceNum, args->eventTime, args->deviceId);
+ new DeviceResetEntry(args->id, args->eventTime, args->deviceId);
needWake = enqueueInboundEventLocked(newEntry);
} // release lock
@@ -4631,7 +4629,7 @@
if (keyEntry->flags & AKEY_EVENT_FLAG_FALLBACK) {
if (!handled) {
// Report the key as unhandled, since the fallback was not handled.
- mReporter->reportUnhandledKey(keyEntry->sequenceNum);
+ mReporter->reportUnhandledKey(keyEntry->id);
}
return false;
}
@@ -4796,7 +4794,7 @@
#endif
// Report the key as unhandled, since there is no fallback key.
- mReporter->reportUnhandledKey(keyEntry->sequenceNum);
+ mReporter->reportUnhandledKey(keyEntry->id);
}
}
return false;
@@ -4818,7 +4816,7 @@
KeyEvent InputDispatcher::createKeyEvent(const KeyEntry& entry) {
KeyEvent event;
- event.initialize(entry.sequenceNum, entry.deviceId, entry.source, entry.displayId, INVALID_HMAC,
+ event.initialize(entry.id, entry.deviceId, entry.source, entry.displayId, INVALID_HMAC,
entry.action, entry.flags, entry.keyCode, entry.scanCode, entry.metaState,
entry.repeatCount, entry.downTime, entry.eventTime);
return event;
diff --git a/services/inputflinger/dispatcher/InputState.cpp b/services/inputflinger/dispatcher/InputState.cpp
index 053598a..7fa9e09 100644
--- a/services/inputflinger/dispatcher/InputState.cpp
+++ b/services/inputflinger/dispatcher/InputState.cpp
@@ -268,9 +268,9 @@
std::vector<EventEntry*> events;
for (KeyMemento& memento : mKeyMementos) {
if (shouldCancelKey(memento, options)) {
- events.push_back(new KeyEntry(SYNTHESIZED_EVENT_SEQUENCE_NUM, currentTime,
- memento.deviceId, memento.source, memento.displayId,
- memento.policyFlags, AKEY_EVENT_ACTION_UP,
+ events.push_back(new KeyEntry(SYNTHESIZED_EVENT_ID, currentTime, memento.deviceId,
+ memento.source, memento.displayId, memento.policyFlags,
+ AKEY_EVENT_ACTION_UP,
memento.flags | AKEY_EVENT_FLAG_CANCELED, memento.keyCode,
memento.scanCode, memento.metaState, 0 /*repeatCount*/,
memento.downTime));
@@ -281,11 +281,10 @@
if (shouldCancelMotion(memento, options)) {
const int32_t action = memento.hovering ? AMOTION_EVENT_ACTION_HOVER_EXIT
: AMOTION_EVENT_ACTION_CANCEL;
- events.push_back(new MotionEntry(SYNTHESIZED_EVENT_SEQUENCE_NUM, currentTime,
- memento.deviceId, memento.source, memento.displayId,
- memento.policyFlags, action, 0 /*actionButton*/,
- memento.flags, AMETA_NONE, 0 /*buttonState*/,
- MotionClassification::NONE,
+ events.push_back(new MotionEntry(SYNTHESIZED_EVENT_ID, currentTime, memento.deviceId,
+ memento.source, memento.displayId, memento.policyFlags,
+ action, 0 /*actionButton*/, memento.flags, AMETA_NONE,
+ 0 /*buttonState*/, MotionClassification::NONE,
AMOTION_EVENT_EDGE_FLAG_NONE, memento.xPrecision,
memento.yPrecision, memento.xCursorPosition,
memento.yCursorPosition, memento.downTime,
@@ -332,16 +331,15 @@
: AMOTION_EVENT_ACTION_POINTER_DOWN
| (i << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT);
- events.push_back(new MotionEntry(SYNTHESIZED_EVENT_SEQUENCE_NUM, currentTime,
- memento.deviceId, memento.source, memento.displayId,
- memento.policyFlags, action, 0 /*actionButton*/,
- memento.flags, AMETA_NONE, 0 /*buttonState*/,
- MotionClassification::NONE,
+ events.push_back(new MotionEntry(SYNTHESIZED_EVENT_ID, currentTime, memento.deviceId,
+ memento.source, memento.displayId, memento.policyFlags,
+ action, 0 /*actionButton*/, memento.flags, AMETA_NONE,
+ 0 /*buttonState*/, MotionClassification::NONE,
AMOTION_EVENT_EDGE_FLAG_NONE, memento.xPrecision,
memento.yPrecision, memento.xCursorPosition,
memento.yCursorPosition, memento.downTime,
- pointerCount, pointerProperties,
- pointerCoords, 0 /*xOffset*/, 0 /*yOffset*/));
+ pointerCount, pointerProperties, pointerCoords,
+ 0 /*xOffset*/, 0 /*yOffset*/));
}
memento.firstNewPointerIdx = INVALID_POINTER_INDEX;