Add: Volume Changing to stop scripts, Fix: Automator ANR

This commit is contained in:
hyb1996
2017-03-20 16:04:59 +08:00
parent c9927a3ce3
commit 1f05bcce98
47 changed files with 497 additions and 141 deletions

View File

@@ -8,6 +8,8 @@ import com.stardust.view.accessibility.AccessibilityDelegate;
import java.util.LinkedList;
import java.util.Queue;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
/**
* Created by Stardust on 2017/3/9.
@@ -16,7 +18,6 @@ import java.util.Queue;
public class AccessibilityEventCommandHost implements AccessibilityDelegate {
public interface Command {
void execute(AccessibilityService service, AccessibilityEvent event);
@@ -31,19 +32,25 @@ public class AccessibilityEventCommandHost implements AccessibilityDelegate {
private static final String TAG = "CommandHostDelegate";
private final Queue<Command> mCommands = new LinkedList<>();
private Executor mExecutor = Executors.newFixedThreadPool(5);
@Override
public boolean onAccessibilityEvent(AccessibilityService service, AccessibilityEvent event) {
public boolean onAccessibilityEvent(final AccessibilityService service, final AccessibilityEvent event) {
synchronized (mCommands) {
if (!mCommands.isEmpty()) {
Log.v(TAG, "execute " + mCommands.size() + " commands");
}
while (!mCommands.isEmpty()) {
Command command = mCommands.poll();
command.execute(service, event);
synchronized (command) {
command.notify();
}
final Command command = mCommands.poll();
mExecutor.execute(new Runnable() {
@Override
public void run() {
command.execute(service, event);
synchronized (command) {
command.notify();
}
}
});
}
}
return false;