add some scripts

This commit is contained in:
hyb1996
2017-05-10 20:48:26 +08:00
parent 1222e00adc
commit 39c1444b0f
31 changed files with 382 additions and 84 deletions

View File

@@ -35,4 +35,11 @@ module.exports = function(__runtime__, scope){
scope.currentActivity = function(){
return __runtime__.info.getLatestActivity();
}
scope.waitActivity = function(activity, delay){
delay = delay || 200;
while(scope.currentActivity() != activity){
sleep(delay);
}
}
}

View File

@@ -87,12 +87,13 @@ public class UiSelector extends UiGlobalSelector {
mAllocator = allocator;
}
@NonNull
@ScriptInterface
public UiObjectCollection find() {
ensureAccessibilityServiceEnabled();
if (AutomatorConfig.isUnintendedGuardEnabled() && isRunningPackageSelf()) {
Log.d(TAG, "isSelfPackage return null");
return null;
return UiObjectCollection.EMPTY;
}
AccessibilityService service = mAccessibilityBridge.getService();
if (service != null) {
@@ -101,7 +102,7 @@ public class UiSelector extends UiGlobalSelector {
return findOf(UiObject.createRoot(root, mAllocator));
}
}
return null;
return UiObjectCollection.EMPTY;
}
private void ensureAccessibilityServiceEnabled() {
@@ -123,7 +124,7 @@ public class UiSelector extends UiGlobalSelector {
throw new ScriptInterruptedException();
}
uiObjectCollection = find();
} while (uiObjectCollection == null || uiObjectCollection.size() == 0);
} while (uiObjectCollection.empty());
return uiObjectCollection;
}
@@ -132,6 +133,12 @@ public class UiSelector extends UiGlobalSelector {
return untilFindOne();
}
@ScriptInterface
public boolean exists() {
UiObjectCollection collection = find();
return collection.nonEmpty();
}
@NonNull
public UiObject untilFindOne() {
UiObjectCollection collection = untilFind();
@@ -159,10 +166,6 @@ public class UiSelector extends UiGlobalSelector {
return untilFind().performAction(action, arguments);
}
public boolean exists() {
UiObjectCollection collection = find();
return collection != null && collection.size() > 0;
}
@ScriptInterface
public boolean click() {