From 2614b958fb71b459ccda0adf5370cf95f52b9a01 Mon Sep 17 00:00:00 2001 From: Stephen Erickson Date: Sun, 4 Jan 2015 00:47:35 -0500 Subject: [PATCH] Fix constructors for Command and JavaCommand --- src/com/stericson/RootShell/RootShell.java | 2 +- .../RootShell/execution/Command.java | 44 ++----------------- .../RootShell/execution/JavaCommand.java | 37 ++++++++++++---- 3 files changed, 33 insertions(+), 50 deletions(-) diff --git a/src/com/stericson/RootShell/RootShell.java b/src/com/stericson/RootShell/RootShell.java index 16801dd..1998346 100644 --- a/src/com/stericson/RootShell/RootShell.java +++ b/src/com/stericson/RootShell/RootShell.java @@ -45,7 +45,7 @@ public class RootShell { public static boolean debugMode = false; - public static final String version = "RootShell v1.1"; + public static final String version = "RootShell v1.2"; /** * Setting this to false will disable the handler that is used diff --git a/src/com/stericson/RootShell/execution/Command.java b/src/com/stericson/RootShell/execution/Command.java index 343c3d8..2857219 100644 --- a/src/com/stericson/RootShell/execution/Command.java +++ b/src/com/stericson/RootShell/execution/Command.java @@ -34,6 +34,10 @@ public class Command { + //directly modified by JavaCommand + protected boolean javaCommand = false; + protected Context context = null; + public int totalOutput = 0; public int totalOutputProcessed = 0; @@ -46,10 +50,6 @@ public class Command { String[] command = {}; - boolean javaCommand = false; - - Context context = null; - boolean finished = false; boolean terminated = false; @@ -106,42 +106,6 @@ public Command(int id, int timeout, String... command) { createHandler(RootShell.handlerEnabled); } - /** - * Constructor for executing Java commands rather than binaries - * - * @param javaCommand when True, it is a java command. - * @param context needed to execute java command. - */ - public Command(int id, boolean javaCommand, Context context, String... command) { - this(id, command); - this.javaCommand = javaCommand; - this.context = context; - } - - /** - * Constructor for executing Java commands rather than binaries - * - * @param javaCommand when True, it is a java command. - * @param context needed to execute java command. - */ - public Command(int id, boolean handlerEnabled, boolean javaCommand, Context context, String... command) { - this(id, handlerEnabled, command); - this.javaCommand = javaCommand; - this.context = context; - } - - /** - * Constructor for executing Java commands rather than binaries - * - * @param javaCommand when True, it is a java command. - * @param context needed to execute java command. - */ - public Command(int id, int timeout, boolean javaCommand, Context context, String... command) { - this(id, timeout, command); - this.javaCommand = javaCommand; - this.context = context; - } - //If you override this you MUST make a final call //to the super method. The super call should be the last line of this method. public void commandOutput(int id, String line) { diff --git a/src/com/stericson/RootShell/execution/JavaCommand.java b/src/com/stericson/RootShell/execution/JavaCommand.java index f175436..032569e 100644 --- a/src/com/stericson/RootShell/execution/JavaCommand.java +++ b/src/com/stericson/RootShell/execution/JavaCommand.java @@ -4,21 +4,40 @@ public class JavaCommand extends Command { - public JavaCommand(int id, Context context, String... command) - { - super(id, true, context, command); + /** + * Constructor for executing Java commands rather than binaries + * + * @param context needed to execute java command. + */ + public JavaCommand(int id, Context context, String... command) { + super(id, command); + this.context = context; + this.javaCommand = true; } - public JavaCommand(int id, boolean handlerEnabled, Context context, String... command) - { - super(id, handlerEnabled, true, context, command); + /** + * Constructor for executing Java commands rather than binaries + * + * @param context needed to execute java command. + */ + public JavaCommand(int id, boolean handlerEnabled, Context context, String... command) { + super(id, handlerEnabled, command); + this.context = context; + this.javaCommand = true; } - public JavaCommand(int id, int timeout, Context context, String... command) - { - super(id, timeout, true, context, command); + /** + * Constructor for executing Java commands rather than binaries + * + * @param context needed to execute java command. + */ + public JavaCommand(int id, int timeout, Context context, String... command) { + super(id, timeout, command); + this.context = context; + this.javaCommand = true; } + @Override public void commandOutput(int id, String line) {