diff --git a/power-libperfmgr/aidl/Power.cpp b/power-libperfmgr/aidl/Power.cpp index f9f59f4..de91b22 100644 --- a/power-libperfmgr/aidl/Power.cpp +++ b/power-libperfmgr/aidl/Power.cpp @@ -83,6 +83,32 @@ Power::Power(std::shared_ptr hm) ALOGI("PowerHAL ready to process hints"); } +static int sysfs_write(const char *path, const char *s) +{ + char buf[80]; + int len; + int ret = 0; + int fd = open(path, O_WRONLY); + + if (fd < 0) { + strerror_r(errno, buf, sizeof(buf)); + ALOGE("Error opening %s: %s\n", path, buf); + return -1 ; + } + + len = write(fd, s, strlen(s)); + if (len < 0) { + strerror_r(errno, buf, sizeof(buf)); + ALOGE("Error writing to %s: %s\n", path, buf); + + ret = -1; + } + + close(fd); + + return ret; +} + ndk::ScopedAStatus Power::setMode(Mode type, bool enabled) { LOG(DEBUG) << "Power setMode: " << toString(type) << " to: " << enabled; ATRACE_INT(toString(type).c_str(), enabled); @@ -131,7 +157,10 @@ ndk::ScopedAStatus Power::setMode(Mode type, bool enabled) { } [[fallthrough]]; case Mode::DOUBLE_TAP_TO_WAKE: - [[fallthrough]]; + { + sysfs_write("/sys/class/touch/tp_dev/gesture_on", enabled ? "1" : "0"); + } + break; case Mode::FIXED_PERFORMANCE: [[fallthrough]]; case Mode::EXPENSIVE_RENDERING: