fix: forceStop not working when recorded file is executed in loop

This commit is contained in:
hyb1996
2017-08-15 10:13:25 +08:00
parent a9ef908ef2
commit 4c0d01c961
3 changed files with 10 additions and 4 deletions

View File

@@ -110,6 +110,5 @@ public class RootAutomatorEngine extends ScriptEngine.AbstractScriptEngine<AutoF
@Override
public synchronized void destroy() {
super.destroy();
Log.d(LOG_TAG, "Shell exit");
}
}

View File

@@ -3,6 +3,7 @@ package com.stardust.autojs.runtime.api;
import android.util.Log;
import com.stardust.autojs.runtime.exception.ScriptInterruptedException;
import com.stardust.autojs.util.ProcessUtils;
import com.stardust.pio.UncheckedIOException;
@@ -202,9 +203,7 @@ public class ProcessShell extends AbstractShell {
commandResult.error = readAll(process.getErrorStream());
Log.d(TAG, commandResult.toString());
} catch (Exception e) {
commandResult.code = -1;
commandResult.error = e.getMessage();
e.printStackTrace();
throw new ScriptInterruptedException(e);
} finally {
try {
if (os != null) os.close();

View File

@@ -6,6 +6,14 @@ package com.stardust.autojs.runtime.exception;
public class ScriptInterruptedException extends ScriptException {
public ScriptInterruptedException(){
}
public ScriptInterruptedException(Throwable e) {
super(e);
}
public static boolean causedByInterrupted(Throwable e) {
return e instanceof ScriptInterruptedException || e.getCause() instanceof ScriptInterruptedException;
}