add: root_automator
This commit is contained in:
@@ -89,7 +89,7 @@ events.onKeyDown("menu", function(event){
|
||||
### events.onTouch(listener)
|
||||
* listener \<Function\> 参数为Point的函数
|
||||
|
||||
注册一个触摸监听函数。
|
||||
注册一个触摸监听函数。相当于`on("touch", listener)`。
|
||||
|
||||
例如:
|
||||
```
|
||||
@@ -147,6 +147,28 @@ events.loop();
|
||||
```
|
||||
|
||||
|
||||
### obverseNotification()
|
||||
|
||||
|
||||
|
||||
|
||||
### toast事件
|
||||
|
||||
|
||||
|
||||
### 事件: 'notification'
|
||||
* notification \<Notification\> 通知
|
||||
|
||||
```
|
||||
events.observeNotification();
|
||||
events.on("notification", function(notification){
|
||||
log(notification.
|
||||
});
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
# EventEmitter
|
||||
|
||||
### EventEmitter.defaultMaxListeners
|
||||
@@ -155,7 +177,7 @@ events.loop();
|
||||
|
||||
设置 EventEmitter.defaultMaxListeners 要谨慎,因为会影响所有 EventEmitter 实例,包括之前创建的。 因而,调用 emitter.setMaxListeners(n) 优先于 EventEmitter.defaultMaxListeners。
|
||||
|
||||
注意,与NodeJs不同,**这是一个硬性限制**。 EventEmitter 实例不允许添加更多的监听器,监听器超过最大数量时会抛出TooManyListenersException。
|
||||
注意,与Node.js不同,**这是一个硬性限制**。 EventEmitter 实例不允许添加更多的监听器,监听器超过最大数量时会抛出TooManyListenersException。
|
||||
```
|
||||
emitter.setMaxListeners(emitter.getMaxListeners() + 1);
|
||||
emitter.once('event', () => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"global" : {
|
||||
"global": {
|
||||
"modules": [
|
||||
"app",
|
||||
"automator",
|
||||
@@ -39,7 +39,7 @@
|
||||
"openConsole",
|
||||
"clearConsole"
|
||||
],
|
||||
"dialogs":[
|
||||
"dialogs": [
|
||||
"rawInput",
|
||||
"input",
|
||||
"alert",
|
||||
@@ -142,12 +142,12 @@
|
||||
"Text"
|
||||
],
|
||||
"timers": [
|
||||
"loop",
|
||||
"setTimeout",
|
||||
"clearTimeout",
|
||||
"setInterval",
|
||||
"clearInterval",
|
||||
"setImmediate",
|
||||
"loop",
|
||||
"setTimeout",
|
||||
"clearTimeout",
|
||||
"setInterval",
|
||||
"clearInterval",
|
||||
"setImmediate",
|
||||
"clearImmediate"
|
||||
],
|
||||
"web": [
|
||||
@@ -211,7 +211,7 @@
|
||||
"error",
|
||||
"assert"
|
||||
],
|
||||
"dialogs":[
|
||||
"dialogs": [
|
||||
"select",
|
||||
"singleChoice",
|
||||
"multiChoice",
|
||||
@@ -248,6 +248,8 @@
|
||||
"onKeyUp",
|
||||
"onceKeyDown",
|
||||
"onceKeyUp",
|
||||
"onToast",
|
||||
"onNotification",
|
||||
"removeAllKeyDownListeners",
|
||||
"removeAllKeyUpListeners",
|
||||
"onTouch",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.stardust.scriptdroid.autojs;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Notification;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
@@ -36,6 +37,7 @@ import com.stardust.scriptdroid.tool.AccessibilityServiceTool;
|
||||
import com.stardust.scriptdroid.ui.console.JraskaConsole;
|
||||
import com.stardust.view.accessibility.AccessibilityServiceUtils;
|
||||
import com.stardust.view.accessibility.LayoutInspector;
|
||||
import com.stardust.view.accessibility.NotificationListener;
|
||||
|
||||
|
||||
/**
|
||||
@@ -55,6 +57,7 @@ public class AutoJs {
|
||||
}
|
||||
|
||||
private final AccessibilityActionRecorder mAccessibilityActionRecorder = new AccessibilityActionRecorder();
|
||||
private final NotificationListener.Observer mNotificationObserver;
|
||||
private final LayoutInspector mLayoutInspector = new LayoutInspector();
|
||||
private final Context mContext;
|
||||
private final UiHandler mUiHandler;
|
||||
@@ -68,6 +71,7 @@ public class AutoJs {
|
||||
mContext = context;
|
||||
mUiHandler = new UiHandler(context);
|
||||
mAppUtils = new AppUtils(context);
|
||||
mNotificationObserver = new NotificationListener.Observer(context);
|
||||
mAccessibilityInfoProvider = new AccessibilityInfoProvider(context.getPackageManager());
|
||||
mScriptEngineService = buildScriptEngineService();
|
||||
addAccessibilityServiceDelegates();
|
||||
@@ -130,6 +134,7 @@ public class AutoJs {
|
||||
|
||||
private void addAccessibilityServiceDelegates() {
|
||||
AccessibilityService.addDelegate(100, mAccessibilityInfoProvider);
|
||||
AccessibilityService.addDelegate(200, mNotificationObserver);
|
||||
AccessibilityService.addDelegate(300, mAccessibilityActionRecorder);
|
||||
}
|
||||
|
||||
@@ -198,6 +203,11 @@ public class AutoJs {
|
||||
return mAccessibilityInfoProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NotificationListener.Observer getNotificationObserver() {
|
||||
return mNotificationObserver;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class ScreenCaptureRequesterImpl extends ScreenCaptureRequester.AbstractScreenCaptureRequester {
|
||||
|
||||
@@ -20,7 +20,6 @@ import com.stardust.scriptdroid.autojs.AutoJs;
|
||||
import com.stardust.view.accessibility.NodeInfo;
|
||||
import com.stardust.scriptdroid.external.floatingwindow.menu.view.FloatingLayoutBoundsView;
|
||||
import com.stardust.scriptdroid.external.floatingwindow.menu.view.FloatingLayoutHierarchyView;
|
||||
import com.stardust.scriptdroid.tool.AccessibilityServiceTool;
|
||||
import com.stardust.theme.ThemeColorManagerCompat;
|
||||
import com.stardust.util.IntentUtil;
|
||||
import com.stardust.util.MessageEvent;
|
||||
@@ -189,7 +188,6 @@ public class HoverMenuService extends Service {
|
||||
tryInitViews();
|
||||
if (mWindowHoverMenu != null)
|
||||
mWindowHoverMenu.show();
|
||||
AccessibilityServiceTool.enableAccessibilityServiceByRootIfNeeded();
|
||||
return START_STICKY;
|
||||
}
|
||||
|
||||
@@ -200,6 +198,8 @@ public class HoverMenuService extends Service {
|
||||
if (eventBus.isRegistered(this))
|
||||
eventBus.unregister(this);
|
||||
setIsRunning(false);
|
||||
if (mWindowViewController == null)
|
||||
return;
|
||||
mWindowViewController.removeView(mFloatingLayoutBoundsView);
|
||||
mWindowViewController.removeView(mFloatingLayoutHierarchyView);
|
||||
}
|
||||
|
||||
@@ -85,9 +85,6 @@ public class RecordNavigatorContent implements NavigatorContent, Recorder.OnStat
|
||||
ButterKnife.bind(this, mView);
|
||||
HoverMenuService.getEventBus().register(this);
|
||||
AccessibilityService.getStickOnKeyObserver().addListener(mVolumeKeyListener);
|
||||
if (Pref.isRecordVolumeControlEnable()) {
|
||||
AutoJs.getInstance().ensureAccessibilityServiceEnabled();
|
||||
}
|
||||
if (Pref.hasRecordTrigger()) {
|
||||
mKeyObserver = new KeyObserver(mContext);
|
||||
mKeyObserver.startListening();
|
||||
|
||||
@@ -14,10 +14,14 @@ public class ProgressDialog {
|
||||
private MaterialDialog mDialog;
|
||||
|
||||
public ProgressDialog(Context context) {
|
||||
this(context, R.string.text_on_progress);
|
||||
}
|
||||
|
||||
public ProgressDialog(Context context, int resId) {
|
||||
mDialog = new MaterialDialog.Builder(context)
|
||||
.progress(true, 0)
|
||||
.cancelable(false)
|
||||
.content(R.string.text_on_progress)
|
||||
.content(resId)
|
||||
.show();
|
||||
}
|
||||
|
||||
|
||||
@@ -133,7 +133,12 @@ public class SideMenuFragment extends android.support.v4.app.Fragment {
|
||||
AccessibilityServiceTool.goToAccessibilitySetting();
|
||||
return;
|
||||
}
|
||||
final ProgressDialog progress = new ProgressDialog(getContext());
|
||||
enableAccessibilityServiceByRoot();
|
||||
|
||||
}
|
||||
|
||||
private void enableAccessibilityServiceByRoot() {
|
||||
final ProgressDialog progress = new ProgressDialog(getContext(), R.string.text_enable_accessibility_service_by_root_ing);
|
||||
UnderuseExecutors.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -156,6 +161,9 @@ public class SideMenuFragment extends android.support.v4.app.Fragment {
|
||||
void setFloatingWindowEnable(CompoundButton button, boolean enable) {
|
||||
if (enable && !HoverMenuManger.isHoverMenuShowing()) {
|
||||
HoverMenuManger.showHoverMenu();
|
||||
if (Pref.enableAccessibilityServiceByRoot()) {
|
||||
enableAccessibilityServiceByRoot();
|
||||
}
|
||||
} else if (!enable && HoverMenuManger.isHoverMenuShowing()) {
|
||||
HoverMenuManger.hideHoverMenu();
|
||||
}
|
||||
|
||||
@@ -212,6 +212,7 @@
|
||||
<string name="text_enable_accessibitliy_service_by_root_failed">使用root权限开启失败</string>
|
||||
<string name="text_on_progress">处理中</string>
|
||||
<string name="text_delete_failed">删除失败</string>
|
||||
<string name="text_enable_accessibility_service_by_root_ing">正在使用root权限启用无障碍服务</string>
|
||||
|
||||
|
||||
<string-array name="record_control_keys">
|
||||
|
||||
Reference in New Issue
Block a user