public static class Shell.Builder
extends java.lang.Object
Shell.Interactive| Constructor and Description |
|---|
Builder() |
| Modifier and Type | Method and Description |
|---|---|
Shell.Builder |
addCommand(java.util.List<java.lang.String> commands)
Add commands to execute
|
Shell.Builder |
addCommand(java.util.List<java.lang.String> commands,
int code,
Shell.OnCommandResultListener onCommandResultListener)
Add commands to execute, with a callback to be called on completion
(of all commands)
|
Shell.Builder |
addCommand(java.lang.String command)
Add a command to execute
|
Shell.Builder |
addCommand(java.lang.String[] commands)
Add commands to execute
|
Shell.Builder |
addCommand(java.lang.String[] commands,
int code,
Shell.OnCommandResultListener onCommandResultListener)
Add commands to execute, with a callback to be called on completion
(of all commands)
|
Shell.Builder |
addCommand(java.lang.String command,
int code,
Shell.OnCommandResultListener onCommandResultListener)
Add a command to execute, with a callback to be called on completion
|
Shell.Builder |
addEnvironment(java.util.Map<java.lang.String,java.lang.String> addEnvironment)
Add or update environment variables
|
Shell.Builder |
addEnvironment(java.lang.String key,
java.lang.String value)
Add or update an environment variable
|
Shell.Interactive |
open()
Construct a
Shell.Interactive instance, and start the shell |
Shell.Interactive |
open(Shell.OnCommandResultListener onCommandResultListener)
Construct a
Shell.Interactive instance, try to start the
shell, and call onCommandResultListener to report success or failure |
Shell.Builder |
setAutoHandler(boolean autoHandler)
Automatically create a handler if possible ? Default to true
|
Shell.Builder |
setHandler(android.os.Handler handler)
Set a custom handler that will be used to post all callbacks to
|
Shell.Builder |
setMinimalLogging(boolean useMinimal)
Enable/disable reduced logcat output
|
Shell.Builder |
setOnSTDERRLineListener(StreamGobbler.OnLineListener onLineListener)
Set a callback called for every line output to STDERR by the shell
|
Shell.Builder |
setOnSTDOUTLineListener(StreamGobbler.OnLineListener onLineListener)
Set a callback called for every line output to STDOUT by the shell
|
Shell.Builder |
setShell(java.lang.String shell)
Set shell binary to use.
|
Shell.Builder |
setWantSTDERR(boolean wantSTDERR)
Set if error output should be appended to command block result output
|
Shell.Builder |
setWatchdogTimeout(int watchdogTimeout)
Enable command timeout callback
|
Shell.Builder |
useSH()
Convenience function to set "sh" as used shell
|
Shell.Builder |
useSU()
Convenience function to set "su" as used shell
|
public Shell.Builder setHandler(android.os.Handler handler)
Set a custom handler that will be used to post all callbacks to
See Shell.Interactive for further details on threading and
handlers
handler - Handler to usepublic Shell.Builder setAutoHandler(boolean autoHandler)
Automatically create a handler if possible ? Default to true
See Shell.Interactive for further details on threading and
handlers
autoHandler - Auto-create handler ?public Shell.Builder setShell(java.lang.String shell)
shell - Shell to usepublic Shell.Builder useSH()
public Shell.Builder useSU()
public Shell.Builder setWantSTDERR(boolean wantSTDERR)
wantSTDERR - Want error output ?public Shell.Builder addEnvironment(java.lang.String key, java.lang.String value)
key - Key of the environment variablevalue - Value of the environment variablepublic Shell.Builder addEnvironment(java.util.Map<java.lang.String,java.lang.String> addEnvironment)
addEnvironment - Map of environment variablespublic Shell.Builder addCommand(java.lang.String command)
command - Command to executepublic Shell.Builder addCommand(java.lang.String command, int code, Shell.OnCommandResultListener onCommandResultListener)
Add a command to execute, with a callback to be called on completion
The thread on which the callback executes is dependent on various
factors, see Shell.Interactive for further details
command - Command to executecode - User-defined value passed back to the callbackonCommandResultListener - Callback to be called on completionpublic Shell.Builder addCommand(java.util.List<java.lang.String> commands)
commands - Commands to executepublic Shell.Builder addCommand(java.util.List<java.lang.String> commands, int code, Shell.OnCommandResultListener onCommandResultListener)
Add commands to execute, with a callback to be called on completion (of all commands)
The thread on which the callback executes is dependent on various
factors, see Shell.Interactive for further details
commands - Commands to executecode - User-defined value passed back to the callbackonCommandResultListener - Callback to be called on completion
(of all commands)public Shell.Builder addCommand(java.lang.String[] commands)
commands - Commands to executepublic Shell.Builder addCommand(java.lang.String[] commands, int code, Shell.OnCommandResultListener onCommandResultListener)
Add commands to execute, with a callback to be called on completion (of all commands)
The thread on which the callback executes is dependent on various
factors, see Shell.Interactive for further details
commands - Commands to executecode - User-defined value passed back to the callbackonCommandResultListener - Callback to be called on completion
(of all commands)public Shell.Builder setOnSTDOUTLineListener(StreamGobbler.OnLineListener onLineListener)
Set a callback called for every line output to STDOUT by the shell
The thread on which the callback executes is dependent on various
factors, see Shell.Interactive for further details
onLineListener - Callback to be called for each linepublic Shell.Builder setOnSTDERRLineListener(StreamGobbler.OnLineListener onLineListener)
Set a callback called for every line output to STDERR by the shell
The thread on which the callback executes is dependent on various
factors, see Shell.Interactive for further details
onLineListener - Callback to be called for each linepublic Shell.Builder setWatchdogTimeout(int watchdogTimeout)
Enable command timeout callback
This will invoke the onCommandResult() callback with exitCode WATCHDOG_EXIT if a command takes longer than watchdogTimeout seconds to complete.
If a watchdog timeout occurs, it generally means that the Interactive session is out of sync with the shell process. The caller should close the current session and open a new one.
watchdogTimeout - Timeout, in seconds; 0 to disablepublic Shell.Builder setMinimalLogging(boolean useMinimal)
Enable/disable reduced logcat output
Note that this is a global setting
useMinimal - true for reduced output, false for full outputpublic Shell.Interactive open()
Shell.Interactive instance, and start the shellpublic Shell.Interactive open(Shell.OnCommandResultListener onCommandResultListener)
Shell.Interactive instance, try to start the
shell, and call onCommandResultListener to report success or failureonCommandResultListener - Callback to return shell open status