Skip to content
Snippets Groups Projects
Commit a587e4eb authored by Bruno Martins's avatar Bruno Martins Committed by Demon000
Browse files

sm6250-common: power: Add support for DT2W feature


Co-authored-by: default avatarLuK1337 <priv.luk@gmail.com>
Co-authored-by: default avatarAbhiShek Aggarwal <warabhishek@gmail.com>
Change-Id: I2f7fb4a8b0c9cd1a16d6c2b93602d285a191f170
parent 40eda54c
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,9 @@ cc_binary {
"Power.cpp",
"service.cpp",
],
header_libs: [
"generated_kernel_headers",
],
shared_libs: [
"liblog",
"libhidlbase",
......
......@@ -16,8 +16,14 @@
#define LOG_TAG "android.hardware.power@1.3-service.xiaomi_sm6250"
#include <linux/input.h>
#include "Power.h"
constexpr static char const* inputDevicesDirectory = "/dev/input/";
constexpr static int wakeupModeOn = 5;
constexpr static int wakeupModeOff = 4;
namespace android {
namespace hardware {
namespace power {
......@@ -33,7 +39,66 @@ Return<void> Power::powerHint(PowerHint_1_0, int32_t) {
return Void();
}
Return<void> Power::setFeature(Feature, bool) {
bool isSupportedInputName(char* name) {
return false;
}
int openInputFd() {
DIR *dir = opendir(inputDevicesDirectory);
if (dir == NULL) {
return -1;
}
struct dirent *ent;
int fd;
int rc;
while ((ent = readdir(dir)) != NULL) {
if (ent->d_type != DT_CHR)
continue;
char absolute_path[PATH_MAX] = {0};
char name[80] = {0};
strcpy(absolute_path, inputDevicesDirectory);
strcat(absolute_path, ent->d_name);
fd = open(absolute_path, O_RDWR);
if (fd < 0)
continue;
rc = ioctl(fd, EVIOCGNAME(sizeof(name) - 1), &name);
if (rc > 0 && isSupportedInputName(name))
break;
close(fd);
fd = -1;
}
closedir(dir);
return fd;
}
Return<void> Power::setFeature(Feature feature, bool activate) {
switch (feature) {
case Feature::POWER_FEATURE_DOUBLE_TAP_TO_WAKE: {
int fd = openInputFd();
if (fd < 0) {
ALOGW("No touchscreen input devices that support DT2W were found");
return Void();
}
struct input_event ev;
ev.type = EV_SYN;
ev.code = SYN_CONFIG;
ev.value = activate ? wakeupModeOn : wakeupModeOff;
write(fd, &ev, sizeof(ev));
close(fd);
} break;
default:
break;
}
return Void();
}
......
service vendor.power-hal-1-0 /vendor/bin/hw/android.hardware.power@1.3-service.xiaomi_sm6250
class hal
user system
group system
group system input
# Allow hal_power_default to write to dt2w nodes
allow hal_power_default input_device:dir r_dir_perms;
allow hal_power_default input_device:chr_file rw_file_perms;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment