public interface

ShellExecutor

androidx.test.services.shellexecutor.ShellExecutor
Known Indirect Subclasses

Class Overview

Executes a shell command in a similar manner and environment as ERROR(#executeShellCommand/UiAutomation #executeShellCommand) , (i.e. as either root or shell user).

Unlike ERROR(/UiAutomation) this is available on all API levels and will not conflict with other instances of ERROR(/UiAutomation).

Summary

Public Methods
abstract InputStream executeShellCommand(String command, List<String> parameters, Map<StringString> shellEnv, boolean executeThroughShell)
Execute a command with elevated permissions and return immediately.
abstract InputStream executeShellCommand(String command, List<String> parameters, Map<StringString> shellEnv, boolean executeThroughShell, long timeoutMs)
Execute a command with elevated permissions and return immediately.
abstract String executeShellCommandSync(String command, List<String> parameters, Map<StringString> shellEnv, boolean executeThroughShell, long timeoutMs)
Execute a command with elevated permissions and block.
abstract String executeShellCommandSync(String command, List<String> parameters, Map<StringString> shellEnv, boolean executeThroughShell)
Execute a command with elevated permissions and block.
abstract String getBinderKey()

Public Methods

public abstract InputStream executeShellCommand (String command, List<String> parameters, Map<StringString> shellEnv, boolean executeThroughShell)

Execute a command with elevated permissions and return immediately.

Parameters
command String: The shell command to be executed.
parameters List: A Map parameters to be given to the shell command
shellEnv Map: A Map of shell environment variables to be set
executeThroughShell boolean: If set to true, the command string will be executed through the shell with parameters given as additional shell arguments.
Returns
InputStream InputStream representing the shell output of the command.
Throws
IOException if cannot execute command on executor service.
ClientNotConnected
RemoteException

public abstract InputStream executeShellCommand (String command, List<String> parameters, Map<StringString> shellEnv, boolean executeThroughShell, long timeoutMs)

Execute a command with elevated permissions and return immediately.

Parameters
command String: The shell command to be executed.
parameters List: A Map parameters to be given to the shell command
shellEnv Map: A Map of shell environment variables to be set
executeThroughShell boolean: If set to true, the command string will be executed through the shell with parameters given as additional shell arguments.
timeoutMs long: Optional, destroys the executing subprocess if it runs longer than this timeout.
Returns
InputStream InputStream representing the shell output of the command.
Throws
IOException if cannot execute command on executor service.
ClientNotConnected
RemoteException

public abstract String executeShellCommandSync (String command, List<String> parameters, Map<StringString> shellEnv, boolean executeThroughShell, long timeoutMs)

Execute a command with elevated permissions and block.

Parameters
command String: The shell command to be executed.
parameters List: A Map parameters to be given to the shell command
shellEnv Map: A Map of shell environment variables to be set
executeThroughShell boolean: If set to true, the command string will be executed through the shell with parameters given as additional shell arguments.
timeoutMs long: Optional, destroys the executing subprocess if it runs longer than this timeout.
Returns
String String representing the contents of the shell output of the command.
Throws
IOException if cannot execute command on executor service.
ClientNotConnected
RemoteException

public abstract String executeShellCommandSync (String command, List<String> parameters, Map<StringString> shellEnv, boolean executeThroughShell)

Execute a command with elevated permissions and block.

Parameters
command String: The shell command to be executed.
parameters List: A Map parameters to be given to the shell command
shellEnv Map: A Map of shell environment variables to be set
executeThroughShell boolean: If set to true, the command string will be executed through the shell with parameters given as additional shell arguments.
Returns
String String representing the contents of the shell output of the command.
Throws
IOException if cannot execute command on executor service.
ClientNotConnected
RemoteException

public abstract String getBinderKey ()

Returns
String