Metrics collector: Log a separate bus for USI styluses
For USI styluses, Vendor IDs are assigned by USI, and are different from
the Vendor IDs for USB devices. Therefore, to identify a device from its
VID/PID, we need to know whether it is reporting USB product/vendor IDs
or USI ones.
Here, we introduce USI as a new bus enum value for metrics purposes.
This way, we can differentiate product identifiers based on the bus
through which it is using.
Bug: 299645968
Test: atest inputflinger_tests
Change-Id: I954e5a7c3db7d1ae3d0c6906923848fe5ced84f1
diff --git a/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp b/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp
index 6ea004d..c3c9fdb 100644
--- a/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp
@@ -125,7 +125,13 @@
mapper->consumeGesture(gesture);
}
-int32_t linuxBusToInputDeviceBusEnum(int32_t linuxBus) {
+int32_t linuxBusToInputDeviceBusEnum(int32_t linuxBus, bool isUsiStylus) {
+ if (isUsiStylus) {
+ // This is a stylus connected over the Universal Stylus Initiative (USI) protocol.
+ // For metrics purposes, we treat this protocol as a separate bus.
+ return util::INPUT_DEVICE_USAGE_REPORTED__DEVICE_BUS__USI;
+ }
+
// When adding cases to this switch, also add them to the copy of this method in
// InputDeviceMetricsCollector.cpp.
// TODO(b/286394420): deduplicate this method with the one in InputDeviceMetricsCollector.cpp.
@@ -199,8 +205,8 @@
for (auto& [id, counters] : mCounters) {
auto [busId, vendorId, productId, versionId] = id;
addAStatsEvent(outEventList, android::util::TOUCHPAD_USAGE, vendorId, productId,
- versionId, linuxBusToInputDeviceBusEnum(busId), counters.fingers,
- counters.palms, counters.twoFingerSwipeGestures,
+ versionId, linuxBusToInputDeviceBusEnum(busId, /*isUsi=*/false),
+ counters.fingers, counters.palms, counters.twoFingerSwipeGestures,
counters.threeFingerSwipeGestures, counters.fourFingerSwipeGestures,
counters.pinchGestures);
}