From c1c4ae8953cb18bd309f48bc3b6a395c5f135328 Mon Sep 17 00:00:00 2001 From: Cosmin Tanislav Date: Sun, 20 Feb 2022 19:21:09 +0200 Subject: [PATCH] sm7125-common: sensors: Implement UDFPS sensor Change-Id: I8b65e3196a7d6f158f4ff589b9755cf7c7e51c92 --- .../frameworks/base/core/res/res/values/config.xml | 3 +++ rootdir/etc/init.samsung.rc | 1 + sensors/Sensor.h | 11 +++++++++++ sensors/SensorsSubHal.cpp | 4 +++- sepolicy/vendor/hal_sensors_default.te | 2 ++ 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/overlay/frameworks/base/core/res/res/values/config.xml b/overlay/frameworks/base/core/res/res/values/config.xml index ad076c8..3d5542a 100644 --- a/overlay/frameworks/base/core/res/res/values/config.xml +++ b/overlay/frameworks/base/core/res/res/values/config.xml @@ -1361,4 +1361,7 @@ true + + + org.lineageos.sensor.udfps diff --git a/rootdir/etc/init.samsung.rc b/rootdir/etc/init.samsung.rc index cb517c3..c59bd79 100644 --- a/rootdir/etc/init.samsung.rc +++ b/rootdir/etc/init.samsung.rc @@ -167,6 +167,7 @@ on boot chmod 0660 /sys/class/sec/tsp/input/enabled chown system system /sys/class/sec/tsp/enabled chmod 0660 /sys/class/sec/tsp/enabled + chown system system /sys/class/sec/tsp/input/fod_pressed chown root system /proc/tsp_msg chmod 0440 /proc/tsp_msg chown system radio /sys/class/sec/tsp/pressure_enable diff --git a/sensors/Sensor.h b/sensors/Sensor.h index 605e8e1..0b0f53c 100644 --- a/sensors/Sensor.h +++ b/sensors/Sensor.h @@ -115,6 +115,17 @@ class SysfsPollingOneShotSensor : public OneShotSensor { int mPollFd; }; +const std::string kTsUdfpsPressedPath = "/sys/class/sec/tsp/input/fod_pressed"; + +class UdfpsSensor : public SysfsPollingOneShotSensor { + public: + UdfpsSensor(int32_t sensorHandle, ISensorsEventCallback* callback) + : SysfsPollingOneShotSensor( + sensorHandle, callback, kTsUdfpsPressedPath, + "UDFPS Sensor", "org.lineageos.sensor.udfps", + static_cast(static_cast(SensorType::DEVICE_PRIVATE_BASE) + 2)) {} +}; + } // namespace implementation } // namespace subhal } // namespace V2_1 diff --git a/sensors/SensorsSubHal.cpp b/sensors/SensorsSubHal.cpp index 6cbcb56..9306b98 100644 --- a/sensors/SensorsSubHal.cpp +++ b/sensors/SensorsSubHal.cpp @@ -32,7 +32,9 @@ 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) { + AddSensor(); +} Return SensorsSubHal::getSensorsList_2_1(ISensors::getSensorsList_2_1_cb _hidl_cb) { std::vector sensors; diff --git a/sepolicy/vendor/hal_sensors_default.te b/sepolicy/vendor/hal_sensors_default.te index e9a587c..4f866e6 100644 --- a/sepolicy/vendor/hal_sensors_default.te +++ b/sepolicy/vendor/hal_sensors_default.te @@ -34,6 +34,8 @@ allow hal_sensors_default sysfs_sec_key:file r_file_perms; allow hal_sensors_default sysfs_sec_touchscreen:dir r_dir_perms; allow hal_sensors_default sysfs_sec_touchscreen:file r_file_perms; allow hal_sensors_default sysfs_sec_touchscreen:lnk_file r_file_perms; +allow hal_sensors_default sysfs_power_writable:dir search; +allow hal_sensors_default sysfs_power_writable:file { read open }; # /sys/class/sec/tsp/cmd allow hal_sensors_default sysfs_touchscreen_writable:file rw_file_perms;