IShellEnabledDevice
public
interface
IShellEnabledDevice
| com.android.ddmlib.IShellEnabledDevice |
可接收殼層指令的抽象裝置。
摘要
公用方法 | |
|---|---|
abstract
void
|
executeShellCommand(String command, IShellOutputReceiver receiver, long maxTimeToOutputResponse, TimeUnit maxTimeUnits)
在裝置上執行殼層指令,並將結果傳送至 receiver。 |
abstract
void
|
executeShellCommand(String command, IShellOutputReceiver receiver, long maxTimeout, long maxTimeToOutputResponse, TimeUnit maxTimeUnits)
在裝置上執行殼層指令,並將結果傳送至 receiver。 |
abstract
String
|
getName()
傳回這部裝置的 (可解讀) 名稱。 |
abstract
ListenableFuture<String>
|
getSystemProperty(String name)
對系統屬性執行潛在的非同步查詢。 |
公用方法
executeShellCommand
public abstract void executeShellCommand (String command,
IShellOutputReceiver receiver,
long maxTimeToOutputResponse,
TimeUnit maxTimeUnits)在裝置上執行殼層指令,並將結果傳送至 receiver。
預期裝置會輸出指令時,maxTimeToOutputResponse 會做為最長等待時間。
在任何時間,如果殼層指令在一段時間內沒有輸出任何內容 (時間長度超過 maxTimeToOutputResponse),這個方法就會擲回 ShellCommandUnresponsiveException。
對於記錄輸出等指令,應使用 maxTimeToOutputResponse 值 0,表示方法絕不會擲回,且會封鎖,直到接收端的 IShellOutputReceiver.isCancelled() 傳回 true 為止。
| 參數 | |
|---|---|
command |
String:要執行的殼層指令 |
receiver |
IShellOutputReceiver:接收殼層指令輸出的 IShellOutputReceiver |
maxTimeToOutputResponse |
long:指令在沒有任何回應的情況下,允許的最長時間。如果值為 0,方法會無限期等待指令輸出內容 (直到 receiver 取消執行),且絕不會擲回。 |
maxTimeUnits |
TimeUnit:非零 maxTimeToOutputResponse 值所用的單位。 |
| 擲回 | |
|---|---|
TimeoutException |
如果傳送指令時連線逾時。 |
AdbCommandRejectedException |
如果 adb 拒絕該指令。 |
ShellCommandUnresponsiveException |
如果殼層指令在超過 maxTimeToOutputResponse 的時間內未傳送任何輸出內容。 |
|
如果連線發生 I/O 錯誤。 |
executeShellCommand
public abstract void executeShellCommand (String command,
IShellOutputReceiver receiver,
long maxTimeout,
long maxTimeToOutputResponse,
TimeUnit maxTimeUnits)在裝置上執行殼層指令,並將結果傳送至 receiver。
預期裝置會輸出指令時,maxTimeToOutputResponse 會做為最長等待時間。
在任何時間,如果殼層指令在一段時間內沒有輸出任何內容 (時間長度超過 maxTimeToOutputResponse),這個方法就會擲回 ShellCommandUnresponsiveException。
對於記錄輸出等指令,應使用 maxTimeToOutputResponse 值 0,表示方法絕不會擲回,且會封鎖,直到接收端的 IShellOutputReceiver.isCancelled() 傳回 true 為止。
| 參數 | |
|---|---|
command |
String:要執行的殼層指令 |
receiver |
IShellOutputReceiver:接收殼層指令輸出的 IShellOutputReceiver |
maxTimeout |
long:指令傳回的逾時時間上限。如果值為 0,表示不會套用逾時上限。 |
maxTimeToOutputResponse |
long:指令在沒有任何回應的情況下,允許的最長時間。如果值為 0,方法會無限期等待指令輸出內容 (直到 receiver 取消執行),且絕不會擲回。 |
maxTimeUnits |
TimeUnit:非零 maxTimeout 和 maxTimeToOutputResponse
值的單位。 |
| 擲回 | |
|---|---|
TimeoutException |
如果傳送指令時連線逾時。 |
AdbCommandRejectedException |
如果 adb 拒絕該指令。 |
ShellCommandUnresponsiveException |
如果殼層指令在超過 maxTimeToOutputResponse 的時間內未傳送任何輸出內容。 |
|
如果連線發生 I/O 錯誤。 |
getName
public abstract String getName ()
傳回這部裝置的 (可讀) 名稱。通常是 AVD 的 AVD 名稱,以及裝置的製造商名稱、型號名稱和序號組合。
| 傳回 | |
|---|---|
String |
|
getSystemProperty
public abstract ListenableFuture<String> getSystemProperty (String name)
對系統屬性執行潛在的非同步查詢。
| 參數 | |
|---|---|
name |
String:要傳回的值名稱。 |
| 傳回 | |
|---|---|
ListenableFuture<String> |
ListenableFuture. ERROR(get/Future#get() get) 可能會傳回空值。 |