Determine whether an input device supports USI using IDC files
It is necessary to identify a USI device so that additional logic can be
applied to the battery information that is exposed via USI.
Bug: 243005009
Test: manual, check dumpsys output
Change-Id: I697008e6600ef16b7ecde85c99732759747b8a9b
diff --git a/include/input/InputDevice.h b/include/input/InputDevice.h
index 0026e82..f4a1523 100644
--- a/include/input/InputDevice.h
+++ b/include/input/InputDevice.h
@@ -280,6 +280,9 @@
std::vector<InputDeviceLightInfo> getLights();
+ inline void setSupportsUsi(bool supportsUsi) { mSupportsUsi = supportsUsi; }
+ inline bool supportsUsi() const { return mSupportsUsi; }
+
private:
int32_t mId;
int32_t mGeneration;
@@ -292,6 +295,8 @@
uint32_t mSources;
int32_t mKeyboardType;
std::shared_ptr<KeyCharacterMap> mKeyCharacterMap;
+ // Whether this device supports the Universal Stylus Initiative (USI) protocol for styluses.
+ bool mSupportsUsi;
bool mHasVibrator;
bool mHasBattery;
diff --git a/libs/input/InputDevice.cpp b/libs/input/InputDevice.cpp
index 3fe03c7..4751a7d 100644
--- a/libs/input/InputDevice.cpp
+++ b/libs/input/InputDevice.cpp
@@ -182,6 +182,7 @@
mSources(other.mSources),
mKeyboardType(other.mKeyboardType),
mKeyCharacterMap(other.mKeyCharacterMap),
+ mSupportsUsi(other.mSupportsUsi),
mHasVibrator(other.mHasVibrator),
mHasBattery(other.mHasBattery),
mHasButtonUnderPad(other.mHasButtonUnderPad),
@@ -210,6 +211,7 @@
mHasBattery = false;
mHasButtonUnderPad = false;
mHasSensor = false;
+ mSupportsUsi = false;
mMotionRanges.clear();
mSensors.clear();
mLights.clear();
diff --git a/services/inputflinger/reader/mapper/TouchInputMapper.cpp b/services/inputflinger/reader/mapper/TouchInputMapper.cpp
index c2454ac..18a73ea 100644
--- a/services/inputflinger/reader/mapper/TouchInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/TouchInputMapper.cpp
@@ -256,6 +256,7 @@
y.resolution);
}
info->setButtonUnderPad(mParameters.hasButtonUnderPad);
+ info->setSupportsUsi(mParameters.supportsUsi);
}
void TouchInputMapper::dump(std::string& dump) {
@@ -505,6 +506,10 @@
// up in your pocket but you can enable it using the input device configuration.
mParameters.wake = getDeviceContext().isExternal();
getDeviceContext().getConfiguration().tryGetProperty("touch.wake", mParameters.wake);
+
+ mParameters.supportsUsi = false;
+ getDeviceContext().getConfiguration().tryGetProperty("touch.supportsUsi",
+ mParameters.supportsUsi);
}
void TouchInputMapper::dumpParameters(std::string& dump) {
@@ -521,6 +526,7 @@
mParameters.uniqueDisplayId.c_str());
dump += StringPrintf(INDENT4 "OrientationAware: %s\n", toString(mParameters.orientationAware));
dump += INDENT4 "Orientation: " + ftl::enum_string(mParameters.orientation) + "\n";
+ dump += StringPrintf(INDENT4 "SupportsUsi: %s\n", toString(mParameters.supportsUsi));
}
void TouchInputMapper::configureRawPointerAxes() {
diff --git a/services/inputflinger/reader/mapper/TouchInputMapper.h b/services/inputflinger/reader/mapper/TouchInputMapper.h
index 50f30c8..7b0327e 100644
--- a/services/inputflinger/reader/mapper/TouchInputMapper.h
+++ b/services/inputflinger/reader/mapper/TouchInputMapper.h
@@ -232,6 +232,9 @@
GestureMode gestureMode;
bool wake;
+
+ // Whether the device supports the Universal Stylus Initiative (USI) protocol for styluses.
+ bool supportsUsi;
} mParameters;
// Immutable calibration parameters in parsed form.