INativeDevice
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 | disableAdbRoot () 關閉adb根目錄。 |
abstract boolean | doesFileExist (String deviceFilePath) 確定設備上文件是否存在的輔助方法。 |
abstract boolean | enableAdbRoot () 打開adb根目錄。 |
abstract boolean | encryptDevice (boolean inplace) 加密設備。 |
abstract String | executeAdbCommand (String... commandArgs) 將adb命令作為系統命令執行的Helper方法。 |
abstract CommandResult | executeFastbootCommand (String... commandArgs) 幫助程序方法,將fastboot命令作為系統命令執行,默認超時為2分鐘。 |
abstract CommandResult | executeFastbootCommand (long timeout, String... commandArgs) 將fastboot命令作為系統命令執行的Helper方法。 |
abstract CommandResult | executeLongFastbootCommand (String... commandArgs) 將長時間運行的fastboot命令作為系統命令執行的Helper方法。 |
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命令,並以適當填充命令狀態輸出stdout和stderr的 |
abstract CommandResult | executeShellV2Command (String command, OutputStream pipeToOutput) Helper方法,該方法執行adb shell命令,並將結果作為 |
abstract CommandResult | executeShellV2Command (String command, File pipeAsInput) Helper方法,該方法執行adb shell命令,並將結果作為 |
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 | fastbootWipePartition (String partition) 擦除設備分區的輔助方法。 |
abstract int | getApiLevel () 獲取設備API級別。 |
abstract String | getBasebandVersion () 獲取此設備的基帶(無線電)版本的便捷方法。 |
abstract Integer | getBattery () 返回設備的當前電池電量;如果電池電量不可用,則返回Null。 |
abstract String | getBootloaderVersion () 獲取此設備的引導程序版本的便捷方法。 |
abstract InputStreamSource | getBugreport () 從設備檢索錯誤報告。 |
abstract InputStreamSource | getBugreportz () 從設備檢索錯誤報告。 |
abstract String | getBuildAlias () 檢索設備當前正在運行的內部版本的別名。 |
abstract String | getBuildFlavor () 檢索設備的構建味道。 |
abstract String | getBuildId () 檢索設備當前正在運行的版本。 |
abstract String | getBuildSigningKeys () 返回用於簽署設備映像的密鑰類型 通常,Android設備可能會使用測試鍵(如AOSP中的簽名)或釋放鍵(由各個設備製造商控制)進行簽名 |
abstract String[] | getChildren (String deviceFilePath) 替代使用 |
abstract String | getDeviceClass () 獲取設備類。 |
abstract long | getDeviceDate () 返回設備的日期,以毫秒為單位。 |
abstract DeviceDescriptor | getDeviceDescriptor () 從設備信息返回 |
abstract TestDeviceState | getDeviceState () 獲取設備的狀態。 |
abstract long | getDeviceTimeOffset (Date date) 幫助程序獲取設備與給定 |
abstract InputStreamSource | getEmulatorOutput () 獲取模擬器stdout和stderr的流 |
abstract long | getExternalStoreFreeSpace () 確定設備外部存儲上可用空間量的輔助方法。 |
abstract String | getFastbootProductType () 在快速啟動模式下獲取此設備產品類型的便捷方法。 |
abstract String | getFastbootProductVariant () 在快速啟動模式下獲取此設備產品類型的便捷方法。 |
abstract IFileEntry | getFileEntry (String path) 檢索對設備上遠程文件的引用。 |
abstract IDevice | getIDevice () 返回對關聯的ddmlib |
abstract long | getLastExpectedRebootTimeMillis () 返回自 |
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方法運行“ ps”命令並返回給定進程名稱的USER,PID和NAME。 |
abstract String | getProcessPid (String process) 返回服務的pid;如果出現問題,則返回null。 |
abstract | getProcesses () Helper方法運行“ ps”命令並返回所有進程的USER,PID和NAME的列表。 |
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擦除或fastboot格式擦除設備上的分區。 |
abstract boolean | isAdbRoot () |
abstract boolean | isAdbTcp () |
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 | logBugreport (String dataName, ITestLogger listener) 進行錯誤報告並將其記錄到報告程序的助手方法。 |
abstract void | logOnDevice (String tag, Log.LogLevel level, String format, Object... args) 在設備的日誌中記錄一條消息。 |
abstract void | nonBlockingReboot () 發出命令以重新引導設備,並在命令完成後以及adb不再可見設備時返回。 |
abstract void | postBootSetup () 執行說明以配置設備以在每次引導後對其進行測試。 |
abstract void | postInvocationTearDown () 特定於設備的所需額外清理步驟將在調用完成後執行。 |
abstract void | preInvocationSetup ( IBuildInfo info) 設備特定的必需設置的額外步驟將在調用流程之前在設備上執行。 |
default void | preInvocationSetup ( IBuildInfo info, testResourceBuildInfos) preInvocationSetup ( IBuildInfo info, testResourceBuildInfos) 設備特定的必需設置的額外步驟將在調用流程之前在設備上執行。 |
abstract boolean | pullDir (String deviceFilePath, File localDir) 從設備遞歸提取目錄內容。 |
abstract File | pullFile (String remoteFilePath) 從設備上檢索文件,將其存儲在本地臨時 |
abstract boolean | pullFile (String remoteFilePath, File localFile) 從設備上檢索文件。 |
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) 將文件推送到設備 |
abstract boolean | pushString (String contents, String deviceFilePath) 將從字符串創建的文件推送到設備 |
abstract void | reboot () 將設備重新引導到adb模式。 |
abstract void | rebootIntoBootloader () 將設備重新引導到引導加載程序模式。 |
abstract void | rebootIntoRecovery () 將設備重新引導到adb恢復模式。 |
abstract void | rebootUntilOnline () 一個 |
abstract void | remountSystemWritable () 使設備上的系統分區可寫。 |
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擦除還是fastboot格式擦除設備上的分區。 |
abstract void | startLogcat () 開始在後台捕獲設備的logcat輸出。 |
abstract void | stopEmulatorOutput () 關閉並刪除仿真器輸出。 |
abstract void | stopLogcat () 停止捕獲設備的logcat輸出,並丟棄當前保存的logcat數據。 |
abstract String | switchToAdbTcp () 將設備切換到adb-over-tcp模式。 |
abstract boolean | switchToAdbUsb () 通過USB模式將設備切換到adb。 |
abstract boolean | syncFiles (File localFileDir, String deviceFilePath) 將本地文件目錄的內容增量同步到設備。 |
abstract Bugreport | takeBugreport () 進行一個錯誤報告,並將其返回到 |
abstract boolean | unencryptDevice () 解密設備。 |
abstract boolean | unlockDevice () 如果設備處於加密狀態,則解鎖設備。 |
abstract boolean | waitForBootComplete (long timeOut) 阻塞,直到設置了設備的啟動完成標誌。 |
abstract void | waitForDeviceAvailable () 等待設備響應並可以進行測試。 |
abstract void | waitForDeviceAvailable (long waitTime) 等待設備響應並可以進行測試。 |
abstract boolean | waitForDeviceInRecovery (long waitTime) 阻止設備處於“ adb恢復”狀態(請注意,這與 |
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 | 如果支持級別,則為True。否則為假。 |
投擲 | |
---|---|
DeviceNotAvailableException |
clearLogcat
public abstract void clearLogcat ()
刪除任何累積的logcat數據。
當您要確保ITestDevice#getLogcat()
僅返回在特定時間點之後生成的日誌數據時(例如在刷新新設備版本後等),這很有用。刪除文件
public abstract void deleteFile (String deviceFilePath)
刪除設備上文件或目錄的輔助方法。
參量 | |
---|---|
deviceFilePath | String :設備上文件的絕對路徑。 |
投擲 | |
---|---|
DeviceNotAvailableException |
disableAdbRoot
public abstract boolean disableAdbRoot ()
關閉adb根目錄。
禁用adb root可能會導致設備與adb斷開連接。該方法將阻塞,直到設備可用。退貨 | |
---|---|
boolean | 如果成功,則為true 。 |
投擲 | |
---|---|
DeviceNotAvailableException | 與設備的連接丟失並且無法恢復。 |
didFileExist
public abstract boolean doesFileExist (String deviceFilePath)
確定設備上文件是否存在的輔助方法。
參量 | |
---|---|
deviceFilePath | String :要檢查的設備上文件的絕對路徑 |
退貨 | |
---|---|
boolean | 如果文件存在則為true ,否則為false 。 |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失並且無法恢復。 |
enableAdbRoot
public abstract boolean enableAdbRoot ()
打開adb根目錄。如果“ enable-root”設置為“ false”,將記錄一條消息並返回而不啟用root。
啟用adb root可能會導致設備與adb斷開連接。該方法將阻塞,直到設備可用。退貨 | |
---|---|
boolean | 如果成功,則為true 。 |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失並且無法恢復。 |
cryptoDevice
public abstract boolean encryptDevice (boolean inplace)
加密設備。
可以對設備進行加密或就地擦除。就地加密不會擦除設備上的任何數據,但通常比擦除要長幾個數量級。如果該設備尚未加密,則此方法將重新啟動設備,並在設備聯機之前將其阻止。此外,重啟後它不會解密設備。因此,當此方法返回時,設備可能未完全啟動和/或未準備好進行測試。參量 | |
---|---|
inplace | boolean :如果加密過程應該就位並且不應擦除設備。 |
退貨 | |
---|---|
boolean | 如果成功,則為true 。 |
投擲 | |
---|---|
DeviceNotAvailableException | 如果重啟後設備不可用。 |
UnsupportedOperationException | 如果設備不支持加密。 |
executeAdbCommand
public abstract String executeAdbCommand (String... commandArgs)
將adb命令作為系統命令執行的Helper方法。
應盡可能使用executeShellCommand(String)
代替,因為該方法可提供更好的故障檢測和性能。參量 | |
---|---|
commandArgs | String :adb命令和要運行的參數 |
退貨 | |
---|---|
String | 命令的標準輸出。如果命令執行失敗,則返回null 。 |
投擲 | |
---|---|
DeviceNotAvailableException | 與設備的連接丟失並且無法恢復。 |
executeFastbootCommand
public abstract CommandResult executeFastbootCommand (String... commandArgs)
幫助程序方法,將fastboot命令作為系統命令執行,默認超時為2分鐘。
預計在設備已經處於快速啟動模式時使用。參量 | |
---|---|
commandArgs | String :fastboot命令和要運行的參數 |
退貨 | |
---|---|
CommandResult | 包含命令輸出的CommandResult |
投擲 | |
---|---|
DeviceNotAvailableException | 與設備的連接丟失並且無法恢復。 |
executeFastbootCommand
public abstract CommandResult executeFastbootCommand (long timeout, String... commandArgs)
將fastboot命令作為系統命令執行的Helper方法。
預計在設備已經處於快速啟動模式時使用。參量 | |
---|---|
timeout | long :命令到期前的時間(以毫秒為單位) |
commandArgs | String :fastboot命令和要運行的參數 |
退貨 | |
---|---|
CommandResult | 包含命令輸出的CommandResult |
投擲 | |
---|---|
DeviceNotAvailableException | 與設備的連接丟失並且無法恢復。 |
executeLongFastbootCommand
public abstract CommandResult executeLongFastbootCommand (String... commandArgs)
將長時間運行的fastboot命令作為系統命令執行的Helper方法。
與executeFastbootCommand(String)
相同,除了使用更長的超時時間。參量 | |
---|---|
commandArgs | String :fastboot命令和要運行的參數 |
退貨 | |
---|---|
CommandResult | 包含命令輸出的CommandResult |
投擲 | |
---|---|
DeviceNotAvailableException | 與設備的連接丟失並且無法恢復。 |
executeShellCommand
public abstract String executeShellCommand (String command)
執行adb shell命令並以String
返回輸出的Helper方法。
參量 | |
---|---|
command | String :要運行的adb shell命令 |
退貨 | |
---|---|
String | 外殼輸出 |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失並且無法恢復。 |
executeShellCommand
public abstract void executeShellCommand (String command, IShellOutputReceiver receiver, long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts)
執行adb shell命令,並使用更多參數來控制命令行為。
參量 | |
---|---|
command | String :要運行的adb shell命令 |
receiver | IShellOutputReceiver :將Shell輸出IShellOutputReceiver 到的IShellOutputReceiver 。 |
maxTimeToOutputShellResponse | long :允許命令不輸出任何響應的最long ; timeUnit 指定的timeUnit |
timeUnit | TimeUnit : maxTimeToOutputShellResponse 單位 |
retryAttempts | int :如果命令由於異常而失敗的最大重試次數。如果執行retryAttempts沒有成功,將引發retryAttempts 。 |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失並且無法恢復。 |
executeShellCommand
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 到的IShellOutputReceiver 。 |
maxTimeoutForCommand | long :命令完成的最大超時; timeUnit 指定的timeUnit |
maxTimeToOutputShellResponse | long :允許命令不輸出任何響應的最long ; timeUnit 指定的timeUnit |
timeUnit | TimeUnit : maxTimeToOutputShellResponse 單位 |
retryAttempts | int :如果命令由於異常而失敗的最大重試次數。如果執行retryAttempts沒有成功,將引發retryAttempts 。 |
投擲 | |
---|---|
DeviceNotAvailableException | 與設備的連接丟失並且無法恢復。 |
executeShellCommand
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 到的IShellOutputReceiver 。 |
投擲 | |
---|---|
DeviceNotAvailableException | 與設備的連接丟失並且無法恢復。 |
executeShellV2Command
public abstract CommandResult executeShellV2Command (String command)
Helper方法,該方法執行adb shell命令並以CommandResult
返回結果,並正確填充命令狀態輸出stdout和stderr。
參量 | |
---|---|
command | String :應運行的命令。 |
退貨 | |
---|---|
CommandResult | CommandResult 的結果。 |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失並且無法恢復。 |
executeShellV2Command
public abstract CommandResult executeShellV2Command (String command, OutputStream pipeToOutput)
Helper方法,該方法執行adb shell命令,並將結果作為CommandResult
返回,並正確填充命令狀態輸出stdout和stderr。
參量 | |
---|---|
command | String :應運行的命令。 |
pipeToOutput | OutputStream : ERROR(/OutputStream) 將在其中重定向標準輸出。 |
退貨 | |
---|---|
CommandResult | CommandResult 的結果。 |
投擲 | |
---|---|
DeviceNotAvailableException | 與設備的連接丟失並且無法恢復。 |
executeShellV2Command
public abstract CommandResult executeShellV2Command (String command, File pipeAsInput)
Helper方法,該方法執行adb shell命令,並將結果作為CommandResult
返回,並正確填充命令狀態輸出stdout和stderr。
參量 | |
---|---|
command | String :應運行的命令。 |
pipeAsInput | File :一個ERROR(/File) ,將通過管道將其作為命令的輸入。 |
退貨 | |
---|---|
CommandResult | CommandResult 的結果。 |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失並且無法恢復。 |
executeShellV2Command
public abstract CommandResult executeShellV2Command (String command, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts)
執行adb shell命令,並使用更多參數來控制命令行為。
參量 | |
---|---|
command | String :要運行的adb shell命令 |
maxTimeoutForCommand | long :命令完成的最大超時; timeUnit 指定的timeUnit |
timeUnit | TimeUnit : maxTimeToOutputShellResponse 單位 |
retryAttempts | int :如果命令由於異常而失敗的最大重試次數。如果執行retryAttempts沒有成功,將引發retryAttempts 。 |
退貨 | |
---|---|
CommandResult |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失並且無法恢復。 |
executeShellV2Command
public abstract CommandResult executeShellV2Command (String command, long maxTimeoutForCommand, TimeUnit timeUnit)
執行adb shell命令,並使用更多參數來控制命令行為。
參量 | |
---|---|
command | String :要運行的adb shell命令 |
maxTimeoutForCommand | long :命令完成的最大超時; timeUnit 指定的timeUnit |
timeUnit | TimeUnit : maxTimeToOutputShellResponse 單位 |
退貨 | |
---|---|
CommandResult |
投擲 | |
---|---|
DeviceNotAvailableException | 與設備的連接丟失並且無法恢復。 |
executeShellV2Command
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) ,將通過管道將其作為命令的輸入。 |
pipeToOutput | OutputStream : ERROR(/OutputStream) 將在其中重定向標準輸出。 |
maxTimeoutForCommand | long :命令完成的最大超時; timeUnit 指定的timeUnit |
timeUnit | TimeUnit : maxTimeToOutputShellResponse 單位 |
retryAttempts | int :如果命令由於異常而失敗的最大重試次數。如果執行retryAttempts沒有成功,將引發retryAttempts 。 |
退貨 | |
---|---|
CommandResult |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失並且無法恢復。 |
fastbootWipePartition
public abstract CommandResult fastbootWipePartition (String partition)
擦除設備分區的輔助方法。
如果getUseFastbootErase()
為true
,則將使用fastboot擦除來擦除分區。然後,設備必須在下次引導時創建文件系統。否則,將使用快速啟動格式,該格式將在設備上創建新的文件系統。預計在設備已經處於快速啟動模式時使用。參量 | |
---|---|
partition | String :要擦除的分區 |
退貨 | |
---|---|
CommandResult | 包含命令輸出的CommandResult |
投擲 | |
---|---|
DeviceNotAvailableException | 與設備的連接丟失並且無法恢復。 |
getApiLevel
public abstract int getApiLevel ()
獲取設備API級別。默認為UNKNOWN_API_LEVEL
。
退貨 | |
---|---|
int | 一個整數,指示設備的API級別 |
投擲 | |
---|---|
DeviceNotAvailableException |
getBasebandVersion
獲取此設備的基帶(無線電)版本的便捷方法。獲取無線電版本是特定於設備的,因此它可能不會為所有設備返回正確的信息。此方法依賴gsm.version.baseband屬性返回正確的版本信息。對於某些CDMA設備,這是不准確的,並且此處返回的版本可能與fastboot報告的版本不匹配,並且可能不會返回CDMA無線電的版本。 TL; DR如果gsm.version.baseband屬性與fastboot getvar version-baseband
返回的版本相同,則此方法僅報告準確的版本。
退貨 | |
---|---|
String | String 基帶版本;如果無法確定,則為null (設備沒有廣播或無法讀取版本字符串) |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失並且無法恢復。 |
getBattery
public abstract Integer getBattery ()
返回設備的當前電池電量;如果電池電量不可用,則返回Null。
退貨 | |
---|---|
Integer |
getBootloaderVersion
public abstract String getBootloaderVersion ()
獲取此設備的引導程序版本的便捷方法。
將嘗試從設備的當前狀態檢索引導加載程序版本。 (即,如果設備處於快速啟動模式,它將嘗試從快速啟動中檢索版本)退貨 | |
---|---|
String | String 引導加載程序版本;如果找不到,則為null |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失並且無法恢復。 |
getBugreport
public abstract InputStreamSource getBugreport ()
從設備檢索錯誤報告。
可以確保在沒有sdcard的設備上(或尚未安裝sdcard的設備)繼續執行此操作。退貨 | |
---|---|
InputStreamSource | 一個InputStreamSource ,它將按需生成錯誤報告內容。如果失敗, InputStreamSource 將產生一個空的ERROR(/InputStream) 。 |
getBugreportz
public abstract InputStreamSource getBugreportz ()
從設備檢索錯誤報告。壓縮格式的bugreport包含主要的bugreport和其他對調試有用的日誌文件。
僅支持“ adb版本”> 1.0.36退貨 | |
---|---|
InputStreamSource | 包含bugreportz的zip文件的InputStreamSource ,如果失敗,則返回null。 |
getBuildAlias
public abstract String getBuildAlias ()
檢索設備當前正在運行的內部版本的別名。
構建別名通常比構建ID(通常是Nexus構建的數字)更具可讀性。例如,最終的Android 4.2版本具有內部別名JDQ39和內部ID 573038
退貨 | |
---|---|
String | 構建別名或如果無法檢索則退回到構建ID |
投擲 | |
---|---|
DeviceNotAvailableException |
getBuildId
public abstract String getBuildId ()
檢索設備當前正在運行的版本。
退貨 | |
---|---|
String | 構建ID或IBuildInfo#UNKNOWN_BUILD_ID 如果無法檢索) |
投擲 | |
---|---|
DeviceNotAvailableException |
getBuildSigningKeys
public abstract String getBuildSigningKeys ()
返回用於簽署設備映像的密鑰類型
通常,Android設備可能會使用測試鍵(如AOSP中的簽名)或釋放鍵(由各個設備製造商控制)進行簽名
退貨 | |
---|---|
String | 如果找到簽名密鑰,則為null。 |
投擲 | |
---|---|
DeviceNotAvailableException |
getChildren
public abstract String[] getChildren (String deviceFilePath)
替代使用IFileEntry
,由於權限的IFileEntry
,有時無法使用。
參量 | |
---|---|
deviceFilePath | String :是設備上進行搜索的路徑 |
退貨 | |
---|---|
String[] | 包含設備路徑中所有文件的字符串數組。 |
投擲 | |
---|---|
DeviceNotAvailableException |
getDeviceDate
public abstract long getDeviceDate ()
返回設備的日期(以紀元為單位),以毫秒為單位。
退貨 | |
---|---|
long | 以日期格式的設備日期。 |
投擲 | |
---|---|
DeviceNotAvailableException |
getDeviceDescriptor
public abstract DeviceDescriptor getDeviceDescriptor ()
從設備信息返回DeviceDescriptor
以獲取有關它的信息,而無需傳遞實際的設備對象。
退貨 | |
---|---|
DeviceDescriptor |
getDeviceTimeOffset
public abstract long getDeviceTimeOffset (Date date)
幫助程序獲取設備與給定ERROR(/Date)
之間的時間差。在內部使用紀元時間。
參量 | |
---|---|
date | Date |
退貨 | |
---|---|
long | 毫秒差 |
投擲 | |
---|---|
DeviceNotAvailableException |
getEmulatorOutput
public abstract InputStreamSource getEmulatorOutput ()
獲取模擬器stdout和stderr的流
退貨 | |
---|---|
InputStreamSource | 仿真器輸出 |
getExternalStoreFreeSpace
public abstract long getExternalStoreFreeSpace ()
確定設備外部存儲上可用空間量的輔助方法。
退貨 | |
---|---|
long | 可用空間量(KB) |
投擲 | |
---|---|
DeviceNotAvailableException | 與設備的連接丟失並且無法恢復。 |
getFastbootProductType
public abstract String getFastbootProductType ()
在快速啟動模式下獲取此設備產品類型的便捷方法。
僅當設備應處於快速啟動狀態時,才應使用此方法。在這種情況下,它比通用的getProductType()
方法更安全一些,因為如果設備處於錯誤狀態或沒有響應,則ITestDevice會知道將設備恢復為快速啟動。退貨 | |
---|---|
String | String 產品類型名稱;如果無法確定,則返回null |
投擲 | |
---|---|
DeviceNotAvailableException | 與設備的連接丟失並且無法恢復。 |
getFastbootProductVariant
public abstract String getFastbootProductVariant ()
在快速啟動模式下獲取此設備產品類型的便捷方法。
僅當設備應處於快速啟動狀態時,才應使用此方法。在這種情況下,它比通用的getProductType()
方法更安全一些,因為如果設備處於錯誤狀態或沒有響應,則ITestDevice會知道將設備恢復為快速啟動。退貨 | |
---|---|
String | String 產品類型名稱;如果無法確定,則返回null |
投擲 | |
---|---|
DeviceNotAvailableException | 與設備的連接丟失並且無法恢復。 |
getFileEntry
public abstract IFileEntry getFileEntry (String path)
檢索對設備上遠程文件的引用。
參量 | |
---|---|
path | String :要檢索的文件路徑。可以是絕對路徑或相對於'/'的路徑。 (即同時支持“ / system”和“ system”語法) |
退貨 | |
---|---|
IFileEntry | IFileEntry 如果找不到指定path下的文件,則IFileEntry null |
投擲 | |
---|---|
DeviceNotAvailableException |
getIDevice
public abstract IDevice getIDevice ()
返回對關聯的ddmlib IDevice
的引用。
IDevice
。因此,調用者不應保留對IDevice
的引用,因為該引用可能會過時。退貨 | |
---|---|
IDevice | IDevice |
getLastExpectedRebootTimeMillis
public abstract long getLastExpectedRebootTimeMillis ()
返回自System.currentTimeMillis()
返回EPOCH以來,Tradefed API上一次觸發重新引導的時間(以毫秒為單位System.currentTimeMillis()
。
退貨 | |
---|---|
long |
getLogcat
public abstract InputStreamSource getLogcat ()
獲取logcat數據的快照流。
在兩種模式下工作:
TestDeviceOptions#getMaxLogcatDataSize()
字節。退貨 | |
---|---|
InputStreamSource |
getLogcat
public abstract InputStreamSource getLogcat (int maxBytes)
捕獲捕獲的logcat數據的最後maxBytes
個快照流。
當您希望捕獲捕獲的logcat數據的頻繁快照而又不會導致獲取整個getLogcat()
快照可能造成較大的磁盤空間損失時,該功能getLogcat()
。
參量 | |
---|---|
maxBytes | int :要返回的最大數據量。應該是可以舒適地容納在內存中的量 |
退貨 | |
---|---|
InputStreamSource |
getLogcatDump
public abstract InputStreamSource getLogcatDump ()
獲取設備的當前logcat的轉儲。與getLogcat()
不同,此方法將始終返回logcat的靜態轉儲。
缺點是如果設備不可達,則不會返回任何內容。
退貨 | |
---|---|
InputStreamSource | logcat數據的InputStreamSource 。如果無法捕獲logcat數據,則返回空流。 |
getLogcatSince
public abstract InputStreamSource getLogcatSince (long date)
從提供的日期開始獲取捕獲的logcat數據的快照流。設備上的時間應使用getDeviceDate()
。
參量 | |
---|---|
date | long :以毫秒為單位,以自從何時開始快照直至出現的時代格式開始。 (可以使用'date +%s'獲得) |
退貨 | |
---|---|
InputStreamSource |
getMountPoint
public abstract String getMountPoint (String mountName)
返回一個掛載點。
如果IDevice
的緩存信息不可用,則直接查詢設備。待辦事項:將此行為移至IDevice#getMountPoint(String)
參量 | |
---|---|
mountName | String :安裝點的名稱 |
退貨 | |
---|---|
String | 掛載點或null |
getMountPointInfo
public abstract ITestDevice.MountPointInfo getMountPointInfo (String mountpoint)
返回與指定的安裝點路徑相對應的MountPointInfo
如果該路徑沒有安裝任何內容,或者否則未在/ proc / mounts中顯示為安裝點,則返回null
。
參量 | |
---|---|
mountpoint | String |
退貨 | |
---|---|
ITestDevice.MountPointInfo | MountPointInfo ERROR(/List) ,其中包含“ / proc / mounts”中的信息 |
投擲 | |
---|---|
DeviceNotAvailableException |
也可以看看:
getMountPointInfo
public abstractgetMountPointInfo ()
返回設備上/ proc / mounts中信息的解析版本
退貨 | |
---|---|
MountPointInfo ERROR(/List) ,其中包含“ / proc / mounts”中的信息 |
投擲 | |
---|---|
DeviceNotAvailableException |
getPartitionFreeSpace
public abstract long getPartitionFreeSpace (String partition)
確定設備分區上可用空間量的輔助方法。
參量 | |
---|---|
partition | String |
退貨 | |
---|---|
long | 可用空間量(KB) |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失並且無法恢復。 |
getProcessByName
public abstract ProcessInfo getProcessByName (String processName)
Helper方法運行“ ps”命令並返回給定進程名稱的USER,PID和NAME。
參量 | |
---|---|
processName | String |
退貨 | |
---|---|
ProcessInfo | 給定processName的ProcessInfo |
投擲 | |
---|---|
DeviceNotAvailableException |
getProcessPid
public abstract String getProcessPid (String process)
返回服務的pid;如果出現問題,則返回null。
參量 | |
---|---|
process | String |
退貨 | |
---|---|
String |
投擲 | |
---|---|
DeviceNotAvailableException |
getProcesses
public abstractgetProcesses ()
Helper方法運行“ ps”命令並返回所有進程的USER,PID和NAME的列表。
退貨 | |
---|---|
ProcessInfo對象列表 |
投擲 | |
---|---|
DeviceNotAvailableException |
getProductType
public abstract String getProductType ()
獲取此設備產品類型的便捷方法。
如果設備處於adb或fastboot模式,則此方法將起作用。退貨 | |
---|---|
String | String 產品類型名稱。不會為空 |
投擲 | |
---|---|
DeviceNotAvailableException | 如果與設備的連接丟失並且無法恢復,或者無法確定產品類型 |
getProductVariant
public abstract String getProductVariant ()
獲取此設備產品變型的便捷方法。
如果設備處於adb或fastboot模式,則此方法將起作用。退貨 | |
---|---|
String | String 產品變體名稱;如果無法確定,則為null |
投擲 | |
---|---|
DeviceNotAvailableException | 與設備的連接丟失並且無法恢復。 |
getProperty
public abstract String getProperty (String name)
從設備檢索給定的屬性值。
參量 | |
---|---|
name | String :屬性名稱 |
退貨 | |
---|---|
String | 屬性值;如果不存在,則返回null |
投擲 | |
---|---|
DeviceNotAvailableException |
getRecoveryMode
public abstract ITestDevice.RecoveryMode getRecoveryMode ()
獲取設備當前使用的恢復模式。
退貨 | |
---|---|
ITestDevice.RecoveryMode | 設備當前使用的恢復模式。 |
getTombstones
public abstractgetTombstones ()
從設備獲取並返回邏輯刪除列表。需要root。
這種方法是盡力而為的,因此,如果出於任何原因未能將一個邏輯刪除,則該邏輯刪除將從列表中丟失。只有DeviceNotAvailableException
會提前終止該方法。
退貨 | |
---|---|
邏輯刪除文件列表,如果沒有邏輯刪除則為空。 |
投擲 | |
---|---|
DeviceNotAvailableException |
也可以看看:
getTotalMemory
public abstract long getTotalMemory ()
返回總的物理內存大小(以字節為單位),如果發生內部錯誤,則返回-1
退貨 | |
---|---|
long |
getUseFastbootErase
public abstract boolean getUseFastbootErase ()
獲取是使用fastboot擦除還是fastboot格式擦除設備上的分區。
退貨 | |
---|---|
boolean | 如果將使用fastboot擦除,則為true 如果將使用fastboot格式,則為false 。 |
isAdbRoot
public abstract boolean isAdbRoot ()
退貨 | |
---|---|
boolean | 如果設備當前具有adb根,則為true ,否則為false 。 |
投擲 | |
---|---|
DeviceNotAvailableException | 與設備的連接丟失並且無法恢復。 |
isAdbTcp
public abstract boolean isAdbTcp ()
退貨 | |
---|---|
boolean | 如果設備連接到adb-over-tcp,則為true ,否則為false 。 |
isDeviceEncrypted
public abstract boolean isDeviceEncrypted ()
返回設備是否已加密。
退貨 | |
---|---|
boolean | 如果設備已加密,則為true 。 |
投擲 | |
---|---|
DeviceNotAvailableException | 與設備的連接丟失並且無法恢復。 |
isDirectory
public abstract boolean isDirectory (String deviceFilePath)
如果設備上的路徑是目錄,則返回True,否則返回false。
參量 | |
---|---|
deviceFilePath | String |
退貨 | |
---|---|
boolean |
投擲 | |
---|---|
DeviceNotAvailableException |
isEncryptionSupported
public abstract boolean isEncryptionSupported ()
返回設備是否支持加密。
退貨 | |
---|---|
boolean | 如果設備支持加密,則為true 。 |
投擲 | |
---|---|
DeviceNotAvailableException |
isExecutable
public abstract boolean isExecutable (String fullPath)
如果設備上的文件路徑是可執行文件,則返回True,否則返回false。
參量 | |
---|---|
fullPath | String |
退貨 | |
---|---|
boolean |
投擲 | |
---|---|
DeviceNotAvailableException |
無頭
public abstract boolean isHeadless ()
如果設備無頭(無屏幕),則返回true,否則返回false。
退貨 | |
---|---|
boolean |
投擲 | |
---|---|
DeviceNotAvailableException |
isRuntimePermissionSupported
public abstract boolean isRuntimePermissionSupported ()
檢查設備上的平台是否支持運行時權限授予
退貨 | |
---|---|
boolean | 如果支持運行時權限,則為true,否則為false。 |
投擲 | |
---|---|
DeviceNotAvailableException |
logBugreport
public abstract boolean logBugreport (String dataName, ITestLogger listener)
進行錯誤報告並將其記錄到報告程序的助手方法。
參量 | |
---|---|
dataName | String :將用來報告錯誤報告的名稱。 |
listener | ITestLogger :用於記錄ITestLogger 的ITestLogger 。 |
退貨 | |
---|---|
boolean | 如果記錄成功,則為True,否則為false。 |
logOnDevice
public abstract void logOnDevice (String tag, Log.LogLevel level, String format, Object... args)
在設備的日誌中記錄一條消息。 This is a safe call that will not throw even if the logging fails.
Parameters | |
---|---|
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 abstract void postInvocationTearDown ()
Extra steps for device specific required clean up that will be executed after the invocation is done.
preInvocationSetup
public abstract void preInvocationSetup (IBuildInfo info)
Extra steps for device specific required setup that will be executed on the device prior to the invocation flow.
Parameters | |
---|---|
info | IBuildInfo |
Throws | |
---|---|
DeviceNotAvailableException | |
TargetSetupError |
preInvocationSetup
public void preInvocationSetup (IBuildInfo info,testResourceBuildInfos)
Extra steps for device specific required setup that will be executed on the device prior to the invocation flow.
Parameters | |
---|---|
info | IBuildInfo |
testResourceBuildInfos |
Throws | |
---|---|
DeviceNotAvailableException | |
TargetSetupError |
pullDir
public abstract boolean pullDir (String deviceFilePath, File localDir)
Recursively pull directory contents from device.
Parameters | |
---|---|
deviceFilePath | String : the absolute file path of the remote source |
localDir | File : the local directory to pull files into |
Returns | |
---|---|
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)
Retrieves a file off device, stores it in a local temporary ERROR(/File)
, and returns that File
.
Parameters | |
---|---|
remoteFilePath | String : the absolute path to file on device. |
Returns | |
---|---|
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.
Parameters | |
---|---|
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. |
Returns | |
---|---|
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.
Parameters | |
---|---|
remoteFilePath | String : the absolute path to file on device. |
Returns | |
---|---|
String | AString 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
.
Parameters | |
---|---|
remoteFilePath | String : the path to file on device, relative to the device's external storage mountpoint |
Returns | |
---|---|
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.
Parameters | |
---|---|
localDir | File : the local directory to push |
deviceFilePath | String : the absolute file path of the remote destination |
excludedDirectories |
Returns | |
---|---|
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.
Parameters | |
---|---|
localDir | File : the local directory to push |
deviceFilePath | String : the absolute file path of the remote destination |
Returns | |
---|---|
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
Parameters | |
---|---|
localFile | File : the local file to push |
deviceFilePath | String : the remote destination absolute file path |
Returns | |
---|---|
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
Parameters | |
---|---|
contents | String : the contents of the file to push |
deviceFilePath | String : the remote destination absolute file path |
Returns | |
---|---|
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 |
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. |
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 |
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 |
remountSystemWritable
public abstract void remountSystemWritable ()
Make the system 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.
Parameters | |
---|---|
runner | IRemoteAndroidTestRunner : the IRemoteAndroidTestRunner which runs the tests |
listeners | ITestLifeCycleReceiver : the test result listener(s) |
Returns | |
---|---|
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.
Parameters | |
---|---|
runner | IRemoteAndroidTestRunner : the IRemoteAndroidTestRunner which runs the tests |
listeners |
Returns | |
---|---|
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.
Parameters | |
---|---|
runner | IRemoteAndroidTestRunner |
userId | int |
listeners | ITestLifeCycleReceiver |
Returns | |
---|---|
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.
Parameters | |
---|---|
runner | IRemoteAndroidTestRunner |
userId | int |
listeners |
Returns | |
---|---|
boolean |
Throws | |
---|---|
DeviceNotAvailableException |
setDate
public abstract void setDate (Date date)
Sets the date on device
Note: setting date on device requires root
Parameters | |
---|---|
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
Parameters | |
---|---|
options | TestDeviceOptions |
setProperty
public abstract boolean setProperty (String propKey, String propValue)
Sets the given property value on the device. Requires adb root is true.
Parameters | |
---|---|
propKey | String : The key targeted to be set. |
propValue | String : The property value to be set. |
Returns | |
---|---|
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.
Parameters | |
---|---|
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, etcParameters | |
---|---|
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.
Parameters | |
---|---|
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.
Returns | |
---|---|
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.
Returns | |
---|---|
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.Parameters | |
---|---|
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 |
Returns | |
---|---|
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()
.Returns | |
---|---|
Bugreport |
unencryptDevice
public abstract boolean unencryptDevice ()
Unencrypts the device.
Unencrypting the device may cause device to be wiped and may reboot device. This method will block until device is available and ready for testing. Requires fastboot inorder to wipe the userdata partition.Returns | |
---|---|
boolean | true if successful. |
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
UnsupportedOperationException | if encryption is not supported on the device. |
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.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.
Parameters | |
---|---|
timeOut | long : time in msecs to wait for the flag to be set |
Returns | |
---|---|
boolean | true if device's boot complete flag is set within the timeout |
Throws | |
---|---|
DeviceNotAvailableException |
waitForDeviceAvailable
public abstract void waitForDeviceAvailable ()
Waits for the device to be responsive and available for testing. Uses default timeout.
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
waitForDeviceAvailable
public abstract void waitForDeviceAvailable (long waitTime)
Waits for the device to be responsive and available for testing.
Parameters | |
---|---|
waitTime | long : the time in ms to wait |
Throws | |
---|---|
DeviceNotAvailableException | if device is still unresponsive after waitTime expires. |
waitForDeviceInRecovery
public abstract boolean waitForDeviceInRecovery (long waitTime)
Blocks for the device to be in the 'adb recovery' state (note this is distinct from IDeviceRecovery
).
Parameters | |
---|---|
waitTime | long : the time in ms to wait |
Returns | |
---|---|
boolean | true if device boots into recovery before time expires. false otherwise |
waitForDeviceNotAvailable
public abstract boolean waitForDeviceNotAvailable (long waitTime)
Blocks for the device to be not available ie missing from adb
Parameters | |
---|---|
waitTime | long : the time in ms to wait |
Returns | |
---|---|
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.Parameters | |
---|---|
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.
Parameters | |
---|---|
waitTime | long : the time in ms to wait |
Returns | |
---|---|
boolean | true if device becomes responsive before waitTime elapses. |