对于辅助功能AccessbilityService,手动功能设置的步骤为 Setttings->Accessibility。
下面探讨使用命令或者代码实现自动授权AccessibilityService,
1. 使用命令授权AccessibilityService,
adb shell "settings put secure enabled_accessibility_services packageName/.ServiceName"
adb shell "settings put secure accessibility_enabled 1"
2. 使用代码授权AccessibilityService,
Settings.Secure.putString(getContentResolver(),
Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES, "pkgname/classname");
Settings.Secure.putString(getContentResolver(),
Settings.Secure.ACCESSIBILITY_ENABLED, "1");
参考资料:
如何以编程方式在Android中启用/禁用辅助功能服务 - VoidCC
(155条消息) Android辅助权限判断,与开启功能介绍_七天不过夜的专栏-CSDN博客