InputListener: Pass NotifyArgs by reference
Bug: 245989146
Test: Presubmit
Change-Id: I15af8a6737625a062f31acc1ab6974d52eb91d66
Merged-In: I15af8a6737625a062f31acc1ab6974d52eb91d66
diff --git a/services/inputflinger/InputListener.cpp b/services/inputflinger/InputListener.cpp
index 1bc1adf..aa55873 100644
--- a/services/inputflinger/InputListener.cpp
+++ b/services/inputflinger/InputListener.cpp
@@ -47,16 +47,14 @@
void InputListenerInterface::notify(const NotifyArgs& generalArgs) {
Visitor v{
[&](const NotifyInputDevicesChangedArgs& args) { notifyInputDevicesChanged(args); },
- [&](const NotifyConfigurationChangedArgs& args) { notifyConfigurationChanged(&args); },
- [&](const NotifyKeyArgs& args) { notifyKey(&args); },
- [&](const NotifyMotionArgs& args) { notifyMotion(&args); },
- [&](const NotifySwitchArgs& args) { notifySwitch(&args); },
- [&](const NotifySensorArgs& args) { notifySensor(&args); },
- [&](const NotifyVibratorStateArgs& args) { notifyVibratorState(&args); },
- [&](const NotifyDeviceResetArgs& args) { notifyDeviceReset(&args); },
- [&](const NotifyPointerCaptureChangedArgs& args) {
- notifyPointerCaptureChanged(&args);
- },
+ [&](const NotifyConfigurationChangedArgs& args) { notifyConfigurationChanged(args); },
+ [&](const NotifyKeyArgs& args) { notifyKey(args); },
+ [&](const NotifyMotionArgs& args) { notifyMotion(args); },
+ [&](const NotifySwitchArgs& args) { notifySwitch(args); },
+ [&](const NotifySensorArgs& args) { notifySensor(args); },
+ [&](const NotifyVibratorStateArgs& args) { notifyVibratorState(args); },
+ [&](const NotifyDeviceResetArgs& args) { notifyDeviceReset(args); },
+ [&](const NotifyPointerCaptureChangedArgs& args) { notifyPointerCaptureChanged(args); },
};
std::visit(v, generalArgs);
}
@@ -78,45 +76,44 @@
mArgsQueue.emplace_back(args);
}
-void QueuedInputListener::notifyConfigurationChanged(
- const NotifyConfigurationChangedArgs* args) {
- traceEvent(__func__, args->id);
- mArgsQueue.emplace_back(*args);
+void QueuedInputListener::notifyConfigurationChanged(const NotifyConfigurationChangedArgs& args) {
+ traceEvent(__func__, args.id);
+ mArgsQueue.emplace_back(args);
}
-void QueuedInputListener::notifyKey(const NotifyKeyArgs* args) {
- traceEvent(__func__, args->id);
- mArgsQueue.emplace_back(*args);
+void QueuedInputListener::notifyKey(const NotifyKeyArgs& args) {
+ traceEvent(__func__, args.id);
+ mArgsQueue.emplace_back(args);
}
-void QueuedInputListener::notifyMotion(const NotifyMotionArgs* args) {
- traceEvent(__func__, args->id);
- mArgsQueue.emplace_back(*args);
+void QueuedInputListener::notifyMotion(const NotifyMotionArgs& args) {
+ traceEvent(__func__, args.id);
+ mArgsQueue.emplace_back(args);
}
-void QueuedInputListener::notifySwitch(const NotifySwitchArgs* args) {
- traceEvent(__func__, args->id);
- mArgsQueue.emplace_back(*args);
+void QueuedInputListener::notifySwitch(const NotifySwitchArgs& args) {
+ traceEvent(__func__, args.id);
+ mArgsQueue.emplace_back(args);
}
-void QueuedInputListener::notifySensor(const NotifySensorArgs* args) {
- traceEvent(__func__, args->id);
- mArgsQueue.emplace_back(*args);
+void QueuedInputListener::notifySensor(const NotifySensorArgs& args) {
+ traceEvent(__func__, args.id);
+ mArgsQueue.emplace_back(args);
}
-void QueuedInputListener::notifyVibratorState(const NotifyVibratorStateArgs* args) {
- traceEvent(__func__, args->id);
- mArgsQueue.emplace_back(*args);
+void QueuedInputListener::notifyVibratorState(const NotifyVibratorStateArgs& args) {
+ traceEvent(__func__, args.id);
+ mArgsQueue.emplace_back(args);
}
-void QueuedInputListener::notifyDeviceReset(const NotifyDeviceResetArgs* args) {
- traceEvent(__func__, args->id);
- mArgsQueue.emplace_back(*args);
+void QueuedInputListener::notifyDeviceReset(const NotifyDeviceResetArgs& args) {
+ traceEvent(__func__, args.id);
+ mArgsQueue.emplace_back(args);
}
-void QueuedInputListener::notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs* args) {
- traceEvent(__func__, args->id);
- mArgsQueue.emplace_back(*args);
+void QueuedInputListener::notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs& args) {
+ traceEvent(__func__, args.id);
+ mArgsQueue.emplace_back(args);
}
void QueuedInputListener::flush() {
diff --git a/services/inputflinger/InputProcessor.cpp b/services/inputflinger/InputProcessor.cpp
index 6c0bcff..7a84be9 100644
--- a/services/inputflinger/InputProcessor.cpp
+++ b/services/inputflinger/InputProcessor.cpp
@@ -419,63 +419,63 @@
mQueuedListener.flush();
}
-void InputProcessor::notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) {
+void InputProcessor::notifyConfigurationChanged(const NotifyConfigurationChangedArgs& args) {
// pass through
mQueuedListener.notifyConfigurationChanged(args);
mQueuedListener.flush();
}
-void InputProcessor::notifyKey(const NotifyKeyArgs* args) {
+void InputProcessor::notifyKey(const NotifyKeyArgs& args) {
// pass through
mQueuedListener.notifyKey(args);
mQueuedListener.flush();
}
-void InputProcessor::notifyMotion(const NotifyMotionArgs* args) {
+void InputProcessor::notifyMotion(const NotifyMotionArgs& args) {
{ // acquire lock
std::scoped_lock lock(mLock);
// MotionClassifier is only used for touch events, for now
- const bool sendToMotionClassifier = mMotionClassifier && isTouchEvent(*args);
+ const bool sendToMotionClassifier = mMotionClassifier && isTouchEvent(args);
if (!sendToMotionClassifier) {
mQueuedListener.notifyMotion(args);
} else {
- NotifyMotionArgs newArgs(*args);
+ NotifyMotionArgs newArgs(args);
const MotionClassification newClassification = mMotionClassifier->classify(newArgs);
- LOG_ALWAYS_FATAL_IF(args->classification != MotionClassification::NONE &&
+ LOG_ALWAYS_FATAL_IF(args.classification != MotionClassification::NONE &&
newClassification != MotionClassification::NONE,
"Conflicting classifications %s (new) and %s (old)!",
motionClassificationToString(newClassification),
- motionClassificationToString(args->classification));
+ motionClassificationToString(args.classification));
newArgs.classification = newClassification;
- mQueuedListener.notifyMotion(&newArgs);
+ mQueuedListener.notifyMotion(newArgs);
}
} // release lock
mQueuedListener.flush();
}
-void InputProcessor::notifySensor(const NotifySensorArgs* args) {
+void InputProcessor::notifySensor(const NotifySensorArgs& args) {
// pass through
mQueuedListener.notifySensor(args);
mQueuedListener.flush();
}
-void InputProcessor::notifyVibratorState(const NotifyVibratorStateArgs* args) {
+void InputProcessor::notifyVibratorState(const NotifyVibratorStateArgs& args) {
// pass through
mQueuedListener.notifyVibratorState(args);
mQueuedListener.flush();
}
-void InputProcessor::notifySwitch(const NotifySwitchArgs* args) {
+void InputProcessor::notifySwitch(const NotifySwitchArgs& args) {
// pass through
mQueuedListener.notifySwitch(args);
mQueuedListener.flush();
}
-void InputProcessor::notifyDeviceReset(const NotifyDeviceResetArgs* args) {
+void InputProcessor::notifyDeviceReset(const NotifyDeviceResetArgs& args) {
{ // acquire lock
std::scoped_lock lock(mLock);
if (mMotionClassifier) {
- mMotionClassifier->reset(*args);
+ mMotionClassifier->reset(args);
}
} // release lock
@@ -484,7 +484,7 @@
mQueuedListener.flush();
}
-void InputProcessor::notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs* args) {
+void InputProcessor::notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs& args) {
// pass through
mQueuedListener.notifyPointerCaptureChanged(args);
mQueuedListener.flush();
diff --git a/services/inputflinger/InputProcessor.h b/services/inputflinger/InputProcessor.h
index 01795a8..dcbfebc 100644
--- a/services/inputflinger/InputProcessor.h
+++ b/services/inputflinger/InputProcessor.h
@@ -246,14 +246,14 @@
explicit InputProcessor(InputListenerInterface& listener);
void notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& args) override;
- void notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) override;
- void notifyKey(const NotifyKeyArgs* args) override;
- void notifyMotion(const NotifyMotionArgs* args) override;
- void notifySwitch(const NotifySwitchArgs* args) override;
- void notifySensor(const NotifySensorArgs* args) override;
- void notifyVibratorState(const NotifyVibratorStateArgs* args) override;
- void notifyDeviceReset(const NotifyDeviceResetArgs* args) override;
- void notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs* args) override;
+ void notifyConfigurationChanged(const NotifyConfigurationChangedArgs& args) override;
+ void notifyKey(const NotifyKeyArgs& args) override;
+ void notifyMotion(const NotifyMotionArgs& args) override;
+ void notifySwitch(const NotifySwitchArgs& args) override;
+ void notifySensor(const NotifySensorArgs& args) override;
+ void notifyVibratorState(const NotifyVibratorStateArgs& args) override;
+ void notifyDeviceReset(const NotifyDeviceResetArgs& args) override;
+ void notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs& args) override;
void dump(std::string& dump) override;
void monitor() override;
diff --git a/services/inputflinger/UnwantedInteractionBlocker.cpp b/services/inputflinger/UnwantedInteractionBlocker.cpp
index 6d43e8d..02bc47d 100644
--- a/services/inputflinger/UnwantedInteractionBlocker.cpp
+++ b/services/inputflinger/UnwantedInteractionBlocker.cpp
@@ -329,24 +329,24 @@
: mQueuedListener(listener), mEnablePalmRejection(enablePalmRejection) {}
void UnwantedInteractionBlocker::notifyConfigurationChanged(
- const NotifyConfigurationChangedArgs* args) {
+ const NotifyConfigurationChangedArgs& args) {
mQueuedListener.notifyConfigurationChanged(args);
mQueuedListener.flush();
}
-void UnwantedInteractionBlocker::notifyKey(const NotifyKeyArgs* args) {
+void UnwantedInteractionBlocker::notifyKey(const NotifyKeyArgs& args) {
mQueuedListener.notifyKey(args);
mQueuedListener.flush();
}
-void UnwantedInteractionBlocker::notifyMotion(const NotifyMotionArgs* args) {
- ALOGD_IF(DEBUG_INBOUND_MOTION, "%s: %s", __func__, args->dump().c_str());
+void UnwantedInteractionBlocker::notifyMotion(const NotifyMotionArgs& args) {
+ ALOGD_IF(DEBUG_INBOUND_MOTION, "%s: %s", __func__, args.dump().c_str());
{ // acquire lock
std::scoped_lock lock(mLock);
const std::vector<NotifyMotionArgs> processedArgs =
- mPreferStylusOverTouchBlocker.processMotion(*args);
+ mPreferStylusOverTouchBlocker.processMotion(args);
for (const NotifyMotionArgs& loopArgs : processedArgs) {
- notifyMotionLocked(&loopArgs);
+ notifyMotionLocked(loopArgs);
}
} // release lock
@@ -356,56 +356,56 @@
void UnwantedInteractionBlocker::enqueueOutboundMotionLocked(const NotifyMotionArgs& args) {
ALOGD_IF(DEBUG_OUTBOUND_MOTION, "%s: %s", __func__, args.dump().c_str());
- mQueuedListener.notifyMotion(&args);
+ mQueuedListener.notifyMotion(args);
}
-void UnwantedInteractionBlocker::notifyMotionLocked(const NotifyMotionArgs* args) {
- auto it = mPalmRejectors.find(args->deviceId);
- const bool sendToPalmRejector = it != mPalmRejectors.end() && isFromTouchscreen(args->source);
+void UnwantedInteractionBlocker::notifyMotionLocked(const NotifyMotionArgs& args) {
+ auto it = mPalmRejectors.find(args.deviceId);
+ const bool sendToPalmRejector = it != mPalmRejectors.end() && isFromTouchscreen(args.source);
if (!sendToPalmRejector) {
- enqueueOutboundMotionLocked(*args);
+ enqueueOutboundMotionLocked(args);
return;
}
- std::vector<NotifyMotionArgs> processedArgs = it->second.processMotion(*args);
+ std::vector<NotifyMotionArgs> processedArgs = it->second.processMotion(args);
for (const NotifyMotionArgs& loopArgs : processedArgs) {
enqueueOutboundMotionLocked(loopArgs);
}
}
-void UnwantedInteractionBlocker::notifySwitch(const NotifySwitchArgs* args) {
+void UnwantedInteractionBlocker::notifySwitch(const NotifySwitchArgs& args) {
mQueuedListener.notifySwitch(args);
mQueuedListener.flush();
}
-void UnwantedInteractionBlocker::notifySensor(const NotifySensorArgs* args) {
+void UnwantedInteractionBlocker::notifySensor(const NotifySensorArgs& args) {
mQueuedListener.notifySensor(args);
mQueuedListener.flush();
}
-void UnwantedInteractionBlocker::notifyVibratorState(const NotifyVibratorStateArgs* args) {
+void UnwantedInteractionBlocker::notifyVibratorState(const NotifyVibratorStateArgs& args) {
mQueuedListener.notifyVibratorState(args);
mQueuedListener.flush();
}
-void UnwantedInteractionBlocker::notifyDeviceReset(const NotifyDeviceResetArgs* args) {
+void UnwantedInteractionBlocker::notifyDeviceReset(const NotifyDeviceResetArgs& args) {
{ // acquire lock
std::scoped_lock lock(mLock);
- auto it = mPalmRejectors.find(args->deviceId);
+ auto it = mPalmRejectors.find(args.deviceId);
if (it != mPalmRejectors.end()) {
AndroidPalmFilterDeviceInfo info = it->second.getPalmFilterDeviceInfo();
// Re-create the object instead of resetting it
mPalmRejectors.erase(it);
- mPalmRejectors.emplace(args->deviceId, info);
+ mPalmRejectors.emplace(args.deviceId, info);
}
mQueuedListener.notifyDeviceReset(args);
- mPreferStylusOverTouchBlocker.notifyDeviceReset(*args);
+ mPreferStylusOverTouchBlocker.notifyDeviceReset(args);
} // release lock
// Send events to the next stage without holding the lock
mQueuedListener.flush();
}
void UnwantedInteractionBlocker::notifyPointerCaptureChanged(
- const NotifyPointerCaptureChangedArgs* args) {
+ const NotifyPointerCaptureChangedArgs& args) {
mQueuedListener.notifyPointerCaptureChanged(args);
mQueuedListener.flush();
}
diff --git a/services/inputflinger/UnwantedInteractionBlocker.h b/services/inputflinger/UnwantedInteractionBlocker.h
index 3bc5240..419da83 100644
--- a/services/inputflinger/UnwantedInteractionBlocker.h
+++ b/services/inputflinger/UnwantedInteractionBlocker.h
@@ -91,14 +91,14 @@
explicit UnwantedInteractionBlocker(InputListenerInterface& listener, bool enablePalmRejection);
void notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& args) override;
- void notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) override;
- void notifyKey(const NotifyKeyArgs* args) override;
- void notifyMotion(const NotifyMotionArgs* args) override;
- void notifySwitch(const NotifySwitchArgs* args) override;
- void notifySensor(const NotifySensorArgs* args) override;
- void notifyVibratorState(const NotifyVibratorStateArgs* args) override;
- void notifyDeviceReset(const NotifyDeviceResetArgs* args) override;
- void notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs* args) override;
+ void notifyConfigurationChanged(const NotifyConfigurationChangedArgs& args) override;
+ void notifyKey(const NotifyKeyArgs& args) override;
+ void notifyMotion(const NotifyMotionArgs& args) override;
+ void notifySwitch(const NotifySwitchArgs& args) override;
+ void notifySensor(const NotifySensorArgs& args) override;
+ void notifyVibratorState(const NotifyVibratorStateArgs& args) override;
+ void notifyDeviceReset(const NotifyDeviceResetArgs& args) override;
+ void notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs& args) override;
void dump(std::string& dump) override;
void monitor() override;
@@ -119,7 +119,7 @@
// Use a separate palm rejector for every touch device.
std::map<int32_t /*deviceId*/, PalmRejector> mPalmRejectors GUARDED_BY(mLock);
// TODO(b/210159205): delete this when simultaneous stylus and touch is supported
- void notifyMotionLocked(const NotifyMotionArgs* args) REQUIRES(mLock);
+ void notifyMotionLocked(const NotifyMotionArgs& args) REQUIRES(mLock);
// Call this function for outbound events so that they can be logged when logging is enabled.
void enqueueOutboundMotionLocked(const NotifyMotionArgs& args) REQUIRES(mLock);
diff --git a/services/inputflinger/benchmarks/InputDispatcher_benchmarks.cpp b/services/inputflinger/benchmarks/InputDispatcher_benchmarks.cpp
index 58324c4..f852001 100644
--- a/services/inputflinger/benchmarks/InputDispatcher_benchmarks.cpp
+++ b/services/inputflinger/benchmarks/InputDispatcher_benchmarks.cpp
@@ -277,12 +277,12 @@
motionArgs.action = AMOTION_EVENT_ACTION_DOWN;
motionArgs.downTime = now();
motionArgs.eventTime = motionArgs.downTime;
- dispatcher.notifyMotion(&motionArgs);
+ dispatcher.notifyMotion(motionArgs);
// Send ACTION_UP
motionArgs.action = AMOTION_EVENT_ACTION_UP;
motionArgs.eventTime = now();
- dispatcher.notifyMotion(&motionArgs);
+ dispatcher.notifyMotion(motionArgs);
window->consumeEvent();
window->consumeEvent();
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index c39c408..d30df09 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -4025,9 +4025,9 @@
return splitMotionEntry;
}
-void InputDispatcher::notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) {
+void InputDispatcher::notifyConfigurationChanged(const NotifyConfigurationChangedArgs& args) {
if (debugInboundEventDetails()) {
- ALOGD("notifyConfigurationChanged - eventTime=%" PRId64, args->eventTime);
+ ALOGD("notifyConfigurationChanged - eventTime=%" PRId64, args.eventTime);
}
bool needWake = false;
@@ -4035,7 +4035,7 @@
std::scoped_lock _l(mLock);
std::unique_ptr<ConfigurationChangedEntry> newEntry =
- std::make_unique<ConfigurationChangedEntry>(args->id, args->eventTime);
+ std::make_unique<ConfigurationChangedEntry>(args.id, args.eventTime);
needWake = enqueueInboundEventLocked(std::move(newEntry));
} // release lock
@@ -4083,23 +4083,22 @@
}
}
-void InputDispatcher::notifyKey(const NotifyKeyArgs* args) {
+void InputDispatcher::notifyKey(const NotifyKeyArgs& args) {
ALOGD_IF(debugInboundEventDetails(),
"notifyKey - id=%" PRIx32 ", eventTime=%" PRId64
", deviceId=%d, source=%s, displayId=%" PRId32
"policyFlags=0x%x, action=%s, flags=0x%x, keyCode=%s, scanCode=0x%x, metaState=0x%x, "
"downTime=%" PRId64,
- args->id, args->eventTime, args->deviceId,
- inputEventSourceToString(args->source).c_str(), args->displayId, args->policyFlags,
- KeyEvent::actionToString(args->action), args->flags, KeyEvent::getLabel(args->keyCode),
- args->scanCode, args->metaState, args->downTime);
- if (!validateKeyEvent(args->action)) {
+ args.id, args.eventTime, args.deviceId, inputEventSourceToString(args.source).c_str(),
+ args.displayId, args.policyFlags, KeyEvent::actionToString(args.action), args.flags,
+ KeyEvent::getLabel(args.keyCode), args.scanCode, args.metaState, args.downTime);
+ if (!validateKeyEvent(args.action)) {
return;
}
- uint32_t policyFlags = args->policyFlags;
- int32_t flags = args->flags;
- int32_t metaState = args->metaState;
+ uint32_t policyFlags = args.policyFlags;
+ int32_t flags = args.flags;
+ int32_t metaState = args.metaState;
// InputDispatcher tracks and generates key repeats on behalf of
// whatever notifies it, so repeatCount should always be set to 0
constexpr int32_t repeatCount = 0;
@@ -4113,13 +4112,13 @@
policyFlags |= POLICY_FLAG_TRUSTED;
- int32_t keyCode = args->keyCode;
- accelerateMetaShortcuts(args->deviceId, args->action, keyCode, metaState);
+ int32_t keyCode = args.keyCode;
+ accelerateMetaShortcuts(args.deviceId, args.action, keyCode, metaState);
KeyEvent event;
- event.initialize(args->id, args->deviceId, args->source, args->displayId, INVALID_HMAC,
- args->action, flags, keyCode, args->scanCode, metaState, repeatCount,
- args->downTime, args->eventTime);
+ event.initialize(args.id, args.deviceId, args.source, args.displayId, INVALID_HMAC, args.action,
+ flags, keyCode, args.scanCode, metaState, repeatCount, args.downTime,
+ args.eventTime);
android::base::Timer t;
mPolicy->interceptKeyBeforeQueueing(&event, /*byref*/ policyFlags);
@@ -4144,10 +4143,9 @@
}
std::unique_ptr<KeyEntry> newEntry =
- std::make_unique<KeyEntry>(args->id, args->eventTime, args->deviceId, args->source,
- args->displayId, policyFlags, args->action, flags,
- keyCode, args->scanCode, metaState, repeatCount,
- args->downTime);
+ std::make_unique<KeyEntry>(args.id, args.eventTime, args.deviceId, args.source,
+ args.displayId, policyFlags, args.action, flags, keyCode,
+ args.scanCode, metaState, repeatCount, args.downTime);
needWake = enqueueInboundEventLocked(std::move(newEntry));
mLock.unlock();
@@ -4158,50 +4156,50 @@
}
}
-bool InputDispatcher::shouldSendKeyToInputFilterLocked(const NotifyKeyArgs* args) {
+bool InputDispatcher::shouldSendKeyToInputFilterLocked(const NotifyKeyArgs& args) {
return mInputFilterEnabled;
}
-void InputDispatcher::notifyMotion(const NotifyMotionArgs* args) {
+void InputDispatcher::notifyMotion(const NotifyMotionArgs& args) {
if (debugInboundEventDetails()) {
ALOGD("notifyMotion - id=%" PRIx32 " eventTime=%" PRId64 ", deviceId=%d, source=%s, "
"displayId=%" PRId32 ", policyFlags=0x%x, "
"action=%s, 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->id, args->eventTime, args->deviceId,
- inputEventSourceToString(args->source).c_str(), args->displayId, args->policyFlags,
- MotionEvent::actionToString(args->action).c_str(), 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++) {
+ args.id, args.eventTime, args.deviceId, inputEventSourceToString(args.source).c_str(),
+ args.displayId, args.policyFlags, MotionEvent::actionToString(args.action).c_str(),
+ 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=%s, x=%f, y=%f, pressure=%f, size=%f, "
"touchMajor=%f, touchMinor=%f, toolMajor=%f, toolMinor=%f, orientation=%f",
- i, args->pointerProperties[i].id,
- ftl::enum_string(args->pointerProperties[i].toolType).c_str(),
- args->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_X),
- args->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_Y),
- args->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_PRESSURE),
- args->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_SIZE),
- args->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR),
- args->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR),
- args->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR),
- args->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR),
- args->pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_ORIENTATION));
+ i, args.pointerProperties[i].id,
+ ftl::enum_string(args.pointerProperties[i].toolType).c_str(),
+ args.pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_X),
+ args.pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_Y),
+ args.pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_PRESSURE),
+ args.pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_SIZE),
+ args.pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR),
+ args.pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR),
+ args.pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR),
+ args.pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR),
+ args.pointerCoords[i].getAxisValue(AMOTION_EVENT_AXIS_ORIENTATION));
}
}
- if (!validateMotionEvent(args->action, args->actionButton, args->pointerCount,
- args->pointerProperties)) {
- LOG(ERROR) << "Invalid event: " << args->dump();
+ if (!validateMotionEvent(args.action, args.actionButton, args.pointerCount,
+ args.pointerProperties)) {
+ LOG(ERROR) << "Invalid event: " << args.dump();
return;
}
- uint32_t policyFlags = args->policyFlags;
+ uint32_t policyFlags = args.policyFlags;
policyFlags |= POLICY_FLAG_TRUSTED;
android::base::Timer t;
- mPolicy->interceptMotionBeforeQueueing(args->displayId, args->eventTime, /*byref*/ policyFlags);
+ mPolicy->interceptMotionBeforeQueueing(args.displayId, args.eventTime, policyFlags);
if (t.duration() > SLOW_INTERCEPTION_THRESHOLD) {
ALOGW("Excessive delay in interceptMotionBeforeQueueing; took %s ms",
std::to_string(t.duration().count()).c_str());
@@ -4213,10 +4211,10 @@
if (!(policyFlags & POLICY_FLAG_PASS_TO_USER)) {
// Set the flag anyway if we already have an ongoing gesture. That would allow us to
// complete the processing of the current stroke.
- const auto touchStateIt = mTouchStatesByDisplay.find(args->displayId);
+ const auto touchStateIt = mTouchStatesByDisplay.find(args.displayId);
if (touchStateIt != mTouchStatesByDisplay.end()) {
const TouchState& touchState = touchStateIt->second;
- if (touchState.deviceId == args->deviceId && touchState.isDown()) {
+ if (touchState.deviceId == args.deviceId && touchState.isDown()) {
policyFlags |= POLICY_FLAG_PASS_TO_USER;
}
}
@@ -4224,20 +4222,20 @@
if (shouldSendMotionToInputFilterLocked(args)) {
ui::Transform displayTransform;
- if (const auto it = mDisplayInfos.find(args->displayId); it != mDisplayInfos.end()) {
+ if (const auto it = mDisplayInfos.find(args.displayId); it != mDisplayInfos.end()) {
displayTransform = it->second.transform;
}
mLock.unlock();
MotionEvent event;
- 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,
- displayTransform, args->xPrecision, args->yPrecision,
- args->xCursorPosition, args->yCursorPosition, displayTransform,
- 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,
+ displayTransform, args.xPrecision, args.yPrecision,
+ args.xCursorPosition, args.yCursorPosition, displayTransform,
+ args.downTime, args.eventTime, args.pointerCount,
+ args.pointerProperties, args.pointerCoords);
policyFlags |= POLICY_FLAG_FILTERED;
if (!mPolicy->filterInputEvent(&event, policyFlags)) {
@@ -4249,21 +4247,20 @@
// Just enqueue a new motion event.
std::unique_ptr<MotionEntry> newEntry =
- std::make_unique<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, args->yPrecision,
- args->xCursorPosition, args->yCursorPosition,
- args->downTime, args->pointerCount,
- args->pointerProperties, args->pointerCoords);
+ std::make_unique<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, args.yPrecision,
+ args.xCursorPosition, args.yCursorPosition,
+ args.downTime, args.pointerCount,
+ args.pointerProperties, args.pointerCoords);
- if (args->id != android::os::IInputConstants::INVALID_INPUT_EVENT_ID &&
- IdGenerator::getSource(args->id) == IdGenerator::Source::INPUT_READER &&
+ if (args.id != android::os::IInputConstants::INVALID_INPUT_EVENT_ID &&
+ IdGenerator::getSource(args.id) == IdGenerator::Source::INPUT_READER &&
!mInputFilterEnabled) {
- const bool isDown = args->action == AMOTION_EVENT_ACTION_DOWN;
- mLatencyTracker.trackListener(args->id, isDown, args->eventTime, args->readTime);
+ const bool isDown = args.action == AMOTION_EVENT_ACTION_DOWN;
+ mLatencyTracker.trackListener(args.id, isDown, args.eventTime, args.readTime);
}
needWake = enqueueInboundEventLocked(std::move(newEntry));
@@ -4275,12 +4272,12 @@
}
}
-void InputDispatcher::notifySensor(const NotifySensorArgs* args) {
+void InputDispatcher::notifySensor(const NotifySensorArgs& args) {
if (debugInboundEventDetails()) {
ALOGD("notifySensor - id=%" PRIx32 " eventTime=%" PRId64 ", deviceId=%d, source=0x%x, "
" sensorType=%s",
- args->id, args->eventTime, args->deviceId, args->source,
- ftl::enum_string(args->sensorType).c_str());
+ args.id, args.eventTime, args.deviceId, args.source,
+ ftl::enum_string(args.sensorType).c_str());
}
bool needWake = false;
@@ -4289,10 +4286,9 @@
// Just enqueue a new sensor event.
std::unique_ptr<SensorEntry> newEntry =
- std::make_unique<SensorEntry>(args->id, args->eventTime, args->deviceId,
- args->source, /* policyFlags=*/0, args->hwTimestamp,
- args->sensorType, args->accuracy,
- args->accuracyChanged, args->values);
+ std::make_unique<SensorEntry>(args.id, args.eventTime, args.deviceId, args.source,
+ /* policyFlags=*/0, args.hwTimestamp, args.sensorType,
+ args.accuracy, args.accuracyChanged, args.values);
needWake = enqueueInboundEventLocked(std::move(newEntry));
mLock.unlock();
@@ -4303,34 +4299,34 @@
}
}
-void InputDispatcher::notifyVibratorState(const NotifyVibratorStateArgs* args) {
+void InputDispatcher::notifyVibratorState(const NotifyVibratorStateArgs& args) {
if (debugInboundEventDetails()) {
- ALOGD("notifyVibratorState - eventTime=%" PRId64 ", device=%d, isOn=%d", args->eventTime,
- args->deviceId, args->isOn);
+ ALOGD("notifyVibratorState - eventTime=%" PRId64 ", device=%d, isOn=%d", args.eventTime,
+ args.deviceId, args.isOn);
}
- mPolicy->notifyVibratorState(args->deviceId, args->isOn);
+ mPolicy->notifyVibratorState(args.deviceId, args.isOn);
}
-bool InputDispatcher::shouldSendMotionToInputFilterLocked(const NotifyMotionArgs* args) {
+bool InputDispatcher::shouldSendMotionToInputFilterLocked(const NotifyMotionArgs& args) {
return mInputFilterEnabled;
}
-void InputDispatcher::notifySwitch(const NotifySwitchArgs* args) {
+void InputDispatcher::notifySwitch(const NotifySwitchArgs& args) {
if (debugInboundEventDetails()) {
ALOGD("notifySwitch - eventTime=%" PRId64 ", policyFlags=0x%x, switchValues=0x%08x, "
"switchMask=0x%08x",
- args->eventTime, args->policyFlags, args->switchValues, args->switchMask);
+ args.eventTime, args.policyFlags, args.switchValues, args.switchMask);
}
- uint32_t policyFlags = args->policyFlags;
+ uint32_t policyFlags = args.policyFlags;
policyFlags |= POLICY_FLAG_TRUSTED;
- mPolicy->notifySwitch(args->eventTime, args->switchValues, args->switchMask, policyFlags);
+ mPolicy->notifySwitch(args.eventTime, args.switchValues, args.switchMask, policyFlags);
}
-void InputDispatcher::notifyDeviceReset(const NotifyDeviceResetArgs* args) {
+void InputDispatcher::notifyDeviceReset(const NotifyDeviceResetArgs& args) {
if (debugInboundEventDetails()) {
- ALOGD("notifyDeviceReset - eventTime=%" PRId64 ", deviceId=%d", args->eventTime,
- args->deviceId);
+ ALOGD("notifyDeviceReset - eventTime=%" PRId64 ", deviceId=%d", args.eventTime,
+ args.deviceId);
}
bool needWake = false;
@@ -4338,7 +4334,7 @@
std::scoped_lock _l(mLock);
std::unique_ptr<DeviceResetEntry> newEntry =
- std::make_unique<DeviceResetEntry>(args->id, args->eventTime, args->deviceId);
+ std::make_unique<DeviceResetEntry>(args.id, args.eventTime, args.deviceId);
needWake = enqueueInboundEventLocked(std::move(newEntry));
} // release lock
@@ -4347,17 +4343,17 @@
}
}
-void InputDispatcher::notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs* args) {
+void InputDispatcher::notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs& args) {
if (debugInboundEventDetails()) {
- ALOGD("notifyPointerCaptureChanged - eventTime=%" PRId64 ", enabled=%s", args->eventTime,
- args->request.enable ? "true" : "false");
+ ALOGD("notifyPointerCaptureChanged - eventTime=%" PRId64 ", enabled=%s", args.eventTime,
+ args.request.enable ? "true" : "false");
}
bool needWake = false;
{ // acquire lock
std::scoped_lock _l(mLock);
- auto entry = std::make_unique<PointerCaptureChangedEntry>(args->id, args->eventTime,
- args->request);
+ auto entry =
+ std::make_unique<PointerCaptureChangedEntry>(args.id, args.eventTime, args.request);
needWake = enqueueInboundEventLocked(std::move(entry));
} // release lock
diff --git a/services/inputflinger/dispatcher/InputDispatcher.h b/services/inputflinger/dispatcher/InputDispatcher.h
index aaf1214..4aba24c 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.h
+++ b/services/inputflinger/dispatcher/InputDispatcher.h
@@ -94,14 +94,14 @@
status_t stop() override;
void notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& args) override{};
- void notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) override;
- void notifyKey(const NotifyKeyArgs* args) override;
- void notifyMotion(const NotifyMotionArgs* args) override;
- void notifySwitch(const NotifySwitchArgs* args) override;
- void notifySensor(const NotifySensorArgs* args) override;
- void notifyVibratorState(const NotifyVibratorStateArgs* args) override;
- void notifyDeviceReset(const NotifyDeviceResetArgs* args) override;
- void notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs* args) override;
+ void notifyConfigurationChanged(const NotifyConfigurationChangedArgs& args) override;
+ void notifyKey(const NotifyKeyArgs& args) override;
+ void notifyMotion(const NotifyMotionArgs& args) override;
+ void notifySwitch(const NotifySwitchArgs& args) override;
+ void notifySensor(const NotifySensorArgs& args) override;
+ void notifyVibratorState(const NotifyVibratorStateArgs& args) override;
+ void notifyDeviceReset(const NotifyDeviceResetArgs& args) override;
+ void notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs& args) override;
android::os::InputEventInjectionResult injectInputEvent(
const InputEvent* event, std::optional<int32_t> targetUid,
@@ -332,8 +332,8 @@
REQUIRES(mLock);
// Input filter processing.
- bool shouldSendKeyToInputFilterLocked(const NotifyKeyArgs* args) REQUIRES(mLock);
- bool shouldSendMotionToInputFilterLocked(const NotifyMotionArgs* args) REQUIRES(mLock);
+ bool shouldSendKeyToInputFilterLocked(const NotifyKeyArgs& args) REQUIRES(mLock);
+ bool shouldSendMotionToInputFilterLocked(const NotifyMotionArgs& args) REQUIRES(mLock);
// Inbound event processing.
void drainInboundQueueLocked() REQUIRES(mLock);
diff --git a/services/inputflinger/include/InputListener.h b/services/inputflinger/include/InputListener.h
index d1b86c8..4f78f03 100644
--- a/services/inputflinger/include/InputListener.h
+++ b/services/inputflinger/include/InputListener.h
@@ -38,14 +38,14 @@
virtual ~InputListenerInterface() { }
virtual void notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& args) = 0;
- virtual void notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) = 0;
- virtual void notifyKey(const NotifyKeyArgs* args) = 0;
- virtual void notifyMotion(const NotifyMotionArgs* args) = 0;
- virtual void notifySwitch(const NotifySwitchArgs* args) = 0;
- virtual void notifySensor(const NotifySensorArgs* args) = 0;
- virtual void notifyVibratorState(const NotifyVibratorStateArgs* args) = 0;
- virtual void notifyDeviceReset(const NotifyDeviceResetArgs* args) = 0;
- virtual void notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs* args) = 0;
+ virtual void notifyConfigurationChanged(const NotifyConfigurationChangedArgs& args) = 0;
+ virtual void notifyKey(const NotifyKeyArgs& args) = 0;
+ virtual void notifyMotion(const NotifyMotionArgs& args) = 0;
+ virtual void notifySwitch(const NotifySwitchArgs& args) = 0;
+ virtual void notifySensor(const NotifySensorArgs& args) = 0;
+ virtual void notifyVibratorState(const NotifyVibratorStateArgs& args) = 0;
+ virtual void notifyDeviceReset(const NotifyDeviceResetArgs& args) = 0;
+ virtual void notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs& args) = 0;
void notify(const NotifyArgs& args);
};
@@ -60,14 +60,14 @@
explicit QueuedInputListener(InputListenerInterface& innerListener);
virtual void notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& args) override;
- virtual void notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) override;
- virtual void notifyKey(const NotifyKeyArgs* args) override;
- virtual void notifyMotion(const NotifyMotionArgs* args) override;
- virtual void notifySwitch(const NotifySwitchArgs* args) override;
- virtual void notifySensor(const NotifySensorArgs* args) override;
- virtual void notifyDeviceReset(const NotifyDeviceResetArgs* args) override;
- void notifyVibratorState(const NotifyVibratorStateArgs* args) override;
- void notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs* args) override;
+ virtual void notifyConfigurationChanged(const NotifyConfigurationChangedArgs& args) override;
+ virtual void notifyKey(const NotifyKeyArgs& args) override;
+ virtual void notifyMotion(const NotifyMotionArgs& args) override;
+ virtual void notifySwitch(const NotifySwitchArgs& args) override;
+ virtual void notifySensor(const NotifySensorArgs& args) override;
+ virtual void notifyDeviceReset(const NotifyDeviceResetArgs& args) override;
+ void notifyVibratorState(const NotifyVibratorStateArgs& args) override;
+ void notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs& args) override;
void flush();
diff --git a/services/inputflinger/include/NotifyArgs.h b/services/inputflinger/include/NotifyArgs.h
index f12482b..7d29dd9 100644
--- a/services/inputflinger/include/NotifyArgs.h
+++ b/services/inputflinger/include/NotifyArgs.h
@@ -36,6 +36,7 @@
bool operator==(const NotifyInputDevicesChangedArgs& rhs) const = default;
NotifyInputDevicesChangedArgs(const NotifyInputDevicesChangedArgs& other) = default;
+ NotifyInputDevicesChangedArgs& operator=(const NotifyInputDevicesChangedArgs&) = default;
};
/* Describes a configuration change event. */
@@ -50,6 +51,7 @@
bool operator==(const NotifyConfigurationChangedArgs& rhs) const = default;
NotifyConfigurationChangedArgs(const NotifyConfigurationChangedArgs& other) = default;
+ NotifyConfigurationChangedArgs& operator=(const NotifyConfigurationChangedArgs&) = default;
};
/* Describes a key event. */
@@ -79,6 +81,7 @@
bool operator==(const NotifyKeyArgs& rhs) const = default;
NotifyKeyArgs(const NotifyKeyArgs& other) = default;
+ NotifyKeyArgs& operator=(const NotifyKeyArgs&) = default;
};
/* Describes a motion event. */
@@ -129,7 +132,6 @@
const std::vector<TouchVideoFrame>& videoFrames);
NotifyMotionArgs(const NotifyMotionArgs& other);
-
NotifyMotionArgs& operator=(const android::NotifyMotionArgs&) = default;
bool operator==(const NotifyMotionArgs& rhs) const;
@@ -157,6 +159,7 @@
bool accuracyChanged, nsecs_t hwTimestamp, std::vector<float> values);
NotifySensorArgs(const NotifySensorArgs& other) = default;
+ NotifySensorArgs& operator=(const NotifySensorArgs&) = default;
};
/* Describes a switch event. */
@@ -174,6 +177,7 @@
uint32_t switchMask);
NotifySwitchArgs(const NotifySwitchArgs& other) = default;
+ NotifySwitchArgs& operator=(const NotifySwitchArgs&) = default;
bool operator==(const NotifySwitchArgs& rhs) const = default;
};
@@ -191,6 +195,7 @@
NotifyDeviceResetArgs(int32_t id, nsecs_t eventTime, int32_t deviceId);
NotifyDeviceResetArgs(const NotifyDeviceResetArgs& other) = default;
+ NotifyDeviceResetArgs& operator=(const NotifyDeviceResetArgs&) = default;
bool operator==(const NotifyDeviceResetArgs& rhs) const = default;
};
@@ -207,6 +212,7 @@
NotifyPointerCaptureChangedArgs(int32_t id, nsecs_t eventTime, const PointerCaptureRequest&);
NotifyPointerCaptureChangedArgs(const NotifyPointerCaptureChangedArgs& other) = default;
+ NotifyPointerCaptureChangedArgs& operator=(const NotifyPointerCaptureChangedArgs&) = default;
};
/* Describes a vibrator state event. */
@@ -222,6 +228,7 @@
NotifyVibratorStateArgs(int32_t id, nsecs_t eventTIme, int32_t deviceId, bool isOn);
NotifyVibratorStateArgs(const NotifyVibratorStateArgs& other) = default;
+ NotifyVibratorStateArgs& operator=(const NotifyVibratorStateArgs&) = default;
};
using NotifyArgs =
diff --git a/services/inputflinger/reader/InputReader.cpp b/services/inputflinger/reader/InputReader.cpp
index 6f54faa..0afe79d 100644
--- a/services/inputflinger/reader/InputReader.cpp
+++ b/services/inputflinger/reader/InputReader.cpp
@@ -387,8 +387,7 @@
updateGlobalMetaStateLocked();
// Enqueue configuration changed.
- NotifyConfigurationChangedArgs args(mContext.getNextId(), when);
- mQueuedListener.notifyConfigurationChanged(&args);
+ mQueuedListener.notifyConfigurationChanged({mContext.getNextId(), when});
}
void InputReader::refreshConfigurationLocked(uint32_t changes) {
@@ -420,9 +419,8 @@
"There was no change in the pointer capture state.");
} else {
mCurrentPointerCaptureRequest = mConfig.pointerCaptureRequest;
- const NotifyPointerCaptureChangedArgs args(mContext.getNextId(), now,
- mCurrentPointerCaptureRequest);
- mQueuedListener.notifyPointerCaptureChanged(&args);
+ mQueuedListener.notifyPointerCaptureChanged(
+ {mContext.getNextId(), now, mCurrentPointerCaptureRequest});
}
}
}
diff --git a/services/inputflinger/tests/InputDispatcher_test.cpp b/services/inputflinger/tests/InputDispatcher_test.cpp
index 5e51bfc..27d7b9c 100644
--- a/services/inputflinger/tests/InputDispatcher_test.cpp
+++ b/services/inputflinger/tests/InputDispatcher_test.cpp
@@ -818,8 +818,7 @@
TEST_F(InputDispatcherTest, NotifyConfigurationChanged_CallsPolicy) {
constexpr nsecs_t eventTime = 20;
- NotifyConfigurationChangedArgs args(/*id=*/10, eventTime);
- mDispatcher->notifyConfigurationChanged(&args);
+ mDispatcher->notifyConfigurationChanged({/*id=*/10, eventTime});
ASSERT_TRUE(mDispatcher->waitForIdle());
mFakePolicy->assertNotifyConfigurationChangedWasCalled(eventTime);
@@ -828,7 +827,7 @@
TEST_F(InputDispatcherTest, NotifySwitch_CallsPolicy) {
NotifySwitchArgs args(/*id=*/10, /*eventTime=*/20, /*policyFlags=*/0, /*switchValues=*/1,
/*switchMask=*/2);
- mDispatcher->notifySwitch(&args);
+ mDispatcher->notifySwitch(args);
// InputDispatcher adds POLICY_FLAG_TRUSTED because the event went through InputListener
args.policyFlags |= POLICY_FLAG_TRUSTED;
@@ -1743,8 +1742,9 @@
return args;
}
-static NotifyMotionArgs generateMotionArgs(int32_t action, int32_t source, int32_t displayId,
- const std::vector<PointF>& points) {
+[[nodiscard]] static NotifyMotionArgs generateMotionArgs(int32_t action, int32_t source,
+ int32_t displayId,
+ const std::vector<PointF>& points) {
size_t pointerCount = points.size();
if (action == AMOTION_EVENT_ACTION_DOWN || action == AMOTION_EVENT_ACTION_UP) {
EXPECT_EQ(1U, pointerCount) << "Actions DOWN and UP can only contain a single pointer";
@@ -1946,26 +1946,20 @@
sp<FakeWindowHandle>::make(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {window}}});
- NotifyMotionArgs args;
// First touch pointer down on right window
- mDispatcher->notifyMotion(&(
- args = MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
- .pointer(PointerBuilder(0, ToolType::FINGER).x(100).y(100))
- .build()));
+ mDispatcher->notifyMotion(MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(100).y(100))
+ .build());
// Second touch pointer down
- mDispatcher->notifyMotion(&(
- args = MotionArgsBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
-
- .pointer(PointerBuilder(0, ToolType::FINGER).x(100).y(100))
- .pointer(PointerBuilder(1, ToolType::FINGER).x(110).y(100))
- .build()));
+ mDispatcher->notifyMotion(MotionArgsBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(100).y(100))
+ .pointer(PointerBuilder(1, ToolType::FINGER).x(110).y(100))
+ .build());
// First touch pointer lifts. The second one remains down
- mDispatcher->notifyMotion(&(
- args = MotionArgsBuilder(POINTER_0_UP, AINPUT_SOURCE_TOUCHSCREEN)
-
- .pointer(PointerBuilder(0, ToolType::FINGER).x(100).y(100))
- .pointer(PointerBuilder(1, ToolType::FINGER).x(110).y(100))
- .build()));
+ mDispatcher->notifyMotion(MotionArgsBuilder(POINTER_0_UP, AINPUT_SOURCE_TOUCHSCREEN)
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(100).y(100))
+ .pointer(PointerBuilder(1, ToolType::FINGER).x(110).y(100))
+ .build());
window->consumeMotionEvent(WithMotionAction(ACTION_DOWN));
window->consumeMotionEvent(WithMotionAction(POINTER_1_DOWN));
window->consumeMotionEvent(WithMotionAction(POINTER_0_UP));
@@ -2256,54 +2250,48 @@
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {spyWindow, window}}});
const int32_t touchDeviceId = 4;
- NotifyMotionArgs args;
// Two pointers down
- mDispatcher->notifyMotion(&(
- args = MotionArgsBuilder(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
- .deviceId(touchDeviceId)
- .policyFlags(DEFAULT_POLICY_FLAGS)
- .pointer(PointerBuilder(0, ToolType::FINGER).x(100).y(100))
- .build()));
+ mDispatcher->notifyMotion(
+ MotionArgsBuilder(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
+ .deviceId(touchDeviceId)
+ .policyFlags(DEFAULT_POLICY_FLAGS)
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(100).y(100))
+ .build());
- mDispatcher->notifyMotion(&(
- args = MotionArgsBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
- .deviceId(touchDeviceId)
- .policyFlags(DEFAULT_POLICY_FLAGS)
- .pointer(PointerBuilder(0, ToolType::FINGER).x(100).y(100))
- .pointer(PointerBuilder(1, ToolType::FINGER).x(120).y(120))
- .build()));
+ mDispatcher->notifyMotion(MotionArgsBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
+ .deviceId(touchDeviceId)
+ .policyFlags(DEFAULT_POLICY_FLAGS)
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(100).y(100))
+ .pointer(PointerBuilder(1, ToolType::FINGER).x(120).y(120))
+ .build());
spyWindow->consumeMotionEvent(WithMotionAction(AMOTION_EVENT_ACTION_DOWN));
spyWindow->consumeMotionEvent(WithMotionAction(POINTER_1_DOWN));
window->consumeMotionEvent(WithMotionAction(AMOTION_EVENT_ACTION_DOWN));
window->consumeMotionEvent(WithMotionAction(POINTER_1_DOWN));
// Cancel the current gesture. Send the cancel without the default policy flags.
- mDispatcher->notifyMotion(&(
- args = MotionArgsBuilder(AMOTION_EVENT_ACTION_CANCEL, AINPUT_SOURCE_TOUCHSCREEN)
- .deviceId(touchDeviceId)
- .policyFlags(0)
- .pointer(PointerBuilder(0, ToolType::FINGER).x(100).y(100))
- .pointer(PointerBuilder(1, ToolType::FINGER).x(120).y(120))
- .build()));
+ mDispatcher->notifyMotion(
+ MotionArgsBuilder(AMOTION_EVENT_ACTION_CANCEL, AINPUT_SOURCE_TOUCHSCREEN)
+ .deviceId(touchDeviceId)
+ .policyFlags(0)
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(100).y(100))
+ .pointer(PointerBuilder(1, ToolType::FINGER).x(120).y(120))
+ .build());
spyWindow->consumeMotionEvent(WithMotionAction(AMOTION_EVENT_ACTION_CANCEL));
window->consumeMotionEvent(WithMotionAction(AMOTION_EVENT_ACTION_CANCEL));
// We don't need to reset the device to reproduce the issue, but the reset event typically
// follows, so we keep it here to model the actual listener behaviour more closely.
- NotifyDeviceResetArgs resetArgs;
- resetArgs.id = 1; // arbitrary id
- resetArgs.eventTime = systemTime(SYSTEM_TIME_MONOTONIC);
- resetArgs.deviceId = touchDeviceId;
- mDispatcher->notifyDeviceReset(&resetArgs);
+ mDispatcher->notifyDeviceReset({/*id=*/1, systemTime(SYSTEM_TIME_MONOTONIC), touchDeviceId});
// Start new gesture
- mDispatcher->notifyMotion(&(
- args = MotionArgsBuilder(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
- .deviceId(touchDeviceId)
- .policyFlags(DEFAULT_POLICY_FLAGS)
- .pointer(PointerBuilder(0, ToolType::FINGER).x(100).y(100))
- .build()));
+ mDispatcher->notifyMotion(
+ MotionArgsBuilder(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
+ .deviceId(touchDeviceId)
+ .policyFlags(DEFAULT_POLICY_FLAGS)
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(100).y(100))
+ .build());
spyWindow->consumeMotionEvent(WithMotionAction(AMOTION_EVENT_ACTION_DOWN));
window->consumeMotionEvent(WithMotionAction(AMOTION_EVENT_ACTION_DOWN));
@@ -2453,53 +2441,49 @@
NotifyMotionArgs args;
// Start hovering over the left window
- mDispatcher->notifyMotion(&(
- args = MotionArgsBuilder(ACTION_HOVER_ENTER, AINPUT_SOURCE_MOUSE)
- .deviceId(mouseDeviceId)
- .pointer(PointerBuilder(0, ToolType::MOUSE).x(100).y(100))
- .build()));
+ mDispatcher->notifyMotion(MotionArgsBuilder(ACTION_HOVER_ENTER, AINPUT_SOURCE_MOUSE)
+ .deviceId(mouseDeviceId)
+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(100).y(100))
+ .build());
leftWindow->consumeMotionEvent(
AllOf(WithMotionAction(ACTION_HOVER_ENTER), WithDeviceId(mouseDeviceId)));
// Mouse down on left window
- mDispatcher->notifyMotion(&(
- args = MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_MOUSE)
- .deviceId(mouseDeviceId)
- .buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
- .pointer(PointerBuilder(0, ToolType::MOUSE).x(100).y(100))
- .build()));
+ mDispatcher->notifyMotion(MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_MOUSE)
+ .deviceId(mouseDeviceId)
+ .buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(100).y(100))
+ .build());
leftWindow->consumeMotionEvent(
AllOf(WithMotionAction(ACTION_HOVER_EXIT), WithDeviceId(mouseDeviceId)));
leftWindow->consumeMotionEvent(
AllOf(WithMotionAction(ACTION_DOWN), WithDeviceId(mouseDeviceId)));
- mDispatcher->notifyMotion(&(
- args = MotionArgsBuilder(AMOTION_EVENT_ACTION_BUTTON_PRESS, AINPUT_SOURCE_MOUSE)
- .deviceId(mouseDeviceId)
- .buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
- .actionButton(AMOTION_EVENT_BUTTON_PRIMARY)
- .pointer(PointerBuilder(0, ToolType::MOUSE).x(100).y(100))
- .build()));
+ mDispatcher->notifyMotion(
+ MotionArgsBuilder(AMOTION_EVENT_ACTION_BUTTON_PRESS, AINPUT_SOURCE_MOUSE)
+ .deviceId(mouseDeviceId)
+ .buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
+ .actionButton(AMOTION_EVENT_BUTTON_PRIMARY)
+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(100).y(100))
+ .build());
leftWindow->consumeMotionEvent(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_PRESS));
// First touch pointer down on right window
- mDispatcher->notifyMotion(&(
- args = MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
- .deviceId(touchDeviceId)
- .pointer(PointerBuilder(0, ToolType::FINGER).x(300).y(100))
- .build()));
+ mDispatcher->notifyMotion(MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
+ .deviceId(touchDeviceId)
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(300).y(100))
+ .build());
leftWindow->consumeMotionEvent(WithMotionAction(ACTION_CANCEL));
rightWindow->consumeMotionEvent(WithMotionAction(ACTION_DOWN));
// Second touch pointer down on left window
- mDispatcher->notifyMotion(&(
- args = MotionArgsBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
- .deviceId(touchDeviceId)
- .pointer(PointerBuilder(0, ToolType::FINGER).x(300).y(100))
- .pointer(PointerBuilder(1, ToolType::FINGER).x(100).y(100))
- .build()));
+ mDispatcher->notifyMotion(MotionArgsBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
+ .deviceId(touchDeviceId)
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(300).y(100))
+ .pointer(PointerBuilder(1, ToolType::FINGER).x(100).y(100))
+ .build());
leftWindow->consumeMotionEvent(
AllOf(WithMotionAction(ACTION_DOWN), WithDeviceId(touchDeviceId)));
// This MOVE event is not necessary (doesn't carry any new information), but it's there in the
@@ -2533,57 +2517,52 @@
NotifyMotionArgs args;
// First touch pointer down
- mDispatcher->notifyMotion(&(
- args = MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
- .deviceId(touchDeviceId)
- .pointer(PointerBuilder(0, ToolType::FINGER).x(300).y(100))
- .build()));
+ mDispatcher->notifyMotion(MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
+ .deviceId(touchDeviceId)
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(300).y(100))
+ .build());
// Second touch pointer down
- mDispatcher->notifyMotion(&(
- args = MotionArgsBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
- .deviceId(touchDeviceId)
- .pointer(PointerBuilder(0, ToolType::FINGER).x(300).y(100))
- .pointer(PointerBuilder(1, ToolType::FINGER).x(350).y(100))
- .build()));
+ mDispatcher->notifyMotion(MotionArgsBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
+ .deviceId(touchDeviceId)
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(300).y(100))
+ .pointer(PointerBuilder(1, ToolType::FINGER).x(350).y(100))
+ .build());
// First touch pointer lifts. The second one remains down
- mDispatcher->notifyMotion(&(
- args = MotionArgsBuilder(POINTER_0_UP, AINPUT_SOURCE_TOUCHSCREEN)
- .deviceId(touchDeviceId)
- .pointer(PointerBuilder(0, ToolType::FINGER).x(300).y(100))
- .pointer(PointerBuilder(1, ToolType::FINGER).x(350).y(100))
- .build()));
+ mDispatcher->notifyMotion(MotionArgsBuilder(POINTER_0_UP, AINPUT_SOURCE_TOUCHSCREEN)
+ .deviceId(touchDeviceId)
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(300).y(100))
+ .pointer(PointerBuilder(1, ToolType::FINGER).x(350).y(100))
+ .build());
window->consumeMotionEvent(WithMotionAction(ACTION_DOWN));
window->consumeMotionEvent(WithMotionAction(POINTER_1_DOWN));
window->consumeMotionEvent(WithMotionAction(POINTER_0_UP));
// Mouse down. The touch should be canceled
- mDispatcher->notifyMotion(&(
- args = MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_MOUSE)
- .deviceId(mouseDeviceId)
- .buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
- .pointer(PointerBuilder(0, ToolType::MOUSE).x(320).y(100))
- .build()));
+ mDispatcher->notifyMotion(MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_MOUSE)
+ .deviceId(mouseDeviceId)
+ .buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(320).y(100))
+ .build());
window->consumeMotionEvent(AllOf(WithMotionAction(ACTION_CANCEL), WithDeviceId(touchDeviceId),
WithPointerCount(1u)));
window->consumeMotionEvent(AllOf(WithMotionAction(ACTION_DOWN), WithDeviceId(mouseDeviceId)));
- mDispatcher->notifyMotion(&(
- args = MotionArgsBuilder(AMOTION_EVENT_ACTION_BUTTON_PRESS, AINPUT_SOURCE_MOUSE)
- .deviceId(mouseDeviceId)
- .buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
- .actionButton(AMOTION_EVENT_BUTTON_PRIMARY)
- .pointer(PointerBuilder(0, ToolType::MOUSE).x(320).y(100))
- .build()));
+ mDispatcher->notifyMotion(
+ MotionArgsBuilder(AMOTION_EVENT_ACTION_BUTTON_PRESS, AINPUT_SOURCE_MOUSE)
+ .deviceId(mouseDeviceId)
+ .buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
+ .actionButton(AMOTION_EVENT_BUTTON_PRIMARY)
+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(320).y(100))
+ .build());
window->consumeMotionEvent(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_PRESS));
// Second touch pointer down.
- mDispatcher->notifyMotion(&(
- args = MotionArgsBuilder(POINTER_0_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
- .deviceId(touchDeviceId)
- .pointer(PointerBuilder(0, ToolType::FINGER).x(300).y(100))
- .pointer(PointerBuilder(1, ToolType::FINGER).x(350).y(100))
- .build()));
+ mDispatcher->notifyMotion(MotionArgsBuilder(POINTER_0_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
+ .deviceId(touchDeviceId)
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(300).y(100))
+ .pointer(PointerBuilder(1, ToolType::FINGER).x(350).y(100))
+ .build());
// The pointer_down event should be ignored
window->assertNoEvents();
}
@@ -2617,11 +2596,10 @@
// Now a real touch comes. Rather than crashing or dropping the real event, the injected pointer
// should be canceled and the new gesture should take over.
- mDispatcher->notifyMotion(&(
- args = MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
- .deviceId(touchDeviceId)
- .pointer(PointerBuilder(0, ToolType::FINGER).x(300).y(100))
- .build()));
+ mDispatcher->notifyMotion(MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
+ .deviceId(touchDeviceId)
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(300).y(100))
+ .build());
window->consumeMotionEvent(
AllOf(WithMotionAction(ACTION_CANCEL), WithDeviceId(VIRTUAL_KEYBOARD_ID)));
@@ -2823,46 +2801,38 @@
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {spyWindow, window}}});
- NotifyMotionArgs args;
-
// Start hovering with stylus
- mDispatcher->notifyMotion(
- &(args = MotionArgsBuilder(ACTION_HOVER_ENTER, AINPUT_SOURCE_STYLUS)
- .pointer(PointerBuilder(0, ToolType::STYLUS).x(50).y(50))
- .build()));
+ mDispatcher->notifyMotion(MotionArgsBuilder(ACTION_HOVER_ENTER, AINPUT_SOURCE_STYLUS)
+ .pointer(PointerBuilder(0, ToolType::STYLUS).x(50).y(50))
+ .build());
spyWindow->consumeMotionEvent(WithMotionAction(ACTION_HOVER_ENTER));
// Stop hovering
- mDispatcher->notifyMotion(
- &(args = MotionArgsBuilder(ACTION_HOVER_EXIT, AINPUT_SOURCE_STYLUS)
- .pointer(PointerBuilder(0, ToolType::STYLUS).x(50).y(50))
- .build()));
+ mDispatcher->notifyMotion(MotionArgsBuilder(ACTION_HOVER_EXIT, AINPUT_SOURCE_STYLUS)
+ .pointer(PointerBuilder(0, ToolType::STYLUS).x(50).y(50))
+ .build());
spyWindow->consumeMotionEvent(WithMotionAction(ACTION_HOVER_EXIT));
// Stylus touches down
- mDispatcher->notifyMotion(
- &(args = MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_STYLUS)
- .pointer(PointerBuilder(0, ToolType::STYLUS).x(50).y(50))
- .build()));
+ mDispatcher->notifyMotion(MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_STYLUS)
+ .pointer(PointerBuilder(0, ToolType::STYLUS).x(50).y(50))
+ .build());
spyWindow->consumeMotionEvent(WithMotionAction(ACTION_DOWN));
// Stylus goes up
- mDispatcher->notifyMotion(
- &(args = MotionArgsBuilder(ACTION_UP, AINPUT_SOURCE_STYLUS)
- .pointer(PointerBuilder(0, ToolType::STYLUS).x(50).y(50))
- .build()));
+ mDispatcher->notifyMotion(MotionArgsBuilder(ACTION_UP, AINPUT_SOURCE_STYLUS)
+ .pointer(PointerBuilder(0, ToolType::STYLUS).x(50).y(50))
+ .build());
spyWindow->consumeMotionEvent(WithMotionAction(ACTION_UP));
// Again hover
- mDispatcher->notifyMotion(
- &(args = MotionArgsBuilder(ACTION_HOVER_ENTER, AINPUT_SOURCE_STYLUS)
- .pointer(PointerBuilder(0, ToolType::STYLUS).x(50).y(50))
- .build()));
+ mDispatcher->notifyMotion(MotionArgsBuilder(ACTION_HOVER_ENTER, AINPUT_SOURCE_STYLUS)
+ .pointer(PointerBuilder(0, ToolType::STYLUS).x(50).y(50))
+ .build());
spyWindow->consumeMotionEvent(WithMotionAction(ACTION_HOVER_ENTER));
// Stop hovering
- mDispatcher->notifyMotion(
- &(args = MotionArgsBuilder(ACTION_HOVER_EXIT, AINPUT_SOURCE_STYLUS)
- .pointer(PointerBuilder(0, ToolType::STYLUS).x(50).y(50))
- .build()));
+ mDispatcher->notifyMotion(MotionArgsBuilder(ACTION_HOVER_EXIT, AINPUT_SOURCE_STYLUS)
+ .pointer(PointerBuilder(0, ToolType::STYLUS).x(50).y(50))
+ .build());
spyWindow->consumeMotionEvent(WithMotionAction(ACTION_HOVER_EXIT));
// No more events
@@ -2891,35 +2861,31 @@
const int32_t mouseDeviceId = 7;
const int32_t touchDeviceId = 4;
- NotifyMotionArgs args;
// Hover a bit with mouse first
- mDispatcher->notifyMotion(&(
- args = MotionArgsBuilder(ACTION_HOVER_ENTER, AINPUT_SOURCE_MOUSE)
- .deviceId(mouseDeviceId)
- .pointer(PointerBuilder(0, ToolType::MOUSE).x(100).y(100))
- .build()));
+ mDispatcher->notifyMotion(MotionArgsBuilder(ACTION_HOVER_ENTER, AINPUT_SOURCE_MOUSE)
+ .deviceId(mouseDeviceId)
+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(100).y(100))
+ .build());
spyWindow->consumeMotionEvent(
AllOf(WithMotionAction(ACTION_HOVER_ENTER), WithDeviceId(mouseDeviceId)));
window->consumeMotionEvent(
AllOf(WithMotionAction(ACTION_HOVER_ENTER), WithDeviceId(mouseDeviceId)));
// Start touching
- mDispatcher->notifyMotion(
- &(args = MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
- .deviceId(touchDeviceId)
- .pointer(PointerBuilder(0, ToolType::FINGER).x(50).y(50))
- .build()));
+ mDispatcher->notifyMotion(MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
+ .deviceId(touchDeviceId)
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(50).y(50))
+ .build());
spyWindow->consumeMotionEvent(WithMotionAction(ACTION_HOVER_EXIT));
window->consumeMotionEvent(WithMotionAction(ACTION_HOVER_EXIT));
spyWindow->consumeMotionEvent(WithMotionAction(ACTION_DOWN));
window->consumeMotionEvent(WithMotionAction(ACTION_DOWN));
- mDispatcher->notifyMotion(
- &(args = MotionArgsBuilder(ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN)
- .deviceId(touchDeviceId)
- .pointer(PointerBuilder(0, ToolType::FINGER).x(55).y(55))
- .build()));
+ mDispatcher->notifyMotion(MotionArgsBuilder(ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN)
+ .deviceId(touchDeviceId)
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(55).y(55))
+ .build());
spyWindow->consumeMotionEvent(WithMotionAction(ACTION_MOVE));
window->consumeMotionEvent(WithMotionAction(ACTION_MOVE));
@@ -2927,20 +2893,18 @@
EXPECT_EQ(OK, mDispatcher->pilferPointers(spyWindow->getToken()));
window->consumeMotionEvent(WithMotionAction(ACTION_CANCEL));
- mDispatcher->notifyMotion(
- &(args = MotionArgsBuilder(ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN)
- .deviceId(touchDeviceId)
- .pointer(PointerBuilder(0, ToolType::FINGER).x(60).y(60))
- .build()));
+ mDispatcher->notifyMotion(MotionArgsBuilder(ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN)
+ .deviceId(touchDeviceId)
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(60).y(60))
+ .build());
spyWindow->consumeMotionEvent(WithMotionAction(ACTION_MOVE));
// Mouse down
- mDispatcher->notifyMotion(&(
- args = MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_MOUSE)
- .deviceId(mouseDeviceId)
- .buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
- .pointer(PointerBuilder(0, ToolType::MOUSE).x(100).y(100))
- .build()));
+ mDispatcher->notifyMotion(MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_MOUSE)
+ .deviceId(mouseDeviceId)
+ .buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(100).y(100))
+ .build());
spyWindow->consumeMotionEvent(
AllOf(WithMotionAction(ACTION_CANCEL), WithDeviceId(touchDeviceId)));
@@ -2948,32 +2912,30 @@
AllOf(WithMotionAction(ACTION_DOWN), WithDeviceId(mouseDeviceId)));
window->consumeMotionEvent(AllOf(WithMotionAction(ACTION_DOWN), WithDeviceId(mouseDeviceId)));
- mDispatcher->notifyMotion(&(
- args = MotionArgsBuilder(AMOTION_EVENT_ACTION_BUTTON_PRESS, AINPUT_SOURCE_MOUSE)
- .deviceId(mouseDeviceId)
- .buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
- .actionButton(AMOTION_EVENT_BUTTON_PRIMARY)
- .pointer(PointerBuilder(0, ToolType::MOUSE).x(100).y(100))
- .build()));
+ mDispatcher->notifyMotion(
+ MotionArgsBuilder(AMOTION_EVENT_ACTION_BUTTON_PRESS, AINPUT_SOURCE_MOUSE)
+ .deviceId(mouseDeviceId)
+ .buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
+ .actionButton(AMOTION_EVENT_BUTTON_PRIMARY)
+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(100).y(100))
+ .build());
spyWindow->consumeMotionEvent(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_PRESS));
window->consumeMotionEvent(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_PRESS));
// Mouse move!
- mDispatcher->notifyMotion(&(
- args = MotionArgsBuilder(ACTION_MOVE, AINPUT_SOURCE_MOUSE)
- .deviceId(mouseDeviceId)
- .buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
- .pointer(PointerBuilder(0, ToolType::MOUSE).x(110).y(110))
- .build()));
+ mDispatcher->notifyMotion(MotionArgsBuilder(ACTION_MOVE, AINPUT_SOURCE_MOUSE)
+ .deviceId(mouseDeviceId)
+ .buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(110).y(110))
+ .build());
spyWindow->consumeMotionEvent(WithMotionAction(ACTION_MOVE));
window->consumeMotionEvent(WithMotionAction(ACTION_MOVE));
// Touch move!
- mDispatcher->notifyMotion(
- &(args = MotionArgsBuilder(ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN)
- .deviceId(touchDeviceId)
- .pointer(PointerBuilder(0, ToolType::FINGER).x(65).y(65))
- .build()));
+ mDispatcher->notifyMotion(MotionArgsBuilder(ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN)
+ .deviceId(touchDeviceId)
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(65).y(65))
+ .build());
// No more events
spyWindow->assertNoEvents();
@@ -2991,16 +2953,15 @@
sp<FakeWindowHandle>::make(application, mDispatcher, "Window", DISPLAY_ID);
mDispatcher->setInputWindows({{DISPLAY_ID, {window}}});
- NotifyMotionArgs args;
// Touch down on the empty space
- mDispatcher->notifyMotion(&(args = generateTouchArgs(AMOTION_EVENT_ACTION_DOWN, {{-1, -1}})));
+ mDispatcher->notifyMotion(generateTouchArgs(AMOTION_EVENT_ACTION_DOWN, {{-1, -1}}));
mDispatcher->waitForIdle();
window->assertNoEvents();
// Now touch down on the window with another pointer
- mDispatcher->notifyMotion(&(args = generateTouchArgs(POINTER_1_DOWN, {{-1, -1}, {10, 10}})));
+ mDispatcher->notifyMotion(generateTouchArgs(POINTER_1_DOWN, {{-1, -1}, {10, 10}}));
mDispatcher->waitForIdle();
window->consumeMotionDown();
}
@@ -3021,16 +2982,15 @@
mDispatcher->setInputWindows({{DISPLAY_ID, {window1, window2}}});
- NotifyMotionArgs args;
// Touch down on the non-touchable window
- mDispatcher->notifyMotion(&(args = generateTouchArgs(AMOTION_EVENT_ACTION_DOWN, {{50, 50}})));
+ mDispatcher->notifyMotion(generateTouchArgs(AMOTION_EVENT_ACTION_DOWN, {{50, 50}}));
mDispatcher->waitForIdle();
window1->assertNoEvents();
window2->assertNoEvents();
// Now touch down on the window with another pointer
- mDispatcher->notifyMotion(&(args = generateTouchArgs(POINTER_1_DOWN, {{50, 50}, {150, 50}})));
+ mDispatcher->notifyMotion(generateTouchArgs(POINTER_1_DOWN, {{50, 50}, {150, 50}}));
mDispatcher->waitForIdle();
window2->consumeMotionDown();
}
@@ -3050,9 +3010,8 @@
mDispatcher->setInputWindows({{DISPLAY_ID, {window1, window2}}});
- NotifyMotionArgs args;
// Touch down on the first window
- mDispatcher->notifyMotion(&(args = generateTouchArgs(AMOTION_EVENT_ACTION_DOWN, {{50, 50}})));
+ mDispatcher->notifyMotion(generateTouchArgs(AMOTION_EVENT_ACTION_DOWN, {{50, 50}}));
mDispatcher->waitForIdle();
InputEvent* inputEvent1 = window1->consume();
@@ -3063,7 +3022,7 @@
ASSERT_EQ(motionEvent1.getDownTime(), motionEvent1.getEventTime());
// Now touch down on the window with another pointer
- mDispatcher->notifyMotion(&(args = generateTouchArgs(POINTER_1_DOWN, {{50, 50}, {150, 50}})));
+ mDispatcher->notifyMotion(generateTouchArgs(POINTER_1_DOWN, {{50, 50}, {150, 50}}));
mDispatcher->waitForIdle();
InputEvent* inputEvent2 = window2->consume();
ASSERT_NE(inputEvent2, nullptr);
@@ -3073,14 +3032,12 @@
ASSERT_EQ(motionEvent2.getDownTime(), motionEvent2.getEventTime());
// Now move the pointer on the second window
- mDispatcher->notifyMotion(
- &(args = generateTouchArgs(AMOTION_EVENT_ACTION_MOVE, {{50, 50}, {151, 51}})));
+ mDispatcher->notifyMotion(generateTouchArgs(AMOTION_EVENT_ACTION_MOVE, {{50, 50}, {151, 51}}));
mDispatcher->waitForIdle();
window2->consumeMotionEvent(WithDownTime(downTimeForWindow2));
// Now add new touch down on the second window
- mDispatcher->notifyMotion(
- &(args = generateTouchArgs(POINTER_2_DOWN, {{50, 50}, {151, 51}, {150, 50}})));
+ mDispatcher->notifyMotion(generateTouchArgs(POINTER_2_DOWN, {{50, 50}, {151, 51}, {150, 50}}));
mDispatcher->waitForIdle();
window2->consumeMotionEvent(WithDownTime(downTimeForWindow2));
@@ -3089,13 +3046,13 @@
window1->assertNoEvents();
// Now move the pointer on the first window
- mDispatcher->notifyMotion(&(
- args = generateTouchArgs(AMOTION_EVENT_ACTION_MOVE, {{51, 51}, {151, 51}, {150, 50}})));
+ mDispatcher->notifyMotion(
+ generateTouchArgs(AMOTION_EVENT_ACTION_MOVE, {{51, 51}, {151, 51}, {150, 50}}));
mDispatcher->waitForIdle();
window1->consumeMotionEvent(WithDownTime(downTimeForWindow1));
- mDispatcher->notifyMotion(&(
- args = generateTouchArgs(POINTER_3_DOWN, {{51, 51}, {151, 51}, {150, 50}, {50, 50}})));
+ mDispatcher->notifyMotion(
+ generateTouchArgs(POINTER_3_DOWN, {{51, 51}, {151, 51}, {150, 50}, {50, 50}}));
mDispatcher->waitForIdle();
window1->consumeMotionEvent(WithDownTime(downTimeForWindow1));
}
@@ -3199,52 +3156,47 @@
const int32_t touchDeviceId = 4;
const int32_t mouseDeviceId = 6;
- NotifyMotionArgs args;
// Two pointers down
- mDispatcher->notifyMotion(&(
- args = MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
- .deviceId(touchDeviceId)
- .pointer(PointerBuilder(0, ToolType::FINGER).x(100).y(100))
- .build()));
+ mDispatcher->notifyMotion(MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
+ .deviceId(touchDeviceId)
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(100).y(100))
+ .build());
- mDispatcher->notifyMotion(&(
- args = MotionArgsBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
- .deviceId(touchDeviceId)
- .pointer(PointerBuilder(0, ToolType::FINGER).x(100).y(100))
- .pointer(PointerBuilder(1, ToolType::FINGER).x(120).y(120))
- .build()));
+ mDispatcher->notifyMotion(MotionArgsBuilder(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
+ .deviceId(touchDeviceId)
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(100).y(100))
+ .pointer(PointerBuilder(1, ToolType::FINGER).x(120).y(120))
+ .build());
window->consumeMotionEvent(WithMotionAction(ACTION_DOWN));
window->consumeMotionEvent(WithMotionAction(POINTER_1_DOWN));
// Inject a series of mouse events for a mouse click
- mDispatcher->notifyMotion(&(
- args = MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_MOUSE)
- .deviceId(mouseDeviceId)
- .buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
- .pointer(PointerBuilder(0, ToolType::MOUSE).x(300).y(400))
- .build()));
+ mDispatcher->notifyMotion(MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_MOUSE)
+ .deviceId(mouseDeviceId)
+ .buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(300).y(400))
+ .build());
window->consumeMotionEvent(AllOf(WithMotionAction(ACTION_CANCEL), WithDeviceId(touchDeviceId),
WithPointerCount(2u)));
window->consumeMotionEvent(AllOf(WithMotionAction(ACTION_DOWN), WithDeviceId(mouseDeviceId)));
- mDispatcher->notifyMotion(&(
- args = MotionArgsBuilder(AMOTION_EVENT_ACTION_BUTTON_PRESS, AINPUT_SOURCE_MOUSE)
- .deviceId(mouseDeviceId)
- .buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
- .actionButton(AMOTION_EVENT_BUTTON_PRIMARY)
- .pointer(PointerBuilder(0, ToolType::MOUSE).x(300).y(400))
- .build()));
+ mDispatcher->notifyMotion(
+ MotionArgsBuilder(AMOTION_EVENT_ACTION_BUTTON_PRESS, AINPUT_SOURCE_MOUSE)
+ .deviceId(mouseDeviceId)
+ .buttonState(AMOTION_EVENT_BUTTON_PRIMARY)
+ .actionButton(AMOTION_EVENT_BUTTON_PRIMARY)
+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(300).y(400))
+ .build());
window->consumeMotionEvent(WithMotionAction(AMOTION_EVENT_ACTION_BUTTON_PRESS));
// Try to send more touch events while the mouse is down. Since it's a continuation of an
// already canceled gesture, it should be ignored.
- mDispatcher->notifyMotion(&(
- args = MotionArgsBuilder(ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN)
- .deviceId(touchDeviceId)
- .pointer(PointerBuilder(0, ToolType::FINGER).x(101).y(101))
- .pointer(PointerBuilder(1, ToolType::FINGER).x(121).y(121))
- .build()));
+ mDispatcher->notifyMotion(MotionArgsBuilder(ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN)
+ .deviceId(touchDeviceId)
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(101).y(101))
+ .pointer(PointerBuilder(1, ToolType::FINGER).x(121).y(121))
+ .build());
window->assertNoEvents();
}
@@ -3508,23 +3460,20 @@
const int32_t mouseDeviceId = 7;
const int32_t touchDeviceId = 4;
- NotifyMotionArgs args;
// Start hovering with the mouse
- mDispatcher->notifyMotion(
- &(args = MotionArgsBuilder(ACTION_HOVER_ENTER, AINPUT_SOURCE_MOUSE)
- .deviceId(mouseDeviceId)
- .pointer(PointerBuilder(0, ToolType::MOUSE).x(10).y(10))
- .build()));
+ mDispatcher->notifyMotion(MotionArgsBuilder(ACTION_HOVER_ENTER, AINPUT_SOURCE_MOUSE)
+ .deviceId(mouseDeviceId)
+ .pointer(PointerBuilder(0, ToolType::MOUSE).x(10).y(10))
+ .build());
window->consumeMotionEvent(
AllOf(WithMotionAction(ACTION_HOVER_ENTER), WithDeviceId(mouseDeviceId)));
// Touch goes down
- mDispatcher->notifyMotion(
- &(args = MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
- .deviceId(touchDeviceId)
- .pointer(PointerBuilder(0, ToolType::FINGER).x(50).y(50))
- .build()));
+ mDispatcher->notifyMotion(MotionArgsBuilder(ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN)
+ .deviceId(touchDeviceId)
+ .pointer(PointerBuilder(0, ToolType::FINGER).x(50).y(50))
+ .build());
window->consumeMotionEvent(
AllOf(WithMotionAction(ACTION_HOVER_EXIT), WithDeviceId(mouseDeviceId)));
@@ -3550,15 +3499,15 @@
ADISPLAY_ID_DEFAULT, {{50, 50}});
motionArgs.xCursorPosition = 50;
motionArgs.yCursorPosition = 50;
- mDispatcher->notifyMotion(&motionArgs);
+ mDispatcher->notifyMotion(motionArgs);
ASSERT_NO_FATAL_FAILURE(
window->consumeMotionEvent(AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
WithSource(AINPUT_SOURCE_MOUSE))));
// Tap on the window
- motionArgs = generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {{10, 10}});
- mDispatcher->notifyMotion(&motionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
+ AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ {{10, 10}}));
ASSERT_NO_FATAL_FAILURE(
window->consumeMotionEvent(AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_EXIT),
WithSource(AINPUT_SOURCE_MOUSE))));
@@ -3567,9 +3516,8 @@
window->consumeMotionEvent(AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN),
WithSource(AINPUT_SOURCE_TOUCHSCREEN))));
- motionArgs = generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {{10, 10}});
- mDispatcher->notifyMotion(&motionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN,
+ ADISPLAY_ID_DEFAULT, {{10, 10}}));
ASSERT_NO_FATAL_FAILURE(
window->consumeMotionEvent(AllOf(WithMotionAction(AMOTION_EVENT_ACTION_UP),
WithSource(AINPUT_SOURCE_TOUCHSCREEN))));
@@ -3661,16 +3609,14 @@
window->consumeFocusEvent(true);
- NotifyKeyArgs keyArgs = generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT);
- mDispatcher->notifyKey(&keyArgs);
+ mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT));
// Window should receive key down event.
window->consumeKeyDown(ADISPLAY_ID_DEFAULT);
// When device reset happens, that key stream should be terminated with FLAG_CANCELED
// on the app side.
- NotifyDeviceResetArgs args(/*id=*/10, /*eventTime=*/20, DEVICE_ID);
- mDispatcher->notifyDeviceReset(&args);
+ mDispatcher->notifyDeviceReset({/*id=*/10, /*eventTime=*/20, DEVICE_ID});
window->consumeEvent(InputEventType::KEY, AKEY_EVENT_ACTION_UP, ADISPLAY_ID_DEFAULT,
AKEY_EVENT_FLAG_CANCELED);
}
@@ -3682,18 +3628,15 @@
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {window}}});
- NotifyMotionArgs motionArgs =
- generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT);
- mDispatcher->notifyMotion(&motionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
+ AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT));
// Window should receive motion down event.
window->consumeMotionDown(ADISPLAY_ID_DEFAULT);
// When device reset happens, that motion stream should be terminated with ACTION_CANCEL
// on the app side.
- NotifyDeviceResetArgs args(/*id=*/10, /*eventTime=*/20, DEVICE_ID);
- mDispatcher->notifyDeviceReset(&args);
+ mDispatcher->notifyDeviceReset({/*id=*/10, /*eventTime=*/20, DEVICE_ID});
window->consumeMotionEvent(
AllOf(WithMotionAction(ACTION_CANCEL), WithDisplayId(ADISPLAY_ID_DEFAULT)));
}
@@ -3709,11 +3652,11 @@
window->consumeFocusEvent(true);
- NotifyKeyArgs keyArgs = generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT);
+ const NotifyKeyArgs keyArgs = generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT);
const std::chrono::milliseconds interceptKeyTimeout = 50ms;
const nsecs_t injectTime = keyArgs.eventTime;
mFakePolicy->setInterceptKeyTimeout(interceptKeyTimeout);
- mDispatcher->notifyKey(&keyArgs);
+ mDispatcher->notifyKey(keyArgs);
// The dispatching time should be always greater than or equal to intercept key timeout.
window->consumeKeyDown(ADISPLAY_ID_DEFAULT);
ASSERT_TRUE((systemTime(SYSTEM_TIME_MONOTONIC) - injectTime) >=
@@ -3731,11 +3674,9 @@
window->consumeFocusEvent(true);
- NotifyKeyArgs keyDown = generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT);
- NotifyKeyArgs keyUp = generateKeyArgs(AKEY_EVENT_ACTION_UP, ADISPLAY_ID_DEFAULT);
mFakePolicy->setInterceptKeyTimeout(150ms);
- mDispatcher->notifyKey(&keyDown);
- mDispatcher->notifyKey(&keyUp);
+ mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT));
+ mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_UP, ADISPLAY_ID_DEFAULT));
// Window should receive key event immediately when same key up.
window->consumeKeyDown(ADISPLAY_ID_DEFAULT);
@@ -3764,10 +3705,9 @@
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {outsideWindow, window}}});
// Tap on first window.
- NotifyMotionArgs motionArgs =
- generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {PointF{50, 50}});
- mDispatcher->notifyMotion(&motionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
+ AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ {PointF{50, 50}}));
window->consumeMotionDown();
// The coordinates of the tap in 'outsideWindow' are relative to its top left corner.
// Therefore, we should offset them by (100, 100) relative to the screen's top left corner.
@@ -3798,18 +3738,17 @@
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {window, secondWindow, thirdWindow}}});
// First pointer lands outside all windows. `window` does not get ACTION_OUTSIDE.
- NotifyMotionArgs motionArgs =
- generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {PointF{-10, -10}});
- mDispatcher->notifyMotion(&motionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
+ AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ {PointF{-10, -10}}));
window->assertNoEvents();
secondWindow->assertNoEvents();
// The second pointer lands inside `secondWindow`, which should receive a DOWN event.
// Now, `window` should get ACTION_OUTSIDE.
- motionArgs = generateMotionArgs(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {PointF{-10, -10}, PointF{105, 105}});
- mDispatcher->notifyMotion(&motionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
+ ADISPLAY_ID_DEFAULT,
+ {PointF{-10, -10}, PointF{105, 105}}));
const std::map<int32_t, PointF> expectedPointers{{0, PointF{-10, -10}}, {1, PointF{105, 105}}};
window->consumeMotionEvent(
AllOf(WithMotionAction(ACTION_OUTSIDE), WithPointers(expectedPointers)));
@@ -3818,9 +3757,9 @@
// The third pointer lands inside `thirdWindow`, which should receive a DOWN event. There is
// no ACTION_OUTSIDE sent to `window` because one has already been sent for this gesture.
- motionArgs = generateMotionArgs(POINTER_2_DOWN, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {PointF{-10, -10}, PointF{105, 105}, PointF{205, 205}});
- mDispatcher->notifyMotion(&motionArgs);
+ mDispatcher->notifyMotion(
+ generateMotionArgs(POINTER_2_DOWN, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ {PointF{-10, -10}, PointF{105, 105}, PointF{205, 205}}));
window->assertNoEvents();
secondWindow->consumeMotionMove();
thirdWindow->consumeMotionDown();
@@ -3837,10 +3776,10 @@
window->consumeFocusEvent(true);
- NotifyKeyArgs keyDown = generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT);
- NotifyKeyArgs keyUp = generateKeyArgs(AKEY_EVENT_ACTION_UP, ADISPLAY_ID_DEFAULT);
- mDispatcher->notifyKey(&keyDown);
- mDispatcher->notifyKey(&keyUp);
+ const NotifyKeyArgs keyDown = generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT);
+ const NotifyKeyArgs keyUp = generateKeyArgs(AKEY_EVENT_ACTION_UP, ADISPLAY_ID_DEFAULT);
+ mDispatcher->notifyKey(keyDown);
+ mDispatcher->notifyKey(keyUp);
window->consumeKeyDown(ADISPLAY_ID_DEFAULT);
window->consumeKeyUp(ADISPLAY_ID_DEFAULT);
@@ -3850,8 +3789,8 @@
window->consumeFocusEvent(false);
- mDispatcher->notifyKey(&keyDown);
- mDispatcher->notifyKey(&keyUp);
+ mDispatcher->notifyKey(keyDown);
+ mDispatcher->notifyKey(keyUp);
window->assertNoEvents();
}
@@ -3959,10 +3898,9 @@
// Send down to the first window. The point is represented in the display space. The point is
// selected so that if the hit test was performed with the point and the bounds being in
// different coordinate spaces, the event would end up in the incorrect window.
- NotifyMotionArgs downMotionArgs =
- generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {PointF{75, 55}});
- mDispatcher->notifyMotion(&downMotionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
+ AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ {PointF{75, 55}}));
firstWindow->consumeMotionDown();
secondWindow->assertNoEvents();
@@ -4013,10 +3951,9 @@
auto [firstWindow, secondWindow] = setupScaledDisplayScenario();
// Send down to the second window.
- NotifyMotionArgs downMotionArgs =
- generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {PointF{150, 220}});
- mDispatcher->notifyMotion(&downMotionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
+ AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ {PointF{150, 220}}));
firstWindow->assertNoEvents();
const MotionEvent* event = secondWindow->consumeMotion();
@@ -4071,14 +4008,14 @@
for (const auto pointInsideWindow : insidePoints) {
const vec2 p = displayTransform.inverse().transform(pointInsideWindow);
const PointF pointInDisplaySpace{p.x, p.y};
- const auto down = generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {pointInDisplaySpace});
- mDispatcher->notifyMotion(&down);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
+ AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ {pointInDisplaySpace}));
window->consumeMotionDown();
- const auto up = generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {pointInDisplaySpace});
- mDispatcher->notifyMotion(&up);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP,
+ AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ {pointInDisplaySpace}));
window->consumeMotionUp();
}
@@ -4088,13 +4025,13 @@
for (const auto pointOutsideWindow : outsidePoints) {
const vec2 p = displayTransform.inverse().transform(pointOutsideWindow);
const PointF pointInDisplaySpace{p.x, p.y};
- const auto down = generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {pointInDisplaySpace});
- mDispatcher->notifyMotion(&down);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
+ AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ {pointInDisplaySpace}));
- const auto up = generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {pointInDisplaySpace});
- mDispatcher->notifyMotion(&up);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP,
+ AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ {pointInDisplaySpace}));
}
window->assertNoEvents();
}
@@ -4132,10 +4069,8 @@
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {firstWindow, secondWindow, wallpaper}}});
// Send down to the first window
- NotifyMotionArgs downMotionArgs =
- generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT);
- mDispatcher->notifyMotion(&downMotionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
+ AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT));
// Only the first window should get the down event
firstWindow->consumeMotionDown();
@@ -4152,10 +4087,8 @@
wallpaper->consumeMotionCancel(ADISPLAY_ID_DEFAULT, expectedWallpaperFlags);
// Send up event to the second window
- NotifyMotionArgs upMotionArgs =
- generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT);
- mDispatcher->notifyMotion(&upMotionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN,
+ ADISPLAY_ID_DEFAULT));
// The first window gets no events and the second gets up
firstWindow->assertNoEvents();
secondWindow->consumeMotionUp();
@@ -4191,10 +4124,8 @@
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {spyWindow, firstWindow, secondWindow}}});
// Send down to the first window
- NotifyMotionArgs downMotionArgs =
- generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT);
- mDispatcher->notifyMotion(&downMotionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
+ AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT));
// Only the first window and spy should get the down event
spyWindow->consumeMotionDown();
firstWindow->consumeMotionDown();
@@ -4209,10 +4140,8 @@
secondWindow->consumeMotionDown();
// Send up event to the second window
- NotifyMotionArgs upMotionArgs =
- generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT);
- mDispatcher->notifyMotion(&upMotionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN,
+ ADISPLAY_ID_DEFAULT));
// The first window gets no events and the second+spy get up
firstWindow->assertNoEvents();
spyWindow->consumeMotionUp();
@@ -4238,19 +4167,16 @@
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {firstWindow, secondWindow}}});
// Send down to the first window
- NotifyMotionArgs downMotionArgs =
- generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {touchPoint});
- mDispatcher->notifyMotion(&downMotionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
+ AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ {touchPoint}));
// Only the first window should get the down event
firstWindow->consumeMotionDown();
secondWindow->assertNoEvents();
// Send pointer down to the first window
- NotifyMotionArgs pointerDownMotionArgs =
- generateMotionArgs(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {touchPoint, touchPoint});
- mDispatcher->notifyMotion(&pointerDownMotionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
+ ADISPLAY_ID_DEFAULT, {touchPoint, touchPoint}));
// Only the first window should get the pointer down event
firstWindow->consumeMotionPointerDown(1);
secondWindow->assertNoEvents();
@@ -4265,19 +4191,15 @@
secondWindow->consumeMotionPointerDown(1);
// Send pointer up to the second window
- NotifyMotionArgs pointerUpMotionArgs =
- generateMotionArgs(POINTER_1_UP, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {touchPoint, touchPoint});
- mDispatcher->notifyMotion(&pointerUpMotionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(POINTER_1_UP, AINPUT_SOURCE_TOUCHSCREEN,
+ ADISPLAY_ID_DEFAULT, {touchPoint, touchPoint}));
// The first window gets nothing and the second gets pointer up
firstWindow->assertNoEvents();
secondWindow->consumeMotionPointerUp(1);
// Send up event to the second window
- NotifyMotionArgs upMotionArgs =
- generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT);
- mDispatcher->notifyMotion(&upMotionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN,
+ ADISPLAY_ID_DEFAULT));
// The first window gets nothing and the second gets up
firstWindow->assertNoEvents();
secondWindow->consumeMotionUp();
@@ -4308,10 +4230,8 @@
{{ADISPLAY_ID_DEFAULT, {firstWindow, wallpaper1, secondWindow, wallpaper2}}});
// Send down to the first window
- NotifyMotionArgs downMotionArgs =
- generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT);
- mDispatcher->notifyMotion(&downMotionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
+ AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT));
// Only the first window should get the down event
firstWindow->consumeMotionDown();
@@ -4331,10 +4251,8 @@
wallpaper2->consumeMotionDown(ADISPLAY_ID_DEFAULT, expectedWallpaperFlags);
// Send up event to the second window
- NotifyMotionArgs upMotionArgs =
- generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT);
- mDispatcher->notifyMotion(&upMotionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN,
+ ADISPLAY_ID_DEFAULT));
// The first window gets no events and the second gets up
firstWindow->assertNoEvents();
secondWindow->consumeMotionUp();
@@ -4378,19 +4296,17 @@
PointF pointInSecond = {300, 600};
// Send down to the first window
- NotifyMotionArgs firstDownMotionArgs =
- generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {pointInFirst});
- mDispatcher->notifyMotion(&firstDownMotionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
+ AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ {pointInFirst}));
// Only the first window should get the down event
firstWindow->consumeMotionDown();
secondWindow->assertNoEvents();
// Send down to the second window
- NotifyMotionArgs secondDownMotionArgs =
- generateMotionArgs(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {pointInFirst, pointInSecond});
- mDispatcher->notifyMotion(&secondDownMotionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
+ ADISPLAY_ID_DEFAULT,
+ {pointInFirst, pointInSecond}));
// The first window gets a move and the second a down
firstWindow->consumeMotionMove();
secondWindow->consumeMotionDown();
@@ -4402,19 +4318,16 @@
secondWindow->consumeMotionPointerDown(1);
// Send pointer up to the second window
- NotifyMotionArgs pointerUpMotionArgs =
- generateMotionArgs(POINTER_1_UP, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {pointInFirst, pointInSecond});
- mDispatcher->notifyMotion(&pointerUpMotionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(POINTER_1_UP, AINPUT_SOURCE_TOUCHSCREEN,
+ ADISPLAY_ID_DEFAULT,
+ {pointInFirst, pointInSecond}));
// The first window gets nothing and the second gets pointer up
firstWindow->assertNoEvents();
secondWindow->consumeMotionPointerUp(1);
// Send up event to the second window
- NotifyMotionArgs upMotionArgs =
- generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT);
- mDispatcher->notifyMotion(&upMotionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN,
+ ADISPLAY_ID_DEFAULT));
// The first window gets nothing and the second gets up
firstWindow->assertNoEvents();
secondWindow->consumeMotionUp();
@@ -4444,19 +4357,17 @@
PointF pointInSecond = {300, 600};
// Send down to the first window
- NotifyMotionArgs firstDownMotionArgs =
- generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {pointInFirst});
- mDispatcher->notifyMotion(&firstDownMotionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
+ AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ {pointInFirst}));
// Only the first window should get the down event
firstWindow->consumeMotionDown();
secondWindow->assertNoEvents();
// Send down to the second window
- NotifyMotionArgs secondDownMotionArgs =
- generateMotionArgs(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {pointInFirst, pointInSecond});
- mDispatcher->notifyMotion(&secondDownMotionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
+ ADISPLAY_ID_DEFAULT,
+ {pointInFirst, pointInSecond}));
// The first window gets a move and the second a down
firstWindow->consumeMotionMove();
secondWindow->consumeMotionDown();
@@ -4471,19 +4382,16 @@
// The rest of the dispatch should proceed as normal
// Send pointer up to the second window
- NotifyMotionArgs pointerUpMotionArgs =
- generateMotionArgs(POINTER_1_UP, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {pointInFirst, pointInSecond});
- mDispatcher->notifyMotion(&pointerUpMotionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(POINTER_1_UP, AINPUT_SOURCE_TOUCHSCREEN,
+ ADISPLAY_ID_DEFAULT,
+ {pointInFirst, pointInSecond}));
// The first window gets MOVE and the second gets pointer up
firstWindow->consumeMotionMove();
secondWindow->consumeMotionUp();
// Send up event to the first window
- NotifyMotionArgs upMotionArgs =
- generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT);
- mDispatcher->notifyMotion(&upMotionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN,
+ ADISPLAY_ID_DEFAULT));
// The first window gets nothing and the second gets up
firstWindow->consumeMotionUp();
secondWindow->assertNoEvents();
@@ -4618,8 +4526,7 @@
window->consumeFocusEvent(true);
- NotifyKeyArgs keyArgs = generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT);
- mDispatcher->notifyKey(&keyArgs);
+ mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT));
// Window should receive key down event.
window->consumeKeyDown(ADISPLAY_ID_DEFAULT);
@@ -4632,8 +4539,7 @@
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {window}}});
- NotifyKeyArgs keyArgs = generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT);
- mDispatcher->notifyKey(&keyArgs);
+ mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT));
mDispatcher->waitForIdle();
window->assertNoEvents();
@@ -4648,13 +4554,10 @@
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {window}}});
// Send key
- NotifyKeyArgs keyArgs = generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT);
- mDispatcher->notifyKey(&keyArgs);
+ mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT));
// Send motion
- NotifyMotionArgs motionArgs =
- generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT);
- mDispatcher->notifyMotion(&motionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
+ AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT));
// Window should receive only the motion event
window->consumeMotionDown(ADISPLAY_ID_DEFAULT);
@@ -4681,19 +4584,17 @@
PointF pointInSecond = {300, 600};
// Send down to the first window
- NotifyMotionArgs firstDownMotionArgs =
- generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {pointInFirst});
- mDispatcher->notifyMotion(&firstDownMotionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
+ AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ {pointInFirst}));
// Only the first window should get the down event
firstWindow->consumeMotionDown();
secondWindow->assertNoEvents();
// Send down to the second window
- NotifyMotionArgs secondDownMotionArgs =
- generateMotionArgs(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {pointInFirst, pointInSecond});
- mDispatcher->notifyMotion(&secondDownMotionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
+ ADISPLAY_ID_DEFAULT,
+ {pointInFirst, pointInSecond}));
// The first window gets a move and the second a down
firstWindow->consumeMotionMove();
secondWindow->consumeMotionDown();
@@ -4703,16 +4604,14 @@
generateMotionArgs(POINTER_1_UP, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
{pointInFirst, pointInSecond});
pointerUpMotionArgs.flags |= AMOTION_EVENT_FLAG_CANCELED;
- mDispatcher->notifyMotion(&pointerUpMotionArgs);
+ mDispatcher->notifyMotion(pointerUpMotionArgs);
// The first window gets move and the second gets cancel.
firstWindow->consumeMotionMove(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_CANCELED);
secondWindow->consumeMotionCancel(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_CANCELED);
// Send up event.
- NotifyMotionArgs upMotionArgs =
- generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT);
- mDispatcher->notifyMotion(&upMotionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN,
+ ADISPLAY_ID_DEFAULT));
// The first window gets up and the second gets nothing.
firstWindow->consumeMotionUp();
secondWindow->assertNoEvents();
@@ -4934,7 +4833,7 @@
generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
ADISPLAY_ID_DEFAULT);
- mDispatcher->notifyMotion(&motionArgs);
+ mDispatcher->notifyMotion(motionArgs);
// Window should receive motion down event.
window->consumeMotionDown(ADISPLAY_ID_DEFAULT);
@@ -4944,7 +4843,7 @@
motionArgs.pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X,
motionArgs.pointerCoords[0].getX() - 10);
- mDispatcher->notifyMotion(&motionArgs);
+ mDispatcher->notifyMotion(motionArgs);
window->consumeEvent(InputEventType::MOTION, AMOTION_EVENT_ACTION_MOVE, ADISPLAY_ID_DEFAULT,
/*expectedFlags=*/0);
}
@@ -5013,8 +4912,8 @@
window->consumeFocusEvent(/*hasFocus=*/true, /*inTouchMode=*/true);
- NotifyKeyArgs keyArgs = generateKeyArgs(AKEY_EVENT_ACTION_DOWN);
- mDispatcher->notifyKey(&keyArgs);
+ const NotifyKeyArgs keyArgs = generateKeyArgs(AKEY_EVENT_ACTION_DOWN);
+ mDispatcher->notifyKey(keyArgs);
InputEvent* event = window->consume();
ASSERT_NE(event, nullptr);
@@ -5055,10 +4954,10 @@
mDispatcher->onWindowInfosChanged({*window->getInfo()}, {displayInfo});
- NotifyMotionArgs motionArgs =
+ const NotifyMotionArgs motionArgs =
generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
ADISPLAY_ID_DEFAULT);
- mDispatcher->notifyMotion(&motionArgs);
+ mDispatcher->notifyMotion(motionArgs);
InputEvent* event = window->consume();
ASSERT_NE(event, nullptr);
@@ -5355,17 +5254,17 @@
{{ADISPLAY_ID_DEFAULT, {slipperyExitWindow, slipperyEnterWindow}}});
// Use notifyMotion instead of injecting to avoid dealing with injection permissions
- NotifyMotionArgs args = generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {{50, 50}});
- mDispatcher->notifyMotion(&args);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
+ AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ {{50, 50}}));
slipperyExitWindow->consumeMotionDown();
slipperyExitWindow->setFrame(Rect(70, 70, 100, 100));
mDispatcher->setInputWindows(
{{ADISPLAY_ID_DEFAULT, {slipperyExitWindow, slipperyEnterWindow}}});
- args = generateMotionArgs(AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {{51, 51}});
- mDispatcher->notifyMotion(&args);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_MOVE,
+ AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ {{51, 51}}));
slipperyExitWindow->consumeMotionCancel();
@@ -5405,7 +5304,7 @@
NotifyKeyArgs keyArgs = generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT);
keyArgs.deviceId = deviceId;
keyArgs.policyFlags |= POLICY_FLAG_TRUSTED; // Otherwise it won't generate repeat event
- mDispatcher->notifyKey(&keyArgs);
+ mDispatcher->notifyKey(keyArgs);
// Window should receive key down event.
mWindow->consumeKeyDown(ADISPLAY_ID_DEFAULT);
@@ -5428,7 +5327,7 @@
NotifyKeyArgs keyArgs = generateKeyArgs(AKEY_EVENT_ACTION_UP, ADISPLAY_ID_DEFAULT);
keyArgs.deviceId = deviceId;
keyArgs.policyFlags |= POLICY_FLAG_TRUSTED; // Unless it won't generate repeat event
- mDispatcher->notifyKey(&keyArgs);
+ mDispatcher->notifyKey(keyArgs);
// Window should receive key down event.
mWindow->consumeEvent(InputEventType::KEY, AKEY_EVENT_ACTION_UP, ADISPLAY_ID_DEFAULT,
@@ -5491,8 +5390,7 @@
TEST_F(InputDispatcherKeyRepeatTest, FocusedWindow_StopsKeyRepeatAfterDisableInputDevice) {
sendAndConsumeKeyDown(DEVICE_ID);
expectKeyRepeatOnce(/*repeatCount=*/1);
- NotifyDeviceResetArgs args(/*id=*/10, /*eventTime=*/20, DEVICE_ID);
- mDispatcher->notifyDeviceReset(&args);
+ mDispatcher->notifyDeviceReset({/*id=*/10, /*eventTime=*/20, DEVICE_ID});
mWindow->consumeKeyUp(ADISPLAY_ID_DEFAULT,
AKEY_EVENT_FLAG_CANCELED | AKEY_EVENT_FLAG_LONG_PRESS);
mWindow->assertNoEvents();
@@ -5744,10 +5642,10 @@
motionArgs =
generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN, displayId);
- mDispatcher->notifyMotion(&motionArgs);
+ mDispatcher->notifyMotion(motionArgs);
motionArgs =
generateMotionArgs(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN, displayId);
- mDispatcher->notifyMotion(&motionArgs);
+ mDispatcher->notifyMotion(motionArgs);
ASSERT_TRUE(mDispatcher->waitForIdle());
if (expectToBeFiltered) {
const auto xy = transform.transform(motionArgs.pointerCoords->getXYValue());
@@ -5761,9 +5659,9 @@
NotifyKeyArgs keyArgs;
keyArgs = generateKeyArgs(AKEY_EVENT_ACTION_DOWN);
- mDispatcher->notifyKey(&keyArgs);
+ mDispatcher->notifyKey(keyArgs);
keyArgs = generateKeyArgs(AKEY_EVENT_ACTION_UP);
- mDispatcher->notifyKey(&keyArgs);
+ mDispatcher->notifyKey(keyArgs);
ASSERT_TRUE(mDispatcher->waitForIdle());
if (expectToBeFiltered) {
@@ -6113,9 +6011,8 @@
void touchAndAssertPositions(int32_t action, const std::vector<PointF>& touchedPoints,
std::vector<PointF> expectedPoints) {
- NotifyMotionArgs motionArgs = generateMotionArgs(action, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, touchedPoints);
- mDispatcher->notifyMotion(&motionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(action, AINPUT_SOURCE_TOUCHSCREEN,
+ ADISPLAY_ID_DEFAULT, touchedPoints));
// Always consume from window1 since it's the window that has the InputReceiver
consumeMotionEvent(mWindow1, action, expectedPoints);
@@ -6988,17 +6885,16 @@
// The other window should not be affected by that.
TEST_F(InputDispatcherMultiWindowAnr, SplitTouch_SingleWindowAnr) {
// Touch Window 1
- NotifyMotionArgs motionArgs =
- generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {FOCUSED_WINDOW_LOCATION});
- mDispatcher->notifyMotion(&motionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
+ AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ {FOCUSED_WINDOW_LOCATION}));
mUnfocusedWindow->consumeEvent(InputEventType::MOTION, AMOTION_EVENT_ACTION_OUTSIDE,
ADISPLAY_ID_DEFAULT, /*flags=*/0);
// Touch Window 2
- motionArgs = generateMotionArgs(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
- {FOCUSED_WINDOW_LOCATION, UNFOCUSED_WINDOW_LOCATION});
- mDispatcher->notifyMotion(&motionArgs);
+ mDispatcher->notifyMotion(
+ generateMotionArgs(POINTER_1_DOWN, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ {FOCUSED_WINDOW_LOCATION, UNFOCUSED_WINDOW_LOCATION}));
const std::chrono::duration timeout =
mFocusedWindow->getDispatchingTimeout(DISPATCHING_TIMEOUT);
@@ -7070,10 +6966,9 @@
std::this_thread::sleep_for(10ms);
// Touch unfocused window. This should force the pending key to get dropped.
- NotifyMotionArgs motionArgs =
- generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {UNFOCUSED_WINDOW_LOCATION});
- mDispatcher->notifyMotion(&motionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
+ AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ {UNFOCUSED_WINDOW_LOCATION}));
// We do not consume the motion right away, because that would require dispatcher to first
// process (== drop) the key event, and by that time, ANR will be raised.
@@ -7128,10 +7023,9 @@
TEST_F(InputDispatcherMultiWindowOcclusionTests, NoInputChannelFeature_DropsTouches) {
PointF touchedPoint = {10, 10};
- NotifyMotionArgs motionArgs =
- generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {touchedPoint});
- mDispatcher->notifyMotion(&motionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
+ AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ {touchedPoint}));
mNoInputWindow->assertNoEvents();
// Even though the window 'mNoInputWindow' positioned above 'mBottomWindow' does not have
@@ -7156,10 +7050,9 @@
PointF touchedPoint = {10, 10};
- NotifyMotionArgs motionArgs =
- generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, {touchedPoint});
- mDispatcher->notifyMotion(&motionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
+ AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ {touchedPoint}));
mNoInputWindow->assertNoEvents();
mBottomWindow->assertNoEvents();
@@ -7332,8 +7225,7 @@
}
void notifyPointerCaptureChanged(const PointerCaptureRequest& request) {
- const NotifyPointerCaptureChangedArgs args = generatePointerCaptureChangedArgs(request);
- mDispatcher->notifyPointerCaptureChanged(&args);
+ mDispatcher->notifyPointerCaptureChanged(generatePointerCaptureChangedArgs(request));
}
PointerCaptureRequest requestAndVerifyPointerCapture(const sp<FakeWindowHandle>& window,
@@ -7509,10 +7401,9 @@
}
void touch(const std::vector<PointF>& points = {PointF{100, 200}}) {
- NotifyMotionArgs args =
- generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT, points);
- mDispatcher->notifyMotion(&args);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
+ AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
+ points));
}
};
@@ -8322,27 +8213,22 @@
window->consumeFocusEvent(/*hasFocus=*/true, /*inTouchMode=*/true);
// With the flag set, window should not get any input
- NotifyKeyArgs keyArgs = generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT);
- mDispatcher->notifyKey(&keyArgs);
+ mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT));
window->assertNoEvents();
- NotifyMotionArgs motionArgs =
- generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT);
- mDispatcher->notifyMotion(&motionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
+ AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT));
window->assertNoEvents();
// With the flag cleared, the window should get input
window->setDropInput(false);
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {window}}});
- keyArgs = generateKeyArgs(AKEY_EVENT_ACTION_UP, ADISPLAY_ID_DEFAULT);
- mDispatcher->notifyKey(&keyArgs);
+ mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_UP, ADISPLAY_ID_DEFAULT));
window->consumeKeyUp(ADISPLAY_ID_DEFAULT);
- motionArgs = generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT);
- mDispatcher->notifyMotion(&motionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
+ AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT));
window->consumeMotionDown(ADISPLAY_ID_DEFAULT);
window->assertNoEvents();
}
@@ -8368,27 +8254,22 @@
window->consumeFocusEvent(/*hasFocus=*/true, /*inTouchMode=*/true);
// With the flag set, window should not get any input
- NotifyKeyArgs keyArgs = generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT);
- mDispatcher->notifyKey(&keyArgs);
+ mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT));
window->assertNoEvents();
- NotifyMotionArgs motionArgs =
- generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT);
- mDispatcher->notifyMotion(&motionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
+ AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT));
window->assertNoEvents();
// With the flag cleared, the window should get input
window->setDropInputIfObscured(false);
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {obscuringWindow, window}}});
- keyArgs = generateKeyArgs(AKEY_EVENT_ACTION_UP, ADISPLAY_ID_DEFAULT);
- mDispatcher->notifyKey(&keyArgs);
+ mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_UP, ADISPLAY_ID_DEFAULT));
window->consumeKeyUp(ADISPLAY_ID_DEFAULT);
- motionArgs = generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT);
- mDispatcher->notifyMotion(&motionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
+ AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT));
window->consumeMotionDown(ADISPLAY_ID_DEFAULT, AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED);
window->assertNoEvents();
}
@@ -8414,26 +8295,21 @@
window->consumeFocusEvent(/*hasFocus=*/true, /*inTouchMode=*/true);
// With the flag set, window should not get any input
- NotifyKeyArgs keyArgs = generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT);
- mDispatcher->notifyKey(&keyArgs);
+ mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_DOWN, ADISPLAY_ID_DEFAULT));
window->assertNoEvents();
- NotifyMotionArgs motionArgs =
- generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT);
- mDispatcher->notifyMotion(&motionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
+ AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT));
window->assertNoEvents();
// When the window is no longer obscured because it went on top, it should get input
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {window, obscuringWindow}}});
- keyArgs = generateKeyArgs(AKEY_EVENT_ACTION_UP, ADISPLAY_ID_DEFAULT);
- mDispatcher->notifyKey(&keyArgs);
+ mDispatcher->notifyKey(generateKeyArgs(AKEY_EVENT_ACTION_UP, ADISPLAY_ID_DEFAULT));
window->consumeKeyUp(ADISPLAY_ID_DEFAULT);
- motionArgs = generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
- ADISPLAY_ID_DEFAULT);
- mDispatcher->notifyMotion(&motionArgs);
+ mDispatcher->notifyMotion(generateMotionArgs(AMOTION_EVENT_ACTION_DOWN,
+ AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT));
window->consumeMotionDown(ADISPLAY_ID_DEFAULT);
window->assertNoEvents();
}
@@ -9167,10 +9043,9 @@
}
void sendFingerEvent(int32_t action) {
- NotifyMotionArgs motionArgs =
+ mDispatcher->notifyMotion(
generateMotionArgs(action, AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS,
- ADISPLAY_ID_DEFAULT, {PointF{20, 20}});
- mDispatcher->notifyMotion(&motionArgs);
+ ADISPLAY_ID_DEFAULT, {PointF{20, 20}}));
}
void sendStylusEvent(int32_t action) {
@@ -9178,7 +9053,7 @@
generateMotionArgs(action, AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS,
ADISPLAY_ID_DEFAULT, {PointF{30, 40}});
motionArgs.pointerProperties[0].toolType = ToolType::STYLUS;
- mDispatcher->notifyMotion(&motionArgs);
+ mDispatcher->notifyMotion(motionArgs);
}
};
diff --git a/services/inputflinger/tests/InputProcessor_test.cpp b/services/inputflinger/tests/InputProcessor_test.cpp
index 0ffdef9..3b7cbfa 100644
--- a/services/inputflinger/tests/InputProcessor_test.cpp
+++ b/services/inputflinger/tests/InputProcessor_test.cpp
@@ -72,7 +72,7 @@
// Create a basic configuration change and send to processor
NotifyConfigurationChangedArgs args(/*sequenceNum=*/1, /*eventTime=*/2);
- mProcessor->notifyConfigurationChanged(&args);
+ mProcessor->notifyConfigurationChanged(args);
NotifyConfigurationChangedArgs outArgs;
ASSERT_NO_FATAL_FAILURE(mTestListener.assertNotifyConfigurationChangedWasCalled(&outArgs));
ASSERT_EQ(args, outArgs);
@@ -85,10 +85,8 @@
AKEY_EVENT_ACTION_DOWN, /*flags=*/4, AKEYCODE_HOME, /*scanCode=*/5,
AMETA_NONE, /*downTime=*/6);
- mProcessor->notifyKey(&args);
- NotifyKeyArgs outArgs;
- ASSERT_NO_FATAL_FAILURE(mTestListener.assertNotifyKeyWasCalled(&outArgs));
- ASSERT_EQ(args, outArgs);
+ mProcessor->notifyKey(args);
+ ASSERT_NO_FATAL_FAILURE(mTestListener.assertNotifyKeyWasCalled(testing::Eq(args)));
}
/**
@@ -97,10 +95,8 @@
*/
TEST_F(InputProcessorTest, SendToNextStage_NotifyMotionArgs) {
NotifyMotionArgs motionArgs = generateBasicMotionArgs();
- mProcessor->notifyMotion(&motionArgs);
- NotifyMotionArgs args;
- ASSERT_NO_FATAL_FAILURE(mTestListener.assertNotifyMotionWasCalled(&args));
- ASSERT_EQ(motionArgs, args);
+ mProcessor->notifyMotion(motionArgs);
+ ASSERT_NO_FATAL_FAILURE(mTestListener.assertNotifyMotionWasCalled(testing::Eq(motionArgs)));
}
/**
@@ -111,7 +107,7 @@
NotifySwitchArgs args(/*sequenceNum=*/1, /*eventTime=*/2, /*policyFlags=*/3,
/*switchValues=*/4, /*switchMask=*/5);
- mProcessor->notifySwitch(&args);
+ mProcessor->notifySwitch(args);
NotifySwitchArgs outArgs;
ASSERT_NO_FATAL_FAILURE(mTestListener.assertNotifySwitchWasCalled(&outArgs));
ASSERT_EQ(args, outArgs);
@@ -124,7 +120,7 @@
TEST_F(InputProcessorTest, SendToNextStage_NotifyDeviceResetArgs) {
NotifyDeviceResetArgs args(/*sequenceNum=*/1, /*eventTime=*/2, /*deviceId=*/3);
- mProcessor->notifyDeviceReset(&args);
+ mProcessor->notifyDeviceReset(args);
NotifyDeviceResetArgs outArgs;
ASSERT_NO_FATAL_FAILURE(mTestListener.assertNotifyDeviceResetWasCalled(&outArgs));
ASSERT_EQ(args, outArgs);
diff --git a/services/inputflinger/tests/TestInputListener.cpp b/services/inputflinger/tests/TestInputListener.cpp
index ac1dc05..fc917dd 100644
--- a/services/inputflinger/tests/TestInputListener.cpp
+++ b/services/inputflinger/tests/TestInputListener.cpp
@@ -168,47 +168,47 @@
}
template <class NotifyArgsType>
-void TestInputListener::addToQueue(const NotifyArgsType* args) {
+void TestInputListener::addToQueue(const NotifyArgsType& args) {
std::scoped_lock<std::mutex> lock(mLock);
std::vector<NotifyArgsType>& queue = std::get<std::vector<NotifyArgsType>>(mQueues);
- queue.push_back(*args);
+ queue.push_back(args);
mCondition.notify_all();
}
void TestInputListener::notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& args) {
- addToQueue<NotifyInputDevicesChangedArgs>(&args);
+ addToQueue<NotifyInputDevicesChangedArgs>(args);
}
-void TestInputListener::notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) {
+void TestInputListener::notifyConfigurationChanged(const NotifyConfigurationChangedArgs& args) {
addToQueue<NotifyConfigurationChangedArgs>(args);
}
-void TestInputListener::notifyDeviceReset(const NotifyDeviceResetArgs* args) {
+void TestInputListener::notifyDeviceReset(const NotifyDeviceResetArgs& args) {
addToQueue<NotifyDeviceResetArgs>(args);
}
-void TestInputListener::notifyKey(const NotifyKeyArgs* args) {
+void TestInputListener::notifyKey(const NotifyKeyArgs& args) {
addToQueue<NotifyKeyArgs>(args);
}
-void TestInputListener::notifyMotion(const NotifyMotionArgs* args) {
+void TestInputListener::notifyMotion(const NotifyMotionArgs& args) {
addToQueue<NotifyMotionArgs>(args);
}
-void TestInputListener::notifySwitch(const NotifySwitchArgs* args) {
+void TestInputListener::notifySwitch(const NotifySwitchArgs& args) {
addToQueue<NotifySwitchArgs>(args);
}
-void TestInputListener::notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs* args) {
+void TestInputListener::notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs& args) {
addToQueue<NotifyPointerCaptureChangedArgs>(args);
}
-void TestInputListener::notifySensor(const NotifySensorArgs* args) {
+void TestInputListener::notifySensor(const NotifySensorArgs& args) {
addToQueue<NotifySensorArgs>(args);
}
-void TestInputListener::notifyVibratorState(const NotifyVibratorStateArgs* args) {
+void TestInputListener::notifyVibratorState(const NotifyVibratorStateArgs& args) {
addToQueue<NotifyVibratorStateArgs>(args);
}
diff --git a/services/inputflinger/tests/TestInputListener.h b/services/inputflinger/tests/TestInputListener.h
index da2cab3..deb6048 100644
--- a/services/inputflinger/tests/TestInputListener.h
+++ b/services/inputflinger/tests/TestInputListener.h
@@ -77,25 +77,25 @@
void assertNotCalled(std::string message, std::optional<TimePoint> timeout = {});
template <class NotifyArgsType>
- void addToQueue(const NotifyArgsType* args);
+ void addToQueue(const NotifyArgsType& args);
virtual void notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& args) override;
- virtual void notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) override;
+ virtual void notifyConfigurationChanged(const NotifyConfigurationChangedArgs& args) override;
- virtual void notifyDeviceReset(const NotifyDeviceResetArgs* args) override;
+ virtual void notifyDeviceReset(const NotifyDeviceResetArgs& args) override;
- virtual void notifyKey(const NotifyKeyArgs* args) override;
+ virtual void notifyKey(const NotifyKeyArgs& args) override;
- virtual void notifyMotion(const NotifyMotionArgs* args) override;
+ virtual void notifyMotion(const NotifyMotionArgs& args) override;
- virtual void notifySwitch(const NotifySwitchArgs* args) override;
+ virtual void notifySwitch(const NotifySwitchArgs& args) override;
- virtual void notifySensor(const NotifySensorArgs* args) override;
+ virtual void notifySensor(const NotifySensorArgs& args) override;
- virtual void notifyVibratorState(const NotifyVibratorStateArgs* args) override;
+ virtual void notifyVibratorState(const NotifyVibratorStateArgs& args) override;
- virtual void notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs* args) override;
+ virtual void notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs& args) override;
std::mutex mLock;
std::condition_variable mCondition;
diff --git a/services/inputflinger/tests/UnwantedInteractionBlocker_test.cpp b/services/inputflinger/tests/UnwantedInteractionBlocker_test.cpp
index be731b1..1fff2c7 100644
--- a/services/inputflinger/tests/UnwantedInteractionBlocker_test.cpp
+++ b/services/inputflinger/tests/UnwantedInteractionBlocker_test.cpp
@@ -421,7 +421,7 @@
// Create a basic configuration change and send to blocker
NotifyConfigurationChangedArgs args(/*sequenceNum=*/1, /*eventTime=*/2);
- mBlocker->notifyConfigurationChanged(&args);
+ mBlocker->notifyConfigurationChanged(args);
NotifyConfigurationChangedArgs outArgs;
ASSERT_NO_FATAL_FAILURE(mTestListener.assertNotifyConfigurationChangedWasCalled(&outArgs));
ASSERT_EQ(args, outArgs);
@@ -438,10 +438,8 @@
AKEY_EVENT_ACTION_DOWN, /*flags=*/4, AKEYCODE_HOME, /*scanCode=*/5,
AMETA_NONE, /*downTime=*/6);
- mBlocker->notifyKey(&args);
- NotifyKeyArgs outArgs;
- ASSERT_NO_FATAL_FAILURE(mTestListener.assertNotifyKeyWasCalled(&outArgs));
- ASSERT_EQ(args, outArgs);
+ mBlocker->notifyKey(args);
+ ASSERT_NO_FATAL_FAILURE(mTestListener.assertNotifyKeyWasCalled(testing::Eq(args)));
}
/**
@@ -452,10 +450,8 @@
TEST_F(UnwantedInteractionBlockerTest, DownEventIsPassedToNextListener) {
NotifyMotionArgs motionArgs =
generateMotionArgs(/*downTime=*/0, /*eventTime=*/0, DOWN, {{1, 2, 3}});
- mBlocker->notifyMotion(&motionArgs);
- NotifyMotionArgs args;
- ASSERT_NO_FATAL_FAILURE(mTestListener.assertNotifyMotionWasCalled(&args));
- ASSERT_EQ(motionArgs, args);
+ mBlocker->notifyMotion(motionArgs);
+ ASSERT_NO_FATAL_FAILURE(mTestListener.assertNotifyMotionWasCalled(testing::Eq(motionArgs)));
}
/**
@@ -466,7 +462,7 @@
NotifySwitchArgs args(/*sequenceNum=*/1, /*eventTime=*/2, /*policyFlags=*/3,
/*switchValues=*/4, /*switchMask=*/5);
- mBlocker->notifySwitch(&args);
+ mBlocker->notifySwitch(args);
NotifySwitchArgs outArgs;
ASSERT_NO_FATAL_FAILURE(mTestListener.assertNotifySwitchWasCalled(&outArgs));
ASSERT_EQ(args, outArgs);
@@ -479,7 +475,7 @@
TEST_F(UnwantedInteractionBlockerTest, DeviceResetIsPassedToNextListener) {
NotifyDeviceResetArgs args(/*sequenceNum=*/1, /*eventTime=*/2, DEVICE_ID);
- mBlocker->notifyDeviceReset(&args);
+ mBlocker->notifyDeviceReset(args);
NotifyDeviceResetArgs outArgs;
ASSERT_NO_FATAL_FAILURE(mTestListener.assertNotifyDeviceResetWasCalled(&outArgs));
ASSERT_EQ(args, outArgs);
@@ -491,17 +487,12 @@
* a crash due to inconsistent event stream could have occurred.
*/
TEST_F(UnwantedInteractionBlockerTest, NoCrashWhenResetHappens) {
- NotifyMotionArgs args;
mBlocker->notifyInputDevicesChanged({/*id=*/0, {generateTestDeviceInfo()}});
- mBlocker->notifyMotion(
- &(args = generateMotionArgs(/*downTime=*/0, /*eventTime=*/1, DOWN, {{1, 2, 3}})));
- mBlocker->notifyMotion(
- &(args = generateMotionArgs(/*downTime=*/0, /*eventTime=*/2, MOVE, {{4, 5, 6}})));
- NotifyDeviceResetArgs resetArgs(/*sequenceNum=*/1, /*eventTime=*/3, DEVICE_ID);
- mBlocker->notifyDeviceReset(&resetArgs);
+ mBlocker->notifyMotion(generateMotionArgs(/*downTime=*/0, /*eventTime=*/1, DOWN, {{1, 2, 3}}));
+ mBlocker->notifyMotion(generateMotionArgs(/*downTime=*/0, /*eventTime=*/2, MOVE, {{4, 5, 6}}));
+ mBlocker->notifyDeviceReset({/*sequenceNum=*/1, /*eventTime=*/3, DEVICE_ID});
// Start a new gesture with a DOWN event, even though the previous event stream was incomplete.
- mBlocker->notifyMotion(
- &(args = generateMotionArgs(/*downTime=*/0, /*eventTime=*/4, DOWN, {{7, 8, 9}})));
+ mBlocker->notifyMotion(generateMotionArgs(/*downTime=*/0, /*eventTime=*/4, DOWN, {{7, 8, 9}}));
}
TEST_F(UnwantedInteractionBlockerTest, NoCrashWhenStylusSourceWithFingerToolIsReceived) {
@@ -509,7 +500,7 @@
NotifyMotionArgs args = generateMotionArgs(/*downTime=*/0, /*eventTime=*/1, DOWN, {{1, 2, 3}});
args.pointerProperties[0].toolType = ToolType::FINGER;
args.source = AINPUT_SOURCE_STYLUS;
- mBlocker->notifyMotion(&args);
+ mBlocker->notifyMotion(args);
}
/**
@@ -517,48 +508,41 @@
* UnwantedInteractionBlocker has not changed, there should not be a reset.
*/
TEST_F(UnwantedInteractionBlockerTest, NoResetIfDeviceInfoChanges) {
- NotifyMotionArgs args;
mBlocker->notifyInputDevicesChanged({/*id=*/0, {generateTestDeviceInfo()}});
- mBlocker->notifyMotion(
- &(args = generateMotionArgs(/*downTime=*/0, /*eventTime=*/1, DOWN, {{1, 2, 3}})));
- mBlocker->notifyMotion(
- &(args = generateMotionArgs(/*downTime=*/0, /*eventTime=*/2, MOVE, {{4, 5, 6}})));
+ mBlocker->notifyMotion(generateMotionArgs(/*downTime=*/0, /*eventTime=*/1, DOWN, {{1, 2, 3}}));
+ mBlocker->notifyMotion(generateMotionArgs(/*downTime=*/0, /*eventTime=*/2, MOVE, {{4, 5, 6}}));
// Now pretend the device changed, even though nothing is different for DEVICE_ID in practice.
mBlocker->notifyInputDevicesChanged({/*id=*/0, {generateTestDeviceInfo()}});
// The MOVE event continues the gesture that started before 'devices changed', so it should not
// cause a crash.
- mBlocker->notifyMotion(
- &(args = generateMotionArgs(/*downTime=*/0, /*eventTime=*/4, MOVE, {{7, 8, 9}})));
+ mBlocker->notifyMotion(generateMotionArgs(/*downTime=*/0, /*eventTime=*/4, MOVE, {{7, 8, 9}}));
}
/**
* Send a touch event, and then a stylus event. Make sure that both work.
*/
TEST_F(UnwantedInteractionBlockerTest, StylusAfterTouchWorks) {
- NotifyMotionArgs args;
mBlocker->notifyInputDevicesChanged({/*id=*/0, {generateTestDeviceInfo()}});
- args = generateMotionArgs(/*downTime=*/0, /*eventTime=*/0, DOWN, {{1, 2, 3}});
- mBlocker->notifyMotion(&args);
- args = generateMotionArgs(/*downTime=*/0, /*eventTime=*/1, MOVE, {{4, 5, 6}});
- mBlocker->notifyMotion(&args);
- args = generateMotionArgs(/*downTime=*/0, /*eventTime=*/2, UP, {{4, 5, 6}});
- mBlocker->notifyMotion(&args);
+ mBlocker->notifyMotion(generateMotionArgs(/*downTime=*/0, /*eventTime=*/0, DOWN, {{1, 2, 3}}));
+ mBlocker->notifyMotion(generateMotionArgs(/*downTime=*/0, /*eventTime=*/1, MOVE, {{4, 5, 6}}));
+ mBlocker->notifyMotion(generateMotionArgs(/*downTime=*/0, /*eventTime=*/2, UP, {{4, 5, 6}}));
// Now touch down stylus
+ NotifyMotionArgs args;
args = generateMotionArgs(/*downTime=*/3, /*eventTime=*/3, DOWN, {{10, 20, 30}});
args.pointerProperties[0].toolType = ToolType::STYLUS;
args.source |= AINPUT_SOURCE_STYLUS;
- mBlocker->notifyMotion(&args);
+ mBlocker->notifyMotion(args);
args = generateMotionArgs(/*downTime=*/3, /*eventTime=*/4, MOVE, {{40, 50, 60}});
args.pointerProperties[0].toolType = ToolType::STYLUS;
args.source |= AINPUT_SOURCE_STYLUS;
- mBlocker->notifyMotion(&args);
+ mBlocker->notifyMotion(args);
args = generateMotionArgs(/*downTime=*/3, /*eventTime=*/5, UP, {{40, 50, 60}});
args.pointerProperties[0].toolType = ToolType::STYLUS;
args.source |= AINPUT_SOURCE_STYLUS;
- mBlocker->notifyMotion(&args);
+ mBlocker->notifyMotion(args);
}
/**
@@ -569,16 +553,13 @@
*/
TEST_F(UnwantedInteractionBlockerTest, DumpCanBeAccessedOnAnotherThread) {
mBlocker->notifyInputDevicesChanged({/*id=*/0, {generateTestDeviceInfo()}});
- NotifyMotionArgs args1 = generateMotionArgs(/*downTime=*/0, /*eventTime=*/0, DOWN, {{1, 2, 3}});
- mBlocker->notifyMotion(&args1);
+ mBlocker->notifyMotion(generateMotionArgs(/*downTime=*/0, /*eventTime=*/0, DOWN, {{1, 2, 3}}));
std::thread dumpThread([this]() {
std::string dump;
mBlocker->dump(dump);
});
- NotifyMotionArgs args2 = generateMotionArgs(/*downTime=*/0, /*eventTime=*/1, MOVE, {{4, 5, 6}});
- mBlocker->notifyMotion(&args2);
- NotifyMotionArgs args3 = generateMotionArgs(/*downTime=*/0, /*eventTime=*/2, UP, {{4, 5, 6}});
- mBlocker->notifyMotion(&args3);
+ mBlocker->notifyMotion(generateMotionArgs(/*downTime=*/0, /*eventTime=*/1, MOVE, {{4, 5, 6}}));
+ mBlocker->notifyMotion(generateMotionArgs(/*downTime=*/0, /*eventTime=*/2, UP, {{4, 5, 6}}));
dumpThread.join();
}
@@ -589,20 +570,17 @@
TEST_F(UnwantedInteractionBlockerTest, HeuristicFilterWorks) {
mBlocker->notifyInputDevicesChanged({/*id=*/0, {generateTestDeviceInfo()}});
// Small touch down
- NotifyMotionArgs args1 = generateMotionArgs(/*downTime=*/0, /*eventTime=*/0, DOWN, {{1, 2, 3}});
- mBlocker->notifyMotion(&args1);
+ mBlocker->notifyMotion(generateMotionArgs(/*downTime=*/0, /*eventTime=*/0, DOWN, {{1, 2, 3}}));
mTestListener.assertNotifyMotionWasCalled(WithMotionAction(DOWN));
// Large touch oval on the next move
- NotifyMotionArgs args2 =
- generateMotionArgs(/*downTime=*/0, RESAMPLE_PERIOD, MOVE, {{4, 5, 200}});
- mBlocker->notifyMotion(&args2);
+ mBlocker->notifyMotion(
+ generateMotionArgs(/*downTime=*/0, RESAMPLE_PERIOD, MOVE, {{4, 5, 200}}));
mTestListener.assertNotifyMotionWasCalled(WithMotionAction(MOVE));
// Lift up the touch to force the model to decide on whether it's a palm
- NotifyMotionArgs args3 =
- generateMotionArgs(/*downTime=*/0, 2 * RESAMPLE_PERIOD, UP, {{4, 5, 200}});
- mBlocker->notifyMotion(&args3);
+ mBlocker->notifyMotion(
+ generateMotionArgs(/*downTime=*/0, 2 * RESAMPLE_PERIOD, UP, {{4, 5, 200}}));
mTestListener.assertNotifyMotionWasCalled(WithMotionAction(CANCEL));
}
@@ -618,14 +596,14 @@
mBlocker->notifyInputDevicesChanged(deviceChangedArgs);
NotifyMotionArgs args1 = generateMotionArgs(/*downTime=*/0, /*eventTime=*/0, DOWN, {{1, 2, 3}});
args1.pointerProperties[0].toolType = ToolType::STYLUS;
- mBlocker->notifyMotion(&args1);
+ mBlocker->notifyMotion(args1);
mTestListener.assertNotifyMotionWasCalled(WithMotionAction(DOWN));
// Move the stylus, setting large TOUCH_MAJOR/TOUCH_MINOR dimensions
NotifyMotionArgs args2 =
generateMotionArgs(/*downTime=*/0, RESAMPLE_PERIOD, MOVE, {{4, 5, 200}});
args2.pointerProperties[0].toolType = ToolType::STYLUS;
- mBlocker->notifyMotion(&args2);
+ mBlocker->notifyMotion(args2);
mTestListener.assertNotifyMotionWasCalled(WithMotionAction(MOVE));
// Lift up the stylus. If it were a touch event, this would force the model to decide on whether
@@ -633,7 +611,7 @@
NotifyMotionArgs args3 =
generateMotionArgs(/*downTime=*/0, 2 * RESAMPLE_PERIOD, UP, {{4, 5, 200}});
args3.pointerProperties[0].toolType = ToolType::STYLUS;
- mBlocker->notifyMotion(&args3);
+ mBlocker->notifyMotion(args3);
mTestListener.assertNotifyMotionWasCalled(WithMotionAction(UP));
}
@@ -649,28 +627,28 @@
// Touch down
NotifyMotionArgs args1 = generateMotionArgs(/*downTime=*/0, /*eventTime=*/0, DOWN, {{1, 2, 3}});
- mBlocker->notifyMotion(&args1);
+ mBlocker->notifyMotion(args1);
mTestListener.assertNotifyMotionWasCalled(WithMotionAction(DOWN));
// Stylus pointer down
NotifyMotionArgs args2 = generateMotionArgs(/*downTime=*/0, RESAMPLE_PERIOD, POINTER_1_DOWN,
{{1, 2, 3}, {10, 20, 30}});
args2.pointerProperties[1].toolType = ToolType::STYLUS;
- mBlocker->notifyMotion(&args2);
+ mBlocker->notifyMotion(args2);
mTestListener.assertNotifyMotionWasCalled(WithMotionAction(POINTER_1_DOWN));
// Large touch oval on the next finger move
NotifyMotionArgs args3 = generateMotionArgs(/*downTime=*/0, 2 * RESAMPLE_PERIOD, MOVE,
{{1, 2, 300}, {11, 21, 30}});
args3.pointerProperties[1].toolType = ToolType::STYLUS;
- mBlocker->notifyMotion(&args3);
+ mBlocker->notifyMotion(args3);
mTestListener.assertNotifyMotionWasCalled(WithMotionAction(MOVE));
// Lift up the finger pointer. It should be canceled due to the heuristic filter.
NotifyMotionArgs args4 = generateMotionArgs(/*downTime=*/0, 3 * RESAMPLE_PERIOD, POINTER_0_UP,
{{1, 2, 300}, {11, 21, 30}});
args4.pointerProperties[1].toolType = ToolType::STYLUS;
- mBlocker->notifyMotion(&args4);
+ mBlocker->notifyMotion(args4);
mTestListener.assertNotifyMotionWasCalled(
AllOf(WithMotionAction(POINTER_0_UP), WithFlags(FLAG_CANCELED)));
@@ -678,7 +656,7 @@
generateMotionArgs(/*downTime=*/0, 4 * RESAMPLE_PERIOD, MOVE, {{12, 22, 30}});
args5.pointerProperties[0].id = args4.pointerProperties[1].id;
args5.pointerProperties[0].toolType = ToolType::STYLUS;
- mBlocker->notifyMotion(&args5);
+ mBlocker->notifyMotion(args5);
mTestListener.assertNotifyMotionWasCalled(WithMotionAction(MOVE));
// Lift up the stylus pointer
@@ -686,7 +664,7 @@
generateMotionArgs(/*downTime=*/0, 5 * RESAMPLE_PERIOD, UP, {{4, 5, 200}});
args6.pointerProperties[0].id = args4.pointerProperties[1].id;
args6.pointerProperties[0].toolType = ToolType::STYLUS;
- mBlocker->notifyMotion(&args6);
+ mBlocker->notifyMotion(args6);
mTestListener.assertNotifyMotionWasCalled(WithMotionAction(UP));
}
@@ -700,17 +678,15 @@
ScopedSilentDeath _silentDeath;
NotifyMotionArgs args;
mBlocker->notifyInputDevicesChanged({/*id=*/0, {generateTestDeviceInfo()}});
- mBlocker->notifyMotion(
- &(args = generateMotionArgs(/*downTime=*/0, /*eventTime=*/1, DOWN, {{1, 2, 3}})));
- mBlocker->notifyMotion(
- &(args = generateMotionArgs(/*downTime=*/0, /*eventTime=*/2, MOVE, {{4, 5, 6}})));
+ mBlocker->notifyMotion(generateMotionArgs(/*downTime=*/0, /*eventTime=*/1, DOWN, {{1, 2, 3}}));
+ mBlocker->notifyMotion(generateMotionArgs(/*downTime=*/0, /*eventTime=*/2, MOVE, {{4, 5, 6}}));
NotifyDeviceResetArgs resetArgs(/*sequenceNum=*/1, /*eventTime=*/3, DEVICE_ID);
- mBlocker->notifyDeviceReset(&resetArgs);
+ mBlocker->notifyDeviceReset(resetArgs);
// Sending MOVE without a DOWN -> should crash!
ASSERT_DEATH(
{
- mBlocker->notifyMotion(&(args = generateMotionArgs(/*downTime=*/0, /*eventTime=*/4,
- MOVE, {{7, 8, 9}})));
+ mBlocker->notifyMotion(
+ generateMotionArgs(/*downTime=*/0, /*eventTime=*/4, MOVE, {{7, 8, 9}}));
},
"Could not find slot");
}
@@ -720,9 +696,13 @@
*/
TEST_F(UnwantedInteractionBlockerTestDeathTest, WhenMoveWithoutDownCausesACrash) {
ScopedSilentDeath _silentDeath;
- NotifyMotionArgs args = generateMotionArgs(/*downTime=*/0, /*eventTime=*/1, MOVE, {{1, 2, 3}});
mBlocker->notifyInputDevicesChanged({/*id=*/0, {generateTestDeviceInfo()}});
- ASSERT_DEATH({ mBlocker->notifyMotion(&args); }, "Could not find slot");
+ ASSERT_DEATH(
+ {
+ mBlocker->notifyMotion(
+ generateMotionArgs(/*downTime=*/0, /*eventTime=*/1, MOVE, {{1, 2, 3}}));
+ },
+ "Could not find slot");
}
class PalmRejectorTest : public testing::Test {
diff --git a/services/inputflinger/tests/fuzzers/InputClassifierFuzzer.cpp b/services/inputflinger/tests/fuzzers/InputClassifierFuzzer.cpp
index 6617f65..f8ebc97 100644
--- a/services/inputflinger/tests/fuzzers/InputClassifierFuzzer.cpp
+++ b/services/inputflinger/tests/fuzzers/InputClassifierFuzzer.cpp
@@ -67,51 +67,42 @@
fdp.PickValueInArray<std::function<void()>>({
[&]() -> void {
// SendToNextStage_NotifyConfigurationChangedArgs
- NotifyConfigurationChangedArgs
- args(/*sequenceNum=*/fdp.ConsumeIntegral<uint32_t>(),
- /*eventTime=*/fdp.ConsumeIntegral<nsecs_t>());
- mClassifier->notifyConfigurationChanged(&args);
+ mClassifier->notifyConfigurationChanged(
+ {/*sequenceNum=*/fdp.ConsumeIntegral<int32_t>(),
+ /*eventTime=*/fdp.ConsumeIntegral<nsecs_t>()});
},
[&]() -> void {
// SendToNextStage_NotifyKeyArgs
const nsecs_t eventTime = fdp.ConsumeIntegral<nsecs_t>();
const nsecs_t readTime =
eventTime + fdp.ConsumeIntegralInRange<nsecs_t>(0, 1E8);
- NotifyKeyArgs keyArgs(/*sequenceNum=*/fdp.ConsumeIntegral<uint32_t>(),
- eventTime, readTime,
- /*deviceId=*/fdp.ConsumeIntegral<int32_t>(),
- AINPUT_SOURCE_KEYBOARD, ADISPLAY_ID_DEFAULT,
- /*policyFlags=*/fdp.ConsumeIntegral<uint32_t>(),
- AKEY_EVENT_ACTION_DOWN,
- /*flags=*/fdp.ConsumeIntegral<int32_t>(), AKEYCODE_HOME,
- /*scanCode=*/fdp.ConsumeIntegral<int32_t>(), AMETA_NONE,
- /*downTime=*/fdp.ConsumeIntegral<nsecs_t>());
-
- mClassifier->notifyKey(&keyArgs);
+ mClassifier->notifyKey({/*sequenceNum=*/fdp.ConsumeIntegral<int32_t>(),
+ eventTime, readTime,
+ /*deviceId=*/fdp.ConsumeIntegral<int32_t>(),
+ AINPUT_SOURCE_KEYBOARD, ADISPLAY_ID_DEFAULT,
+ /*policyFlags=*/fdp.ConsumeIntegral<uint32_t>(),
+ AKEY_EVENT_ACTION_DOWN,
+ /*flags=*/fdp.ConsumeIntegral<int32_t>(), AKEYCODE_HOME,
+ /*scanCode=*/fdp.ConsumeIntegral<int32_t>(), AMETA_NONE,
+ /*downTime=*/fdp.ConsumeIntegral<nsecs_t>()});
},
[&]() -> void {
// SendToNextStage_NotifyMotionArgs
- NotifyMotionArgs motionArgs = generateFuzzedMotionArgs(fdp);
- mClassifier->notifyMotion(&motionArgs);
+ mClassifier->notifyMotion(generateFuzzedMotionArgs(fdp));
},
[&]() -> void {
// SendToNextStage_NotifySwitchArgs
- NotifySwitchArgs switchArgs(/*sequenceNum=*/fdp.ConsumeIntegral<uint32_t>(),
- /*eventTime=*/fdp.ConsumeIntegral<nsecs_t>(),
- /*policyFlags=*/fdp.ConsumeIntegral<uint32_t>(),
- /*switchValues=*/fdp.ConsumeIntegral<uint32_t>(),
- /*switchMask=*/fdp.ConsumeIntegral<uint32_t>());
-
- mClassifier->notifySwitch(&switchArgs);
+ mClassifier->notifySwitch({/*sequenceNum=*/fdp.ConsumeIntegral<int32_t>(),
+ /*eventTime=*/fdp.ConsumeIntegral<nsecs_t>(),
+ /*policyFlags=*/fdp.ConsumeIntegral<uint32_t>(),
+ /*switchValues=*/fdp.ConsumeIntegral<uint32_t>(),
+ /*switchMask=*/fdp.ConsumeIntegral<uint32_t>()});
},
[&]() -> void {
// SendToNextStage_NotifyDeviceResetArgs
- NotifyDeviceResetArgs resetArgs(
- /*sequenceNum=*/fdp.ConsumeIntegral<uint32_t>(),
- /*eventTime=*/fdp.ConsumeIntegral<nsecs_t>(),
- /*deviceId=*/fdp.ConsumeIntegral<int32_t>());
-
- mClassifier->notifyDeviceReset(&resetArgs);
+ mClassifier->notifyDeviceReset({/*sequenceNum=*/fdp.ConsumeIntegral<int32_t>(),
+ /*eventTime=*/fdp.ConsumeIntegral<nsecs_t>(),
+ /*deviceId=*/fdp.ConsumeIntegral<int32_t>()});
},
[&]() -> void {
// InputClassifierConverterTest
diff --git a/services/inputflinger/tests/fuzzers/MapperHelpers.h b/services/inputflinger/tests/fuzzers/MapperHelpers.h
index 0dc627a..1e44e0f 100644
--- a/services/inputflinger/tests/fuzzers/MapperHelpers.h
+++ b/services/inputflinger/tests/fuzzers/MapperHelpers.h
@@ -294,14 +294,14 @@
class FuzzInputListener : public virtual InputListenerInterface {
public:
void notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& args) override {}
- void notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) override {}
- void notifyKey(const NotifyKeyArgs* args) override {}
- void notifyMotion(const NotifyMotionArgs* args) override {}
- void notifySwitch(const NotifySwitchArgs* args) override {}
- void notifySensor(const NotifySensorArgs* args) override{};
- void notifyVibratorState(const NotifyVibratorStateArgs* args) override{};
- void notifyDeviceReset(const NotifyDeviceResetArgs* args) override {}
- void notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs* args) override{};
+ void notifyConfigurationChanged(const NotifyConfigurationChangedArgs& args) override {}
+ void notifyKey(const NotifyKeyArgs& args) override {}
+ void notifyMotion(const NotifyMotionArgs& args) override {}
+ void notifySwitch(const NotifySwitchArgs& args) override {}
+ void notifySensor(const NotifySensorArgs& args) override{};
+ void notifyVibratorState(const NotifyVibratorStateArgs& args) override{};
+ void notifyDeviceReset(const NotifyDeviceResetArgs& args) override {}
+ void notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs& args) override{};
};
class FuzzInputReaderContext : public InputReaderContext {