sm7125-common: sensors: Toggle touchscreen on/off if needed

* Due to config_powerDecoupleInteractiveModeFromDisplay we need to wait for the sensors sub HAL to re-start every time we fail a fingerprint unlock with screen off or on AOD.
* To prevent killing said overlay and having the touchscreen constantly enabled on AOD, we simply toggle the touchscreen on/off with every screen-off-UDFPS unlock

Change-Id: I819b9ef4387a914ccf17d7f4c6023ad08b3d14a0
urubino-microg
Simon1511 10 months ago committed by Ruchit
parent e9214cb4bc
commit 6b5aa7d041
  1. 29
      sensors/Sensor.cpp
  2. 2
      sepolicy/vendor/hal_sensors_default.te

@ -20,8 +20,26 @@
#include <log/log.h>
#include <utils/SystemClock.h>
#include <fstream>
#include <cmath>
#define TSP_ENABLED_PATH "/sys/class/sec/tsp/input/enabled"
template <typename T>
static void set(const std::string& path, const T& value) {
std::ofstream file(path);
file << value;
}
template <typename T>
static T get(const std::string& path, const T& def) {
std::ifstream file(path);
T result;
file >> result;
return file.fail() ? def : result;
}
static bool readBool(int fd, bool seek) {
char c;
int rc;
@ -262,6 +280,10 @@ SysfsPollingOneShotSensor::~SysfsPollingOneShotSensor() {
void SysfsPollingOneShotSensor::activate(bool enable, bool notify, bool lock) {
std::unique_lock<std::mutex> runLock(mRunMutex, std::defer_lock);
if (!enable && strcmp(get<std::string>(TSP_ENABLED_PATH, "0").c_str(), "0") == 0) {
set(TSP_ENABLED_PATH, "1");
}
if (lock) {
runLock.lock();
}
@ -278,6 +300,10 @@ void SysfsPollingOneShotSensor::activate(bool enable, bool notify, bool lock) {
if (lock) {
runLock.unlock();
}
if (enable && strcmp(get<std::string>(TSP_ENABLED_PATH, "0").c_str(), "1") == 0) {
set(TSP_ENABLED_PATH, "0");
}
}
void SysfsPollingOneShotSensor::activate(bool enable) {
@ -310,6 +336,9 @@ void SysfsPollingOneShotSensor::run() {
}
if (mPolls[1].revents == mPolls[1].events && readBool(mPollFd, true /* seek */)) {
if (strcmp(get<std::string>(TSP_ENABLED_PATH, "0").c_str(), "0") == 0) {
set(TSP_ENABLED_PATH, "1");
}
activate(false, false, false);
mCallback->postEvents(readEvents(), isWakeUpSensor());
} else if (mPolls[0].revents == mPolls[0].events) {

@ -37,7 +37,7 @@ 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 };
allow hal_sensors_default sysfs_power_writable:file rw_file_perms;
# /sys/class/sec/tsp/cmd
allow hal_sensors_default sysfs_touchscreen_writable:file rw_file_perms;

Loading…
Cancel
Save