NativeDeviceStateMonitor
public class NativeDeviceStateMonitor
extends Object
implements IDeviceStateMonitor
java.lang.Object | |
↳ | com.android.tradefed.device.NativeDeviceStateMonitor |
用於在沒有框架支援的情況下監視IDevice
狀態的幫助程式類別。
概括
常數 | |
---|---|
long | MAX_CHECK_POLL_TIME |
int | MAX_OP_TIME 「輪詢回應能力」指令的最大操作時間(以毫秒為單位) |
領域 | |
---|---|
protected static final String | PERM_DENIED_ERROR_PATTERN
|
公共構造函數 | |
---|---|
NativeDeviceStateMonitor ( IDeviceManager mgr, IDevice device, boolean fastbootEnabled) |
公共方法 | |
---|---|
TestDeviceState | getDeviceState () 獲取設備狀態。 |
String | getFastbootSerialNumber () 取得快速啟動模式序號。 |
String | getMountPoint (String mountName) 傳回一個掛載點。 |
String | getSerialNumber () 取得設備的序號。 |
boolean | isAdbTcp () |
void | setDefaultAvailableTimeout (long timeoutMs) 在 |
void | setDefaultOnlineTimeout (long timeoutMs) 在 |
void | setFastbootSerialNumber (String serial) 設定fastboot模式序號。 |
void | setIDevice (IDevice newDevice) 更新目前的 IDevice。 |
void | setState ( TestDeviceState deviceState) 設定設備目前狀態。 |
boolean | waitForBootComplete (long waitTime) 阻塞直到設定設備的啟動完成標誌 |
IDevice | waitForDeviceAvailable (long waitTime) 等待設備響應並可用於測試。 |
IDevice | waitForDeviceAvailable () 等待設備響應並可用於測試。 |
IDevice | waitForDeviceAvailableInRecoverPath (long waitTime) 在恢復路徑期間呼叫 |
boolean | waitForDeviceBootloader (long time) 等待設備進入引導程式。 |
void | waitForDeviceBootloaderStateUpdate () 等待裝置引導程式狀態刷新 |
boolean | waitForDeviceFastbootd (String fastbootPath, long time) 等待裝置進入 fastbootd。 |
IDevice | waitForDeviceInRecovery () 使用標準啟動逾時等待設備進入恢復模式。 |
boolean | waitForDeviceInRecovery (long waitTime) 等待設備處於“adb recovery”狀態 |
boolean | waitForDeviceInSideload (long waitTime) 等待設備處於“adb sideload”狀態 |
boolean | waitForDeviceNotAvailable (long waitTime) 等待設備不可用 |
IDevice | waitForDeviceOnline () 使用標準啟動超時等待設備上線。 |
IDevice | waitForDeviceOnline (long waitTime) 等待設備上線。 |
boolean | waitForDeviceShell (long waitTime) 等待設備回應基本的 adb shell 命令。 |
受保護的方法 | |
---|---|
CollectingOutputReceiver | createOutputReceiver () 暴露測試 |
long | getCheckPollTime () 暴露測試 |
long | getCurrentTime () 暴露測試 |
IDevice | getIDevice () |
boolean | postOnlineCheck (long waitTime) 在線上設備上進行額外檢查 |
boolean | waitForStoreMount (long waitTime) 等待安裝設備的外部儲存。 |
常數
MAX_CHECK_POLL_TIME
protected static final long MAX_CHECK_POLL_TIME
常數值:10000 (0x0000000000002710)
最長操作時間
protected static final int MAX_OP_TIME
「輪詢回應能力」指令的最大操作時間(以毫秒為單位)
常數值:10000 (0x00002710)
領域
PERM_DENIED_ERROR_PATTERN
protected static final String PERM_DENIED_ERROR_PATTERN
公共構造函數
NativeDeviceStateMonitor
public NativeDeviceStateMonitor (IDeviceManager mgr, IDevice device, boolean fastbootEnabled)
參數 | |
---|---|
mgr | IDeviceManager |
device | IDevice |
fastbootEnabled | boolean |
公共方法
取得Fastboot序號
public String getFastbootSerialNumber ()
取得快速啟動模式序號。
退貨 | |
---|---|
String |
取得掛載點
public String getMountPoint (String mountName)
傳回一個掛載點。
如果IDevice
中的快取資訊不可用,則直接查詢設備。
TODO:將此行為移至IDevice#getMountPoint(String)
參數 | |
---|---|
mountName | String : 掛載點的名稱 |
退貨 | |
---|---|
String | 掛載點或null |
投擲 | |
---|---|
DeviceNotAvailableException |
取得序號
public String getSerialNumber ()
取得設備的序號。
退貨 | |
---|---|
String |
是AdbTcp
public boolean isAdbTcp ()
退貨 | |
---|---|
boolean |
設定預設可用逾時
public void setDefaultAvailableTimeout (long timeoutMs)
在waitForDeviceAvailable()
中設定等待裝置可用的時間(以毫秒為單位)。
參數 | |
---|---|
timeoutMs | long |
設定預設線上超時
public void setDefaultOnlineTimeout (long timeoutMs)
在waitForDeviceOnline()
中設定等待裝置上線的時間(以毫秒為單位)。
參數 | |
---|---|
timeoutMs | long |
設定快速啟動序號
public void setFastbootSerialNumber (String serial)
設定fastboot模式序號。
參數 | |
---|---|
serial | String |
設定設備
public void setIDevice (IDevice newDevice)
更新目前的 IDevice。
等待啟動完成
public boolean waitForBootComplete (long waitTime)
阻塞直到設定設備的啟動完成標誌
參數 | |
---|---|
waitTime | long :等待的時間(以毫秒為單位) |
退貨 | |
---|---|
boolean |
等待設備可用
public IDevice waitForDeviceAvailable (long waitTime)
等待設備響應並可用於測試。目前這意味著套件管理器和外部儲存可用。
參數 | |
---|---|
waitTime | long :等待時間(以毫秒為單位) |
退貨 | |
---|---|
IDevice | 如果設備在時間到期之前上線,則IDevice 。否則為null 。 |
等待設備可用
public IDevice waitForDeviceAvailable ()
等待設備響應並可用於測試。
相當於waitForDeviceAvailable(long)
,但使用預設裝置啟動逾時。退貨 | |
---|---|
IDevice | 如果設備在時間到期之前上線,則IDevice 。否則為null 。 |
waitForDeviceAvailableInRecoverPath
public IDevice waitForDeviceAvailableInRecoverPath (long waitTime)
在恢復路徑期間呼叫waitForDeviceAvailable(long)
的特殊變體以自訂處理。
參數 | |
---|---|
waitTime | long |
退貨 | |
---|---|
IDevice |
投擲 | |
---|---|
DeviceNotAvailableException |
等待設備引導程式
public boolean waitForDeviceBootloader (long time)
等待設備進入引導程式。
參數 | |
---|---|
time | long :等待的最長時間(以毫秒為單位) |
退貨 | |
---|---|
boolean | 如果設備在時間到期之前處於引導程式中,則為true |
waitForDeviceBootloaderStateUpdate
public void waitForDeviceBootloaderStateUpdate ()
等待裝置引導程式狀態刷新
等待設備快速啟動
public boolean waitForDeviceFastbootd (String fastbootPath, long time)
等待裝置進入 fastbootd。
參數 | |
---|---|
fastbootPath | String :要使用的 fastboot 二進位檔案的路徑。 |
time | long :等待的最長時間(以毫秒為單位) |
退貨 | |
---|---|
boolean | 如果裝置在時間到期之前處於 fastbootd 狀態, true |
等待設備恢復
public IDevice waitForDeviceInRecovery ()
使用標準啟動逾時等待設備進入恢復模式。
退貨 | |
---|---|
IDevice | 如果設備在時間到期之前恢復,則IDevice 。否則為null 。 |
等待設備恢復
public boolean waitForDeviceInRecovery (long waitTime)
等待設備處於“adb recovery”狀態
參數 | |
---|---|
waitTime | long :等待的最長時間(以毫秒為單位) |
退貨 | |
---|---|
boolean | 如果裝置在逾時前處於恢復狀態,則為 True,否則為 False。 |
waitForDeviceInSideload
public boolean waitForDeviceInSideload (long waitTime)
等待設備處於“adb sideload”狀態
參數 | |
---|---|
waitTime | long :等待的最長時間(以毫秒為單位) |
退貨 | |
---|---|
boolean | 如果裝置在逾時之前處於旁載入狀態,則為 True,否則為 False。 |
等待設備不可用
public boolean waitForDeviceNotAvailable (long waitTime)
等待設備不可用
參數 | |
---|---|
waitTime | long :等待的最長時間(以毫秒為單位) |
退貨 | |
---|---|
boolean | 如果設備不可用則為true |
等待設備在線
public IDevice waitForDeviceOnline ()
使用標準啟動超時等待設備上線。
注意:一旦裝置透過 DDMS 可見,此方法就會回傳。它不保證設備實際上會回應 adb 命令 - 請改用waitForDeviceAvailable()
。退貨 | |
---|---|
IDevice | 如果設備在時間到期之前上線,則IDevice 。否則為null 。 |
等待設備在線
public IDevice waitForDeviceOnline (long waitTime)
等待設備上線。
注意:一旦裝置透過 DDMS 可見,此方法就會回傳。它不保證設備實際上會回應 adb 命令 - 請改用waitForDeviceAvailable()
。參數 | |
---|---|
waitTime | long :等待的最長時間(以毫秒為單位) |
退貨 | |
---|---|
IDevice | 如果設備在時間到期之前上線,則IDevice 。否則為null 。 |
等待設備外殼
public boolean waitForDeviceShell (long waitTime)
等待設備回應基本的 adb shell 命令。
參數 | |
---|---|
waitTime | long :等待時間(以毫秒為單位) |
退貨 | |
---|---|
boolean | 如果裝置在waitTime過去之前變得響應,則為true 。 |
受保護的方法
建立輸出接收器
protected CollectingOutputReceiver createOutputReceiver ()
暴露測試
退貨 | |
---|---|
CollectingOutputReceiver | CollectingOutputReceiver |
取得檢查輪詢時間
protected long getCheckPollTime ()
暴露測試
退貨 | |
---|---|
long |
取得當前時間
protected long getCurrentTime ()
暴露測試
退貨 | |
---|---|
long |
在線檢查後
protected boolean postOnlineCheck (long waitTime)
在線上設備上進行額外檢查
參數 | |
---|---|
waitTime | long :放棄前等待的時間(以毫秒為單位) |
退貨 | |
---|---|
boolean | 如果在 waitTime 到期之前檢查成功,則為true 。否則為false |
投擲 | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
DeviceNotAvailableException |
等待StoreMount
protected boolean waitForStoreMount (long waitTime)
等待安裝設備的外部儲存。
參數 | |
---|---|
waitTime | long :放棄前等待的時間(以毫秒為單位) |
退貨 | |
---|---|
boolean | 如果在 waitTime 到期之前安裝了外部存儲,則為true 。否則為false |
投擲 | |
---|---|
DeviceNotAvailableException |