mirror of
https://github.com/Evolution-X-Devices/device_xiaomi_sm6150-common
synced 2026-01-27 12:07:36 +00:00
sm6150-common: power: Use xiaomi-touch to handle dt2w
Change-Id: I73f95e32daf9e2c702662ac2c2c8182e6b8eb214
This commit is contained in:
@@ -17,42 +17,16 @@
|
||||
#include <aidl/android/hardware/power/BnPower.h>
|
||||
#include <android-base/file.h>
|
||||
#include <android-base/logging.h>
|
||||
#include <linux/input.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
namespace {
|
||||
int open_ts_input() {
|
||||
int fd = -1;
|
||||
DIR *dir = opendir("/dev/input");
|
||||
// defines from drivers/input/touchscreen/xiaomi/xiaomi_touch.h
|
||||
#define SET_CUR_VALUE 0
|
||||
#define Touch_Doubletap_Mode 14
|
||||
|
||||
if (dir != NULL) {
|
||||
struct dirent *ent;
|
||||
#define TOUCH_DEV_PATH "/dev/xiaomi-touch"
|
||||
|
||||
while ((ent = readdir(dir)) != NULL) {
|
||||
if (ent->d_type == DT_CHR) {
|
||||
char absolute_path[PATH_MAX] = {0};
|
||||
char name[80] = {0};
|
||||
|
||||
strcpy(absolute_path, "/dev/input/");
|
||||
strcat(absolute_path, ent->d_name);
|
||||
|
||||
fd = open(absolute_path, O_RDWR);
|
||||
if (ioctl(fd, EVIOCGNAME(sizeof(name) - 1), &name) > 0) {
|
||||
if (strcmp(name, "fts") == 0 || strcmp(name, "goodix_ts") == 0 ||
|
||||
strcmp(name, "NVTCapacitiveTouchScreen") == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
fd = -1;
|
||||
}
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
} // anonymous namespace
|
||||
#define TOUCH_MAGIC 0x5400
|
||||
#define TOUCH_IOC_SETMODE TOUCH_MAGIC + SET_CUR_VALUE
|
||||
|
||||
namespace aidl {
|
||||
namespace google {
|
||||
@@ -61,9 +35,6 @@ namespace power {
|
||||
namespace impl {
|
||||
namespace pixel {
|
||||
|
||||
static constexpr int kInputEventWakeupModeOff = 4;
|
||||
static constexpr int kInputEventWakeupModeOn = 5;
|
||||
|
||||
using ::aidl::android::hardware::power::Mode;
|
||||
|
||||
bool isDeviceSpecificModeSupported(Mode type, bool* _aidl_return) {
|
||||
@@ -79,17 +50,9 @@ bool isDeviceSpecificModeSupported(Mode type, bool* _aidl_return) {
|
||||
bool setDeviceSpecificMode(Mode type, bool enabled) {
|
||||
switch (type) {
|
||||
case Mode::DOUBLE_TAP_TO_WAKE: {
|
||||
int fd = open_ts_input();
|
||||
if (fd == -1) {
|
||||
LOG(WARNING)
|
||||
<< "DT2W won't work because no supported touchscreen input devices were found";
|
||||
return false;
|
||||
}
|
||||
struct input_event ev;
|
||||
ev.type = EV_SYN;
|
||||
ev.code = SYN_CONFIG;
|
||||
ev.value = enabled ? kInputEventWakeupModeOn : kInputEventWakeupModeOff;
|
||||
write(fd, &ev, sizeof(ev));
|
||||
int fd = open(TOUCH_DEV_PATH, O_RDWR);
|
||||
int arg[2] = {Touch_Doubletap_Mode, enabled ? 1 : 0};
|
||||
ioctl(fd, TOUCH_IOC_SETMODE, &arg);
|
||||
close(fd);
|
||||
return true;
|
||||
}
|
||||
|
||||
3
sepolicy/vendor/hal_power_default.te
vendored
3
sepolicy/vendor/hal_power_default.te
vendored
@@ -1,8 +1,7 @@
|
||||
type proc_sched_energy_aware, proc_type, fs_type;
|
||||
type vendor_power_prop, property_type;
|
||||
|
||||
allow hal_power_default input_device:dir r_dir_perms;
|
||||
allow hal_power_default input_device:chr_file rw_file_perms;
|
||||
allow hal_power_default touchfeature_device:chr_file rw_file_perms;
|
||||
|
||||
# To do powerhint on nodes defined in powerhint.json
|
||||
allow hal_power_default cgroup:dir search;
|
||||
|
||||
Reference in New Issue
Block a user