diff --git a/cmds/xiaomi-touch.cpp b/cmds/xiaomi-touch.cpp index 3a3283fd..978e65af 100644 --- a/cmds/xiaomi-touch.cpp +++ b/cmds/xiaomi-touch.cpp @@ -25,22 +25,23 @@ #define Touch_Nonui_Mode 17 #define Touch_Debug_Level 18 #define Touch_Power_Status 19 -#define Touch_Mode_NUM 20 +#define Touch_Pen_ENABLE 20 +#define Touch_Mode_NUM 21 #define TOUCH_DEV_PATH "/dev/xiaomi-touch" #define TOUCH_ID 0 #define TOUCH_MAGIC 0x5400 #define TOUCH_IOC_SETMODE TOUCH_MAGIC + SET_CUR_VALUE -int main(int argc, char **argv) { - if(argc != 3) { - fprintf(stderr, "Usage: %s <0|1>\n", argv[0]); +int main(int argc, char **argv) +{ + if (argc != 3) { + fprintf(stderr, "Usage: %s \n", argv[0]); return -1; } int mode = atoi(argv[1]); int enabled = atoi(argv[2]); - if (mode < 0 || mode > 20) return -1; - if (enabled != 0 && enabled != 1) return -1; + if (mode < 0 || mode > Touch_Mode_NUM) return -1; int fd = open(TOUCH_DEV_PATH, O_RDWR); // Xiaomi has two competing ABIs, no idea how to detect it int arg[3] = {TOUCH_ID, mode, enabled}; diff --git a/phh-prop-handler.sh b/phh-prop-handler.sh index e1874662..4498ded1 100644 --- a/phh-prop-handler.sh +++ b/phh-prop-handler.sh @@ -62,6 +62,16 @@ xiaomi_toggle_dt2w_ioctl() { return 1 } +xiaomi_toggle_pen_enable() { + if [ -c "/dev/xiaomi-touch" ]; then + echo "Trying Enable Xiaomi Smart Pen with ioctl on xiaomi-touch" + # 20 - Touch_Pen_ENABLE + xiaomi-touch 20 "$1" + return + fi + return 1 +} + restartAudio() { setprop ctl.restart audioserver audioHal="$(getprop |sed -nE 's/.*init\.svc\.(.*audio-hal[^]]*).*/\1/p')" @@ -100,6 +110,11 @@ if [ "$1" == "persist.sys.phh.xiaomi.dt2w" ]; then exit fi +if [ "$1" == "persist.sys.phh.xiaomi.pen" ]; then + xiaomi_toggle_pen_enable "$prop_value" + exit +fi + if [ "$1" == "persist.sys.phh.oppo.dt2w" ]; then if [[ "$prop_value" != "0" && "$prop_value" != "1" ]]; then exit 1 diff --git a/vndk.rc b/vndk.rc index 6bd39501..d43b1a2d 100644 --- a/vndk.rc +++ b/vndk.rc @@ -46,6 +46,9 @@ on property:persist.sys.phh.transsion.dt2w=* on property:persist.sys.phh.xiaomi.dt2w=* exec u:r:phhsu_daemon:s0 root -- /system/bin/phh-prop-handler.sh "persist.sys.phh.xiaomi.dt2w" +on property:persist.sys.phh.xiaomi.pen=* + exec u:r:phhsu_daemon:s0 root -- /system/bin/phh-prop-handler.sh "persist.sys.phh.xiaomi.pen" + on property:persist.sys.phh.allow_binder_thread_on_incoming_calls=* exec u:r:phhsu_daemon:s0 root -- /system/bin/phh-prop-handler.sh "persist.sys.phh.allow_binder_thread_on_incoming_calls"