/*
* @Author: your name
* @Date: 2021-09-30 11:14:54
* @LastEditTime: 2021-09-30 20:06:45
* @LastEditors: DESKTOP-K37CL87
* @Description: In User Settings Edit
* @FilePath: \autojs\麒麟社-晋级课程\自启无障碍不掉线.js
* 使用方法 电脑点击手机开启USB链接 使用adb //授权方法:开启usb调试并使用adb工具连接手机,执行 adb shell pm grant org.autojs.autojspro android.permission.WRITE_SECURE_SETTING
* adb devices 查看设备
*/
importClass(android.content.Context);
importClass(android.provider.Settings);
try {
var enabledServices = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
// toastLog('启用的是', enabledServices);
var Services = enabledServices + ":org.autojs.autojspro/com.stardust.autojs.core.accessibility.AccessibilityService";
Settings.Secure.putString(context.getContentResolver(), Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES, Services);
Settings.Secure.putString(context.getContentResolver(), Settings.Secure.ACCESSIBILITY_ENABLED, '1');
toastLog("成功开启AutoJS的辅助服务");
} catch (error) {
toastLog("请给与adb权限", error);
}
|