sensors: Implement double tap sensor

Change-Id: I6c217c994d6e4d5ae062a31a44fffc9f097a7f6f
This commit is contained in:
Cosmin Tanislav 2022-09-21 10:09:08 +05:30 committed by Arian
parent 0fb685b768
commit 55b7558c79
2 changed files with 16 additions and 1 deletions

View File

@ -121,6 +121,17 @@ class SysfsPollingOneShotSensor : public OneShotSensor {
int mPollFd;
};
class DoubleTapSensor : public SysfsPollingOneShotSensor {
public:
DoubleTapSensor(int32_t sensorHandle, ISensorsEventCallback* callback)
: SysfsPollingOneShotSensor(
sensorHandle, callback, "/sys/class/touch/touch_dev/gesture_double_tap_state",
"/sys/class/touch/touch_dev/gesture_double_tap_enabled", "Double Tap Sensor",
"org.lineageos.sensor.double_tap",
static_cast<SensorType>(static_cast<int32_t>(SensorType::DEVICE_PRIVATE_BASE) +
1)) {}
};
} // namespace implementation
} // namespace subhal
} // namespace V2_1

View File

@ -32,7 +32,11 @@ namespace implementation {
using ::android::hardware::Void;
using ::android::hardware::sensors::V2_0::implementation::ScopedWakelock;
SensorsSubHal::SensorsSubHal() : mCallback(nullptr), mNextHandle(1) {}
SensorsSubHal::SensorsSubHal() : mCallback(nullptr), mNextHandle(1) {
if (property_get_bool("ro.vendor.sensors.xiaomi.double_tap", false)) {
AddSensor<DoubleTapSensor>();
}
}
Return<void> SensorsSubHal::getSensorsList_2_1(ISensors::getSensorsList_2_1_cb _hidl_cb) {
std::vector<SensorInfo> sensors;