fix: lag when accessibility service switch toggled
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user