原生設備
public interface INativeDevice
com.android.tradefed.device.INativeDevice |
為 ddmlib IDevice
提供可靠且稍高級別的 API。
概括
常數 | |
---|---|
int | UNKNOWN_API_LEVEL 無法檢測 API 級別時的默認值 |
公共方法 | |
---|---|
abstract boolean | checkApiLevelAgainstNextRelease (int strictMinLevel) 在給定最低支持級別的情況下,檢查當前是否支持某個功能。 |
abstract void | clearLogcat () 刪除任何累積的 logcat 數據。 |
abstract void | deleteFile (String deviceFilePath) 用於刪除設備上的文件或目錄的輔助方法。 |
abstract boolean | deviceSoftRestarted ( ProcessInfo prevSystemServerProcess) 通過比較當前 system_server 和以前的 system_server |
abstract boolean | deviceSoftRestartedSince (long utcEpochTime, TimeUnit timeUnit) 輔助方法,用於檢查設備是否自 UTC 時間以來從設備及其 |
abstract boolean | disableAdbRoot () 關閉 adb root。 |
abstract boolean | doesFileExist (String deviceFilePath) 確定設備上的文件是否存在的幫助方法。 |
abstract boolean | enableAdbRoot () 打開 adb root。 |
abstract String | executeAdbCommand (long timeout, String... commandArgs) 輔助方法,它執行 adb 命令作為具有指定超時的系統命令。 |
abstract String | executeAdbCommand (String... commandArgs) 將 adb 命令作為系統命令執行的輔助方法。 |
abstract CommandResult | executeFastbootCommand (String... commandArgs) 將 fastboot 命令作為系統命令執行的輔助方法,默認超時為 2 分鐘。 |
abstract CommandResult | executeFastbootCommand (long timeout, String... commandArgs) 將 fastboot 命令作為系統命令執行的輔助方法。 |
abstract CommandResult | executeLongFastbootCommand ( envVarMap, String... commandArgs) executeLongFastbootCommand ( envVarMap, String... commandArgs) 輔助方法,它將長時間運行的 fastboot 命令作為具有系統環境變量的系統命令執行。 |
abstract CommandResult | executeLongFastbootCommand (String... commandArgs) 將長時間運行的快速啟動命令作為系統命令執行的輔助方法。 |
abstract String | executeShellCommand (String command) 執行 adb shell 命令並以 |
abstract void | executeShellCommand (String command, IShellOutputReceiver receiver, long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts) 執行 adb shell 命令,帶有更多參數來控制命令行為。 |
abstract void | executeShellCommand (String command, IShellOutputReceiver receiver, long maxTimeoutForCommand, long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts) 執行 adb shell 命令,帶有更多參數來控制命令行為。 |
abstract void | executeShellCommand (String command, IShellOutputReceiver receiver) 執行給定的 adb shell 命令,如果命令失敗則重試多次。 |
abstract CommandResult | executeShellV2Command (String command) 輔助方法,它執行 adb shell 命令並將結果作為 |
abstract CommandResult | executeShellV2Command (String command, OutputStream pipeToOutput) 輔助方法,它執行 |
abstract CommandResult | executeShellV2Command (String command, File pipeAsInput) 輔助方法,它執行 adb shell 命令並將結果作為正確填充命令狀態輸出、stdout 和 stderr 的 |
abstract CommandResult | executeShellV2Command (String command, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts) 執行 adb shell 命令,帶有更多參數來控制命令行為。 |
abstract CommandResult | executeShellV2Command (String command, long maxTimeoutForCommand, TimeUnit timeUnit) 執行 adb shell 命令,帶有更多參數來控制命令行為。 |
abstract CommandResult | executeShellV2Command (String command, File pipeAsInput, OutputStream pipeToOutput, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts) 執行 adb shell 命令,帶有更多參數來控制命令行為。 |
abstract CommandResult | executeShellV2Command (String command, File pipeAsInput, OutputStream pipeToOutput, OutputStream pipeToError, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts) 執行 adb shell 命令,帶有更多參數來控制命令行為。 |
abstract CommandResult | fastbootWipePartition (String partition) 擦除設備分區的輔助方法。 |
abstract int | getApiLevel () 獲取設備 API 級別。 |
abstract String | getBasebandVersion () 獲取此設備的基帶(無線電)版本的便捷方法。 |
abstract Integer | getBattery () 返回設備的當前電池電量,如果電池電量不可用,則返回 Null。 |
abstract boolean | getBooleanProperty (String name, boolean defaultValue) 返回給定屬性的布爾值。 |
abstract | getBootHistory () Helper 方法收集帶有啟動時間和啟動原因的啟動歷史映射。 |
abstract | getBootHistorySince (long utcEpochTime, TimeUnit timeUnit) Helper 方法收集自給定時間以來從設備和指定的時間單位開始的啟動時間和啟動原因的啟動歷史映射。 |
abstract String | getBootloaderVersion () 獲取此設備的引導加載程序版本的便捷方法。 |
abstract InputStreamSource | getBugreport () 從設備中檢索錯誤報告。 |
abstract InputStreamSource | getBugreportz () 從設備中檢索錯誤報告。 |
abstract String | getBuildAlias () 檢索設備當前正在運行的構建的別名。 |
abstract String | getBuildFlavor () 檢索設備的構建風格。 |
abstract String | getBuildId () 檢索設備當前正在運行的構建。 |
abstract String | getBuildSigningKeys () 返回用於簽署設備映像的密鑰類型 通常,Android 設備可以使用測試密鑰(如在 AOSP 中)或發布密鑰(由各個設備製造商控制)進行簽名 |
abstract DeviceDescriptor | getCachedDeviceDescriptor () 如果設備已分配,則返回緩存的 |
abstract DeviceDescriptor | getCachedDeviceDescriptor (boolean shortDescriptor) 如果設備已分配,則返回緩存的 |
abstract String[] | getChildren (String deviceFilePath) 替代使用有時由於權限而無法工作的 |
abstract String | getDeviceClass () 獲取設備類。 |
abstract long | getDeviceDate () 返回自紀元以來設備的日期(以毫秒為單位)。 |
abstract DeviceDescriptor | getDeviceDescriptor () 從設備信息中返回一個 |
abstract DeviceDescriptor | getDeviceDescriptor (boolean shortDescriptor) 從設備信息中返回一個 |
abstract TestDeviceState | getDeviceState () 獲取設備的狀態。 |
abstract long | getDeviceTimeOffset (Date date) 幫助獲取設備與給定 |
abstract InputStreamSource | getEmulatorOutput () 獲取模擬器stdout和stderr的流 |
abstract long | getExternalStoreFreeSpace () 確定設備外部存儲可用空間量的輔助方法。 |
abstract String | getFastbootProductType () 在快速啟動模式下獲取此設備產品類型的便捷方法。 |
abstract String | getFastbootProductVariant () 在快速啟動模式下獲取此設備產品類型的便捷方法。 |
abstract String | getFastbootSerialNumber () 返回快速啟動模式序列號。 |
abstract String | getFastbootVariable (String variableName) 從設備中檢索給定的 fastboot 變量值。 |
abstract IFileEntry | getFileEntry (String path) 檢索對設備上遠程文件的引用。 |
abstract IDevice | getIDevice () 返回對關聯的 ddmlib |
abstract long | getIntProperty (String name, long defaultValue) 從設備返回給定屬性的整數值。 |
abstract long | getLastExpectedRebootTimeMillis () 返回自 EPOCH 以來 Tradefed API 觸發重啟的最後一次時間(以毫秒為單位),由 |
abstract int | getLaunchApiLevel () 獲取設備的第一個啟動的 API 級別。 |
abstract InputStreamSource | getLogcat () 抓取 logcat 數據的快照流。 |
abstract InputStreamSource | getLogcat (int maxBytes) 獲取捕獲的 logcat 數據的最後一個 |
abstract InputStreamSource | getLogcatDump () 獲取設備當前 logcat 的轉儲。 |
abstract InputStreamSource | getLogcatSince (long date) 從提供的日期開始抓取捕獲的 logcat 數據的快照流。 |
abstract String | getMountPoint (String mountName) 返回一個掛載點。 |
abstract ITestDevice.MountPointInfo | getMountPointInfo (String mountpoint) 返回與指定掛載點路徑相對應的 |
abstract | getMountPointInfo () 返回設備上 /proc/mounts 中信息的解析版本 |
abstract long | getPartitionFreeSpace (String partition) 確定設備分區上可用空間量的輔助方法。 |
abstract ProcessInfo | getProcessByName (String processName) Helper 方法運行“pidof”和“stat”命令並返回帶有 PID 和給定進程的進程啟動時間的 |
abstract String | getProcessPid (String process) 如果出現問題,則返回服務的 pid 或 null。 |
abstract String | getProductType () 獲取此設備產品類型的便捷方法。 |
abstract String | getProductVariant () 獲取此設備產品變體的便捷方法。 |
abstract String | getProperty (String name) 從設備中檢索給定的屬性值。 |
abstract ITestDevice.RecoveryMode | getRecoveryMode () 獲取設備當前使用的恢復模式。 |
abstract String | getSerialNumber () 獲取此設備序列號的便捷方法。 |
abstract | getTombstones () 從設備中獲取並返回墓碑列表。 |
abstract long | getTotalMemory () 返回以字節為單位的總物理內存大小,如果出現內部錯誤,則返回 -1 |
abstract boolean | getUseFastbootErase () 獲取是否使用 fastboot erase 或 fastboot 格式擦除設備上的分區。 |
abstract boolean | isAdbRoot () |
abstract boolean | isAdbTcp () |
abstract boolean | isAppEnumerationSupported () 檢查設備上的平台是否支持應用枚舉 |
abstract boolean | isDeviceEncrypted () 如果設備已加密,則返回。 |
abstract boolean | isDirectory (String deviceFilePath) 如果設備上的路徑是目錄,則返回 True,否則返回 false。 |
abstract boolean | isEncryptionSupported () 返回設備是否支持加密。 |
abstract boolean | isExecutable (String fullPath) 如果設備上的文件路徑是可執行文件,則返回 True,否則返回 false。 |
abstract boolean | isHeadless () 如果設備是無頭的(無屏幕),則返回 true,否則返回 false。 |
abstract boolean | isRuntimePermissionSupported () 檢查設備上的平台是否支持運行時權限授予 |
abstract boolean | isStateBootloaderOrFastbootd () 如果設備處於 |
abstract boolean | logAnrs ( ITestLogger logger) 從設備收集並記錄 ANR。 |
abstract boolean | logBugreport (String dataName, ITestLogger listener) 獲取錯誤報告並將其記錄到報告者的輔助方法。 |
abstract void | logOnDevice (String tag, Log.LogLevel level, String format, Object... args) 在設備的 logcat 中記錄一條消息。 |
abstract void | nonBlockingReboot () 發出命令以重新啟動設備並在命令完成以及設備對 adb 不再可見時返回。 |
abstract void | postBootSetup () 執行說明以配置設備以在每次啟動後進行測試。 |
default void | postInvocationTearDown () 此方法已棄用。請改用 |
abstract void | postInvocationTearDown (Throwable invocationException) 調用完成後將執行的特定設備所需清理的額外步驟。 |
default void | preInvocationSetup ( IBuildInfo info, MultiMap <String, String> attributes) 設備特定所需設置的額外步驟,將在調用流程之前在設備上執行。 |
abstract boolean | pullDir (String deviceFilePath, File localDir) 從設備遞歸提取目錄內容。 |
abstract File | pullFile (String remoteFilePath, int userId) 從設備中檢索文件,將其存儲在本地臨時 |
abstract File | pullFile (String remoteFilePath) 從設備中檢索文件,將其存儲在本地臨時 |
abstract boolean | pullFile (String remoteFilePath, File localFile) 從設備中檢索文件。 |
abstract boolean | pullFile (String remoteFilePath, File localFile, int userId) 從設備中檢索文件。 |
abstract String | pullFileContents (String remoteFilePath) 從設備中檢索文件,並返回內容。 |
abstract File | pullFileFromExternal (String remoteFilePath) 一種從設備的外部存儲中檢索文件、將其存儲在本地臨時 |
abstract boolean | pushDir (File localDir, String deviceFilePath, excludedDirectories) pushDir (File localDir, String deviceFilePath, excludedDirectories) 遞歸地將目錄內容推送到設備,同時排除一些被過濾的目錄。 |
abstract boolean | pushDir (File localDir, String deviceFilePath) 遞歸地將目錄內容推送到設備。 |
abstract boolean | pushFile (File localFile, String deviceFilePath, boolean evaluateContentProviderNeeded) |
abstract boolean | pushFile (File localFile, String deviceFilePath) 將文件推送到設備。 |
abstract boolean | pushString (String contents, String deviceFilePath) 將從字符串創建的文件推送到設備 |
abstract void | reboot () 將設備重新啟動到 adb 模式。 |
abstract void | reboot (String reason) 將設備重新啟動到 adb 模式,並在重新啟動後保留給定的 |
abstract void | rebootIntoBootloader () 將設備重新啟動到引導加載程序模式。 |
abstract void | rebootIntoFastbootd () 將設備重新啟動到 fastbootd 模式。 |
abstract void | rebootIntoRecovery () 將設備重新啟動到 adb 恢復模式。 |
abstract void | rebootIntoSideload (boolean autoReboot) 重啟設備進入 adb sideload 模式(注意這是恢復中的特殊模式) 阻塞直到設備進入側載模式 |
abstract void | rebootIntoSideload () 重啟設備進入 adb sideload 模式(注意這是恢復中的特殊模式) 阻塞直到設備進入側載模式 |
abstract void | rebootUntilOnline () |
abstract void | rebootUntilOnline (String reason) |
abstract void | rebootUserspace () 僅重新啟動設備的用戶空間部分。 |
abstract void | rebootUserspaceUntilOnline () |
abstract void | remountSystemWritable () 使設備上的系統分區可寫。 |
abstract void | remountVendorWritable () 使設備上的供應商分區可寫。 |
abstract boolean | runInstrumentationTests (IRemoteAndroidTestRunner runner, ITestLifeCycleReceiver... listeners) 使用一個或多個作為參數傳遞的偵聽器執行 |
abstract boolean | runInstrumentationTests (IRemoteAndroidTestRunner runner, listeners) runInstrumentationTests (IRemoteAndroidTestRunner runner, listeners) 運行儀器測試,並提供設備恢復。 |
abstract boolean | runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId, ITestLifeCycleReceiver... listeners) 與 |
abstract boolean | runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId, listeners) runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId, listeners) |
abstract void | setDate (Date date) 在設備上設置日期 注意:在設備上設置日期需要root |
abstract void | setOptions ( TestDeviceOptions options) 為設備設置 |
abstract boolean | setProperty (String propKey, String propValue) 在設備上設置給定的屬性值。 |
abstract void | setRecovery ( IDeviceRecovery recovery) 設置要用於此設備的 |
abstract void | setRecoveryMode ( ITestDevice.RecoveryMode mode) 設置要用於設備的當前恢復模式。 |
abstract void | setUseFastbootErase (boolean useFastbootErase) 設置是否使用 fastboot erase 或 fastboot 格式擦除設備上的分區。 |
abstract void | startLogcat () 開始在後台從設備捕獲 logcat 輸出。 |
abstract void | stopEmulatorOutput () 關閉並刪除模擬器輸出。 |
abstract void | stopLogcat () 停止從設備捕獲 logcat 輸出,並丟棄當前保存的 logcat 數據。 |
abstract String | switchToAdbTcp () 將設備切換到 adb-over-tcp 模式。 |
abstract boolean | switchToAdbUsb () 將設備切換到 adb over usb 模式。 |
abstract boolean | syncFiles (File localFileDir, String deviceFilePath) 將本地文件目錄的內容增量同步到設備。 |
abstract Bugreport | takeBugreport () 獲取錯誤報告並將其返回到 |
abstract boolean | unlockDevice () 如果設備處於加密狀態,則解鎖設備。 |
abstract boolean | waitForBootComplete (long timeOut) 阻塞直到設備的啟動完成標誌被設置。 |
abstract boolean | waitForDeviceAvailable () 等待設備響應並可用於測試。 |
abstract boolean | waitForDeviceAvailable (long waitTime) 等待設備響應並可用於測試。 |
abstract void | waitForDeviceBootloader () 阻塞直到設備通過 fastboot 可見。 |
abstract boolean | waitForDeviceInRecovery (long waitTime) 阻止設備處於“adb recovery”狀態(注意這與 |
abstract boolean | waitForDeviceInSideload (long waitTime) 阻止設備處於“adb sideload”狀態 |
abstract boolean | waitForDeviceNotAvailable (long waitTime) 設備不可用的塊,即從 adb 中丟失 |
abstract void | waitForDeviceOnline () 阻塞直到設備通過 adb 可見。 |
abstract void | waitForDeviceOnline (long waitTime) 阻塞直到設備通過 adb 可見。 |
abstract boolean | waitForDeviceShell (long waitTime) 等待設備響應基本的 adb shell 命令。 |
常數
UNKNOWN_API_LEVEL
public static final int UNKNOWN_API_LEVEL
無法檢測 API 級別時的默認值
常數值:-1 (0xffffffff)
公共方法
checkApiLevelAgainstNextRelease
public abstract boolean checkApiLevelAgainstNextRelease (int strictMinLevel)
在給定最低支持級別的情況下,檢查當前是否支持某個功能。在 API 級別提升之前,此方法考慮了尚未發布的功能。
參數 | |
---|---|
strictMinLevel | int :支持該功能的嚴格最小可能級別。 |
退貨 | |
---|---|
boolean | 如果支持該級別,則為真。否則為假。 |
投擲 | |
---|---|
DeviceNotAvailableException |
清除Logcat
public abstract void clearLogcat ()
刪除任何累積的 logcat 數據。
這對於您希望確保ITestDevice#getLogcat()
僅返回某個點之後生成的日誌數據(例如在刷新新設備構建之後等)的情況很有用。 刪除文件
public abstract void deleteFile (String deviceFilePath)
用於刪除設備上的文件或目錄的輔助方法。
參數 | |
---|---|
deviceFilePath | String : 文件在設備上的絕對路徑。 |
投擲 | |
---|---|
DeviceNotAvailableException |
deviceSoftRestarted
public abstract boolean deviceSoftRestarted (ProcessInfo prevSystemServerProcess)
通過比較當前 system_server 和以前的 system_server ProcessInfo
來檢查設備是否軟重啟的輔助方法。使用getProcessByName(String)
獲取ProcessInfo
。
參數 | |
---|---|
prevSystemServerProcess | ProcessInfo :之前的 system_server 進程ProcessInfo 。 |
退貨 | |
---|---|
boolean | 如果設備軟重啟,則為true |
投擲 | |
---|---|
RuntimeException | 如果設備有異常啟動原因 |
DeviceNotAvailableException |
deviceSoftRestartedSince
public abstract boolean deviceSoftRestartedSince (long utcEpochTime, TimeUnit timeUnit)
輔助方法,用於檢查設備是否自 UTC 時間以來從設備及其ERROR(/TimeUnit)
開始軟重啟。軟重啟是指 system_server 在設備硬重啟之外重啟(例如:請求重啟)。可以通過getDeviceDate()
方法獲取 Milliseseccond 中的當前設備 utcEpochTime。
參數 | |
---|---|
utcEpochTime | long :自紀元以來的設備時間,以秒為單位。 |
timeUnit | TimeUnit :給定 utcEpochTime 的時間單位TimeUnit 。 |
退貨 | |
---|---|
boolean | 如果設備軟重啟,則為true |
投擲 | |
---|---|
RuntimeException | 如果設備有異常啟動原因 |
DeviceNotAvailableException |
禁用AdbRoot
public abstract boolean disableAdbRoot ()
關閉 adb root。
禁用 adb root 可能會導致設備與 adb 斷開連接。此方法將阻塞,直到設備可用。退貨 | |
---|---|
boolean | 如果成功,則為true 。 |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失且無法恢復。 |
文件存在
public abstract boolean doesFileExist (String deviceFilePath)
確定設備上的文件是否存在的幫助方法。
參數 | |
---|---|
deviceFilePath | String : 設備上要檢查的文件的絕對路徑 |
退貨 | |
---|---|
boolean | 如果文件存在則為true ,否則為false 。 |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失且無法恢復。 |
啟用AdbRoot
public abstract boolean enableAdbRoot ()
打開 adb root。如果“enable-root”設置為“false”,將記錄一條消息並在不啟用 root 的情況下返回。
啟用 adb root 可能會導致設備與 adb 斷開連接。此方法將阻塞,直到設備可用。退貨 | |
---|---|
boolean | 如果成功,則為true 。 |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失且無法恢復。 |
執行AdbCommand
public abstract String executeAdbCommand (long timeout, String... commandArgs)
輔助方法,它執行 adb 命令作為具有指定超時的系統命令。
應盡可能使用executeShellCommand(String)
,因為該方法提供了更好的故障檢測和性能。
參數 | |
---|---|
timeout | long :設備被認為無響應之前的時間(以毫秒為單位),0L 表示沒有超時 |
commandArgs | String :要運行的 adb 命令和參數 |
退貨 | |
---|---|
String | 命令的標準輸出。如果命令執行失敗,則返回null 。 |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失且無法恢復。 |
執行AdbCommand
public abstract String executeAdbCommand (String... commandArgs)
將 adb 命令作為系統命令執行的輔助方法。
應盡可能使用executeShellCommand(String)
,因為該方法提供了更好的故障檢測和性能。參數 | |
---|---|
commandArgs | String :要運行的 adb 命令和參數 |
退貨 | |
---|---|
String | 命令的標準輸出。如果命令執行失敗,則返回null 。 |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失且無法恢復。 |
執行Fastboot命令
public abstract CommandResult executeFastbootCommand (String... commandArgs)
將 fastboot 命令作為系統命令執行的輔助方法,默認超時為 2 分鐘。
預計在設備已處於快速啟動模式時使用。參數 | |
---|---|
commandArgs | String : 要運行的 fastboot 命令和參數 |
退貨 | |
---|---|
CommandResult | 包含命令輸出的 CommandResult |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失且無法恢復。 |
執行Fastboot命令
public abstract CommandResult executeFastbootCommand (long timeout, String... commandArgs)
將 fastboot 命令作為系統命令執行的輔助方法。
預計在設備已處於快速啟動模式時使用。參數 | |
---|---|
timeout | long :命令過期前的時間(以毫秒為單位) |
commandArgs | String : 要運行的 fastboot 命令和參數 |
退貨 | |
---|---|
CommandResult | 包含命令輸出的 CommandResult |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失且無法恢復。 |
執行LongFastboot命令
public abstract CommandResult executeLongFastbootCommand (envVarMap, String... commandArgs)
輔助方法,它將長時間運行的 fastboot 命令作為具有系統環境變量的系統命令執行。
與executeFastbootCommand(String)
相同,只是使用了更長的超時時間。
參數 | |
---|---|
envVarMap | |
commandArgs | String : 要運行的 fastboot 命令和參數 |
退貨 | |
---|---|
CommandResult | 包含命令輸出的 CommandResult |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失且無法恢復。 |
執行LongFastboot命令
public abstract CommandResult executeLongFastbootCommand (String... commandArgs)
將長時間運行的快速啟動命令作為系統命令執行的輔助方法。
與executeFastbootCommand(String)
相同,只是使用了更長的超時時間。參數 | |
---|---|
commandArgs | String : 要運行的 fastboot 命令和參數 |
退貨 | |
---|---|
CommandResult | 包含命令輸出的 CommandResult |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失且無法恢復。 |
執行ShellCommand
public abstract String executeShellCommand (String command)
執行 adb shell 命令並以String
形式返回輸出的輔助方法。
參數 | |
---|---|
command | String : 要運行的 adb shell 命令 |
退貨 | |
---|---|
String | 外殼輸出 |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失且無法恢復。 |
執行ShellCommand
public abstract void executeShellCommand (String command, IShellOutputReceiver receiver, long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts)
執行 adb shell 命令,帶有更多參數來控制命令行為。
參數 | |
---|---|
command | String : 要運行的 adb shell 命令 |
receiver | IShellOutputReceiver :將 shell 輸出定向到的IShellOutputReceiver 。 |
maxTimeToOutputShellResponse | long :允許命令不輸出任何響應的最長時間; timeUnit 中指定的單位 |
timeUnit | TimeUnit : maxTimeToOutputShellResponse 的單位 |
retryAttempts | int :如果由於異常而失敗,則重試命令的最大次數。如果retryAttempts未成功執行,將拋出 DeviceNotResponsiveException。 |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失且無法恢復。 |
執行ShellCommand
public abstract void executeShellCommand (String command, IShellOutputReceiver receiver, long maxTimeoutForCommand, long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts)
執行 adb shell 命令,帶有更多參數來控制命令行為。
參數 | |
---|---|
command | String : 要運行的 adb shell 命令 |
receiver | IShellOutputReceiver :將 shell 輸出定向到的IShellOutputReceiver 。 |
maxTimeoutForCommand | long :命令完成的最大超時時間; timeUnit 中指定的單位 |
maxTimeToOutputShellResponse | long :允許命令不輸出任何響應的最長時間; timeUnit 中指定的單位 |
timeUnit | TimeUnit : maxTimeToOutputShellResponse 的單位 |
retryAttempts | int :如果由於異常而失敗,則重試命令的最大次數。如果retryAttempts未成功執行,將拋出 DeviceNotResponsiveException。 |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失且無法恢復。 |
執行ShellCommand
public abstract void executeShellCommand (String command, IShellOutputReceiver receiver)
執行給定的 adb shell 命令,如果命令失敗則重試多次。
具有默認值的executeShellCommand(String, com.android.ddmlib.IShellOutputReceiver, long, TimeUnit, int)
的更簡單形式。參數 | |
---|---|
command | String : 要運行的 adb shell 命令 |
receiver | IShellOutputReceiver :將 shell 輸出定向到的IShellOutputReceiver 。 |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失且無法恢復。 |
執行ShellV2命令
public abstract CommandResult executeShellV2Command (String command)
輔助方法,它執行 adb shell 命令並將結果作為CommandResult
正確填充,其中包含命令狀態輸出、stdout 和 stderr。
參數 | |
---|---|
command | String :應該運行的命令。 |
退貨 | |
---|---|
CommandResult | CommandResult 中的結果。 |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失且無法恢復。 |
執行ShellV2命令
public abstract CommandResult executeShellV2Command (String command, OutputStream pipeToOutput)
輔助方法,它執行CommandResult
shell 命令並將結果作為正確填充命令狀態輸出和標準錯誤的命令結果返回。 stdout 被定向到指定的流。
參數 | |
---|---|
command | String :應該運行的命令。 |
pipeToOutput | OutputStream : ERROR(/OutputStream) 將重定向 std 輸出,或者為 null。 |
退貨 | |
---|---|
CommandResult | CommandResult 中的結果。 |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失且無法恢復。 |
執行ShellV2命令
public abstract CommandResult executeShellV2Command (String command, File pipeAsInput)
輔助方法,它執行 adb shell 命令並將結果作為正確填充命令狀態輸出、stdout 和 stderr 的CommandResult
返回。
參數 | |
---|---|
command | String :應該運行的命令。 |
pipeAsInput | File : 一個ERROR(/File) 將作為命令的輸入通過管道傳輸,或者為 null。 |
退貨 | |
---|---|
CommandResult | CommandResult 中的結果。 |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失且無法恢復。 |
執行ShellV2命令
public abstract CommandResult executeShellV2Command (String command, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts)
執行 adb shell 命令,帶有更多參數來控制命令行為。
參數 | |
---|---|
command | String : 要運行的 adb shell 命令 |
maxTimeoutForCommand | long :命令完成的最大超時時間; timeUnit 中指定的單位 |
timeUnit | TimeUnit : maxTimeToOutputShellResponse 的單位 |
retryAttempts | int :如果由於異常而失敗,則重試命令的最大次數。如果retryAttempts未成功執行,將拋出 DeviceNotResponsiveException。 |
退貨 | |
---|---|
CommandResult |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失且無法恢復。 |
執行ShellV2命令
public abstract CommandResult executeShellV2Command (String command, long maxTimeoutForCommand, TimeUnit timeUnit)
執行 adb shell 命令,帶有更多參數來控制命令行為。
參數 | |
---|---|
command | String : 要運行的 adb shell 命令 |
maxTimeoutForCommand | long :命令完成的最大超時時間; timeUnit 中指定的單位 |
timeUnit | TimeUnit : maxTimeToOutputShellResponse 的單位 |
退貨 | |
---|---|
CommandResult |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失且無法恢復。 |
執行ShellV2命令
public abstract CommandResult executeShellV2Command (String command, File pipeAsInput, OutputStream pipeToOutput, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts)
執行 adb shell 命令,帶有更多參數來控制命令行為。
參數 | |
---|---|
command | String : 要運行的 adb shell 命令 |
pipeAsInput | File : 一個ERROR(/File) 將作為命令的輸入通過管道傳輸,或者為 null。 |
pipeToOutput | OutputStream : ERROR(/OutputStream) 將重定向 std 輸出,或者為 null。 |
maxTimeoutForCommand | long :命令完成的最大超時時間; timeUnit 中指定的單位 |
timeUnit | TimeUnit : maxTimeToOutputShellResponse 的單位 |
retryAttempts | int :如果由於異常而失敗,則重試命令的最大次數。如果retryAttempts未成功執行,將拋出 DeviceNotResponsiveException。 |
退貨 | |
---|---|
CommandResult |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失且無法恢復。 |
執行ShellV2命令
public abstract CommandResult executeShellV2Command (String command, File pipeAsInput, OutputStream pipeToOutput, OutputStream pipeToError, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts)
執行 adb shell 命令,帶有更多參數來控制命令行為。
參數 | |
---|---|
command | String : 要運行的 adb shell 命令 |
pipeAsInput | File : 一個ERROR(/File) 將作為命令的輸入通過管道傳輸,或者為 null。 |
pipeToOutput | OutputStream : ERROR(/OutputStream) 將重定向 std 輸出,或者為 null。 |
pipeToError | OutputStream : ERROR(/OutputStream) 將重定向 std 錯誤的位置,或者為 null。 |
maxTimeoutForCommand | long :命令完成的最大超時時間; timeUnit 中指定的單位 |
timeUnit | TimeUnit : maxTimeToOutputShellResponse 的單位 |
retryAttempts | int :如果由於異常而失敗,則重試命令的最大次數。如果retryAttempts未成功執行,將拋出 DeviceNotResponsiveException。 |
退貨 | |
---|---|
CommandResult |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失且無法恢復。 |
fastbootWipePartition
public abstract CommandResult fastbootWipePartition (String partition)
擦除設備分區的輔助方法。
如果getUseFastbootErase()
為true
,那麼 fastboot erase 將用於擦除分區。然後,設備必須在下次設備引導時創建文件系統。否則,將使用 fastboot 格式,這將在設備上創建一個新的文件系統。預計在設備已處於快速啟動模式時使用。參數 | |
---|---|
partition | String : 要擦除的分區 |
退貨 | |
---|---|
CommandResult | 包含命令輸出的 CommandResult |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失且無法恢復。 |
獲取 API 級別
public abstract int getApiLevel ()
獲取設備 API 級別。默認為UNKNOWN_API_LEVEL
。
退貨 | |
---|---|
int | 一個整數,指示設備的 API 級別 |
投擲 | |
---|---|
DeviceNotAvailableException |
獲取基帶版本
public abstract String getBasebandVersion ()
獲取此設備的基帶(無線電)版本的便捷方法。獲取無線電版本是特定於設備的,因此它可能不會為所有設備返回正確的信息。此方法依賴 gsm.version.baseband 屬性來返回正確的版本信息。這對於某些 CDMA 設備並不准確,此處返回的版本可能與從 fastboot 報告的版本不匹配,並且可能不會返回 CDMA 無線電的版本。 TL;DR 如果 gsm.version.baseband 屬性與fastboot getvar version-baseband
返回的版本相同,此方法僅報告準確的版本。
退貨 | |
---|---|
String | String 基帶版本,如果無法確定,則null (設備沒有無線電或無法讀取版本字符串) |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失且無法恢復。 |
獲取電池
public abstract Integer getBattery ()
返回設備的當前電池電量,如果電池電量不可用,則返回 Null。
退貨 | |
---|---|
Integer |
獲取布爾屬性
public abstract boolean getBooleanProperty (String name, boolean defaultValue)
返回給定屬性的布爾值。
參數 | |
---|---|
name | String : 屬性名 |
defaultValue | boolean :如果屬性為空或不存在,則返回默認值。 |
退貨 | |
---|---|
boolean | true 屬性值為"1" 、 "y" 、 "yes" 、 "on" 或"true" ,則為false ,如果屬性值為"0" 、 "n" 、 "no" 、 "off" ,則為 false , "false" ,否則為defaultValue 。 |
投擲 | |
---|---|
DeviceNotAvailableException |
獲取啟動歷史
public abstractgetBootHistory ()
Helper 方法收集帶有啟動時間和啟動原因的啟動歷史映射。
退貨 | |
---|---|
啟動時間(自 Epoch 以來以秒為單位的 UTC 時間)和啟動原因的映射 |
投擲 | |
---|---|
DeviceNotAvailableException |
getBootHistorySince
public abstractgetBootHistorySince (long utcEpochTime, TimeUnit timeUnit)
Helper 方法收集自給定時間以來從設備和指定的時間單位開始的啟動時間和啟動原因的啟動歷史映射。可以通過getDeviceDate()
方法獲取當前設備的 utcEpochTime,以毫秒為單位。
參數 | |
---|---|
utcEpochTime | long :自 Epoch 以來的設備時間。 |
timeUnit | TimeUnit :時間單位TimeUnit 。 |
退貨 | |
---|---|
啟動時間(自 Epoch 以來以秒為單位的 UTC 時間)和啟動原因的映射 |
投擲 | |
---|---|
DeviceNotAvailableException |
獲取引導加載程序版本
public abstract String getBootloaderVersion ()
獲取此設備的引導加載程序版本的便捷方法。
將嘗試從設備的當前狀態檢索引導加載程序版本。 (即如果設備處於快速啟動模式,它將嘗試從快速啟動中檢索版本)退貨 | |
---|---|
String | String 引導加載程序版本,如果找不到,則返回null |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失且無法恢復。 |
獲取報告
public abstract InputStreamSource getBugreport ()
從設備中檢索錯誤報告。
保證此實現可以繼續在沒有 sdcard 的設備上工作(或尚未安裝 sdcard 的設備)。退貨 | |
---|---|
InputStreamSource | InputStreamSource 將根據需要生成錯誤報告內容。如果失敗, InputStreamSource 將產生一個空的ERROR(/InputStream) 。 |
getBugreportz
public abstract InputStreamSource getBugreportz ()
從設備中檢索錯誤報告。 Zip 格式的 bugreport 包含主要的 bugreport 和其他對調試有用的日誌文件。
僅支持“adb 版本”> 1.0.36退貨 | |
---|---|
InputStreamSource | 包含 bugreportz 的 zip 文件的InputStreamSource ,如果失敗則返回 null。 |
獲取構建別名
public abstract String getBuildAlias ()
檢索設備當前正在運行的構建的別名。
構建別名通常是比構建 ID 更易讀的字符串(通常是 Nexus 構建的數字)。例如,最終的 Android 4.2 版本具有構建別名 JDQ39,構建 ID 為 573038
退貨 | |
---|---|
String | 構建別名或回退到構建 ID(如果無法檢索) |
投擲 | |
---|---|
DeviceNotAvailableException |
獲取BuildFlavor
public abstract String getBuildFlavor ()
檢索設備的構建風格。
退貨 | |
---|---|
String | 構建風格或 null 如果無法檢索 |
投擲 | |
---|---|
DeviceNotAvailableException |
獲取BuildId
public abstract String getBuildId ()
檢索設備當前正在運行的構建。
退貨 | |
---|---|
String | 構建 ID 或IBuildInfo#UNKNOWN_BUILD_ID (如果無法檢索) |
投擲 | |
---|---|
DeviceNotAvailableException |
getBuildSigningKeys
public abstract String getBuildSigningKeys ()
返回用於簽署設備映像的密鑰類型
通常,Android 設備可以使用測試密鑰(如在 AOSP 中)或發布密鑰(由各個設備製造商控制)進行簽名
退貨 | |
---|---|
String | 如果找到簽名密鑰,則返回 null。 |
投擲 | |
---|---|
DeviceNotAvailableException |
getCachedDeviceDescriptor
public abstract DeviceDescriptor getCachedDeviceDescriptor ()
如果設備已分配,則返回緩存的DeviceDescriptor
,否則返回當前的DeviceDescriptor
。
退貨 | |
---|---|
DeviceDescriptor |
getCachedDeviceDescriptor
public abstract DeviceDescriptor getCachedDeviceDescriptor (boolean shortDescriptor)
如果設備已分配,則返回緩存的DeviceDescriptor
,否則返回當前的DeviceDescriptor
。
參數 | |
---|---|
shortDescriptor | boolean : 是否將描述符限制為最小信息 |
退貨 | |
---|---|
DeviceDescriptor |
得到孩子
public abstract String[] getChildren (String deviceFilePath)
替代使用有時由於權限而無法工作的IFileEntry
。
參數 | |
---|---|
deviceFilePath | String : 是設備上進行搜索的路徑 |
退貨 | |
---|---|
String[] | 包含設備路徑中所有文件的字符串數組。 |
投擲 | |
---|---|
DeviceNotAvailableException |
獲取設備日期
public abstract long getDeviceDate ()
返回自紀元以來設備的日期(以毫秒為單位)。
退貨 | |
---|---|
long | 紀元格式的設備日期。 |
投擲 | |
---|---|
DeviceNotAvailableException |
獲取設備描述符
public abstract DeviceDescriptor getDeviceDescriptor ()
從設備信息中返回一個DeviceDescriptor
以獲取有關它的信息,而無需傳遞實際的設備對象。
退貨 | |
---|---|
DeviceDescriptor |
獲取設備描述符
public abstract DeviceDescriptor getDeviceDescriptor (boolean shortDescriptor)
從設備信息中返回一個DeviceDescriptor
以獲取有關它的信息,而無需傳遞實際的設備對象。
參數 | |
---|---|
shortDescriptor | boolean : 是否將描述符限制為最小信息 |
退貨 | |
---|---|
DeviceDescriptor |
獲取設備時間偏移
public abstract long getDeviceTimeOffset (Date date)
幫助獲取設備與給定ERROR(/Date)
之間的時間差。在內部使用紀元時間。
參數 | |
---|---|
date | Date |
退貨 | |
---|---|
long | 以毫秒為單位的差異 |
投擲 | |
---|---|
DeviceNotAvailableException |
得到模擬器輸出
public abstract InputStreamSource getEmulatorOutput ()
獲取模擬器stdout和stderr的流
退貨 | |
---|---|
InputStreamSource | 模擬器輸出 |
獲取ExternalStoreFreeSpace
public abstract long getExternalStoreFreeSpace ()
確定設備外部存儲可用空間量的輔助方法。
退貨 | |
---|---|
long | 以 KB 為單位的可用空間量 |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失且無法恢復。 |
獲取快速啟動產品類型
public abstract String getFastbootProductType ()
在快速啟動模式下獲取此設備產品類型的便捷方法。
僅當設備應處於快速啟動狀態時才應使用此方法。在這種情況下,它比通用getProductType()
方法更安全一些,因為如果設備處於錯誤狀態或無響應,ITestDevice 會知道將設備恢復到快速啟動。退貨 | |
---|---|
String | String 產品類型名稱,如果無法確定,則null |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失且無法恢復。 |
獲取FastbootProductVariant
public abstract String getFastbootProductVariant ()
在快速啟動模式下獲取此設備產品類型的便捷方法。
僅當設備應處於快速啟動狀態時才應使用此方法。在這種情況下,它比通用getProductType()
方法更安全一些,因為如果設備處於錯誤狀態或無響應,ITestDevice 會知道將設備恢復到快速啟動。退貨 | |
---|---|
String | String 產品類型名稱,如果無法確定,則null |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失且無法恢復。 |
getFastbootSerialNumber
public abstract String getFastbootSerialNumber ()
返回快速啟動模式序列號。
退貨 | |
---|---|
String |
獲取快速啟動變量
public abstract String getFastbootVariable (String variableName)
從設備中檢索給定的 fastboot 變量值。
參數 | |
---|---|
variableName | String : 變量名 |
退貨 | |
---|---|
String | 屬性值,如果不存在則為null |
投擲 | |
---|---|
| 不支持的操作異常 |
DeviceNotAvailableException |
獲取文件條目
public abstract IFileEntry getFileEntry (String path)
檢索對設備上遠程文件的引用。
參數 | |
---|---|
path | String : 要檢索的文件路徑。可以是絕對路徑或相對於 '/' 的路徑。 (即支持“/system”和“system”語法) |
退貨 | |
---|---|
IFileEntry | 如果找不到給定path的文件,則IFileEntry 或null |
投擲 | |
---|---|
DeviceNotAvailableException |
獲取設備
public abstract IDevice getIDevice ()
返回對關聯的 ddmlib IDevice
的引用。
IDevice
。因此,調用者不應保留對IDevice
的引用,因為該引用可能會變得陳舊。退貨 | |
---|---|
IDevice | IDevice |
獲取IntProperty
public abstract long getIntProperty (String name, long defaultValue)
從設備返回給定屬性的整數值。
參數 | |
---|---|
name | String : 屬性名 |
defaultValue | long :如果屬性為空或不存在,則返回默認值。 |
退貨 | |
---|---|
long | 如果屬性為空、不存在或沒有整數值,則為屬性值或defaultValue 。 |
投擲 | |
---|---|
DeviceNotAvailableException |
getLastExpectedRebootTimeMillis
public abstract long getLastExpectedRebootTimeMillis ()
返回自 EPOCH 以來 Tradefed API 觸發重啟的最後一次時間(以毫秒為單位),由System.currentTimeMillis()
返回。
退貨 | |
---|---|
long |
getLaunchApiLevel
public abstract int getLaunchApiLevel ()
獲取設備的第一個啟動的 API 級別。默認為UNKNOWN_API_LEVEL
。
退貨 | |
---|---|
int | 一個整數,指示設備的第一個啟動的 API 級別 |
投擲 | |
---|---|
DeviceNotAvailableException |
獲取日誌貓
public abstract InputStreamSource getLogcat ()
抓取 logcat 數據的快照流。
以兩種模式工作:
TestDeviceOptions.getMaxLogcatDataSize()
字節的後台logcat捕獲的當前內容退貨 | |
---|---|
InputStreamSource |
獲取日誌貓
public abstract InputStreamSource getLogcat (int maxBytes)
Grabs a snapshot stream of the last maxBytes
of captured logcat data.
Useful for cases when you want to capture frequent snapshots of the captured logcat data without incurring the potentially big disk space penalty of getting the entire getLogcat()
snapshot.
參數 | |
---|---|
maxBytes | int : the maximum amount of data to return. Should be an amount that can comfortably fit in memory |
退貨 | |
---|---|
InputStreamSource |
getLogcatDump
public abstract InputStreamSource getLogcatDump ()
Get a dump of the current logcat for device. Unlike getLogcat()
, this method will always return a static dump of the logcat.
Has the disadvantage that nothing will be returned if device is not reachable.
退貨 | |
---|---|
InputStreamSource | a InputStreamSource of the logcat data. An empty stream is returned if fail to capture logcat data. |
getLogcatSince
public abstract InputStreamSource getLogcatSince (long date)
Grabs a snapshot stream of captured logcat data starting the date provided. The time on the device should be used getDeviceDate()
.
參數 | |
---|---|
date | long : in millisecond since epoch format of when to start the snapshot until present. (can be be obtained using 'date +%s') |
退貨 | |
---|---|
InputStreamSource |
getMountPoint
public abstract String getMountPoint (String mountName)
Returns a mount point.
Queries the device directly if the cached info inIDevice
is not available. TODO: move this behavior to IDevice#getMountPoint(String)
參數 | |
---|---|
mountName | String : the name of the mount point |
退貨 | |
---|---|
String | the mount point or null |
See also:
getMountPointInfo
public abstract ITestDevice.MountPointInfo getMountPointInfo (String mountpoint)
Returns a MountPointInfo
corresponding to the specified mountpoint path, or null
if that path has nothing mounted or otherwise does not appear in /proc/mounts as a mountpoint.
參數 | |
---|---|
mountpoint | String |
退貨 | |
---|---|
ITestDevice.MountPointInfo | A ERROR(/List) of MountPointInfo containing the information in "/proc/mounts" |
Throws | |
---|---|
DeviceNotAvailableException |
See also:
getMountPointInfo
public abstractgetMountPointInfo ()
Returns a parsed version of the information in /proc/mounts on the device
退貨 | |
---|---|
A ERROR(/List) of MountPointInfo containing the information in "/proc/mounts" |
Throws | |
---|---|
DeviceNotAvailableException |
getPartitionFreeSpace
public abstract long getPartitionFreeSpace (String partition)
Helper method to determine amount of free space on device partition.
參數 | |
---|---|
partition | String |
退貨 | |
---|---|
long | the amount of free space in KB |
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
getProcessByName
public abstract ProcessInfo getProcessByName (String processName)
Helper method runs the "pidof" and "stat" command and returns ProcessInfo
object with PID and process start time of the given process.
參數 | |
---|---|
processName | String : the proces name String. |
退貨 | |
---|---|
ProcessInfo | ProcessInfo of given processName |
Throws | |
---|---|
DeviceNotAvailableException |
getProcessPid
public abstract String getProcessPid (String process)
Returns the pid of the service or null if something went wrong.
參數 | |
---|---|
process | String : The proces name String. |
退貨 | |
---|---|
String |
Throws | |
---|---|
DeviceNotAvailableException |
getProductType
public abstract String getProductType ()
Convenience method to get the product type of this device.
This method will work if device is in either adb or fastboot mode.退貨 | |
---|---|
String | the String product type name. Will not be null |
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered, or if product type can not be determined |
getProductVariant
public abstract String getProductVariant ()
Convenience method to get the product variant of this device.
This method will work if device is in either adb or fastboot mode.退貨 | |
---|---|
String | the String product variant name or null if it cannot be determined |
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
getProperty
public abstract String getProperty (String name)
Retrieve the given property value from the device.
參數 | |
---|---|
name | String : the property name |
退貨 | |
---|---|
String | the property value or null if it does not exist |
Throws | |
---|---|
DeviceNotAvailableException |
getRecoveryMode
public abstract ITestDevice.RecoveryMode getRecoveryMode ()
Get the current recovery mode used for the device.
退貨 | |
---|---|
ITestDevice.RecoveryMode | the current recovery mode used for the device. |
getSerialNumber
public abstract String getSerialNumber ()
Convenience method to get serial number of this device.
退貨 | |
---|---|
String | the String serial number |
getTombstones
public abstractgetTombstones ()
Fetch and return the list of tombstones from the devices. Requires root.
method is best-effort so if one tombstone fails to be pulled for any reason it will be missing from the list. Only a DeviceNotAvailableException
will terminate the method early.
退貨 | |
---|---|
A list of tombstone files, empty if no tombstone. |
Throws | |
---|---|
DeviceNotAvailableException |
See also:
getTotalMemory
public abstract long getTotalMemory ()
Returns total physical memory size in bytes or -1 in case of internal error
退貨 | |
---|---|
long |
getUseFastbootErase
public abstract boolean getUseFastbootErase ()
Get whether to use fastboot erase or fastboot format to wipe a partition on the device.
退貨 | |
---|---|
boolean | true if fastboot erase will be used or false if fastboot format will be used. |
See also:
isAdbRoot
public abstract boolean isAdbRoot ()
退貨 | |
---|---|
boolean | true if device currently has adb root, false otherwise. |
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
isAdbTcp
public abstract boolean isAdbTcp ()
退貨 | |
---|---|
boolean | true if device is connected to adb-over-tcp, false otherwise. |
isAppEnumerationSupported
public abstract boolean isAppEnumerationSupported ()
Check whether platform on device supports app enumeration
退貨 | |
---|---|
boolean | True if app enumeration is supported, false otherwise |
Throws | |
---|---|
DeviceNotAvailableException |
isDeviceEncrypted
public abstract boolean isDeviceEncrypted ()
Returns if the device is encrypted.
退貨 | |
---|---|
boolean | true if the device is encrypted. |
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
isDirectory
public abstract boolean isDirectory (String deviceFilePath)
Return True if the path on the device is a directory, false otherwise.
參數 | |
---|---|
deviceFilePath | String |
退貨 | |
---|---|
boolean |
Throws | |
---|---|
DeviceNotAvailableException |
isEncryptionSupported
public abstract boolean isEncryptionSupported ()
Returns if encryption is supported on the device.
退貨 | |
---|---|
boolean | true if the device supports encryption. |
Throws | |
---|---|
DeviceNotAvailableException |
isExecutable
public abstract boolean isExecutable (String fullPath)
Returns True if the file path on the device is an executable file, false otherwise.
參數 | |
---|---|
fullPath | String |
退貨 | |
---|---|
boolean |
Throws | |
---|---|
DeviceNotAvailableException |
isHeadless
public abstract boolean isHeadless ()
Return true if the device is headless (no screen), false otherwise.
退貨 | |
---|---|
boolean |
Throws | |
---|---|
DeviceNotAvailableException |
isRuntimePermissionSupported
public abstract boolean isRuntimePermissionSupported ()
Check whether platform on device supports runtime permission granting
退貨 | |
---|---|
boolean | True if runtime permission are supported, false otherwise. |
Throws | |
---|---|
DeviceNotAvailableException |
isStateBootloaderOrFastbootd
public abstract boolean isStateBootloaderOrFastbootd ()
Returns true if device is in TestDeviceState#FASTBOOT
or TestDeviceState.FASTBOOTD
.
退貨 | |
---|---|
boolean |
logAnrs
public abstract boolean logAnrs (ITestLogger logger)
Collects and log ANRs from the device.
參數 | |
---|---|
logger | ITestLogger : an ITestLogger to log the ANRs. |
退貨 | |
---|---|
boolean | True if the logging was successful, false otherwise. |
Throws | |
---|---|
DeviceNotAvailableException |
logBugreport
public abstract boolean logBugreport (String dataName, ITestLogger listener)
Helper method to take a bugreport and log it to the reporters.
參數 | |
---|---|
dataName | String : name under which the bugreport will be reported. |
listener | ITestLogger : an ITestLogger to log the bugreport. |
退貨 | |
---|---|
boolean | True if the logging was successful, false otherwise. |
logOnDevice
public abstract void logOnDevice (String tag, Log.LogLevel level, String format, Object... args)
Log a message in the logcat of the device. This is a safe call that will not throw even if the logging fails.
參數 | |
---|---|
tag | String : The tag under which we log our message in the logcat. |
level | Log.LogLevel : The debug level of the message in the logcat. |
format | String : The message format. |
args | Object : the args to be replaced via String.format(). |
nonBlockingReboot
public abstract void nonBlockingReboot ()
Issues a command to reboot device and returns on command complete and when device is no longer visible to adb.
Throws | |
---|---|
DeviceNotAvailableException |
postBootSetup
public abstract void postBootSetup ()
Perform instructions to configure device for testing that after every boot.
Should be called after device is fully booted/available In normal circumstances this method doesn't need to be called explicitly, as implementations should perform these steps automatically when performing a reboot. Where it may need to be called is when device reboots due to other events (eg when a fastboot update command has completed)Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
postInvocationTearDown
public void postInvocationTearDown ()
This method is deprecated.
Use postInvocationTearDown(Throwable)
instead.
Extra steps for device specific required clean up that will be executed after the invocation is done.
postInvocationTearDown
public abstract void postInvocationTearDown (Throwable invocationException)
Extra steps for device specific required clean up that will be executed after the invocation is done.
參數 | |
---|---|
invocationException | Throwable : if any, the final exception raised by the invocation failure. |
preInvocationSetup
public void preInvocationSetup (IBuildInfo info, MultiMap<String, String> attributes)
Extra steps for device specific required setup that will be executed on the device prior to the invocation flow.
參數 | |
---|---|
info | IBuildInfo : The IBuildInfo of the device. |
attributes | MultiMap : The attributes stored in the invocation context |
Throws | |
---|---|
| com.android.tradefed.targetprep.TargetSetupError |
DeviceNotAvailableException | |
TargetSetupError |
pullDir
public abstract boolean pullDir (String deviceFilePath, File localDir)
Recursively pull directory contents from device.
參數 | |
---|---|
deviceFilePath | String : the absolute file path of the remote source |
localDir | File : the local directory to pull files into |
退貨 | |
---|---|
boolean | true if file was pulled successfully. false otherwise. |
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
pullFile
public abstract File pullFile (String remoteFilePath, int userId)
Retrieves a file off device, stores it in a local temporary ERROR(/File)
, and returns that File
.
參數 | |
---|---|
remoteFilePath | String : the absolute path to file on device. |
userId | int : The user id to pull from |
退貨 | |
---|---|
File | A ERROR(/File) containing the contents of the device file, or null if the copy failed for any reason (including problems with the host filesystem) |
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
pullFile
public abstract File pullFile (String remoteFilePath)
Retrieves a file off device, stores it in a local temporary ERROR(/File)
, and returns that File
.
參數 | |
---|---|
remoteFilePath | String : the absolute path to file on device. |
退貨 | |
---|---|
File | A ERROR(/File) containing the contents of the device file, or null if the copy failed for any reason (including problems with the host filesystem) |
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
pullFile
public abstract boolean pullFile (String remoteFilePath, File localFile)
Retrieves a file off device.
參數 | |
---|---|
remoteFilePath | String : the absolute path to file on device. |
localFile | File : the local file to store contents in. If non-empty, contents will be replaced. |
退貨 | |
---|---|
boolean | true if file was retrieved successfully. false otherwise. |
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
pullFile
public abstract boolean pullFile (String remoteFilePath, File localFile, int userId)
Retrieves a file off device.
參數 | |
---|---|
remoteFilePath | String : the absolute path to file on device. |
localFile | File : the local file to store contents in. If non-empty, contents will be replaced. |
userId | int : The user id to pull from |
退貨 | |
---|---|
boolean | true if file was retrieved successfully. false otherwise. |
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
pullFileContents
public abstract String pullFileContents (String remoteFilePath)
Retrieves a file off device, and returns the contents.
參數 | |
---|---|
remoteFilePath | String : the absolute path to file on device. |
退貨 | |
---|---|
String | A String containing the contents of the device file, or null if the copy failed for any reason (including problems with the host filesystem) |
Throws | |
---|---|
DeviceNotAvailableException |
pullFileFromExternal
public abstract File pullFileFromExternal (String remoteFilePath)
A convenience method to retrieve a file from the device's external storage, stores it in a local temporary ERROR(/File)
, and return a reference to that File
.
參數 | |
---|---|
remoteFilePath | String : the path to file on device, relative to the device's external storage mountpoint |
退貨 | |
---|---|
File | A ERROR(/File) containing the contents of the device file, or null if the copy failed for any reason (including problems with the host filesystem) |
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
pushDir
public abstract boolean pushDir (File localDir, String deviceFilePath,excludedDirectories)
Recursively push directory contents to device while excluding some directories that are filtered.
參數 | |
---|---|
localDir | File : the local directory to push |
deviceFilePath | String : the absolute file path of the remote destination |
excludedDirectories |
退貨 | |
---|---|
boolean | true if file was pushed successfully. false otherwise. |
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
pushDir
public abstract boolean pushDir (File localDir, String deviceFilePath)
Recursively push directory contents to device.
參數 | |
---|---|
localDir | File : the local directory to push |
deviceFilePath | String : the absolute file path of the remote destination |
退貨 | |
---|---|
boolean | true if file was pushed successfully. false otherwise. |
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
pushFile
public abstract boolean pushFile (File localFile, String deviceFilePath, boolean evaluateContentProviderNeeded)
Variant of pushFile(File, String)
which can optionally consider evaluating the need for the content provider.
參數 | |
---|---|
localFile | File : the local file to push |
deviceFilePath | String : the remote destination absolute file path |
evaluateContentProviderNeeded | boolean : whether to check if we need the content provider |
退貨 | |
---|---|
boolean | true if file was pushed successfully. false otherwise. |
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
pushFile
public abstract boolean pushFile (File localFile, String deviceFilePath)
Push a file to device. By default using a content provider.
參數 | |
---|---|
localFile | File : the local file to push |
deviceFilePath | String : the remote destination absolute file path |
退貨 | |
---|---|
boolean | true if file was pushed successfully. false otherwise. |
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
pushString
public abstract boolean pushString (String contents, String deviceFilePath)
Push file created from a string to device
參數 | |
---|---|
contents | String : the contents of the file to push |
deviceFilePath | String : the remote destination absolute file path |
退貨 | |
---|---|
boolean | true if string was pushed successfully. false otherwise. |
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
reboot
public abstract void reboot ()
Reboots the device into adb mode.
Blocks until device becomes available.Throws | |
---|---|
DeviceNotAvailableException | if device is not available after reboot |
reboot
public abstract void reboot (String reason)
Reboots the device into adb mode with given reason
to be persisted across reboot.
Blocks until device becomes available.
Last reboot reason can be obtained by querying sys.boot.reason
propety.
參數 | |
---|---|
reason | String : a reason for this reboot, or null if no reason is specified. |
Throws | |
---|---|
DeviceNotAvailableException | if device is not available after reboot |
rebootIntoBootloader
public abstract void rebootIntoBootloader ()
Reboots the device into bootloader mode.
Blocks until device is in bootloader mode.Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
rebootIntoFastbootd
public abstract void rebootIntoFastbootd ()
Reboots the device into fastbootd mode.
Blocks until device is in fastbootd mode.
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
rebootIntoRecovery
public abstract void rebootIntoRecovery ()
Reboots the device into adb recovery mode.
Blocks until device enters recoveryThrows | |
---|---|
DeviceNotAvailableException | if device is not available after reboot |
rebootIntoSideload
public abstract void rebootIntoSideload (boolean autoReboot)
Reboots the device into adb sideload mode (note that this is a special mode under recovery)
Blocks until device enters sideload mode
參數 | |
---|---|
autoReboot | boolean : whether to automatically reboot the device after sideload |
Throws | |
---|---|
DeviceNotAvailableException | if device is not in sideload after reboot |
rebootIntoSideload
public abstract void rebootIntoSideload ()
Reboots the device into adb sideload mode (note that this is a special mode under recovery)
Blocks until device enters sideload mode
Throws | |
---|---|
DeviceNotAvailableException | if device is not in sideload after reboot |
rebootUntilOnline
public abstract void rebootUntilOnline ()
An alternate to reboot()
that only blocks until device is online ie visible to adb.
Throws | |
---|---|
DeviceNotAvailableException | if device is not available after reboot |
rebootUntilOnline
public abstract void rebootUntilOnline (String reason)
An alternate to reboot()
that only blocks until device is online ie visible to adb.
參數 | |
---|---|
reason | String : a reason for this reboot, or null if no reason is specified. |
Throws | |
---|---|
DeviceNotAvailableException | if device is not available after reboot |
See also:
rebootUserspace
public abstract void rebootUserspace ()
Reboots only userspace part of device.
Blocks until device becomes available.
WARNING. Userspace reboot is currently under active development, use it on your own risk.
Throws | |
---|---|
DeviceNotAvailableException | if device is not available after reboot |
rebootUserspaceUntilOnline
public abstract void rebootUserspaceUntilOnline ()
An alternate to rebootUserspace()
()} that only blocks until device is online ie visible to adb.
Throws | |
---|---|
DeviceNotAvailableException | if device is not available after reboot |
remountSystemWritable
public abstract void remountSystemWritable ()
Make the system partition on the device writable. May reboot the device.
Throws | |
---|---|
DeviceNotAvailableException |
remountVendorWritable
public abstract void remountVendorWritable ()
Make the vendor partition on the device writable. May reboot the device.
Throws | |
---|---|
DeviceNotAvailableException |
runInstrumentationTests
public abstract boolean runInstrumentationTests (IRemoteAndroidTestRunner runner, ITestLifeCycleReceiver... listeners)
Convenience method for performing ERROR(/#runInstrumentationTests(com.android.ddmlib.testrunner.IRemoteAndroidTestRunner,Collection))
with one or more listeners passed as parameters.
參數 | |
---|---|
runner | IRemoteAndroidTestRunner : the IRemoteAndroidTestRunner which runs the tests |
listeners | ITestLifeCycleReceiver : the test result listener(s) |
退貨 | |
---|---|
boolean | true if test command completed. false if it failed to complete, but recovery succeeded |
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. ie test command failed to complete and recovery failed. |
runInstrumentationTests
public abstract boolean runInstrumentationTests (IRemoteAndroidTestRunner runner,listeners)
Runs instrumentation tests, and provides device recovery.
If connection with device is lost before test run completes, and recovery succeeds, all listeners will be informed of testRunFailed and "false" will be returned. The test command will not be rerun. It is left to callers to retry if necessary.
If connection with device is lost before test run completes, and recovery fails, all listeners will be informed of testRunFailed and DeviceNotAvailableException will be thrown.
參數 | |
---|---|
runner | IRemoteAndroidTestRunner : the IRemoteAndroidTestRunner which runs the tests |
listeners |
退貨 | |
---|---|
boolean | true if test command completed. false if it failed to complete due to device communication exception, but recovery succeeded |
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. ie test command failed to complete and recovery failed. |
runInstrumentationTestsAsUser
public abstract boolean runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId, ITestLifeCycleReceiver... listeners)
Same as ITestDevice#runInstrumentationTests(IRemoteAndroidTestRunner, ITestLifeCycleReceiver...)
but runs the test for a given user.
參數 | |
---|---|
runner | IRemoteAndroidTestRunner |
userId | int |
listeners | ITestLifeCycleReceiver |
退貨 | |
---|---|
boolean |
Throws | |
---|---|
DeviceNotAvailableException |
runInstrumentationTestsAsUser
public abstract boolean runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId,listeners)
Same as ERROR(ITestDevice#runInstrumentationTests(IRemoteAndroidTestRunner, Collection)/com.android.tradefed.device.ITestDevice#runInstrumentationTests(com.android.ddmlib.testrunner.IRemoteAndroidTestRunner,Collection) ITestDevice#runInstrumentationTests(IRemoteAndroidTestRunner, Collection))
but runs the test for the given user.
參數 | |
---|---|
runner | IRemoteAndroidTestRunner |
userId | int |
listeners |
退貨 | |
---|---|
boolean |
Throws | |
---|---|
DeviceNotAvailableException |
setDate
public abstract void setDate (Date date)
Sets the date on device
Note: setting date on device requires root
參數 | |
---|---|
date | Date : specify a particular date; will use host date if null |
Throws | |
---|---|
DeviceNotAvailableException |
setOptions
public abstract void setOptions (TestDeviceOptions options)
Set the TestDeviceOptions
for the device
參數 | |
---|---|
options | TestDeviceOptions |
setProperty
public abstract boolean setProperty (String propKey, String propValue)
Sets the given property value on the device. Requires adb root is true.
參數 | |
---|---|
propKey | String : The key targeted to be set. |
propValue | String : The property value to be set. |
退貨 | |
---|---|
boolean | returns True if the setprop command was successful, False otherwise. |
Throws | |
---|---|
DeviceNotAvailableException |
setRecovery
public abstract void setRecovery (IDeviceRecovery recovery)
Set the IDeviceRecovery
to use for this device. Should be set when device is first allocated.
參數 | |
---|---|
recovery | IDeviceRecovery : the IDeviceRecovery |
setRecoveryMode
public abstract void setRecoveryMode (ITestDevice.RecoveryMode mode)
Set the current recovery mode to use for the device.
Used to control what recovery method to use when a device communication problem is encountered. Its recommended to only use this method sparingly when needed (for example, when framework is down, etc參數 | |
---|---|
mode | ITestDevice.RecoveryMode : whether 'recover till online only' mode should be on or not. |
setUseFastbootErase
public abstract void setUseFastbootErase (boolean useFastbootErase)
Set whether to use fastboot erase or fastboot format to wipe a partition on the device.
參數 | |
---|---|
useFastbootErase | boolean : true if fastboot erase should be used or false if fastboot format should be used. |
See also:
startLogcat
public abstract void startLogcat ()
Start capturing logcat output from device in the background.
Will have no effect if logcat output is already being captured. Data can be later retrieved via getLogcat. When the device is no longer in use,stopLogcat()
must be called. startLogcat()
and stopLogcat()
do not normally need to be called when within a TF invocation context, as the TF framework will start and stop logcat.stopEmulatorOutput
public abstract void stopEmulatorOutput ()
Close and delete the emulator output.
stopLogcat
public abstract void stopLogcat ()
Stop capturing logcat output from device, and discard currently saved logcat data.
Will have no effect if logcat output is not being captured.switchToAdbTcp
public abstract String switchToAdbTcp ()
Switch device to adb-over-tcp mode.
退貨 | |
---|---|
String | the tcp serial number or null if device could not be switched |
Throws | |
---|---|
DeviceNotAvailableException |
switchToAdbUsb
public abstract boolean switchToAdbUsb ()
Switch device to adb over usb mode.
退貨 | |
---|---|
boolean | true if switch was successful, false otherwise. |
Throws | |
---|---|
DeviceNotAvailableException |
syncFiles
public abstract boolean syncFiles (File localFileDir, String deviceFilePath)
Incrementally syncs the contents of a local file directory to device.
Decides which files to push by comparing timestamps of local files with their remote equivalents. Only 'newer' or non-existent files will be pushed to device. Thus overhead should be relatively small if file set on device is already up to date. Hidden files (with names starting with ".") will be ignored. Example usage: syncFiles("/tmp/files", "/sdcard") will created a /sdcard/files directory if it doesn't already exist, and recursively push the /tmp/files contents to /sdcard/files.參數 | |
---|---|
localFileDir | File : the local file directory containing files to recursively push. |
deviceFilePath | String : the remote destination absolute file path root. All directories in thos file path must be readable. ie pushing to /data/local/tmp when adb is not root will fail |
退貨 | |
---|---|
boolean | true if files were synced successfully. false otherwise. |
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
takeBugreport
public abstract Bugreport takeBugreport ()
Take a bugreport and returns it inside a Bugreport
object to handle it. Return null in case of issue.
Bugreport#close()
.退貨 | |
---|---|
Bugreport |
unlockDevice
public abstract boolean unlockDevice ()
Unlocks the device if the device is in an encrypted state.
This method may restart the framework but will not callpostBootSetup()
. Therefore, the device might not be fully ready to be tested when this method returns.退貨 | |
---|---|
boolean | true if successful or if the device is unencrypted. |
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
UnsupportedOperationException | if encryption is not supported on the device. |
waitForBootComplete
public abstract boolean waitForBootComplete (long timeOut)
Blocks until the device's boot complete flag is set.
參數 | |
---|---|
timeOut | long : time in msecs to wait for the flag to be set |
退貨 | |
---|---|
boolean | true if device's boot complete flag is set within the timeout |
Throws | |
---|---|
DeviceNotAvailableException |
waitForDeviceAvailable
public abstract boolean waitForDeviceAvailable ()
Waits for the device to be responsive and available for testing. Uses default timeout.
退貨 | |
---|---|
boolean | True if device is available, False if recovery is disabled and unavailable. |
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
waitForDeviceAvailable
public abstract boolean waitForDeviceAvailable (long waitTime)
Waits for the device to be responsive and available for testing.
參數 | |
---|---|
waitTime | long : the time in ms to wait |
退貨 | |
---|---|
boolean | True if device is available, False if recovery is disabled and unavailable. |
Throws | |
---|---|
DeviceNotAvailableException | if device is still unresponsive after waitTime expires. |
waitForDeviceBootloader
public abstract void waitForDeviceBootloader ()
Blocks until device is visible via fastboot. Use default timeout.
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
waitForDeviceInRecovery
public abstract boolean waitForDeviceInRecovery (long waitTime)
Blocks for the device to be in the 'adb recovery' state (note this is distinct from IDeviceRecovery
).
參數 | |
---|---|
waitTime | long : the time in ms to wait |
退貨 | |
---|---|
boolean | true if device boots into recovery before time expires. false otherwise |
waitForDeviceInSideload
public abstract boolean waitForDeviceInSideload (long waitTime)
Blocks for the device to be in the 'adb sideload' state
參數 | |
---|---|
waitTime | long : the time in ms to wait |
退貨 | |
---|---|
boolean | true if device boots into sideload before time expires. false otherwise |
waitForDeviceNotAvailable
public abstract boolean waitForDeviceNotAvailable (long waitTime)
Blocks for the device to be not available ie missing from adb
參數 | |
---|---|
waitTime | long : the time in ms to wait |
退貨 | |
---|---|
boolean | true if device becomes not available before time expires. false otherwise |
waitForDeviceOnline
public abstract void waitForDeviceOnline ()
Blocks until device is visible via adb. Uses default timeout
Note the device may not necessarily be responsive to commands on completion. UsewaitForDeviceAvailable()
instead.Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
waitForDeviceOnline
public abstract void waitForDeviceOnline (long waitTime)
Blocks until device is visible via adb.
Note the device may not necessarily be responsive to commands on completion. UsewaitForDeviceAvailable()
instead.參數 | |
---|---|
waitTime | long : the time in ms to wait |
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
waitForDeviceShell
public abstract boolean waitForDeviceShell (long waitTime)
Waits for device to be responsive to a basic adb shell command.
參數 | |
---|---|
waitTime | long : the time in ms to wait |
退貨 | |
---|---|
boolean | true if device becomes responsive before waitTime elapses. |