IShellEnabledDevice

public interface IShellEnabledDevice

com.android.ddmlib.IShellEnabledDevice


可接收殼層指令的抽象裝置。

摘要

公用方法

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

在裝置上執行殼層指令,並將結果傳送至 receiver

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

在裝置上執行殼層指令,並將結果傳送至 receiver

abstract String getName()

傳回這部裝置的 (易記) 名稱。

abstract ListenableFuture<String> getSystemProperty(String name)

針對系統屬性執行潛在的非同步查詢。

公用方法

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:非零 maxTimeoutmaxTimeToOutputResponse 值的單位。

擲回
AdbCommandRejectedException 如果 ADB 拒絕執行指令。
ShellCommandUnresponsiveException 如果殼層指令在超過 maxTimeToOutputResponse 的時間內未傳送任何輸出內容,就會發生這種情況。
TimeoutException 如果傳送指令時連線逾時。
IOException 如果連線發生 I/O 錯誤。

另請參閱:

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 值的單位。

擲回
AdbCommandRejectedException 如果 ADB 拒絕執行指令。
ShellCommandUnresponsiveException 如果殼層指令在超過 maxTimeToOutputResponse 的時間內未傳送任何輸出內容,就會發生這種情況。
TimeoutException 如果傳送指令時連線逾時。
IOException 如果連線發生 I/O 錯誤。

另請參閱:

getName

public abstract String getName ()

傳回這部裝置的 (人性化) 名稱。通常是 AVD 的 AVD 名稱,以及裝置的製造商名稱、型號名稱和序號組合。

傳回
String

getSystemProperty

public abstract ListenableFuture<String> getSystemProperty (String name)

針對系統屬性執行潛在的非同步查詢。

參數
name String:要傳回的值名稱。

傳回
ListenableFuture<String> ListenableFuture. get 可能會傳回空值。