我知道调用InputManager时会有权限检查(pid / uid)。
猴子进程的UID与当前活动的UID不相等。 但为什么猴子进程可以将事件注入当前的活动窗口?
答案 0 :(得分:1)
adb shell monkey --port 12345
USER PID PPID VSIZE RSS WCHAN PC NAME
root 1 0 676 520 c0159a9c 00010378 S / init
root 19691 1 4716 452 ffffffff 00018498 S / sbin / adbd
root 5972 19691 440824 19700 ffffffff 40077dc8 S com.android.commands.monkey
答案 1 :(得分:1)
这是因为“adb shell”用户拥有该权限。检查/etc/permissions/platform.xml:
<assign-permission name="android.permission.INJECT_EVENTS" uid="shell" />