IShellEnabledDevice

public interface IShellEnabledDevice

com.android.ddmlib.IShellEnabledDevice


An abstract device that can receive shell commands.

Summary

Public methods

abstract void executeShellCommand(String command, IShellOutputReceiver receiver, long maxTimeToOutputResponse, TimeUnit maxTimeUnits)

Executes a shell command on the device, and sends the result to a receiver.

abstract void executeShellCommand(String command, IShellOutputReceiver receiver, long maxTimeout, long maxTimeToOutputResponse, TimeUnit maxTimeUnits)

Executes a shell command on the device, and sends the result to a receiver.

abstract String getName()

Returns a (humanized) name for this device.

abstract ListenableFuture<String> getSystemProperty(String name)

Do a potential asynchronous query for a system property.

Public methods

executeShellCommand

public abstract void executeShellCommand (String command, 
                IShellOutputReceiver receiver, 
                long maxTimeToOutputResponse, 
                TimeUnit maxTimeUnits)

Executes a shell command on the device, and sends the result to a receiver.

maxTimeToOutputResponse is used as a maximum waiting time when expecting the command output from the device.
At any time, if the shell command does not output anything for a period longer than maxTimeToOutputResponse, then the method will throw ShellCommandUnresponsiveException.

For commands like log output, a maxTimeToOutputResponse value of 0, meaning that the method will never throw and will block until the receiver's IShellOutputReceiver.isCancelled() returns true, should be used.

Parameters
command String: the shell command to execute

receiver IShellOutputReceiver: the IShellOutputReceiver that will receives the output of the shell command

maxTimeToOutputResponse long: the maximum amount of time during which the command is allowed to not output any response. A value of 0 means the method will wait forever (until the receiver cancels the execution) for command output and never throw.

maxTimeUnits TimeUnit: Units for non-zero maxTimeToOutputResponse values.

Throws
TimeoutException in case of timeout on the connection when sending the command.
AdbCommandRejectedException if adb rejects the command.
ShellCommandUnresponsiveException in case the shell command doesn't send any output for a period longer than maxTimeToOutputResponse.
in case of I/O error on the connection.

executeShellCommand

public abstract void executeShellCommand (String command, 
                IShellOutputReceiver receiver, 
                long maxTimeout, 
                long maxTimeToOutputResponse, 
                TimeUnit maxTimeUnits)

Executes a shell command on the device, and sends the result to a receiver.

maxTimeToOutputResponse is used as a maximum waiting time when expecting the command output from the device.
At any time, if the shell command does not output anything for a period longer than maxTimeToOutputResponse, then the method will throw ShellCommandUnresponsiveException.

For commands like log output, a maxTimeToOutputResponse value of 0, meaning that the method will never throw and will block until the receiver's IShellOutputReceiver.isCancelled() returns true, should be used.

Parameters
command String: the shell command to execute

receiver IShellOutputReceiver: the IShellOutputReceiver that will receives the output of the shell command

maxTimeout long: the maximum timeout for the command to return. A value of 0 means no max timeout will be applied.

maxTimeToOutputResponse long: the maximum amount of time during which the command is allowed to not output any response. A value of 0 means the method will wait forever (until the receiver cancels the execution) for command output and never throw.

maxTimeUnits TimeUnit: Units for non-zero maxTimeout and maxTimeToOutputResponse values.

Throws
TimeoutException in case of timeout on the connection when sending the command.
AdbCommandRejectedException if adb rejects the command.
ShellCommandUnresponsiveException in case the shell command doesn't send any output for a period longer than maxTimeToOutputResponse.
in case of I/O error on the connection.

getName

public abstract String getName ()

Returns a (humanized) name for this device. Typically this is the AVD name for AVD's, and a combination of the manufacturer name, model name & serial number for devices.

Returns
String

getSystemProperty

public abstract ListenableFuture<String> getSystemProperty (String name)

Do a potential asynchronous query for a system property.

Parameters
name String: the name of the value to return.

Returns
ListenableFuture<String> a ListenableFuture. ERROR(get/Future#get() get) may return null.