summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Atif Niyaz <atifniyaz@google.com> 2019-07-25 11:12:39 -0700
committer Atif Niyaz <atifniyaz@google.com> 2019-08-05 16:13:07 -0700
commit3d3fa52c8bbe481ffb87d75e24725444bef0b939 (patch)
tree20ac43f46ed45fe58e07271234a9db28ce964724
parent8384682fd25b54921fd74288788f2a9299dd8dba (diff)
Move LatencyStatistics collection from InputReader to InputTransport
This move allows us to grab a bigger context of how much time a motion event is spent from the kernel to right before the event was published. Test: Modified LatencyStats to report ever 10 seconds. Utilized logs to check that logs were reporting every 10 seconds. Checked also using logs that data was being added and calculated correctly. Change-Id: Iee0f9a2155e93ae77de5a5cd8b9fd1506186c60f Signed-off-by: Atif Niyaz <atifniyaz@google.com>
-rw-r--r--include/input/InputTransport.h12
-rw-r--r--libs/input/Android.bp3
-rw-r--r--libs/input/InputTransport.cpp16
-rw-r--r--services/inputflinger/Android.bp1
-rw-r--r--services/inputflinger/InputReader.cpp13
-rw-r--r--services/inputflinger/InputReader.h8
6 files changed, 28 insertions, 25 deletions
diff --git a/include/input/InputTransport.h b/include/input/InputTransport.h
index df23f613c8..690e0a11c8 100644
--- a/include/input/InputTransport.h
+++ b/include/input/InputTransport.h
@@ -31,13 +31,16 @@
#include <string>
+#include <android-base/chrono_utils.h>
+
#include <binder/IBinder.h>
#include <input/Input.h>
+#include <input/LatencyStatistics.h>
+#include <utils/BitSet.h>
#include <utils/Errors.h>
-#include <utils/Timers.h>
#include <utils/RefBase.h>
+#include <utils/Timers.h>
#include <utils/Vector.h>
-#include <utils/BitSet.h>
namespace android {
class Parcel;
@@ -286,7 +289,12 @@ public:
status_t receiveFinishedSignal(uint32_t* outSeq, bool* outHandled);
private:
+ static constexpr std::chrono::duration TOUCH_STATS_REPORT_PERIOD = 5min;
+
sp<InputChannel> mChannel;
+ LatencyStatistics mTouchStatistics{TOUCH_STATS_REPORT_PERIOD};
+
+ void reportTouchEventForStatistics(nsecs_t evdevTime);
};
/*
diff --git a/libs/input/Android.bp b/libs/input/Android.bp
index 17138506e5..7749e66c4d 100644
--- a/libs/input/Android.bp
+++ b/libs/input/Android.bp
@@ -56,7 +56,8 @@ cc_library {
shared_libs: [
"libutils",
"libbinder",
- "libui"
+ "libui",
+ "libstatslog",
],
sanitize: {
diff --git a/libs/input/InputTransport.cpp b/libs/input/InputTransport.cpp
index 904a6feb03..2ff301e270 100644
--- a/libs/input/InputTransport.cpp
+++ b/libs/input/InputTransport.cpp
@@ -34,6 +34,7 @@
#include <utils/Trace.h>
#include <input/InputTransport.h>
+#include <statslog.h>
using android::base::StringPrintf;
@@ -531,6 +532,10 @@ status_t InputPublisher::publishMotionEvent(
msg.body.motion.pointers[i].properties.copyFrom(pointerProperties[i]);
msg.body.motion.pointers[i].coords.copyFrom(pointerCoords[i]);
}
+
+ if (source == AINPUT_SOURCE_TOUCHSCREEN) {
+ reportTouchEventForStatistics(eventTime);
+ }
return mChannel->sendMessage(&msg);
}
@@ -557,6 +562,17 @@ status_t InputPublisher::receiveFinishedSignal(uint32_t* outSeq, bool* outHandle
return OK;
}
+void InputPublisher::reportTouchEventForStatistics(nsecs_t evdevTime) {
+ if (mTouchStatistics.shouldReport()) {
+ android::util::stats_write(android::util::TOUCH_EVENT_REPORTED, mTouchStatistics.getMin(),
+ mTouchStatistics.getMax(), mTouchStatistics.getMean(),
+ mTouchStatistics.getStDev(), mTouchStatistics.getCount());
+ mTouchStatistics.reset();
+ }
+ nsecs_t latency = nanoseconds_to_microseconds(systemTime(CLOCK_MONOTONIC) - evdevTime);
+ mTouchStatistics.addValue(latency);
+}
+
// --- InputConsumer ---
InputConsumer::InputConsumer(const sp<InputChannel>& channel) :
diff --git a/services/inputflinger/Android.bp b/services/inputflinger/Android.bp
index 8dd4d1df63..bdee6fe043 100644
--- a/services/inputflinger/Android.bp
+++ b/services/inputflinger/Android.bp
@@ -88,7 +88,6 @@ cc_library_shared {
"libui",
"libutils",
"libhardware_legacy",
- "libstatslog",
],
header_libs: [
diff --git a/services/inputflinger/InputReader.cpp b/services/inputflinger/InputReader.cpp
index df5dcafec9..d565e3ab38 100644
--- a/services/inputflinger/InputReader.cpp
+++ b/services/inputflinger/InputReader.cpp
@@ -57,7 +57,6 @@
#include <android-base/stringprintf.h>
#include <input/Keyboard.h>
#include <input/VirtualKeyMap.h>
-#include <statslog.h>
#define INDENT " "
#define INDENT2 " "
@@ -4310,24 +4309,12 @@ void TouchInputMapper::clearStylusDataPendingFlags() {
mExternalStylusFusionTimeout = LLONG_MAX;
}
-void TouchInputMapper::reportEventForStatistics(nsecs_t evdevTime) {
- if (mStatistics.shouldReport()) {
- android::util::stats_write(android::util::TOUCH_EVENT_REPORTED, mStatistics.getMin(),
- mStatistics.getMax(), mStatistics.getMean(),
- mStatistics.getStDev(), mStatistics.getCount());
- mStatistics.reset();
- }
- nsecs_t latency = nanoseconds_to_microseconds(systemTime(CLOCK_MONOTONIC) - evdevTime);
- mStatistics.addValue(latency);
-}
-
void TouchInputMapper::process(const RawEvent* rawEvent) {
mCursorButtonAccumulator.process(rawEvent);
mCursorScrollAccumulator.process(rawEvent);
mTouchButtonAccumulator.process(rawEvent);
if (rawEvent->type == EV_SYN && rawEvent->code == SYN_REPORT) {
- reportEventForStatistics(rawEvent->when);
sync(rawEvent->when);
}
}
diff --git a/services/inputflinger/InputReader.h b/services/inputflinger/InputReader.h
index 33763b6cdf..e434869996 100644
--- a/services/inputflinger/InputReader.h
+++ b/services/inputflinger/InputReader.h
@@ -24,7 +24,6 @@
#include <input/DisplayViewport.h>
#include <input/Input.h>
-#include <input/LatencyStatistics.h>
#include <input/VelocityControl.h>
#include <input/VelocityTracker.h>
#include <ui/DisplayInfo.h>
@@ -1509,11 +1508,6 @@ private:
VelocityControl mWheelXVelocityControl;
VelocityControl mWheelYVelocityControl;
- static constexpr std::chrono::duration STATS_REPORT_PERIOD = 5min;
-
- // Latency statistics for touch events
- LatencyStatistics mStatistics{STATS_REPORT_PERIOD};
-
std::optional<DisplayViewport> findViewport();
void resetExternalStylus();
@@ -1582,8 +1576,6 @@ private:
static void assignPointerIds(const RawState* last, RawState* current);
- void reportEventForStatistics(nsecs_t evdevTime);
-
const char* modeToString(DeviceMode deviceMode);
};