From 73f753e0ef03a72a133b28b34e84f086dcaf871b Mon Sep 17 00:00:00 2001 From: Cyber Knight Date: Fri, 21 Apr 2023 12:54:34 +0800 Subject: [PATCH] sensors: Implement Single Tap Sensor - This implements a modernized tap to wake sensor for devices that support it. - It is guarded by a SOONG variable hence to use it, a maintainer would have to configure it in the BoardConfig. - An example is as below: SOONG_CONFIG_NAMESPACES += SENSORS_XIAOMI SOONG_CONFIG_SENSORS_XIAOMI += USES_SINGLE_TAP_SENSOR SOONG_CONFIG_SENSORS_XIAOMI_USES_SINGLE_TAP_SENSOR := true Change-Id: I30d190d0f07ca2517826cc2263153ad39bacc204 Signed-off-by: Cyber Knight --- sensors/Android.bp | 5 ++++- sensors/Sensor.h | 16 ++++++++++++++++ sensors/SensorsSubHal.cpp | 3 +++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/sensors/Android.bp b/sensors/Android.bp index 30dc413..5980c83 100644 --- a/sensors/Android.bp +++ b/sensors/Android.bp @@ -8,7 +8,7 @@ soong_config_module_type { name: "sensors_xiaomi_cc_defaults", module_type: "cc_defaults", config_namespace: "SENSORS_XIAOMI", - bool_variables: ["USES_UDFPS_SENSOR", "USES_DOUBLE_TAP_SENSOR"], + bool_variables: ["USES_UDFPS_SENSOR", "USES_DOUBLE_TAP_SENSOR", "USES_SINGLE_TAP_SENSOR"], properties: ["cppflags"], } @@ -21,6 +21,9 @@ sensors_xiaomi_cc_defaults { USES_DOUBLE_TAP_SENSOR: { cppflags: ["-DUSES_DOUBLE_TAP_SENSOR"], }, + USES_SINGLE_TAP_SENSOR: { + cppflags: ["-DUSES_SINGLE_TAP_SENSOR"], + }, }, } diff --git a/sensors/Sensor.h b/sensors/Sensor.h index 8cc0c6f..2c43179 100644 --- a/sensors/Sensor.h +++ b/sensors/Sensor.h @@ -152,6 +152,22 @@ class DoubleTapSensor : public SysfsPollingOneShotSensor { }; #endif +#ifdef USES_SINGLE_TAP_SENSOR +static const char* singleTapPaths[] = { + "/sys/devices/platform/soc/884000.i2c/i2c-1/1-0038/single_tap_pressed", + NULL +}; + +class SingleTapSensor : public SysfsPollingOneShotSensor { + public: + SingleTapSensor(int32_t sensorHandle, ISensorsEventCallback* callback) + : SysfsPollingOneShotSensor( + sensorHandle, callback, GetPollPath(singleTapPaths), + "Single Tap Sensor", "co.aospa.sensor.single_tap", + static_cast(static_cast(SensorType::DEVICE_PRIVATE_BASE) + 1)) {} +}; +#endif + } // namespace implementation } // namespace subhal } // namespace V2_1 diff --git a/sensors/SensorsSubHal.cpp b/sensors/SensorsSubHal.cpp index 23e1ac7..7515423 100644 --- a/sensors/SensorsSubHal.cpp +++ b/sensors/SensorsSubHal.cpp @@ -39,6 +39,9 @@ SensorsSubHal::SensorsSubHal() : mCallback(nullptr), mNextHandle(1) { #ifdef USES_DOUBLE_TAP_SENSOR AddSensor(); #endif +#ifdef USES_SINGLE_TAP_SENSOR + AddSensor(); +#endif } Return SensorsSubHal::getSensorsList_2_1(ISensors::getSensorsList_2_1_cb _hidl_cb) {