尝试修复某些设备上死机和重启的问题。修复在4.4上无法显示悬浮窗的问题。增加英文语言。增加获取WebView内容。
This commit is contained in:
@@ -31,31 +31,50 @@ public class AccessibilityEventCommandHost implements AccessibilityDelegate {
|
||||
|
||||
private static final String TAG = "CommandHostDelegate";
|
||||
|
||||
public static final int RUN_MODE_SINGLE_THREAD = 0;
|
||||
public static final int RUN_MODE_THREAD_POOL = 1;
|
||||
public static final int RUN_MODE_NEW_THREAD_EVERY_TIME = 2;
|
||||
|
||||
|
||||
private final Queue<Command> mCommands = new LinkedList<>();
|
||||
private Executor mExecutor = Executors.newFixedThreadPool(5);
|
||||
private int mRunMode = 0;
|
||||
|
||||
@Override
|
||||
public boolean onAccessibilityEvent(final AccessibilityService service, final AccessibilityEvent event) {
|
||||
synchronized (mCommands) {
|
||||
if (!mCommands.isEmpty()) {
|
||||
Log.v(TAG, "execute " + mCommands.size() + " commands");
|
||||
Log.v(TAG, "will execute " + mCommands.size() + " commands");
|
||||
}
|
||||
while (!mCommands.isEmpty()) {
|
||||
final Command command = mCommands.poll();
|
||||
mExecutor.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
command.execute(service, event);
|
||||
synchronized (command) {
|
||||
command.notify();
|
||||
}
|
||||
}
|
||||
});
|
||||
executeCommand(command, service, event);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void executeCommand(final Command command, final AccessibilityService service, final AccessibilityEvent event) {
|
||||
Runnable r = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Log.v(TAG, "executing " + command);
|
||||
command.execute(service, event);
|
||||
synchronized (command) {
|
||||
Log.v(TAG, "notify " + mCommands.size() + " commands");
|
||||
command.notify();
|
||||
}
|
||||
}
|
||||
};
|
||||
if (mRunMode == RUN_MODE_SINGLE_THREAD) {
|
||||
r.run();
|
||||
} else if (mRunMode == RUN_MODE_NEW_THREAD_EVERY_TIME) {
|
||||
new Thread(r).start();
|
||||
} else {
|
||||
mExecutor.execute(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void executeAndWaitForEvent(Command command) {
|
||||
synchronized (mCommands) {
|
||||
@@ -70,4 +89,8 @@ public class AccessibilityEventCommandHost implements AccessibilityDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
public void setRunMode(int mode) {
|
||||
mRunMode = mode;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user