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 @Override
public synchronized void destroy() { public synchronized void destroy() {
super.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 android.util.Log;
import com.stardust.autojs.runtime.exception.ScriptInterruptedException;
import com.stardust.autojs.util.ProcessUtils; import com.stardust.autojs.util.ProcessUtils;
import com.stardust.pio.UncheckedIOException; import com.stardust.pio.UncheckedIOException;
@@ -202,9 +203,7 @@ public class ProcessShell extends AbstractShell {
commandResult.error = readAll(process.getErrorStream()); commandResult.error = readAll(process.getErrorStream());
Log.d(TAG, commandResult.toString()); Log.d(TAG, commandResult.toString());
} catch (Exception e) { } catch (Exception e) {
commandResult.code = -1; throw new ScriptInterruptedException(e);
commandResult.error = e.getMessage();
e.printStackTrace();
} finally { } finally {
try { try {
if (os != null) os.close(); if (os != null) os.close();

View File

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