Skip to content

Commit 2a88cfa

Browse files
committed
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
1 parent 19005b2 commit 2a88cfa

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

sensors/Sensor.cpp

+29
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,26 @@
2020
#include <log/log.h>
2121
#include <utils/SystemClock.h>
2222

23+
#include <fstream>
24+
2325
#include <cmath>
2426

27+
#define TSP_ENABLED_PATH "/sys/class/sec/tsp/input/enabled"
28+
29+
template <typename T>
30+
static void set(const std::string& path, const T& value) {
31+
std::ofstream file(path);
32+
file << value;
33+
}
34+
35+
template <typename T>
36+
static T get(const std::string& path, const T& def) {
37+
std::ifstream file(path);
38+
T result;
39+
file >> result;
40+
return file.fail() ? def : result;
41+
}
42+
2543
static bool readBool(int fd, bool seek) {
2644
char c;
2745
int rc;
@@ -262,6 +280,10 @@ SysfsPollingOneShotSensor::~SysfsPollingOneShotSensor() {
262280
void SysfsPollingOneShotSensor::activate(bool enable, bool notify, bool lock) {
263281
std::unique_lock<std::mutex> runLock(mRunMutex, std::defer_lock);
264282

283+
if (!enable && strcmp(get<std::string>(TSP_ENABLED_PATH, "0").c_str(), "0") == 0) {
284+
set(TSP_ENABLED_PATH, "1");
285+
}
286+
265287
if (lock) {
266288
runLock.lock();
267289
}
@@ -278,6 +300,10 @@ void SysfsPollingOneShotSensor::activate(bool enable, bool notify, bool lock) {
278300
if (lock) {
279301
runLock.unlock();
280302
}
303+
304+
if (enable && strcmp(get<std::string>(TSP_ENABLED_PATH, "0").c_str(), "1") == 0) {
305+
set(TSP_ENABLED_PATH, "0");
306+
}
281307
}
282308

283309
void SysfsPollingOneShotSensor::activate(bool enable) {
@@ -310,6 +336,9 @@ void SysfsPollingOneShotSensor::run() {
310336
}
311337

312338
if (mPolls[1].revents == mPolls[1].events && readBool(mPollFd, true /* seek */)) {
339+
if (strcmp(get<std::string>(TSP_ENABLED_PATH, "0").c_str(), "0") == 0) {
340+
set(TSP_ENABLED_PATH, "1");
341+
}
313342
activate(false, false, false);
314343
mCallback->postEvents(readEvents(), isWakeUpSensor());
315344
} else if (mPolls[0].revents == mPolls[0].events) {

sepolicy/vendor/hal_sensors_default.te

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ allow hal_sensors_default sysfs_sec_touchscreen:dir r_dir_perms;
3737
allow hal_sensors_default sysfs_sec_touchscreen:file r_file_perms;
3838
allow hal_sensors_default sysfs_sec_touchscreen:lnk_file r_file_perms;
3939
allow hal_sensors_default sysfs_power_writable:dir search;
40-
allow hal_sensors_default sysfs_power_writable:file { read open };
40+
allow hal_sensors_default sysfs_power_writable:file rw_file_perms;
4141

4242
# /sys/class/sec/tsp/cmd
4343
allow hal_sensors_default sysfs_touchscreen_writable:file rw_file_perms;

0 commit comments

Comments
 (0)