a52sxq: 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
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user