summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2023-08-24 14:02:13 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2023-08-24 14:02:13 +0000
commitcde5086ba5d624f98c3227d7528a9ae38f6b5874 (patch)
treeb5047c634cca1b2e7c67479ac52ace2156462492
parente3ce97eab1b86e366e1d55cdfd6221221b35cf77 (diff)
parent6d1cb0125e748eb90510e5f50c315fa1fa2132a9 (diff)
Merge changes I65538cd3,I4da2cff3,Ibee1e7dc into main
* changes: Remove tracing for InputDispatcher::enqueueDispatchEntryLocked Trace all InputListener stages Improve existing InputDispatcher traces
-rw-r--r--include/input/TraceTools.h25
-rw-r--r--libs/input/InputTransport.cpp78
-rw-r--r--services/inputflinger/InputListener.cpp95
-rw-r--r--services/inputflinger/InputManager.cpp19
-rw-r--r--services/inputflinger/InputManager.h2
-rw-r--r--services/inputflinger/dispatcher/InputDispatcher.cpp46
-rw-r--r--services/inputflinger/include/InputListener.h22
7 files changed, 193 insertions, 94 deletions
diff --git a/include/input/TraceTools.h b/include/input/TraceTools.h
new file mode 100644
index 0000000000..70b23c5875
--- /dev/null
+++ b/include/input/TraceTools.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <utils/Trace.h>
+#include <optional>
+
+#define ATRACE_NAME_IF(condition, messageProvider) \
+ const auto _trace_token = condition \
+ ? std::make_optional<android::ScopedTrace>(ATRACE_TAG, messageProvider().c_str()) \
+ : std::nullopt
diff --git a/libs/input/InputTransport.cpp b/libs/input/InputTransport.cpp
index 3446540ccf..843ef273f6 100644
--- a/libs/input/InputTransport.cpp
+++ b/libs/input/InputTransport.cpp
@@ -24,6 +24,7 @@
#include <utils/Trace.h>
#include <input/InputTransport.h>
+#include <input/TraceTools.h>
namespace {
@@ -432,6 +433,10 @@ status_t InputChannel::openInputChannelPair(const std::string& name,
}
status_t InputChannel::sendMessage(const InputMessage* msg) {
+ ATRACE_NAME_IF(ATRACE_ENABLED(), [&]() {
+ return StringPrintf("sendMessage(inputChannel=%s, seq=0x%" PRIx32 ", type=0x%" PRIx32 ")",
+ mName.c_str(), msg->header.seq, msg->header.type);
+ });
const size_t msgLength = msg->size();
InputMessage cleanMsg;
msg->getSanitizedCopy(&cleanMsg);
@@ -463,16 +468,13 @@ status_t InputChannel::sendMessage(const InputMessage* msg) {
ALOGD_IF(DEBUG_CHANNEL_MESSAGES, "channel '%s' ~ sent message of type %s", mName.c_str(),
ftl::enum_string(msg->header.type).c_str());
- if (ATRACE_ENABLED()) {
- std::string message =
- StringPrintf("sendMessage(inputChannel=%s, seq=0x%" PRIx32 ", type=0x%" PRIx32 ")",
- mName.c_str(), msg->header.seq, msg->header.type);
- ATRACE_NAME(message.c_str());
- }
return OK;
}
status_t InputChannel::receiveMessage(InputMessage* msg) {
+ ATRACE_NAME_IF(ATRACE_ENABLED(), [&]() {
+ return StringPrintf("receiveMessage(inputChannel=%s)", mName.c_str());
+ });
ssize_t nRead;
do {
nRead = ::recv(getFd(), msg, sizeof(InputMessage), MSG_DONTWAIT);
@@ -504,8 +506,8 @@ status_t InputChannel::receiveMessage(InputMessage* msg) {
ALOGD_IF(DEBUG_CHANNEL_MESSAGES, "channel '%s' ~ received message of type %s", mName.c_str(),
ftl::enum_string(msg->header.type).c_str());
-
if (ATRACE_ENABLED()) {
+ // Add an additional trace point to include data about the received message.
std::string message = StringPrintf("receiveMessage(inputChannel=%s, seq=0x%" PRIx32
", type=0x%" PRIx32 ")",
mName.c_str(), msg->header.seq, msg->header.type);
@@ -578,13 +580,11 @@ status_t InputPublisher::publishKeyEvent(uint32_t seq, int32_t eventId, int32_t
int32_t flags, int32_t keyCode, int32_t scanCode,
int32_t metaState, int32_t repeatCount, nsecs_t downTime,
nsecs_t eventTime) {
- if (ATRACE_ENABLED()) {
- std::string message =
- StringPrintf("publishKeyEvent(inputChannel=%s, action=%s, keyCode=%s)",
- mChannel->getName().c_str(), KeyEvent::actionToString(action),
- KeyEvent::getLabel(keyCode));
- ATRACE_NAME(message.c_str());
- }
+ ATRACE_NAME_IF(ATRACE_ENABLED(), [&]() {
+ return StringPrintf("publishKeyEvent(inputChannel=%s, action=%s, keyCode=%s)",
+ mChannel->getName().c_str(), KeyEvent::actionToString(action),
+ KeyEvent::getLabel(keyCode));
+ });
ALOGD_IF(debugTransportPublisher(),
"channel '%s' publisher ~ %s: seq=%u, id=%d, deviceId=%d, source=%s, "
"action=%s, flags=0x%x, keyCode=%s, scanCode=%d, metaState=0x%x, repeatCount=%d,"
@@ -626,12 +626,11 @@ status_t InputPublisher::publishMotionEvent(
const ui::Transform& rawTransform, nsecs_t downTime, nsecs_t eventTime,
uint32_t pointerCount, const PointerProperties* pointerProperties,
const PointerCoords* pointerCoords) {
- if (ATRACE_ENABLED()) {
- std::string message = StringPrintf("publishMotionEvent(inputChannel=%s, action=%s)",
- mChannel->getName().c_str(),
- MotionEvent::actionToString(action).c_str());
- ATRACE_NAME(message.c_str());
- }
+ ATRACE_NAME_IF(ATRACE_ENABLED(), [&]() {
+ return StringPrintf("publishMotionEvent(inputChannel=%s, action=%s)",
+ mChannel->getName().c_str(),
+ MotionEvent::actionToString(action).c_str());
+ });
if (verifyEvents()) {
Result<void> result =
mInputVerifier.processMovement(deviceId, action, pointerCount, pointerProperties,
@@ -710,11 +709,10 @@ status_t InputPublisher::publishMotionEvent(
}
status_t InputPublisher::publishFocusEvent(uint32_t seq, int32_t eventId, bool hasFocus) {
- if (ATRACE_ENABLED()) {
- std::string message = StringPrintf("publishFocusEvent(inputChannel=%s, hasFocus=%s)",
- mChannel->getName().c_str(), toString(hasFocus));
- ATRACE_NAME(message.c_str());
- }
+ ATRACE_NAME_IF(ATRACE_ENABLED(), [&]() {
+ return StringPrintf("publishFocusEvent(inputChannel=%s, hasFocus=%s)",
+ mChannel->getName().c_str(), toString(hasFocus));
+ });
ALOGD_IF(debugTransportPublisher(), "channel '%s' publisher ~ %s: seq=%u, id=%d, hasFocus=%s",
mChannel->getName().c_str(), __func__, seq, eventId, toString(hasFocus));
@@ -728,12 +726,10 @@ status_t InputPublisher::publishFocusEvent(uint32_t seq, int32_t eventId, bool h
status_t InputPublisher::publishCaptureEvent(uint32_t seq, int32_t eventId,
bool pointerCaptureEnabled) {
- if (ATRACE_ENABLED()) {
- std::string message =
- StringPrintf("publishCaptureEvent(inputChannel=%s, pointerCaptureEnabled=%s)",
- mChannel->getName().c_str(), toString(pointerCaptureEnabled));
- ATRACE_NAME(message.c_str());
- }
+ ATRACE_NAME_IF(ATRACE_ENABLED(), [&]() {
+ return StringPrintf("publishCaptureEvent(inputChannel=%s, pointerCaptureEnabled=%s)",
+ mChannel->getName().c_str(), toString(pointerCaptureEnabled));
+ });
ALOGD_IF(debugTransportPublisher(),
"channel '%s' publisher ~ %s: seq=%u, id=%d, pointerCaptureEnabled=%s",
mChannel->getName().c_str(), __func__, seq, eventId, toString(pointerCaptureEnabled));
@@ -748,12 +744,10 @@ status_t InputPublisher::publishCaptureEvent(uint32_t seq, int32_t eventId,
status_t InputPublisher::publishDragEvent(uint32_t seq, int32_t eventId, float x, float y,
bool isExiting) {
- if (ATRACE_ENABLED()) {
- std::string message =
- StringPrintf("publishDragEvent(inputChannel=%s, x=%f, y=%f, isExiting=%s)",
- mChannel->getName().c_str(), x, y, toString(isExiting));
- ATRACE_NAME(message.c_str());
- }
+ ATRACE_NAME_IF(ATRACE_ENABLED(), [&]() {
+ return StringPrintf("publishDragEvent(inputChannel=%s, x=%f, y=%f, isExiting=%s)",
+ mChannel->getName().c_str(), x, y, toString(isExiting));
+ });
ALOGD_IF(debugTransportPublisher(),
"channel '%s' publisher ~ %s: seq=%u, id=%d, x=%f, y=%f, isExiting=%s",
mChannel->getName().c_str(), __func__, seq, eventId, x, y, toString(isExiting));
@@ -769,12 +763,10 @@ status_t InputPublisher::publishDragEvent(uint32_t seq, int32_t eventId, float x
}
status_t InputPublisher::publishTouchModeEvent(uint32_t seq, int32_t eventId, bool isInTouchMode) {
- if (ATRACE_ENABLED()) {
- std::string message =
- StringPrintf("publishTouchModeEvent(inputChannel=%s, isInTouchMode=%s)",
- mChannel->getName().c_str(), toString(isInTouchMode));
- ATRACE_NAME(message.c_str());
- }
+ ATRACE_NAME_IF(ATRACE_ENABLED(), [&]() {
+ return StringPrintf("publishTouchModeEvent(inputChannel=%s, isInTouchMode=%s)",
+ mChannel->getName().c_str(), toString(isInTouchMode));
+ });
ALOGD_IF(debugTransportPublisher(),
"channel '%s' publisher ~ %s: seq=%u, id=%d, isInTouchMode=%s",
mChannel->getName().c_str(), __func__, seq, eventId, toString(isInTouchMode));
diff --git a/services/inputflinger/InputListener.cpp b/services/inputflinger/InputListener.cpp
index aa55873aa5..d319d6dbb4 100644
--- a/services/inputflinger/InputListener.cpp
+++ b/services/inputflinger/InputListener.cpp
@@ -24,7 +24,7 @@
#include <android-base/stringprintf.h>
#include <android/log.h>
-#include <utils/Trace.h>
+#include <input/TraceTools.h>
using android::base::StringPrintf;
@@ -61,58 +61,42 @@ void InputListenerInterface::notify(const NotifyArgs& generalArgs) {
// --- QueuedInputListener ---
-static inline void traceEvent(const char* functionName, int32_t id) {
- if (ATRACE_ENABLED()) {
- std::string message = StringPrintf("%s(id=0x%" PRIx32 ")", functionName, id);
- ATRACE_NAME(message.c_str());
- }
-}
-
QueuedInputListener::QueuedInputListener(InputListenerInterface& innerListener)
: mInnerListener(innerListener) {}
void QueuedInputListener::notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& 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::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::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::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);
}
@@ -123,4 +107,81 @@ void QueuedInputListener::flush() {
mArgsQueue.clear();
}
+// --- TracedInputListener ---
+
+TracedInputListener::TracedInputListener(const char* name, InputListenerInterface& innerListener)
+ : mInnerListener(innerListener), mName(name) {}
+
+void TracedInputListener::notifyInputDevicesChanged(const NotifyInputDevicesChangedArgs& args) {
+ constexpr static auto& fnName = __func__;
+ ATRACE_NAME_IF(ATRACE_ENABLED(), [&]() {
+ return StringPrintf("%s::%s(id=0x%" PRIx32 ")", mName, fnName, args.id);
+ });
+ mInnerListener.notify(args);
+}
+
+void TracedInputListener::notifyConfigurationChanged(const NotifyConfigurationChangedArgs& args) {
+ constexpr static auto& fnName = __func__;
+ ATRACE_NAME_IF(ATRACE_ENABLED(), [&]() {
+ return StringPrintf("%s::%s(id=0x%" PRIx32 ")", mName, fnName, args.id);
+ });
+ mInnerListener.notify(args);
+}
+
+void TracedInputListener::notifyKey(const NotifyKeyArgs& args) {
+ constexpr static auto& fnName = __func__;
+ ATRACE_NAME_IF(ATRACE_ENABLED(), [&]() {
+ return StringPrintf("%s::%s(id=0x%" PRIx32 ")", mName, fnName, args.id);
+ });
+ mInnerListener.notify(args);
+}
+
+void TracedInputListener::notifyMotion(const NotifyMotionArgs& args) {
+ constexpr static auto& fnName = __func__;
+ ATRACE_NAME_IF(ATRACE_ENABLED(), [&]() {
+ return StringPrintf("%s::%s(id=0x%" PRIx32 ")", mName, fnName, args.id);
+ });
+ mInnerListener.notify(args);
+}
+
+void TracedInputListener::notifySwitch(const NotifySwitchArgs& args) {
+ constexpr static auto& fnName = __func__;
+ ATRACE_NAME_IF(ATRACE_ENABLED(), [&]() {
+ return StringPrintf("%s::%s(id=0x%" PRIx32 ")", mName, fnName, args.id);
+ });
+ mInnerListener.notify(args);
+}
+
+void TracedInputListener::notifySensor(const NotifySensorArgs& args) {
+ constexpr static auto& fnName = __func__;
+ ATRACE_NAME_IF(ATRACE_ENABLED(), [&]() {
+ return StringPrintf("%s::%s(id=0x%" PRIx32 ")", mName, fnName, args.id);
+ });
+ mInnerListener.notify(args);
+}
+
+void TracedInputListener::notifyVibratorState(const NotifyVibratorStateArgs& args) {
+ constexpr static auto& fnName = __func__;
+ ATRACE_NAME_IF(ATRACE_ENABLED(), [&]() {
+ return StringPrintf("%s::%s(id=0x%" PRIx32 ")", mName, fnName, args.id);
+ });
+ mInnerListener.notify(args);
+}
+
+void TracedInputListener::notifyDeviceReset(const NotifyDeviceResetArgs& args) {
+ constexpr static auto& fnName = __func__;
+ ATRACE_NAME_IF(ATRACE_ENABLED(), [&]() {
+ return StringPrintf("%s::%s(id=0x%" PRIx32 ")", mName, fnName, args.id);
+ });
+ mInnerListener.notify(args);
+}
+
+void TracedInputListener::notifyPointerCaptureChanged(const NotifyPointerCaptureChangedArgs& args) {
+ constexpr static auto& fnName = __func__;
+ ATRACE_NAME_IF(ATRACE_ENABLED(), [&]() {
+ return StringPrintf("%s::%s(id=0x%" PRIx32 ")", mName, fnName, args.id);
+ });
+ mInnerListener.notify(args);
+}
+
} // namespace android
diff --git a/services/inputflinger/InputManager.cpp b/services/inputflinger/InputManager.cpp
index da79ae3a48..0733a1c7c6 100644
--- a/services/inputflinger/InputManager.cpp
+++ b/services/inputflinger/InputManager.cpp
@@ -122,15 +122,24 @@ InputManager::InputManager(const sp<InputReaderPolicyInterface>& readerPolicy,
mInputFlingerRust = createInputFlingerRust();
mDispatcher = createInputDispatcher(dispatcherPolicy);
+ mTracingStages.emplace_back(
+ std::make_unique<TracedInputListener>("InputDispatcher", *mDispatcher));
if (ENABLE_INPUT_DEVICE_USAGE_METRICS) {
- mCollector = std::make_unique<InputDeviceMetricsCollector>(*mDispatcher);
+ mCollector = std::make_unique<InputDeviceMetricsCollector>(*mTracingStages.back());
+ mTracingStages.emplace_back(
+ std::make_unique<TracedInputListener>("MetricsCollector", *mCollector));
}
- mProcessor = ENABLE_INPUT_DEVICE_USAGE_METRICS ? std::make_unique<InputProcessor>(*mCollector)
- : std::make_unique<InputProcessor>(*mDispatcher);
- mBlocker = std::make_unique<UnwantedInteractionBlocker>(*mProcessor);
- mReader = createInputReader(readerPolicy, *mBlocker);
+ mProcessor = std::make_unique<InputProcessor>(*mTracingStages.back());
+ mTracingStages.emplace_back(
+ std::make_unique<TracedInputListener>("InputProcessor", *mProcessor));
+
+ mBlocker = std::make_unique<UnwantedInteractionBlocker>(*mTracingStages.back());
+ mTracingStages.emplace_back(
+ std::make_unique<TracedInputListener>("UnwantedInteractionBlocker", *mBlocker));
+
+ mReader = createInputReader(readerPolicy, *mTracingStages.back());
}
InputManager::~InputManager() {
diff --git a/services/inputflinger/InputManager.h b/services/inputflinger/InputManager.h
index 528d2aa5ca..51d582fba1 100644
--- a/services/inputflinger/InputManager.h
+++ b/services/inputflinger/InputManager.h
@@ -137,6 +137,8 @@ private:
std::unique_ptr<InputDispatcherInterface> mDispatcher;
std::shared_ptr<IInputFlingerRust> mInputFlingerRust;
+
+ std::vector<std::unique_ptr<TracedInputListener>> mTracingStages;
};
} // namespace android
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 630542fe47..13dbe656dd 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -32,6 +32,7 @@
#endif
#include <input/InputDevice.h>
#include <input/PrintTools.h>
+#include <input/TraceTools.h>
#include <openssl/mem.h>
#include <powermanager/PowerManager.h>
#include <unistd.h>
@@ -3161,12 +3162,10 @@ void InputDispatcher::prepareDispatchCycleLocked(nsecs_t currentTime,
const std::shared_ptr<Connection>& connection,
std::shared_ptr<EventEntry> eventEntry,
const InputTarget& inputTarget) {
- if (ATRACE_ENABLED()) {
- std::string message =
- StringPrintf("prepareDispatchCycleLocked(inputChannel=%s, id=0x%" PRIx32 ")",
- connection->getInputChannelName().c_str(), eventEntry->id);
- ATRACE_NAME(message.c_str());
- }
+ ATRACE_NAME_IF(ATRACE_ENABLED(), [&]() {
+ return StringPrintf("prepareDispatchCycleLocked(inputChannel=%s, id=0x%" PRIx32 ")",
+ connection->getInputChannelName().c_str(), eventEntry->id);
+ });
if (DEBUG_DISPATCH_CYCLE) {
ALOGD("channel '%s' ~ prepareDispatchCycle - flags=%s, "
"globalScaleFactor=%f, pointerIds=%s %s",
@@ -3231,12 +3230,10 @@ void InputDispatcher::enqueueDispatchEntriesLocked(nsecs_t currentTime,
const std::shared_ptr<Connection>& connection,
std::shared_ptr<EventEntry> eventEntry,
const InputTarget& inputTarget) {
- if (ATRACE_ENABLED()) {
- std::string message =
- StringPrintf("enqueueDispatchEntriesLocked(inputChannel=%s, id=0x%" PRIx32 ")",
- connection->getInputChannelName().c_str(), eventEntry->id);
- ATRACE_NAME(message.c_str());
- }
+ ATRACE_NAME_IF(ATRACE_ENABLED(), [&]() {
+ return StringPrintf("enqueueDispatchEntriesLocked(inputChannel=%s, id=0x%" PRIx32 ")",
+ connection->getInputChannelName().c_str(), eventEntry->id);
+ });
LOG_ALWAYS_FATAL_IF(!inputTarget.flags.any(InputTarget::DISPATCH_MASK),
"No dispatch flags are set for %s", eventEntry->getDescription().c_str());
@@ -3266,12 +3263,6 @@ void InputDispatcher::enqueueDispatchEntryLocked(const std::shared_ptr<Connectio
std::shared_ptr<EventEntry> eventEntry,
const InputTarget& inputTarget,
ftl::Flags<InputTarget::Flags> dispatchMode) {
- if (ATRACE_ENABLED()) {
- std::string message = StringPrintf("enqueueDispatchEntry(inputChannel=%s, dispatchMode=%s)",
- connection->getInputChannelName().c_str(),
- dispatchMode.string().c_str());
- ATRACE_NAME(message.c_str());
- }
ftl::Flags<InputTarget::Flags> inputTargetFlags = inputTarget.flags;
if (!inputTargetFlags.any(dispatchMode)) {
return;
@@ -3558,11 +3549,10 @@ status_t InputDispatcher::publishMotionEvent(Connection& connection,
void InputDispatcher::startDispatchCycleLocked(nsecs_t currentTime,
const std::shared_ptr<Connection>& connection) {
- if (ATRACE_ENABLED()) {
- std::string message = StringPrintf("startDispatchCycleLocked(inputChannel=%s)",
- connection->getInputChannelName().c_str());
- ATRACE_NAME(message.c_str());
- }
+ ATRACE_NAME_IF(ATRACE_ENABLED(), [&]() {
+ return StringPrintf("startDispatchCycleLocked(inputChannel=%s)",
+ connection->getInputChannelName().c_str());
+ });
if (DEBUG_DISPATCH_CYCLE) {
ALOGD("channel '%s' ~ startDispatchCycle", connection->getInputChannelName().c_str());
}
@@ -4136,12 +4126,10 @@ std::unique_ptr<MotionEntry> InputDispatcher::splitMotionEvent(
}
int32_t newId = mIdGenerator.nextId();
- if (ATRACE_ENABLED()) {
- std::string message = StringPrintf("Split MotionEvent(id=0x%" PRIx32
- ") to MotionEvent(id=0x%" PRIx32 ").",
- originalMotionEntry.id, newId);
- ATRACE_NAME(message.c_str());
- }
+ ATRACE_NAME_IF(ATRACE_ENABLED(), [&]() {
+ return StringPrintf("Split MotionEvent(id=0x%" PRIx32 ") to MotionEvent(id=0x%" PRIx32 ").",
+ originalMotionEntry.id, newId);
+ });
std::unique_ptr<MotionEntry> splitMotionEntry =
std::make_unique<MotionEntry>(newId, originalMotionEntry.eventTime,
originalMotionEntry.deviceId, originalMotionEntry.source,
diff --git a/services/inputflinger/include/InputListener.h b/services/inputflinger/include/InputListener.h
index 4f78f032c7..0b7f7c2831 100644
--- a/services/inputflinger/include/InputListener.h
+++ b/services/inputflinger/include/InputListener.h
@@ -76,4 +76,26 @@ private:
std::vector<NotifyArgs> mArgsQueue;
};
+/*
+ * An implementation of the listener interface that traces the calls to its inner listener.
+ */
+class TracedInputListener : public InputListenerInterface {
+public:
+ explicit TracedInputListener(const char* name, 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;
+
+private:
+ InputListenerInterface& mInnerListener;
+ const char* mName;
+};
+
} // namespace android