35-Android之打开adb的sendevent功能
平台: MTK6739 Android10
客户测试发现,无法使用adb的sendevent功能。 通过查看日志发现报的是selinux权限错误。
搜索代码发现,Android10已经将该功能关闭。
文件:
system/sepolicy/prebuilts/api/29.0/public/shell.te
system/sepolicy/public/shell.te
allow shell input_device:dir r_dir_perms;
# 修改,添加下面的语句,begin @{
allow shell input_device:chr_file { r_file_perms write };
#}@ end
# b/30861057: Shell access to existing input devices is an abuse
# vector. The shell user can inject events that look like they
# originate from the touchscreen etc.
# Everyone should have already moved to UiAutomation#injectInputEvent
# if they are running instrumentation tests (i.e. CTS), Monkey for
# their stress tests, and the input command (adb shell input ...) for
# injecting swipes and things.
# 修改,将此处注释掉 begin @{
# neverallow shell input_device:chr_file no_w_file_perms;
# }@ end
system/sepolicy/prebuilts/api/29.0/public/vendor_shell.te
system/sepolicy/public/vendor_shell.te
allow vendor_shell input_device:dir r_dir_perms;
# 修改,添加下面的语句,begin @{
allow vendor_shell input_device:chr_file { rw_file_perms write};
#}@ end