創新設備

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 ProcessInfo進行比較來檢查設備是否軟重啟的輔助方法。

abstract boolean deviceSoftRestartedSince (long utcEpochTime, TimeUnit timeUnit)

檢查設備是否從設備紀元以來的 UTC 時間及其ERROR(/TimeUnit)軟重啟的輔助方法。

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 String executeAdbCommand (long timeout, envMap, String... commandArgs) executeAdbCommand (long timeout, envMap, String... commandArgs)

將 adb 命令作為具有指定超時的系統命令執行的輔助方法。

abstract CommandResult executeFastbootCommand (long timeout, String... commandArgs)

將 fastboot 命令作為系統命令執行的輔助方法。

abstract CommandResult executeFastbootCommand (String... commandArgs)

將 fastboot 命令作為系統命令執行的輔助方法,默認超時為 2 分鐘。

abstract CommandResult executeLongFastbootCommand (String... commandArgs)

將長時間運行的 fastboot 命令作為系統命令執行的輔助方法。

abstract CommandResult executeLongFastbootCommand ( envVarMap, String... commandArgs) executeLongFastbootCommand ( envVarMap, String... commandArgs)

將長時間運行的 fastboot 命令作為具有系統環境變量的系統命令執行的輔助方法。

abstract String executeShellCommand (String command)

執行 adb shell 命令並將輸出作為ERROR(/String)返回的幫助程序方法。

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 命令並將結果作為CommandResult返回的輔助方法,其中正確填充了命令狀態輸出、stdout 和 stderr。

abstract CommandResult executeShellV2Command (String command, OutputStream pipeToOutput)

執行 adb shell 命令並將結果作為CommandResult返回的幫助程序方法,其中正確填充了命令狀態輸出和 stderr。

abstract CommandResult executeShellV2Command (String command, File pipeAsInput)

執行 adb shell 命令並將結果作為CommandResult返回的幫助程序方法,其中正確填充了命令狀態輸出、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 String getBuildAlias ()

檢索設備當前運行的構建的別名。

abstract String getBuildFlavor ()

檢索設備的構建風格。

abstract String getBuildId ()

檢索設備當前正在運行的版本。

abstract String getBuildSigningKeys ()

返回用於簽署設備映像的密鑰類型

通常,Android 設備可能使用測試密鑰(如 AOSP)或發布密鑰(由各個設備製造商控制)進行簽名

abstract DeviceDescriptor getCachedDeviceDescriptor ()

如果分配了設備,則返回緩存的DeviceDescriptor ,否則返回當前的DeviceDescriptor

abstract DeviceDescriptor getCachedDeviceDescriptor (boolean shortDescriptor)

如果分配了設備,則返回緩存的DeviceDescriptor ,否則返回當前的DeviceDescriptor

abstract String[] getChildren (String deviceFilePath)

使用IFileEntry的替代方法有時會因為權限問題而無法工作。

abstract AbstractConnection getConnection ()

返回與設備關聯的連接。

abstract String getDeviceClass ()

獲取設備類。

abstract long getDeviceDate ()

從紀元開始以毫秒為單位返回設備的日期。

abstract DeviceDescriptor getDeviceDescriptor ()

從設備信息中返回一個DeviceDescriptor以獲取有關它的信息,而不傳遞實際的設備對象。

abstract DeviceDescriptor getDeviceDescriptor (boolean shortDescriptor)

從設備信息中返回一個DeviceDescriptor以獲取有關它的信息,而不傳遞實際的設備對象。

abstract TestDeviceState getDeviceState ()

獲取設備的狀態。

abstract long getDeviceTimeOffset (Date date)

幫助獲取設備與給定ERROR(/Date)之間的時差。

abstract InputStreamSource getEmulatorOutput ()

獲取模擬器stdout和stderr的流

abstract long getExternalStoreFreeSpace ()

確定設備外部存儲可用空間量的輔助方法。

abstract String getFastbootProductType ()

在 fastboot 模式下獲取此設備的產品類型的便捷方法。

abstract String getFastbootProductVariant ()

在 fastboot 模式下獲取此設備的產品類型的便捷方法。

abstract String getFastbootSerialNumber ()

返回快速啟動模式序列號。

abstract String getFastbootVariable (String variableName)

從設備中檢索給定的 fastboot 變量值。

abstract IFileEntry getFileEntry (String path)

檢索對設備上遠程文件的引用。

abstract IDevice getIDevice ()

返回對關聯的 ddmlib IDevice引用。

abstract long getIntProperty (String name, long defaultValue)

從設備返回給定屬性的整數值。

abstract long getLastExpectedRebootTimeMillis ()

返回自ERROR(/System#currentTimeMillis())返回的 EPOCH 以來 Tradefed API 上次觸發重啟的毫秒數。

abstract int getLaunchApiLevel ()

獲取設備首次啟動的 API 級別。

abstract InputStreamSource getLogcat ()

獲取 logcat 數據的快照流。

abstract InputStreamSource getLogcat (int maxBytes)

獲取捕獲的 logcat 數據的最後maxBytes的快照流。

abstract InputStreamSource getLogcatDump ()

獲取設備當前 logcat 的轉儲。

abstract InputStreamSource getLogcatSince (long date)

從提供的日期開始獲取捕獲的 logcat 數據的快照流。

abstract String getMountPoint (String mountName)

返回掛載點。

abstract ITestDevice.MountPointInfo getMountPointInfo (String mountpoint)

返回對應於指定掛載點路徑的MountPointInfo ,如果該路徑沒有掛載任何內容或不作為掛載點出現在 /proc/mounts 中,則返回null

abstract getMountPointInfo ()

返回設備上 /proc/mounts 中信息的解析版本

abstract long getPartitionFreeSpace (String partition)

確定設備分區上可用空間量的輔助方法。

abstract ProcessInfo getProcessByName (String processName)

Helper 方法運行“pidof”和“stat”命令並返回具有給定進程的 PID 和進程啟動時間的ProcessInfo對象。

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 format 擦除設備上的分區。

abstract boolean isAdbRoot ()
abstract boolean isAdbTcp ()
abstract boolean isAppEnumerationSupported ()

檢查設備上的平台是否支持應用枚舉

abstract boolean isBypassLowTargetSdkBlockSupported ()

檢查設備上的平台是否支持在應用安裝時繞過低目標 sdk 塊

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 ()

如果設備處於TestDeviceState#FASTBOOTTestDeviceState.FASTBOOTD中,則返回 true。

abstract boolean logAnrs ( ITestLogger logger)

從設備收集和記錄 ANR。

abstract void logOnDevice (String tag, Log.LogLevel level, String format, Object... args)

在設備的 logcat 中記錄一條消息。

abstract void nonBlockingReboot ()

發出命令以重新啟動設備並在命令完成時返回,當設備不再對 adb 可見時。

abstract void postBootSetup ()

執行說明以配置設備以在每次啟動後進行測試。

default void postInvocationTearDown ()

此方法已棄用。請改用postInvocationTearDown(Throwable)

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)

從設備中檢索文件,將其存儲在本地臨時ERROR(/File)中,然後返回該File

abstract File pullFile (String remoteFilePath)

從設備中檢索文件,將其存儲在本地臨時ERROR(/File)中,然後返回該File

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)

從設備的外部存儲中檢索文件的便捷方法,將其存儲在本地臨時ERROR(/File)中,並返回對該File的引用。

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)

pushFile(File, String)的變體,可以選擇考慮評估對內容提供者的需求。

abstract boolean pushFile (File localFile, String deviceFilePath)

將文件推送到設備。

abstract boolean pushString (String contents, String deviceFilePath)

將從字符串創建的文件推送到設備

abstract void reboot ()

將設備重新啟動到 adb 模式。

abstract void reboot (String reason)

將設備重新啟動到 adb 模式,並給出在重新啟動後保持不變的reason

abstract void rebootIntoBootloader ()

將設備重新啟動到引導加載程序模式。

abstract void rebootIntoFastbootd ()

將設備重新啟動到 fastbootd 模式。

abstract void rebootIntoRecovery ()

將設備重新啟動到 adb 恢復模式。

abstract void rebootIntoSideload (boolean autoReboot)

將設備重新啟動到 adb sideload 模式(請注意,這是 recovery 下的一種特殊模式)

阻塞直到設備進入側載模式

abstract void rebootIntoSideload ()

將設備重新啟動到 adb sideload 模式(請注意,這是 recovery 下的一種特殊模式)

阻塞直到設備進入側載模式

abstract void rebootUntilOnline ()

reboot()的替代方法,它只會阻塞直到設備在線,即對 adb 可見。

abstract void rebootUntilOnline (String reason)

reboot()的替代方法,它只會阻塞直到設備在線,即對 adb 可見。

abstract void rebootUserspace ()

僅重啟設備的用戶空間部分。

abstract void rebootUserspaceUntilOnline ()

rebootUserspace() ()} 的替代方法,它只會阻塞直到設備在線,即對 adb 可見。

abstract void remountSystemWritable ()

使設備上的系統分區可寫。

abstract void remountVendorWritable ()

使設備上的供應商分區可寫。

abstract boolean runInstrumentationTests (IRemoteAndroidTestRunner runner, ITestLifeCycleReceiver... listeners)

使用作為參數傳遞的一個或多個偵聽器執行ERROR(/#runInstrumentationTests(com.android.ddmlib.testrunner.IRemoteAndroidTestRunner,Collection))的便捷方法。

abstract boolean runInstrumentationTests (IRemoteAndroidTestRunner runner, listeners) runInstrumentationTests (IRemoteAndroidTestRunner runner, listeners)

運行儀器測試,並提供設備恢復。

abstract boolean runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId, listeners) runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId, listeners)

ERROR(ITestDevice#runInstrumentationTests(IRemoteAndroidTestRunner, Collection)/com.android.tradefed.device.ITestDevice#runInstrumentationTests(com.android.ddmlib.testrunner.IRemoteAndroidTestRunner,Collection) ITestDevice#runInstrumentationTests(IRemoteAndroidTestRunner, Collection))但運行測試對於給定的用戶。

abstract boolean runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId, ITestLifeCycleReceiver... listeners)

ITestDevice#runInstrumentationTests(IRemoteAndroidTestRunner, ITestLifeCycleReceiver...)相同,但為給定用戶運行測試。

abstract void setDate (Date date)

在設備上設置日期

注意:在設備上設置日期需要 root

abstract void setOptions ( TestDeviceOptions options)

為設備設置TestDeviceOptions

abstract boolean setProperty (String propKey, String propValue)

在設備上設置給定的屬性值。

abstract void setRecovery ( IDeviceRecovery recovery)

設置要用於此設備的IDeviceRecovery

abstract void setRecoveryMode ( ITestDevice.RecoveryMode mode)

設置當前用於設備的恢復模式。

abstract void setUseFastbootErase (boolean useFastbootErase)

設置是否使用 fastboot erase 或 fastboot format 擦除設備上的分區。

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 boolean unlockDevice ()

如果設備處於加密狀態,則解鎖設備。

abstract boolean waitForBootComplete (long timeOut)

阻塞,直到設置設備的啟動完成標誌。

abstract boolean waitForDeviceAvailable ()

等待設備響應並可用於測試。

abstract boolean waitForDeviceAvailable (long waitTime)

等待設備響應並可用於測試。

abstract boolean waitForDeviceAvailableInRecoverPath (long waitTime)

等待設備響應並可用,而不考慮恢復路徑。

abstract void waitForDeviceBootloader ()

阻塞直到設備通過快速啟動可見。

abstract boolean waitForDeviceInRecovery (long waitTime)

設備處於“adb recovery”狀態的塊(注意這與IDeviceRecovery不同)。

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)

公共方法

檢查 ApiLevelAgainstNextRelease

public abstract boolean checkApiLevelAgainstNextRelease (int strictMinLevel)

在給定最低支持級別的情況下,檢查當前是否支持某個功能。在提升 API 級別之前,此方法考慮了尚未發布的功能。

參數
strictMinLevel int :支持該功能的嚴格最小可能級別。

退貨
boolean如果支持該級別,則為真。否則為假。

投擲
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

清除日誌貓

public abstract void clearLogcat ()

刪除任何累積的 logcat 數據。

這對於您想要確保ITestDevice#getLogcat()僅返回在特定點之後生成的日誌數據(例如在刷新新設備構建之後等)的情況很有用。

刪除文件

public abstract void deleteFile (String deviceFilePath)

用於刪除設備上的文件或目錄的輔助方法。

參數
deviceFilePath String : 文件在設備上的絕對路徑。

投擲
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

設備軟重啟

public abstract boolean deviceSoftRestarted (ProcessInfo prevSystemServerProcess)

通過將當前 system_server 與之前的 system_server ProcessInfo進行比較來檢查設備是否軟重啟的輔助方法。使用getProcessByName(String)獲取ProcessInfo

參數
prevSystemServerProcess ProcessInfo :之前的system_server進程ProcessInfo

退貨
boolean如果設備軟重啟true

投擲
如果設備有異常啟動原因
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

deviceSoftRestartedSince

public abstract boolean deviceSoftRestartedSince (long utcEpochTime, 
                TimeUnit timeUnit)

檢查設備是否從設備紀元以來的 UTC 時間及其ERROR(/TimeUnit)軟重啟的輔助方法。軟重啟是指 system_server 在設備硬重啟之外重啟(例如:請求重啟)。可以通過方法getDeviceDate()獲取以毫秒為單位的當前設備 utcEpochTime。

參數
utcEpochTime long :自紀元以來以秒為單位的設備時間。

timeUnit TimeUnit :給定 utcEpochTime 的時間單位TimeUnit

退貨
boolean如果設備軟重啟true

投擲
如果設備有異常啟動原因
com.android.tradefed.device.DeviceNotAvailableException
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如果與設備的連接丟失且無法恢復。

執行 Adb 命令

public abstract String executeAdbCommand (long timeout, 
                String... commandArgs)

將 adb 命令作為具有指定超時的系統命令執行的輔助方法。

executeShellCommand(String)應盡可能改用,因為該方法可提供更好的故障檢測和性能。

參數
timeout long :設備被認為無響應之前的時間(以毫秒為單位),0L 表示沒有超時

commandArgs String :要運行的 adb 命令和參數

退貨
String來自命令的標準輸出。如果命令執行失敗則為null

投擲
DeviceNotAvailableException如果與設備的連接丟失且無法恢復。

執行 Adb 命令

public abstract String executeAdbCommand (String... commandArgs)

將 adb 命令作為系統命令執行的輔助方法。

executeShellCommand(String)應盡可能改用,因為該方法可提供更好的故障檢測和性能。

參數
commandArgs String :要運行的 adb 命令和參數

退貨
String來自命令的標準輸出。如果命令執行失敗則為null

投擲
DeviceNotAvailableException如果與設備的連接丟失且無法恢復。

執行 Adb 命令

public abstract String executeAdbCommand (long timeout, 
                 envMap, 
                String... commandArgs)

將 adb 命令作為具有指定超時的系統命令執行的輔助方法。

executeShellCommand(String)應盡可能改用,因為該方法可提供更好的故障檢測和性能。

參數
timeout long :設備被認為無響應之前的時間(以毫秒為單位),0L 表示沒有超時

envMap :為命令設置的環境

commandArgs String :要運行的 adb 命令和參數

退貨
String來自命令的標準輸出。如果命令執行失敗則為null

投擲
DeviceNotAvailableException如果與設備的連接丟失且無法恢復。

執行Fastboot命令

public abstract CommandResult executeFastbootCommand (long timeout, 
                String... commandArgs)

將 fastboot 命令作為系統命令執行的輔助方法。

預計在設備已經處於快速啟動模式時使用。

參數
timeout long :命令過期前的時間(以毫秒為單位)

commandArgs String :要運行的 fastboot 命令和參數

退貨
CommandResult包含命令輸出的 CommandResult

投擲
DeviceNotAvailableException如果與設備的連接丟失且無法恢復。

執行Fastboot命令

public abstract CommandResult executeFastbootCommand (String... commandArgs)

將 fastboot 命令作為系統命令執行的輔助方法,默認超時為 2 分鐘。

預計在設備已經處於快速啟動模式時使用。

參數
commandArgs String :要運行的 fastboot 命令和參數

退貨
CommandResult包含命令輸出的 CommandResult

投擲
DeviceNotAvailableException如果與設備的連接丟失且無法恢復。

executeLongFastbootCommand

public abstract CommandResult executeLongFastbootCommand (String... commandArgs)

將長時間運行的 fastboot 命令作為系統命令執行的輔助方法。

executeFastbootCommand(String)相同,只是使用了更長的超時時間。

參數
commandArgs String :要運行的 fastboot 命令和參數

退貨
CommandResult包含命令輸出的 CommandResult

投擲
DeviceNotAvailableException如果與設備的連接丟失且無法恢復。

executeLongFastbootCommand

public abstract CommandResult executeLongFastbootCommand ( envVarMap, 
                String... commandArgs)

將長時間運行的 fastboot 命令作為具有系統環境變量的系統命令執行的輔助方法。

executeFastbootCommand(String)相同,只是使用了更長的超時時間。

參數
envVarMap : fastboot命令運行的系統環境變量

commandArgs String :要運行的 fastboot 命令和參數

退貨
CommandResult包含命令輸出的 CommandResult

投擲
DeviceNotAvailableException如果與設備的連接丟失且無法恢復。

執行Shell命令

public abstract String executeShellCommand (String command)

執行 adb shell 命令並將輸出作為ERROR(/String)返回的幫助程序方法。

參數
command String :要運行的 adb shell 命令

退貨
String外殼輸出

投擲
DeviceNotAvailableException如果與設備的連接丟失且無法恢復。

執行Shell命令

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如果與設備的連接丟失且無法恢復。

執行Shell命令

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如果與設備的連接丟失且無法恢復。

執行Shell命令

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)

執行 adb shell 命令並將結果作為CommandResult返回的幫助程序方法,其中正確填充了命令狀態輸出和 stderr。 stdout 被定向到指定的流。

參數
command String :應該運行的命令。

pipeToOutput OutputStream : ERROR(/OutputStream) std 輸出將被重定向的位置,或者為 null。

退貨
CommandResult CommandResult中的結果。

投擲
DeviceNotAvailableException如果與設備的連接丟失且無法恢復。

執行ShellV2命令

public abstract CommandResult executeShellV2Command (String command, 
                File pipeAsInput)

執行 adb shell 命令並將結果作為CommandResult返回的幫助程序方法,其中正確填充了命令狀態輸出、stdout 和 stderr。

參數
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)標準錯誤將被重定向,或者為空。

maxTimeoutForCommand long :命令完成的最大超時時間; timeUnit中指定的單位

timeUnit TimeUnit : maxTimeToOutputShellResponse的單位

retryAttempts int :如果由於異常而失敗,重試命令的最大次數。如果retryAttempts執行失敗,將拋出 DeviceNotResponsiveException。

退貨
CommandResult

投擲
DeviceNotAvailableException如果與設備的連接丟失且無法恢復。

fastboot擦除分區

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 級別

投擲
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

獲取基帶版本

public abstract String getBasebandVersion ()

獲取此設備的基帶(無線電)版本的便捷方法。獲取無線電版本是特定於設備的,因此它可能不會為所有設備返回正確的信息。此方法依賴 gsm.version.baseband 屬性返回正確的版本信息。這對於某些 CDMA 設備不准確,此處返回的版本可能與 fastboot 報告的版本不匹配,並且可能不會返回 CDMA 無線電的版本。 TL;DR 此方法僅在 gsm.version.baseband 屬性與fastboot getvar version-baseband返回的版本相同時報告準確的版本。

退貨
String ERROR(/String)基帶版本,如果無法確定則為null (設備沒有無線電或無法讀取版本字符串)

投擲
DeviceNotAvailableException如果與設備的連接丟失且無法恢復。

獲取電池

public abstract Integer getBattery ()

返回設備的當前電池電量,如果電池電量不可用,則返回 Null。

退貨
Integer

獲取布爾屬性

public abstract boolean getBooleanProperty (String name, 
                boolean defaultValue)

返回給定屬性的布爾值。

參數
name String : 屬性名稱

defaultValue boolean :屬性為空或不存在時返回的默認值。

退貨
boolean如果屬性值為"1""y""yes""on""true" ,則為true ;如果屬性值為"0""n""no""off" ,則為false"false" ,否則為defaultValue

投擲
DeviceNotAvailableException

獲取啟動歷史

public abstract  getBootHistory ()

Helper 方法收集帶有啟動時間和啟動原因的啟動歷史映射。

退貨
啟動時間映射(UTC 時間,自紀元以來的秒數)和啟動原因

投擲
DeviceNotAvailableException

getBootHistorySince

public abstract  getBootHistorySince (long utcEpochTime, 
                TimeUnit timeUnit)

Helper 方法從設備的紀元以來的給定時間和指定的時間單位收集啟動歷史映射,其中包含啟動時間和啟動原因。可以通過方法getDeviceDate()獲取以毫秒為單位的當前設備 utcEpochTime。

參數
utcEpochTime long :自紀元以來的設備時間。

timeUnit TimeUnit :時間單位TimeUnit

退貨
啟動時間映射(UTC 時間,自紀元以來的秒數)和啟動原因

投擲
DeviceNotAvailableException

獲取引導程序版本

public abstract String getBootloaderVersion ()

獲取此設備的引導加載程序版本的便捷方法。

將嘗試從設備的當前狀態檢索引導加載程序版本。 (即如果設備處於快速啟動模式,它將嘗試從快速啟動中檢索版本)

退貨
String ERROR(/String)引導加載程序版本,如果找不到則為null

投擲
DeviceNotAvailableException如果與設備的連接丟失且無法恢復。

getBuildAlias

public abstract String getBuildAlias ()

檢索設備當前運行的構建的別名。

構建別名通常是比構建 ID 更易讀的字符串(通常是 Nexus 構建的數字)。例如,最終的 Android 4.2 版本具有構建別名 JDQ39 和構建 ID 573038

退貨
String構建別名,如果無法檢索則回退到構建 ID

投擲
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

獲取BuildFlavor

public abstract String getBuildFlavor ()

檢索設備的構建風格。

退貨
String構建風格,如果無法檢索則為 null

投擲
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

獲取BuildId

public abstract String getBuildId ()

檢索設備當前正在運行的版本。

退貨
String構建 ID 或IBuildInfo#UNKNOWN_BUILD_ID (如果無法檢索)

投擲
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

getBuildSigningKeys

public abstract String getBuildSigningKeys ()

返回用於簽署設備映像的密鑰類型

通常,Android 設備可能使用測試密鑰(如 AOSP)或發布密鑰(由各個設備製造商控制)進行簽名

退貨
String如果找到簽名密鑰,否則為 null。

投擲
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

獲取緩存設備描述符

public abstract DeviceDescriptor getCachedDeviceDescriptor ()

如果分配了設備,則返回緩存的DeviceDescriptor ,否則返回當前的DeviceDescriptor

退貨
DeviceDescriptor

獲取緩存設備描述符

public abstract DeviceDescriptor getCachedDeviceDescriptor (boolean shortDescriptor)

如果分配了設備,則返回緩存的DeviceDescriptor ,否則返回當前的DeviceDescriptor

參數
shortDescriptor boolean :是否將描述符限制為最低限度的信息

退貨
DeviceDescriptor

得到孩子

public abstract String[] getChildren (String deviceFilePath)

使用IFileEntry的替代方法有時會因為權限問題而無法工作。

參數
deviceFilePath String :是設備上進行搜索的路徑

退貨
String[]包含設備路徑中所有文件的字符串數組。

投擲
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

獲取連接

public abstract AbstractConnection getConnection ()

返回與設備關聯的連接。

退貨
AbstractConnection

獲取設備類

public abstract String getDeviceClass ()

獲取設備類。

退貨
String ERROR(/String)設備類。

獲取設備日期

public abstract long getDeviceDate ()

從紀元開始以毫秒為單位返回設備的日期。

退貨
long紀元格式的設備日期。

投擲
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

獲取設備描述符

public abstract DeviceDescriptor getDeviceDescriptor ()

從設備信息中返回一個DeviceDescriptor以獲取有關它的信息,而不傳遞實際的設備對象。

退貨
DeviceDescriptor

獲取設備描述符

public abstract DeviceDescriptor getDeviceDescriptor (boolean shortDescriptor)

從設備信息中返回一個DeviceDescriptor以獲取有關它的信息,而不傳遞實際的設備對象。

參數
shortDescriptor boolean :是否將描述符限制為最低限度的信息

退貨
DeviceDescriptor

獲取設備狀態

public abstract TestDeviceState getDeviceState ()

獲取設備的狀態。

退貨
TestDeviceState

獲取設備時間偏移量

public abstract long getDeviceTimeOffset (Date date)

幫助獲取設備與給定ERROR(/Date)之間的時差。在內部使用大紀元時間。

參數
date Date

退貨
long以毫秒為單位的差異

投擲
DeviceNotAvailableException

獲取模擬器輸出

public abstract InputStreamSource getEmulatorOutput ()

獲取模擬器stdout和stderr的流

退貨
InputStreamSource模擬器輸出

getExternalStoreFreeSpace

public abstract long getExternalStoreFreeSpace ()

確定設備外部存儲可用空間量的輔助方法。

退貨
long以 KB 為單位的可用空間量

投擲
DeviceNotAvailableException如果與設備的連接丟失且無法恢復。

getFastbootProductType

public abstract String getFastbootProductType ()

在 fastboot 模式下獲取此設備的產品類型的便捷方法。

僅當設備應處於快速啟動時才應使用此方法。在這種情況下,它比通用的getProductType()方法更安全一些,因為如果設備處於不正確的狀態或沒有響應,ITestDevice 將知道將設備恢復到快速啟動。

退貨
String ERROR(/String)產品類型名稱,如果無法確定則為null

投擲
DeviceNotAvailableException如果與設備的連接丟失且無法恢復。

getFastbootProductVariant

public abstract String getFastbootProductVariant ()

在 fastboot 模式下獲取此設備的產品類型的便捷方法。

僅當設備應處於快速啟動時才應使用此方法。在這種情況下,它比通用的getProductType()方法更安全一些,因為如果設備處於不正確的狀態或沒有響應,ITestDevice 將知道將設備恢復到快速啟動。

退貨
String ERROR(/String)產品類型名稱,如果無法確定則為null

投擲
DeviceNotAvailableException如果與設備的連接丟失且無法恢復。

getFastbootSerialNumber

public abstract String getFastbootSerialNumber ()

返回快速啟動模式序列號。

退貨
String

getFastboot變量

public abstract String getFastbootVariable (String variableName)

從設備中檢索給定的 fastboot 變量值。

參數
variableName String : 變量名

退貨
String屬性值,如果不存在則為null

投擲
不支持的操作異常
DeviceNotAvailableException

獲取文件入口

public abstract IFileEntry getFileEntry (String path)

檢索對設備上遠程文件的引用。

參數
path String :要檢索的文件路徑。可以是絕對路徑或相對於“/”的路徑。 (即支持“/system”和“system”語法)

退貨
IFileEntry如果找不到給定path的文件,則IFileEntrynull

投擲
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

獲取設備

public abstract IDevice getIDevice ()

返回對關聯的 ddmlib IDevice引用。

每次設備與 adb 斷開連接並重新連接時,DDMS 可能會分配一個新的IDevice 。因此,調用者不應保留對IDevice引用,因為該引用可能會過時。

退貨
IDevice IDevice

getInt屬性

public abstract long getIntProperty (String name, 
                long defaultValue)

從設備返回給定屬性的整數值。

參數
name String : 屬性名稱

defaultValue long :屬性為空或不存在時返回的默認值。

退貨
long屬性值或defaultValue (如果屬性為空、不存在或沒有整數值)。

投擲
DeviceNotAvailableException

getLastExpectedRebootTimeMillis

public abstract long getLastExpectedRebootTimeMillis ()

返回自ERROR(/System#currentTimeMillis())返回的 EPOCH 以來 Tradefed API 上次觸發重啟的毫秒數。

退貨
long

getLaunchApiLevel

public abstract int getLaunchApiLevel ()

獲取設備首次啟動的 API 級別。 Defaults to UNKNOWN_API_LEVEL .

退貨
int an integer indicating the first launched API Level of device

投擲
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

getLogcat

public abstract InputStreamSource getLogcat ()

Grabs a snapshot stream of the logcat data.

Works in two modes:

  • If the logcat is currently being captured in the background, will return up to TestDeviceOptions.getMaxLogcatDataSize() bytes of the current contents of the background logcat capture
  • Otherwise, will return a static dump of the logcat data if device is currently responding

    退貨
    InputStreamSource

  • getLogcat

    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 in IDevice 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

    也可以看看:

    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"

    投擲
    DeviceNotAvailableException

    也可以看看:

    getMountPointInfo

    public abstract  getMountPointInfo ()

    Returns a parsed version of the information in /proc/mounts on the device

    退貨
    A ERROR(/List) of MountPointInfo containing the information in "/proc/mounts"

    投擲
    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

    投擲
    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

    投擲
    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

    投擲
    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 ERROR(/String) product type name. Will not be null

    投擲
    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 ERROR(/String) product variant name or null if it cannot be determined

    投擲
    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

    投擲
    com.android.tradefed.device.DeviceNotAvailableException
    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 ERROR(/String) serial number

    getTombstones

    public abstract  getTombstones ()

    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.

    投擲
    DeviceNotAvailableException

    也可以看看:

    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.

    isAdbRoot

    public abstract boolean isAdbRoot ()

    退貨
    boolean true if device currently has adb root, false otherwise.

    投擲
    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

    投擲
    com.android.tradefed.device.DeviceNotAvailableException
    DeviceNotAvailableException

    isBypassLowTargetSdkBlockSupported

    public abstract boolean isBypassLowTargetSdkBlockSupported ()

    Check whether platform on device supports bypassing low target sdk block on app installs

    退貨
    boolean True if bypass low target sdk block is supported, false otherwise

    投擲
    com.android.tradefed.device.DeviceNotAvailableException
    DeviceNotAvailableException

    isDeviceEncrypted

    public abstract boolean isDeviceEncrypted ()

    Returns if the device is encrypted.

    退貨
    boolean true if the device is encrypted.

    投擲
    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

    投擲
    com.android.tradefed.device.DeviceNotAvailableException
    DeviceNotAvailableException

    isEncryptionSupported

    public abstract boolean isEncryptionSupported ()

    Returns if encryption is supported on the device.

    退貨
    boolean true if the device supports encryption.

    投擲
    com.android.tradefed.device.DeviceNotAvailableException
    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

    投擲
    com.android.tradefed.device.DeviceNotAvailableException
    DeviceNotAvailableException

    isHeadless

    public abstract boolean isHeadless ()

    Return true if the device is headless (no screen), false otherwise.

    退貨
    boolean

    投擲
    DeviceNotAvailableException

    isRuntimePermissionSupported

    public abstract boolean isRuntimePermissionSupported ()

    Check whether platform on device supports runtime permission granting

    退貨
    boolean True if runtime permission are supported, false otherwise.

    投擲
    com.android.tradefed.device.DeviceNotAvailableException
    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.

    投擲
    DeviceNotAvailableException

    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.

    投擲
    com.android.tradefed.device.DeviceNotAvailableException
    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)

    投擲
    DeviceNotAvailableException if connection with device is lost and cannot be recovered.

    postInvocationTearDown

    public void postInvocationTearDown ()

    此方法已棄用。
    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

    投擲
    com.android.tradefed.targetprep.TargetSetupError
    com.android.tradefed.device.DeviceNotAvailableException
    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.

    投擲
    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)

    投擲
    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)

    投擲
    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.

    投擲
    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.

    投擲
    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 ERROR(/String) containing the contents of the device file, or null if the copy failed for any reason (including problems with the host filesystem)

    投擲
    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)

    投擲
    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 : Set of excluded directories names that shouldn't be pushed.

    退貨
    boolean true if file was pushed successfully. false otherwise.

    投擲
    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.

    投擲
    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.

    投擲
    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.

    投擲
    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.

    投擲
    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.

    投擲
    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.

    投擲
    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.

    投擲
    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.

    投擲
    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 recovery

    投擲
    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

    投擲
    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

    投擲
    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.

    投擲
    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.

    投擲
    DeviceNotAvailableException if device is not available after reboot

    也可以看看:

    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.

    投擲
    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.

    投擲
    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.

    投擲
    com.android.tradefed.device.DeviceNotAvailableException
    DeviceNotAvailableException

    remountVendorWritable

    public abstract void remountVendorWritable ()

    Make the vendor partition on the device writable. May reboot the device.

    投擲
    com.android.tradefed.device.DeviceNotAvailableException
    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

    投擲
    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 : the test result listeners

    退貨
    boolean true if test command completed. false if it failed to complete due to device communication exception, but recovery succeeded

    投擲
    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, 
                     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

    投擲
    DeviceNotAvailableException

    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

    投擲
    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

    投擲
    com.android.tradefed.device.DeviceNotAvailableException
    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.

    投擲
    com.android.tradefed.device.DeviceNotAvailableException
    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.

    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

    投擲
    com.android.tradefed.device.DeviceNotAvailableException
    DeviceNotAvailableException

    switchToAdbUsb

    public abstract boolean switchToAdbUsb ()

    Switch device to adb over usb mode.

    退貨
    boolean true if switch was successful, false otherwise.

    投擲
    com.android.tradefed.device.DeviceNotAvailableException
    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.

    投擲
    DeviceNotAvailableException if connection with device is lost and cannot be recovered.

    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 call postBootSetup() . 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.

    投擲
    DeviceNotAvailableException if connection with device is lost and cannot be recovered.
    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

    投擲
    com.android.tradefed.device.DeviceNotAvailableException
    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.

    投擲
    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.

    投擲
    DeviceNotAvailableException if device is still unresponsive after waitTime expires.

    waitForDeviceAvailableInRecoverPath

    public abstract boolean waitForDeviceAvailableInRecoverPath (long waitTime)

    Waits for the device to be responsive and available without considering recovery path.

    參數
    waitTime long

    退貨
    boolean True if device is available, False if unavailable.

    投擲
    DeviceNotAvailableException if connection with device is lost and cannot be recovered.

    waitForDeviceBootloader

    public abstract void waitForDeviceBootloader ()

    Blocks until device is visible via fastboot. Use default timeout.

    投擲
    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. Use waitForDeviceAvailable() instead.

    投擲
    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. Use waitForDeviceAvailable() instead.

    參數
    waitTime long : the time in ms to wait

    投擲
    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.