fix: lag when accessibility service switch toggled

This commit is contained in:
hyb1996
2017-07-31 21:28:13 +08:00
parent 6307d3aa96
commit f51d791d98
10 changed files with 75 additions and 14 deletions

View File

@@ -2,7 +2,8 @@ package com.stardust.autojs.runtime.api;
import android.support.annotation.NonNull;
import com.stardust.autojs.runtime.ScriptStopException;
import com.stardust.autojs.runtime.ScriptException;
import java.util.ArrayList;
import java.util.HashMap;
@@ -38,7 +39,7 @@ public class EventEmitter {
private void ensureListenersNotAtLimit() {
if (mMaxListeners != 0 && mListenersMap.size() >= mMaxListeners) {
throw new ScriptStopException(new TooManyListenersException("max = " + mMaxListeners));
throw new ScriptException(new TooManyListenersException("max = " + mMaxListeners));
}
}

View File

@@ -8,7 +8,7 @@ import android.util.SparseArray;
import android.view.KeyEvent;
import com.stardust.autojs.runtime.AccessibilityBridge;
import com.stardust.autojs.runtime.ScriptStopException;
import com.stardust.autojs.runtime.ScriptException;
import com.stardust.autojs.runtime.record.inputevent.TouchObserver;
import com.stardust.view.accessibility.AccessibilityService;
import com.stardust.view.accessibility.OnKeyListener;
@@ -53,12 +53,12 @@ public class Events extends EventEmitter implements OnKeyListener, TouchObserver
mAccessibilityBridge.ensureServiceEnabled();
AccessibilityService service = mAccessibilityBridge.getService();
if (service == null)
throw new ScriptStopException();
throw new ScriptException();
service.getOnKeyObserver().addListener(this);
}
private void ensureHandler() {
if(mHandler == null){
if (mHandler == null) {
mHandler = new Handler();
}
}

View File

@@ -82,7 +82,7 @@ public class Loopers {
}
public static void prepare() {
if(Looper.myLooper() == Looper.getMainLooper())
if (Looper.myLooper() == Looper.getMainLooper())
return;
if (Looper.myLooper() == null)
Looper.prepare();