Skip to content

Commit

Permalink
sensors: Implement Single Tap Sensor
Browse files Browse the repository at this point in the history
- 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 <[email protected]>
  • Loading branch information
cyberknight777 committed May 10, 2023
1 parent 0e6d85a commit 73f753e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sensors/Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
}

Expand All @@ -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"],
},
},
}

Expand Down
16 changes: 16 additions & 0 deletions sensors/Sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<SensorType>(static_cast<int32_t>(SensorType::DEVICE_PRIVATE_BASE) + 1)) {}
};
#endif

} // namespace implementation
} // namespace subhal
} // namespace V2_1
Expand Down
3 changes: 3 additions & 0 deletions sensors/SensorsSubHal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ SensorsSubHal::SensorsSubHal() : mCallback(nullptr), mNextHandle(1) {
#ifdef USES_DOUBLE_TAP_SENSOR
AddSensor<DoubleTapSensor>();
#endif
#ifdef USES_SINGLE_TAP_SENSOR
AddSensor<SingleTapSensor>();
#endif
}

Return<void> SensorsSubHal::getSensorsList_2_1(ISensors::getSensorsList_2_1_cb _hidl_cb) {
Expand Down

0 comments on commit 73f753e

Please sign in to comment.