<toolbar title="悬浮窗权限无障碍服务"/>
<Switch id="无障碍服务" text="无障碍服务" checked="{{auto.service != null}}" padding="8 8 8 8" textSize="15sp"/>
<Switch id="悬浮窗权限" text="悬浮窗权限" checked="{{floaty.checkPermission() != false}}" padding="8 8 8 8" textSize="15sp"/>
<button id="start" text="启动脚本"/>
ui.无障碍服务.on("check", function(checked) {
// 用户勾选无障碍服务的选项时,跳转到页面让用户去开启
if (checked && auto.service == null) {
action: "android.settings.ACCESSIBILITY_SETTINGS"
if (!checked && auto.service != null) {
auto.service.disableSelf();
ui.悬浮窗权限.on("check", function(checked) {
importClass(android.content.Intent);
importClass(android.net.Uri);
importClass(android.provider.Settings);
var intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
Uri.parse("package:" + context.getPackageName()));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
app.startActivity(intent);
// 当用户回到本界面时,resume事件会被触发
ui.emitter.on("resume", function() {
// 此时根据无障碍服务的开启情况,同步开关的状态
ui.无障碍服务.checked = auto.service != null;
ui.悬浮窗权限.checked = floaty.checkPermission() != false
ui.start.on("click", function() {
if (floaty.checkPermission() == false) {
if (auto.service == null) {
