cleanup(autojs): ScriptRuntime.requiresApi()

This commit is contained in:
hyb1996
2018-03-31 21:29:30 +08:00
parent e3335f4b79
commit 77c0d6bd19
2 changed files with 8 additions and 8 deletions

View File

@@ -51,7 +51,7 @@ public class SimpleActionAutomator {
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@ScriptInterface @ScriptInterface
public ActionTarget editable(int i) { public ActionTarget editable(int i) {
mScriptRuntime.requiresApi(Build.VERSION_CODES.LOLLIPOP); ScriptRuntime.requiresApi(Build.VERSION_CODES.LOLLIPOP);
return new ActionTarget.EditableActionTarget(i); return new ActionTarget.EditableActionTarget(i);
} }
@@ -113,14 +113,14 @@ public class SimpleActionAutomator {
@ScriptInterface @ScriptInterface
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public boolean setText(ActionTarget target, String text) { public boolean setText(ActionTarget target, String text) {
mScriptRuntime.requiresApi(Build.VERSION_CODES.LOLLIPOP); ScriptRuntime.requiresApi(Build.VERSION_CODES.LOLLIPOP);
return performAction(target.createAction(AccessibilityNodeInfo.ACTION_SET_TEXT, text)); return performAction(target.createAction(AccessibilityNodeInfo.ACTION_SET_TEXT, text));
} }
@ScriptInterface @ScriptInterface
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public boolean appendText(ActionTarget target, String text) { public boolean appendText(ActionTarget target, String text) {
mScriptRuntime.requiresApi(Build.VERSION_CODES.LOLLIPOP); ScriptRuntime.requiresApi(Build.VERSION_CODES.LOLLIPOP);
return performAction(target.createAction(UiObject.ACTION_APPEND_TEXT, text)); return performAction(target.createAction(UiObject.ACTION_APPEND_TEXT, text));
} }
@@ -137,7 +137,7 @@ public class SimpleActionAutomator {
@ScriptInterface @ScriptInterface
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public boolean powerDialog() { public boolean powerDialog() {
mScriptRuntime.requiresApi(Build.VERSION_CODES.LOLLIPOP); ScriptRuntime.requiresApi(Build.VERSION_CODES.LOLLIPOP);
return performGlobalAction(AccessibilityService.GLOBAL_ACTION_POWER_DIALOG); return performGlobalAction(AccessibilityService.GLOBAL_ACTION_POWER_DIALOG);
} }
@@ -189,8 +189,8 @@ public class SimpleActionAutomator {
} }
private void prepareForGesture() { private void prepareForGesture() {
ScriptRuntime.requiresApi(24);
ensureAccessibilityServiceEnabled(); ensureAccessibilityServiceEnabled();
mScriptRuntime.requiresApi(24);
if (mGlobalActionAutomator != null) if (mGlobalActionAutomator != null)
return; return;
mGlobalActionAutomator = new GlobalActionAutomator(new Handler(mScriptRuntime.loopers.getServantLooper())); mGlobalActionAutomator = new GlobalActionAutomator(new Handler(mScriptRuntime.loopers.getServantLooper()));
@@ -237,7 +237,7 @@ public class SimpleActionAutomator {
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2) @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
@ScriptInterface @ScriptInterface
public boolean paste(ActionTarget target) { public boolean paste(ActionTarget target) {
mScriptRuntime.requiresApi(18); ScriptRuntime.requiresApi(18);
return performAction(target.createAction(AccessibilityNodeInfo.ACTION_PASTE)); return performAction(target.createAction(AccessibilityNodeInfo.ACTION_PASTE));
} }

View File

@@ -68,7 +68,7 @@ public class Images {
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public boolean requestScreenCapture(final int width, final int height) { public boolean requestScreenCapture(final int width, final int height) {
mScriptRuntime.requiresApi(21); ScriptRuntime.requiresApi(21);
final VolatileDispose<Boolean> requestResult = new VolatileDispose<>(); final VolatileDispose<Boolean> requestResult = new VolatileDispose<>();
mScreenCaptureRequester.setOnActivityResultCallback((result, data) -> { mScreenCaptureRequester.setOnActivityResultCallback((result, data) -> {
if (result == Activity.RESULT_OK) { if (result == Activity.RESULT_OK) {
@@ -101,7 +101,7 @@ public class Images {
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public ImageWrapper captureScreen() { public ImageWrapper captureScreen() {
mScriptRuntime.requiresApi(21); ScriptRuntime.requiresApi(21);
if (mScreenCapturer == null) { if (mScreenCapturer == null) {
throw new SecurityException("No screen capture permission"); throw new SecurityException("No screen capture permission");
} }