use of com.stardust.autojs.script.StringScriptSource in project Auto.js by hyb1996.
the class ScriptIntents method handleIntent.
public static boolean handleIntent(Context context, Intent intent) {
String path = getPath(intent);
String script = intent.getStringExtra(ScriptIntents.EXTRA_KEY_PRE_EXECUTE_SCRIPT);
int loopTimes = intent.getIntExtra(EXTRA_KEY_LOOP_TIMES, 1);
long delay = intent.getLongExtra(EXTRA_KEY_DELAY, 0);
long interval = intent.getLongExtra(EXTRA_KEY_LOOP_INTERVAL, 0);
ScriptSource source = null;
ExecutionConfig config = new ExecutionConfig().loop(delay, loopTimes, interval);
if (path == null && script != null) {
source = new StringScriptSource(script);
} else if (path != null && new PathChecker(context).checkAndToastError(path)) {
JavaScriptFileSource fileScriptSource = new JavaScriptFileSource(path);
if (script != null) {
source = new SequenceScriptSource(fileScriptSource.getName(), new StringScriptSource(script), fileScriptSource);
} else {
source = fileScriptSource;
}
config.executePath(new File(path).getParent());
} else {
config.executePath(StorageFileProvider.DEFAULT_DIRECTORY_PATH);
}
if (source == null) {
return false;
}
AutoJs.getInstance().getScriptEngineService().execute(source, config);
return true;
}
use of com.stardust.autojs.script.StringScriptSource in project Auto.js by hyb1996.
the class RunIntentActivity method handleIntent.
private void handleIntent(Intent intent) throws FileNotFoundException {
Uri uri = intent.getData();
if (uri != null && "content".equals(uri.getScheme())) {
InputStream stream = getContentResolver().openInputStream(uri);
Scripts.run(new StringScriptSource(PFiles.read(stream)));
} else {
ScriptIntents.handleIntent(this, intent);
}
}
Aggregations