修复 调试时在不能断点的地方打断点会崩溃的问题
This commit is contained in:
@@ -1,196 +0,0 @@
|
||||
package com.stardust.autojs.core.accessibility;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
|
||||
import com.stardust.automator.ActionArgument;
|
||||
import com.stardust.automator.UiGlobalSelector;
|
||||
import com.stardust.automator.UiObject;
|
||||
import com.stardust.automator.UiObjectCollection;
|
||||
import com.stardust.util.ArrayUtils;
|
||||
import com.stardust.util.Consumer;
|
||||
import com.stardust.util.Func1;
|
||||
|
||||
import org.mozilla.javascript.Context;
|
||||
import org.mozilla.javascript.NativeArray;
|
||||
import org.mozilla.javascript.NativeJavaObject;
|
||||
import org.mozilla.javascript.Scriptable;
|
||||
import org.mozilla.javascript.ScriptableObject;
|
||||
import org.mozilla.javascript.ast.Scope;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/10/31.
|
||||
*/
|
||||
|
||||
public class UiCollection extends NativeJavaObject {
|
||||
|
||||
private UiObjectCollection mUiObjectCollection;
|
||||
|
||||
public UiCollection(UiObjectCollection c, Scriptable scope) {
|
||||
super(scope, c, UiObjectCollection.class);
|
||||
mUiObjectCollection = c;
|
||||
}
|
||||
|
||||
public boolean performAction(int action) {
|
||||
return mUiObjectCollection.performAction(action);
|
||||
}
|
||||
|
||||
public boolean performAction(int action, ActionArgument... arguments) {
|
||||
return mUiObjectCollection.performAction(action, arguments);
|
||||
}
|
||||
|
||||
public boolean click() {
|
||||
return mUiObjectCollection.click();
|
||||
}
|
||||
|
||||
public boolean longClick() {
|
||||
return mUiObjectCollection.longClick();
|
||||
}
|
||||
|
||||
public boolean accessibilityFocus() {
|
||||
return mUiObjectCollection.accessibilityFocus();
|
||||
}
|
||||
|
||||
public boolean clearAccessibilityFocus() {
|
||||
return mUiObjectCollection.clearAccessibilityFocus();
|
||||
}
|
||||
|
||||
public boolean focus() {
|
||||
return mUiObjectCollection.focus();
|
||||
}
|
||||
|
||||
public boolean clearFocus() {
|
||||
return mUiObjectCollection.clearFocus();
|
||||
}
|
||||
|
||||
public boolean copy() {
|
||||
return mUiObjectCollection.copy();
|
||||
}
|
||||
|
||||
public boolean paste() {
|
||||
return mUiObjectCollection.paste();
|
||||
}
|
||||
|
||||
public boolean select() {
|
||||
return mUiObjectCollection.select();
|
||||
}
|
||||
|
||||
public boolean cut() {
|
||||
return mUiObjectCollection.cut();
|
||||
}
|
||||
|
||||
public boolean collapse() {
|
||||
return mUiObjectCollection.collapse();
|
||||
}
|
||||
|
||||
|
||||
public boolean expand() {
|
||||
return mUiObjectCollection.expand();
|
||||
}
|
||||
|
||||
public boolean dismiss() {
|
||||
return mUiObjectCollection.dismiss();
|
||||
}
|
||||
|
||||
public boolean show() {
|
||||
return mUiObjectCollection.show();
|
||||
}
|
||||
|
||||
public boolean scrollForward() {
|
||||
return mUiObjectCollection.scrollForward();
|
||||
}
|
||||
|
||||
public boolean scrollBackward() {
|
||||
return mUiObjectCollection.scrollBackward();
|
||||
}
|
||||
|
||||
public boolean scrollUp() {
|
||||
return mUiObjectCollection.scrollUp();
|
||||
}
|
||||
|
||||
public boolean scrollDown() {
|
||||
return mUiObjectCollection.scrollDown();
|
||||
}
|
||||
|
||||
public boolean scrollLeft() {
|
||||
return mUiObjectCollection.scrollLeft();
|
||||
}
|
||||
|
||||
public boolean scrollRight() {
|
||||
return mUiObjectCollection.scrollRight();
|
||||
}
|
||||
|
||||
public boolean contextClick() {
|
||||
return mUiObjectCollection.contextClick();
|
||||
}
|
||||
|
||||
public boolean setSelection(int s, int e) {
|
||||
return mUiObjectCollection.setSelection(s, e);
|
||||
}
|
||||
|
||||
public boolean setText(CharSequence text) {
|
||||
return mUiObjectCollection.setText(text);
|
||||
}
|
||||
|
||||
public boolean setProgress(float value) {
|
||||
return mUiObjectCollection.setProgress(value);
|
||||
}
|
||||
|
||||
public boolean scrollTo(int row, int column) {
|
||||
return mUiObjectCollection.scrollTo(row, column);
|
||||
}
|
||||
|
||||
public UiCollection each(Consumer<UiObject> consumer) {
|
||||
mUiObjectCollection.each(consumer);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UiCollection find(UiGlobalSelector selector) {
|
||||
return new UiCollection(mUiObjectCollection.find(selector), getParentScope());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public UiObject findOne(UiGlobalSelector selector) {
|
||||
return mUiObjectCollection.findOne(selector);
|
||||
}
|
||||
|
||||
public boolean empty() {
|
||||
return mUiObjectCollection.empty();
|
||||
}
|
||||
|
||||
public boolean nonEmpty() {
|
||||
return mUiObjectCollection.nonEmpty();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean has(int index, Scriptable start) {
|
||||
return index > 0 && index < mUiObjectCollection.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get(int index, Scriptable start) {
|
||||
return mUiObjectCollection.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get(String name, Scriptable start) {
|
||||
if ("length".equals(name)) {
|
||||
return mUiObjectCollection.size();
|
||||
}
|
||||
return super.get(name, start);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String name, Scriptable start) {
|
||||
if ("length".equals(name)) {
|
||||
return true;
|
||||
}
|
||||
return super.has(name, start);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@ import android.view.View;
|
||||
|
||||
import com.stardust.autojs.BuildConfig;
|
||||
import com.stardust.autojs.core.ui.ViewExtras;
|
||||
import com.stardust.autojs.rhino.NativeArrayLikeJavaObject;
|
||||
import com.stardust.autojs.rhino.RhinoAndroidHelper;
|
||||
import com.stardust.autojs.rhino.TopLevelScope;
|
||||
import com.stardust.autojs.runtime.ScriptRuntime;
|
||||
import com.stardust.autojs.script.JavaScriptSource;
|
||||
import com.stardust.autojs.script.StringScriptSource;
|
||||
import com.stardust.automator.UiObject;
|
||||
@@ -17,18 +17,16 @@ import com.stardust.pio.UncheckedIOException;
|
||||
|
||||
import org.mozilla.javascript.Context;
|
||||
import org.mozilla.javascript.NativeArray;
|
||||
import org.mozilla.javascript.NativeJavaObject;
|
||||
import org.mozilla.javascript.Scriptable;
|
||||
import org.mozilla.javascript.ScriptableObject;
|
||||
import org.mozilla.javascript.TopLevel;
|
||||
import org.mozilla.javascript.commonjs.module.RequireBuilder;
|
||||
import org.mozilla.javascript.commonjs.module.provider.SoftCachingModuleScriptProvider;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@@ -177,8 +175,8 @@ public class RhinoJavaScriptEngine extends JavaScriptEngine {
|
||||
array[i] = wrapAsJavaObject(cx, scope, collection.get(i), UiObject.class);
|
||||
}
|
||||
NativeArray nativeArray = new NativeArray(array);
|
||||
nativeArray.setPrototype(new NativeJavaObject(scope, collection, staticType));
|
||||
result = nativeArray;
|
||||
nativeArray.setPrototype(TopLevel.getBuiltinPrototype(scope, TopLevel.Builtins.Array));
|
||||
result = new NativeArrayLikeJavaObject(scope, collection, staticType, nativeArray);
|
||||
} else {
|
||||
result = super.wrap(cx, scope, obj, staticType);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,230 @@
|
||||
package com.stardust.autojs.rhino;
|
||||
|
||||
import android.os.Build;
|
||||
import android.support.annotation.RequiresApi;
|
||||
|
||||
import org.mozilla.javascript.NativeArray;
|
||||
import org.mozilla.javascript.NativeJavaObject;
|
||||
import org.mozilla.javascript.Scriptable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Spliterator;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.UnaryOperator;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class NativeArrayLikeJavaObject extends NativeJavaObject implements List {
|
||||
|
||||
private final NativeArray mArray;
|
||||
|
||||
public NativeArrayLikeJavaObject(Scriptable scope, Object javaObject, Class<?> staticType, NativeArray array) {
|
||||
super(scope, javaObject, staticType);
|
||||
mArray = array;
|
||||
setPrototype(mArray);
|
||||
}
|
||||
|
||||
public NativeArrayLikeJavaObject(Scriptable scope, Object javaObject, Class<?> staticType, boolean isAdapter, NativeArray array) {
|
||||
super(scope, javaObject, staticType, isAdapter);
|
||||
mArray = array;
|
||||
setPrototype(mArray);
|
||||
}
|
||||
|
||||
public NativeArrayLikeJavaObject(NativeArray array) {
|
||||
mArray = array;
|
||||
setPrototype(mArray);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean has(int index, Scriptable start) {
|
||||
return mArray.has(index, start);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get(int index, Scriptable start) {
|
||||
return mArray.get(index, start);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(int index, Scriptable start, Object value) {
|
||||
mArray.put(index, start, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object o) {
|
||||
return mArray.contains(o);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object[] toArray() {
|
||||
return mArray.toArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(Object o) {
|
||||
return mArray.add(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] toArray(Object[] a) {
|
||||
return mArray.toArray(a);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAll(Collection c) {
|
||||
return mArray.containsAll(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return mArray.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return mArray.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get(int index) {
|
||||
return mArray.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int indexOf(Object o) {
|
||||
return mArray.indexOf(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int lastIndexOf(Object o) {
|
||||
return mArray.lastIndexOf(o);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Iterator iterator() {
|
||||
return mArray.iterator();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ListIterator listIterator() {
|
||||
return mArray.listIterator();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ListIterator listIterator(int start) {
|
||||
return mArray.listIterator(start);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object o) {
|
||||
return mArray.remove(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection c) {
|
||||
return mArray.addAll(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(int index, Collection c) {
|
||||
return mArray.addAll(index, c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(Collection c) {
|
||||
return mArray.removeAll(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(Collection c) {
|
||||
return mArray.retainAll(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object set(int index, Object element) {
|
||||
return mArray.set(index, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(int index, Object element) {
|
||||
mArray.add(index, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object remove(int index) {
|
||||
return mArray.remove(index);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List subList(int fromIndex, int toIndex) {
|
||||
return mArray.subList(fromIndex, toIndex);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
@Override
|
||||
public void replaceAll(UnaryOperator operator) {
|
||||
mArray.replaceAll(operator);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
@Override
|
||||
public void sort(Comparator c) {
|
||||
mArray.sort(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
mArray.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return mArray.equals(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return mArray.hashCode();
|
||||
}
|
||||
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
@Override
|
||||
public Spliterator spliterator() {
|
||||
return mArray.spliterator();
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
@Override
|
||||
public boolean removeIf(Predicate filter) {
|
||||
return mArray.removeIf(filter);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
@Override
|
||||
public Stream stream() {
|
||||
return mArray.stream();
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
@Override
|
||||
public Stream parallelStream() {
|
||||
return mArray.parallelStream();
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
@Override
|
||||
public void forEach(Consumer action) {
|
||||
mArray.forEach(action);
|
||||
}
|
||||
}
|
||||
@@ -24,27 +24,26 @@ public class NativeJavaObjectWithPrototype extends NativeJavaObject {
|
||||
@Override
|
||||
public boolean has(String name, Scriptable start) {
|
||||
return super.has(name, start) || (prototype != null && prototype.has(name, start))
|
||||
|| name.equals("prototype");
|
||||
|| name.equals("__proto__");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get(String name, Scriptable start) {
|
||||
if (name.equals("prototype")) {
|
||||
if (name.equals("__proto__")) {
|
||||
return prototype;
|
||||
}
|
||||
Object o = super.get(name, start);
|
||||
if (o != Scriptable.NOT_FOUND) {
|
||||
return o;
|
||||
if(super.has(name, start)){
|
||||
return super.get(name, start);
|
||||
}
|
||||
if (prototype == null) {
|
||||
return o;
|
||||
return Scriptable.NOT_FOUND;
|
||||
}
|
||||
return prototype.get(name, start);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(String name, Scriptable start, Object value) {
|
||||
if (name.equals("prototype")) {
|
||||
if (name.equals("__proto__")) {
|
||||
prototype = (Scriptable) value;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1531,7 +1531,7 @@ public class Dim {
|
||||
*/
|
||||
public boolean breakpoint(int line, boolean value) {
|
||||
if (!breakableLine(line)) {
|
||||
throw new IllegalArgumentException(String.valueOf(line));
|
||||
return false;
|
||||
}
|
||||
boolean changed;
|
||||
synchronized (breakpoints) {
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
package com.stardust.autojs.runtime;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import com.stardust.autojs.core.accessibility.UiCollection;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/7/21.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user