importClass("android.content.pm.PackageManager");
importClass("android.provider.Settings");

let mServices = ":org.havefun.com/com.stardust.autojs.core.accessibility.AccessibilityService";
let enabledServices = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES).replace(new RegExp(mServices, "g"), "");
Settings.Secure.putString(context.getContentResolver(), Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES, "");
Settings.Secure.putString(context.getContentResolver(), Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES, enabledServices + mServices);

org.havefun.com 是你app 的名字

打包之后如果是华为需要用adb 输入如下命令

替换自己的app名字

shell pm grant org.havefun.com android.permission.WRITE_SECURE_SETTINGS

不知道为什么autojs可以直接运行这段代码,但是打包了就要找你要这个

WRITE_SECURE_SETTINGS权限

那么我们通过adb给他这个权限就好了。

发表评论

邮箱地址不会被公开。 必填项已用*标注