修复 调试时在不能断点的地方打断点会崩溃的问题
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.BuildConfig;
|
||||||
import com.stardust.autojs.core.ui.ViewExtras;
|
import com.stardust.autojs.core.ui.ViewExtras;
|
||||||
|
import com.stardust.autojs.rhino.NativeArrayLikeJavaObject;
|
||||||
import com.stardust.autojs.rhino.RhinoAndroidHelper;
|
import com.stardust.autojs.rhino.RhinoAndroidHelper;
|
||||||
import com.stardust.autojs.rhino.TopLevelScope;
|
import com.stardust.autojs.rhino.TopLevelScope;
|
||||||
import com.stardust.autojs.runtime.ScriptRuntime;
|
|
||||||
import com.stardust.autojs.script.JavaScriptSource;
|
import com.stardust.autojs.script.JavaScriptSource;
|
||||||
import com.stardust.autojs.script.StringScriptSource;
|
import com.stardust.autojs.script.StringScriptSource;
|
||||||
import com.stardust.automator.UiObject;
|
import com.stardust.automator.UiObject;
|
||||||
@@ -17,18 +17,16 @@ import com.stardust.pio.UncheckedIOException;
|
|||||||
|
|
||||||
import org.mozilla.javascript.Context;
|
import org.mozilla.javascript.Context;
|
||||||
import org.mozilla.javascript.NativeArray;
|
import org.mozilla.javascript.NativeArray;
|
||||||
import org.mozilla.javascript.NativeJavaObject;
|
|
||||||
import org.mozilla.javascript.Scriptable;
|
import org.mozilla.javascript.Scriptable;
|
||||||
import org.mozilla.javascript.ScriptableObject;
|
import org.mozilla.javascript.ScriptableObject;
|
||||||
|
import org.mozilla.javascript.TopLevel;
|
||||||
import org.mozilla.javascript.commonjs.module.RequireBuilder;
|
import org.mozilla.javascript.commonjs.module.RequireBuilder;
|
||||||
import org.mozilla.javascript.commonjs.module.provider.SoftCachingModuleScriptProvider;
|
import org.mozilla.javascript.commonjs.module.provider.SoftCachingModuleScriptProvider;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
@@ -177,8 +175,8 @@ public class RhinoJavaScriptEngine extends JavaScriptEngine {
|
|||||||
array[i] = wrapAsJavaObject(cx, scope, collection.get(i), UiObject.class);
|
array[i] = wrapAsJavaObject(cx, scope, collection.get(i), UiObject.class);
|
||||||
}
|
}
|
||||||
NativeArray nativeArray = new NativeArray(array);
|
NativeArray nativeArray = new NativeArray(array);
|
||||||
nativeArray.setPrototype(new NativeJavaObject(scope, collection, staticType));
|
nativeArray.setPrototype(TopLevel.getBuiltinPrototype(scope, TopLevel.Builtins.Array));
|
||||||
result = nativeArray;
|
result = new NativeArrayLikeJavaObject(scope, collection, staticType, nativeArray);
|
||||||
} else {
|
} else {
|
||||||
result = super.wrap(cx, scope, obj, staticType);
|
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
|
@Override
|
||||||
public boolean has(String name, Scriptable start) {
|
public boolean has(String name, Scriptable start) {
|
||||||
return super.has(name, start) || (prototype != null && prototype.has(name, start))
|
return super.has(name, start) || (prototype != null && prototype.has(name, start))
|
||||||
|| name.equals("prototype");
|
|| name.equals("__proto__");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object get(String name, Scriptable start) {
|
public Object get(String name, Scriptable start) {
|
||||||
if (name.equals("prototype")) {
|
if (name.equals("__proto__")) {
|
||||||
return prototype;
|
return prototype;
|
||||||
}
|
}
|
||||||
Object o = super.get(name, start);
|
if(super.has(name, start)){
|
||||||
if (o != Scriptable.NOT_FOUND) {
|
return super.get(name, start);
|
||||||
return o;
|
|
||||||
}
|
}
|
||||||
if (prototype == null) {
|
if (prototype == null) {
|
||||||
return o;
|
return Scriptable.NOT_FOUND;
|
||||||
}
|
}
|
||||||
return prototype.get(name, start);
|
return prototype.get(name, start);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void put(String name, Scriptable start, Object value) {
|
public void put(String name, Scriptable start, Object value) {
|
||||||
if (name.equals("prototype")) {
|
if (name.equals("__proto__")) {
|
||||||
prototype = (Scriptable) value;
|
prototype = (Scriptable) value;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1531,7 +1531,7 @@ public class Dim {
|
|||||||
*/
|
*/
|
||||||
public boolean breakpoint(int line, boolean value) {
|
public boolean breakpoint(int line, boolean value) {
|
||||||
if (!breakableLine(line)) {
|
if (!breakableLine(line)) {
|
||||||
throw new IllegalArgumentException(String.valueOf(line));
|
return false;
|
||||||
}
|
}
|
||||||
boolean changed;
|
boolean changed;
|
||||||
synchronized (breakpoints) {
|
synchronized (breakpoints) {
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
package com.stardust.autojs.runtime;
|
package com.stardust.autojs.runtime;
|
||||||
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import com.stardust.autojs.core.accessibility.UiCollection;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Stardust on 2017/7/21.
|
* Created by Stardust on 2017/7/21.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,19 +1,47 @@
|
|||||||
package com.stardust.automator;
|
package com.stardust.automator;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat;
|
import android.support.annotation.RequiresApi;
|
||||||
import android.view.accessibility.AccessibilityNodeInfo;
|
|
||||||
|
|
||||||
import com.stardust.util.Consumer;
|
import com.stardust.util.Consumer;
|
||||||
import com.stardust.util.Func1;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.ListIterator;
|
||||||
|
import java.util.Spliterator;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
import java.util.function.UnaryOperator;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.*;
|
import static android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.ACTION_ACCESSIBILITY_FOCUS;
|
||||||
|
import static android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.ACTION_ARGUMENT_COLUMN_INT;
|
||||||
|
import static android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.ACTION_ARGUMENT_PROGRESS_VALUE;
|
||||||
|
import static android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.ACTION_ARGUMENT_ROW_INT;
|
||||||
|
import static android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.ACTION_ARGUMENT_SELECTION_END_INT;
|
||||||
|
import static android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.ACTION_ARGUMENT_SELECTION_START_INT;
|
||||||
|
import static android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE;
|
||||||
|
import static android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.ACTION_CLEAR_ACCESSIBILITY_FOCUS;
|
||||||
|
import static android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.ACTION_CLEAR_FOCUS;
|
||||||
|
import static android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.ACTION_CLICK;
|
||||||
|
import static android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.ACTION_COLLAPSE;
|
||||||
|
import static android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.ACTION_COPY;
|
||||||
|
import static android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.ACTION_CUT;
|
||||||
|
import static android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.ACTION_DISMISS;
|
||||||
|
import static android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.ACTION_EXPAND;
|
||||||
|
import static android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.ACTION_FOCUS;
|
||||||
|
import static android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.ACTION_LONG_CLICK;
|
||||||
|
import static android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.ACTION_PASTE;
|
||||||
|
import static android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD;
|
||||||
|
import static android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD;
|
||||||
|
import static android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.ACTION_SELECT;
|
||||||
|
import static android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.ACTION_SET_SELECTION;
|
||||||
|
import static android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.ACTION_SET_TEXT;
|
||||||
import static android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_CONTEXT_CLICK;
|
import static android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_CONTEXT_CLICK;
|
||||||
import static android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_SCROLL_DOWN;
|
import static android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_SCROLL_DOWN;
|
||||||
import static android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_SCROLL_LEFT;
|
import static android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_SCROLL_LEFT;
|
||||||
@@ -27,7 +55,7 @@ import static android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.
|
|||||||
* Created by Stardust on 2017/3/9.
|
* Created by Stardust on 2017/3/9.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class UiObjectCollection {
|
public class UiObjectCollection implements List<UiObject> {
|
||||||
|
|
||||||
public static final UiObjectCollection EMPTY = UiObjectCollection.of(Collections.<UiObject>emptyList());
|
public static final UiObjectCollection EMPTY = UiObjectCollection.of(Collections.<UiObject>emptyList());
|
||||||
|
|
||||||
@@ -41,10 +69,67 @@ public class UiObjectCollection {
|
|||||||
mNodes = list;
|
mNodes = list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UiObject[] toArray(){
|
public UiObject[] toArray() {
|
||||||
return mNodes.toArray(new UiObject[0]);
|
return mNodes.toArray(new UiObject[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> T[] toArray(T[] a) {
|
||||||
|
return mNodes.toArray(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean add(UiObject uiObject) {
|
||||||
|
return mNodes.add(uiObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean remove(Object o) {
|
||||||
|
return mNodes.remove(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean containsAll(Collection<?> c) {
|
||||||
|
return mNodes.containsAll(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addAll(Collection<? extends UiObject> c) {
|
||||||
|
return mNodes.addAll(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addAll(int index, Collection<? extends UiObject> c) {
|
||||||
|
return mNodes.addAll(index, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean removeAll(Collection<?> c) {
|
||||||
|
return mNodes.removeAll(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean retainAll(Collection<?> c) {
|
||||||
|
return mNodes.retainAll(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||||
|
@Override
|
||||||
|
public void replaceAll(UnaryOperator<UiObject> operator) {
|
||||||
|
mNodes.replaceAll(operator);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||||
|
@Override
|
||||||
|
public void sort(Comparator<? super UiObject> c) {
|
||||||
|
mNodes.sort(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clear() {
|
||||||
|
mNodes.clear();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean performAction(int action) {
|
public boolean performAction(int action) {
|
||||||
boolean fail = false;
|
boolean fail = false;
|
||||||
for (UiObject node : mNodes) {
|
for (UiObject node : mNodes) {
|
||||||
@@ -185,10 +270,98 @@ public class UiObjectCollection {
|
|||||||
return mNodes.get(i);
|
return mNodes.get(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UiObject set(int index, UiObject element) {
|
||||||
|
return mNodes.set(index, element);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void add(int index, UiObject element) {
|
||||||
|
mNodes.add(index, element);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UiObject remove(int index) {
|
||||||
|
return mNodes.remove(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int indexOf(Object o) {
|
||||||
|
return mNodes.indexOf(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int lastIndexOf(Object o) {
|
||||||
|
return mNodes.lastIndexOf(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||||
|
@Override
|
||||||
|
public ListIterator<UiObject> listIterator() {
|
||||||
|
return mNodes.listIterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||||
|
@Override
|
||||||
|
public ListIterator<UiObject> listIterator(int index) {
|
||||||
|
return mNodes.listIterator(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||||
|
@Override
|
||||||
|
public List<UiObject> subList(int fromIndex, int toIndex) {
|
||||||
|
return mNodes.subList(fromIndex, toIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||||
|
@Override
|
||||||
|
public Spliterator<UiObject> spliterator() {
|
||||||
|
return mNodes.spliterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||||
|
@Override
|
||||||
|
public boolean removeIf(Predicate<? super UiObject> filter) {
|
||||||
|
return mNodes.removeIf(filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||||
|
@Override
|
||||||
|
public Stream<UiObject> stream() {
|
||||||
|
return mNodes.stream();
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||||
|
@Override
|
||||||
|
public Stream<UiObject> parallelStream() {
|
||||||
|
return mNodes.parallelStream();
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||||
|
@Override
|
||||||
|
public void forEach(java.util.function.Consumer<? super UiObject> action) {
|
||||||
|
mNodes.forEach(action);
|
||||||
|
}
|
||||||
|
|
||||||
public int size() {
|
public int size() {
|
||||||
return mNodes.size();
|
return mNodes.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return mNodes.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean contains(Object o) {
|
||||||
|
return mNodes.contains(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterator<UiObject> iterator() {
|
||||||
|
return mNodes.iterator();
|
||||||
|
}
|
||||||
|
|
||||||
public UiObjectCollection each(Consumer<UiObject> consumer) {
|
public UiObjectCollection each(Consumer<UiObject> consumer) {
|
||||||
for (UiObject uiObject : mNodes) {
|
for (UiObject uiObject : mNodes) {
|
||||||
consumer.accept(uiObject);
|
consumer.accept(uiObject);
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":431,"versionName":"4.0.4 Alpha2","enabled":true,"outputFile":"commonRelease-4.0.4 Alpha2.apk","fullName":"commonRelease","baseName":"common-release"},"path":"commonRelease-4.0.4 Alpha2.apk","properties":{}}]
|
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":432,"versionName":"4.0.4 Alpha3","enabled":true,"outputFile":"commonRelease-4.0.4 Alpha3.apk","fullName":"commonRelease","baseName":"common-release"},"path":"commonRelease-4.0.4 Alpha3.apk","properties":{}}]
|
||||||
Reference in New Issue
Block a user