本地設備

public interface INativeDevice

com.android.tradefed.device.INativeDevice


為 ddmlib IDevice提供可靠且等級稍高的 API。

重試設備指令可設定的次數,並為無回應的設備提供設備恢復介面。

概括

常數

int UNKNOWN_API_LEVEL

無法偵測API Level時的預設值

公共方法

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 指令並以String形式傳回輸出的 Helper 方法。

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)

幫助程序方法收集啟動歷史記錄圖,其中包含自設備紀元以來的給定時間和指定的時間單位以來的啟動時間和啟動原因。

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

當設備處於快速啟動模式時取得該設備的產品類型的便利方法。

abstract String getFastbootProductVariant ()

當設備處於快速啟動模式時取得該設備的產品類型的便利方法。

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

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 擦除或 fastboot 格式來擦除裝置上的分割區。

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

檢查設備平台是否支援應用程式枚舉

abstract boolean isBypassLowTargetSdkBlockSupported ()

檢查裝置上的平台是否支援繞過應用程式安裝時的低目標 sdk 區塊

abstract boolean isDebugfsMounted ()

檢查 debugfs 是否已安裝。

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

掛載調試檔案。

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 模式(請注意,這是恢復下的特殊模式)

阻塞直到設備進入旁加載模式

abstract void rebootIntoSideload ()

重新啟動裝置進入 adb sideload 模式(請注意,這是恢復下的特殊模式)

阻塞直到設備進入旁加載模式

abstract void rebootUntilOnline ()

reboot()的替代方法,僅在裝置線上(即對 adb 可見)之前阻塞。

abstract void rebootUntilOnline (String reason)

reboot()的替代方法,僅在裝置線上(即對 adb 可見)之前阻塞。

abstract void rebootUserspace ()

僅重新啟動裝置的使用者空間部分。

abstract void rebootUserspaceUntilOnline ()

rebootUserspace() ()} 的替代方案,僅在裝置線上(即對 adb 可見)之前阻塞。

abstract void remountSystemReadOnly ()

將設備上的系統分區設定為唯讀。

abstract void remountSystemWritable ()

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

abstract void remountVendorReadOnly ()

將設備上的供應商分區設定為唯讀。

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 擦除或 fastboot 格式來擦除裝置上的分割區。

abstract void startLogcat ()

開始在背景擷取裝置的 logcat 輸出。

abstract void stopEmulatorOutput ()

關閉並刪除模擬器輸出。

abstract void stopLogcat ()

停止從裝置擷取 logcat 輸出,並丟棄目前儲存的 logcat 資料。

abstract String switchToAdbTcp ()

將設備切換到 adb-over-tcp 模式。

abstract boolean switchToAdbUsb ()

將設備切換到 adb over usb 模式。

abstract boolean syncFiles (File localFileDir, String deviceFilePath)

將本機檔案目錄的內容增量同步到裝置。

abstract boolean unlockDevice ()

如果裝置處於加密狀態,則解鎖裝置。

abstract void unmountDebugfs ()

卸載 debugfs。

abstract boolean waitForBootComplete (long timeOut)

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

abstract boolean waitForDeviceAvailable ()

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

abstract boolean waitForDeviceAvailable (long waitTime)

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

abstract boolean waitForDeviceAvailableInRecoverPath (long waitTime)

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

abstract void waitForDeviceBootloader ()

阻塞直到裝置透過 fastboot 可見。

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 Level時的預設值

常量值:-1 (0xffffffff)

公共方法

檢查 ApiLevelAgainstNextRelease

public abstract boolean checkApiLevelAgainstNextRelease (int strictMinLevel)

檢查目前是否支援給定最低支援等級的功能。此方法考慮了 API 等級提升之前尚未發布的功能。

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

退貨
boolean如果支援該級別,則為 true。否則為假。

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

清除Logcat

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

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

設備軟重啟以來

public abstract boolean deviceSoftRestartedSince (long utcEpochTime, 
                TimeUnit timeUnit)

用於檢查設備是否自 UTC 時間以來設備及其ERROR(/TimeUnit)軟重啟的方法。軟重啟是指在裝置硬重啟之外重新啟動的 system_server(例如:請求重新啟動)。可以透過getDeviceDate()方法來取得目前裝置的 utcEpochTime(以毫秒為單位)。

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

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

退貨
boolean如果裝置軟重啟則為true

投擲
RuntimeException如果設備有異常啟動原因
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如果與設備的連線遺失且無法恢復。

執行LongFastboot命令

public abstract CommandResult executeLongFastbootCommand (String... commandArgs)

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

executeFastbootCommand(String)相同,但使用更長的逾時。

參數
commandArgs String :要執行的 fastboot 指令和參數

退貨
CommandResult包含指令輸出的 CommandResult

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

執行LongFastboot命令

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 指令並以String形式傳回輸出的 Helper 方法。

參數
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) ,或為空。

退貨
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) ,或為空。

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) ,或為空。

pipeToOutput OutputStream : ERROR(/OutputStream)其中 std 輸出將被重定向,或為 null。

pipeToError OutputStream : ERROR(/OutputStream)其中 std 錯誤將被重定向,或為 null。

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

取得啟動歷史記錄

public abstract  getBootHistorySince (long utcEpochTime, 
                TimeUnit timeUnit)

幫助程序方法收集啟動歷史記錄圖,其中包含自設備紀元以來的給定時間和指定的時間單位以來的啟動時間和啟動原因。目前裝置的 utcEpochTime(以毫秒為單位)可以透過方法getDeviceDate()取得。

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

timeUnit TimeUnit :時間單位TimeUnit

退貨
啟動時間圖(自紀元以來以秒為單位的 UTC 時間)和啟動原因

投擲
DeviceNotAvailableException

取得Bootloader版本

public abstract String getBootloaderVersion ()

取得該裝置的引導程式版本的便捷方法。

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

退貨
String String引導程式版本,如果找不到則為null

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

取得建置別名

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

取得建置ID

public abstract String getBuildId ()

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

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

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

取得建置簽署金鑰

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 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仿真器輸出

取得外部儲存空閒空間

public abstract long getExternalStoreFreeSpace ()

用於確定設備外部儲存上的可用空間量的幫助程序方法。

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

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

取得FastbootProductType

public abstract String getFastbootProductType ()

當設備處於快速啟動模式時取得該設備的產品類型的便利方法。

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

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

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

取得FastbootProductVariant

public abstract String getFastbootProductVariant ()

當設備處於快速啟動模式時取得該設備的產品類型的便利方法。

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

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

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

取得Fastboot序號

public abstract String getFastbootSerialNumber ()

返回快速啟動模式序號。

退貨
String

取得Fastboot變數

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

取得整數屬性

public abstract long getIntProperty (String name, 
                long defaultValue)

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

參數
name String : 屬性名稱

defaultValue long :如果屬性為空或不存在,則傳回預設值。

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

投擲
DeviceNotAvailableException

getLastExpectedRebootTimeMillis

public abstract long getLastExpectedRebootTimeMillis ()

System.currentTimeMillis()傳回的 EPOCH 以來 Tradefed API 上次觸發重新啟動的時間(以毫秒為單位)。

退貨
long

取得LaunchApiLevel

public abstract int getLaunchApiLevel ()

取得設備首次啟動的 API 等級。預設為UNKNOWN_API_LEVEL

退貨
int一個整數,表示設備首次啟動的 API 級別

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

取得Logcat

public abstract InputStreamSource getLogcat ()

取得 logcat 資料的快照流。

有兩種工作模式:

  • 如果logcat目前正在後台捕獲,將傳回最多TestDeviceOptions.getMaxLogcatDataSize()位元組的後台logcat捕獲的目前內容
  • 否則,如果裝置目前正在回應,將傳回 logcat 資料的靜態轉儲

    退貨
    InputStreamSource

  • 取得Logcat

    public abstract InputStreamSource getLogcat (int maxBytes)

    取得捕獲的 logcat 資料的最後maxBytes的快照流。

    當您想要捕獲所捕獲的 logcat 資料的頻繁快照而又不會因獲取整個getLogcat()快照而導致潛在的巨大磁碟空間損失時,該情況非常有用。

    參數
    maxBytes int :要傳回的最大資料量。應該是一個可以輕鬆放入記憶體的數量

    退貨
    InputStreamSource

    取得LogcatDump

    public abstract InputStreamSource getLogcatDump ()

    取得設備目前 logcat 的轉儲。與getLogcat()不同,此方法將始終傳回 logcat 的靜態轉儲。

    缺點是如果設備無法訪問,則不會返回任何內容。

    退貨
    InputStreamSource logcat 資料的InputStreamSource 。如果無法擷取 logcat 數據,則傳回空流。

    取得LogcatSince

    public abstract InputStreamSource getLogcatSince (long date)

    取得從提供的日期開始擷取的 logcat 資料的快照流。設備上的時間應使用getDeviceDate()

    參數
    date long :以毫秒為單位,以紀元格式表示從何時開始快照到現在。 (可以使用“日期+%s”取得)

    退貨
    InputStreamSource

    取得掛載點

    public abstract String getMountPoint (String mountName)

    傳回一個掛載點。

    如果IDevice中的快取資訊不可用,則直接查詢設備。

    TODO:將此行為移至IDevice#getMountPoint(String)

    參數
    mountName String : 掛載點的名稱

    退貨
    String掛載點或null

    也可以看看:

    取得掛載點資訊

    public abstract ITestDevice.MountPointInfo getMountPointInfo (String mountpoint)

    傳回與指定掛載點路徑相對應的MountPointInfo ,如果路徑沒有掛載任何內容,或未以掛載點出現在 /proc/mounts 中,則傳回null

    參數
    mountpoint String

    退貨
    ITestDevice.MountPointInfo MountPointInfoERROR(/List)包含「/proc/mounts」中的信息

    投擲
    DeviceNotAvailableException

    也可以看看:

    取得掛載點資訊

    public abstract  getMountPointInfo ()

    傳回裝置上 /proc/mounts 中資訊的已解析版本

    退貨
    MountPointInfoERROR(/List)包含「/proc/mounts」中的信息

    投擲
    DeviceNotAvailableException

    取得分區空閒空間

    public abstract long getPartitionFreeSpace (String partition)

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

    參數
    partition String

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

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

    按名稱取得進程

    public abstract ProcessInfo getProcessByName (String processName)

    Helper 方法執行「pidof」和「stat」指令,並傳回帶有給定進程的 PID 和進程啟動時間的ProcessInfo物件。

    參數
    processName String :進程名稱字串。

    退貨
    ProcessInfo給定進程名稱的進程訊息

    投擲
    DeviceNotAvailableException

    取得進程Pid

    public abstract String getProcessPid (String process)

    傳回服務的 pid,如果出現問題則傳回 null。

    參數
    process String :進程名稱字串。

    退貨
    String

    投擲
    DeviceNotAvailableException

    取得產品類型

    public abstract String getProductType ()

    取得該設備的產品類型的便捷方法。

    如果裝置處於 adb 或 fastboot 模式,則此方法將會起作用。

    退貨
    String String產品類型名稱。不會為空

    投擲
    DeviceNotAvailableException如果與裝置的連線遺失且無法恢復,或無法確定產品類型

    取得產品變體

    public abstract String getProductVariant ()

    取得該設備的產品變型的便捷方法。

    如果裝置處於 adb 或 fastboot 模式,則此方法將會起作用。

    退貨
    String String產品變體名稱,如果無法確定則為null

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

    取得屬性

    public abstract String getProperty (String name)

    從設備中檢索給定的屬性值。

    參數
    name String : 屬性名稱

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

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

    取得恢復模式

    public abstract ITestDevice.RecoveryMode getRecoveryMode ()

    取得設備目前使用的恢復模式。

    退貨
    ITestDevice.RecoveryMode設備目前使用的恢復模式。

    取得序號

    public abstract String getSerialNumber ()

    取得該設備序號的便捷方法。

    退貨
    String String序號

    取得墓碑

    public abstract  getTombstones ()

    從設備中取得並返回邏輯刪除清單。需要根。

    方法是盡力而為的,因此如果一個墓碑因任何原因未能被拉出,它將從清單中丟失。只有DeviceNotAvailableException才會提前終止該方法。

    退貨
    邏輯刪除檔案列表,如果沒有邏輯刪除則為空。

    投擲
    DeviceNotAvailableException

    也可以看看:

    取得總記憶體

    public abstract long getTotalMemory ()

    傳回總實體記憶體大小(以位元組為單位),如果出現內部錯誤,則傳回 -1

    退貨
    long

    getUseFastbootErase

    public abstract boolean getUseFastbootErase ()

    取得是否使用 fastboot 擦除或 fastboot 格式來擦除裝置上的分割區。

    退貨
    boolean如果將使用 fastboot 擦除,則為true ;如果將使用 fastboot 格式,則為false

    也可以看看:

    是AdbRoot

    public abstract boolean isAdbRoot ()

    退貨
    boolean如果裝置目前有 adb root, true ,否則為false

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

    是AdbTcp

    public abstract boolean isAdbTcp ()

    退貨
    boolean如果裝置連接到 adb-over-tcp, true ,否則為false

    isAppEnumerationSupported 是否支持

    public abstract boolean isAppEnumerationSupported ()

    檢查設備平台是否支援應用程式枚舉

    退貨
    boolean如果支援應用程式枚舉,則為 true,否則為 false

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

    isBypassLowTargetSdkBlockSupported

    public abstract boolean isBypassLowTargetSdkBlockSupported ()

    檢查裝置上的平台是否支援繞過應用程式安裝時的低目標 sdk 區塊

    退貨
    boolean如果支援繞過低目標 sdk 區塊則為 true,否則為 false

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

    已安裝偵錯工具

    public abstract boolean isDebugfsMounted ()

    檢查 debugfs 是否已安裝。

    退貨
    boolean true如果 debugfs 已安裝

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

    裝置已加密

    public abstract boolean isDeviceEncrypted ()

    返回裝置是否已加密。

    退貨
    boolean如果裝置已加密,則為true

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

    是目錄

    public abstract boolean isDirectory (String deviceFilePath)

    如果裝置上的路徑是目錄,則傳回 True,否則傳回 false。

    參數
    deviceFilePath String

    退貨
    boolean

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

    是否支援加密

    public abstract boolean isEncryptionSupported ()

    返回裝置是否支援加密。

    退貨
    boolean如果裝置支援加密,則為true

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

    是執行檔

    public abstract boolean isExecutable (String fullPath)

    如果裝置上的檔案路徑是可執行文件,則傳回 True,否則傳回 false。

    參數
    fullPath String

    退貨
    boolean

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

    是無頭的

    public abstract boolean isHeadless ()

    如果裝置是無頭的(無螢幕),則傳回 true,否則傳回 false。

    退貨
    boolean

    投擲
    DeviceNotAvailableException

    isRuntimePermissionSupported

    public abstract boolean isRuntimePermissionSupported ()

    檢查設備平台是否支援運行時權限授予

    退貨
    boolean如果支援運行時權限則為 true,否則為 false。

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

    isStateBootloaderOrFastbootd

    public abstract boolean isStateBootloaderOrFastbootd ()

    如果裝置處於TestDeviceState#FASTBOOTTestDeviceState.FASTBOOTD狀態,則傳回 true。

    退貨
    boolean

    對數

    public abstract boolean logAnrs (ITestLogger logger)

    從設備收集並記錄 ANR。

    參數
    logger ITestLogger :用來記錄 ANR 的ITestLogger

    退貨
    boolean如果記錄成功則為 true,否則為 false。

    投擲
    DeviceNotAvailableException

    登入裝置

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

    在設備的 logcat 中記錄訊息。這是一個安全的調用,即使日誌記錄失敗也不會拋出異常。

    參數
    tag String :我們在 logcat 中記錄訊息的標籤。

    level Log.LogLevel :logcat 中訊息的偵錯等級。

    format String :訊息格式。

    args Object :要透過 String.format() 取代的參數。

    掛載偵錯文件

    public abstract void mountDebugfs ()

    掛載調試檔案。

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

    非阻塞重啟

    public abstract void nonBlockingReboot ()

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

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

    啟動後設定

    public abstract void postBootSetup ()

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

    應在設備完全啟動/可用後調用

    在正常情況下,不需要明確呼叫此方法,因為實作應在執行重新啟動時自動執行這些步驟。

    可能需要呼叫它的是當裝置因其他事件而重新啟動時(例如,當 fastboot 更新命令完成時)

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

    調用後拆卸

    public void postInvocationTearDown ()

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

    設備特定所需清理的額外步驟將在呼叫完成後執行。

    調用後拆卸

    public abstract void postInvocationTearDown (Throwable invocationException)

    設備特定所需清理的額外步驟將在呼叫完成後執行。

    參數
    invocationException Throwable :如果有的話,呼叫失敗引發的最終異常。

    調用前設定

    public void preInvocationSetup (IBuildInfo info, 
                    MultiMap<String, String> attributes)

    設備特定所需設定的額外步驟將在呼叫流程之前在設備上執行。

    參數
    info IBuildInfo :設備的IBuildInfo

    attributes MultiMap :儲存在呼叫上下文中的屬性

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

    拉目錄

    public abstract boolean pullDir (String deviceFilePath, 
                    File localDir)

    從裝置中遞歸提取目錄內容。

    參數
    deviceFilePath String : 遠端來源的絕對檔案路徑

    localDir File :將檔案拉入的本機目錄

    退貨
    boolean如果檔案已成功拉取,則為true 。否則為false

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

    拉文件

    public abstract File pullFile (String remoteFilePath, 
                    int userId)

    從裝置上擷取文件,將其儲存在本機臨時ERROR(/File)中,然後傳回該File

    參數
    remoteFilePath String :裝置上檔案的絕對路徑。

    userId int :要從中提取的使用者 ID

    退貨
    File包含設備檔案內容的ERROR(/File) ,如果因任何原因(包括主機檔案系統問題)複製失敗,則為null

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

    拉文件

    public abstract File pullFile (String remoteFilePath)

    從裝置上擷取文件,將其儲存在本機臨時ERROR(/File)中,然後傳回該File

    參數
    remoteFilePath String :裝置上檔案的絕對路徑。

    退貨
    File包含設備檔案內容的ERROR(/File) ,如果因任何原因(包括主機檔案系統問題)複製失敗,則為null

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

    拉文件

    public abstract boolean pullFile (String remoteFilePath, 
                    File localFile)

    從設備上檢索文件。

    參數
    remoteFilePath String :裝置上檔案的絕對路徑。

    localFile File :儲存內容的本機檔案。如果非空,內容將被取代。

    退貨
    boolean如果文件檢索成功則為true 。否則為false

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

    拉文件

    public abstract boolean pullFile (String remoteFilePath, 
                    File localFile, 
                    int userId)

    從設備上檢索文件。

    參數
    remoteFilePath String :裝置上檔案的絕對路徑。

    localFile File :儲存內容的本機檔案。如果非空,內容將被取代。

    userId int :要從中提取的使用者 ID

    退貨
    boolean如果文件檢索成功則為true 。否則為false

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

    拉取文件內容

    public abstract String pullFileContents (String remoteFilePath)

    從設備上檢索文件並返回內容。

    參數
    remoteFilePath String :裝置上檔案的絕對路徑。

    退貨
    String包含裝置檔案內容的String ,如果因任何原因(包括主機檔案系統問題)複製失敗,則為null

    投擲
    DeviceNotAvailableException

    從外部拉文件

    public abstract File pullFileFromExternal (String remoteFilePath)

    一種從裝置的外部儲存檢索檔案、將其儲存在本地臨時ERROR(/File)中並傳回對該File的參考的便捷方法。

    參數
    remoteFilePath String :裝置上檔案的路徑,相對於裝置的外部儲存掛載點

    退貨
    File包含設備檔案內容的ERROR(/File) ,如果因任何原因(包括主機檔案系統問題)複製失敗,則為null

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

    推目錄

    public abstract boolean pushDir (File localDir, 
                    String deviceFilePath, 
                     excludedDirectories)

    將目錄內容遞歸推送到設備,同時排除一些被過濾的目錄。

    參數
    localDir File :要推送的本機目錄

    deviceFilePath String : 遠端目標的絕對檔案路徑

    excludedDirectories :不應推送的一組排除目錄名稱。

    退貨
    boolean如果檔案推送成功則為true 。否則為false

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

    推目錄

    public abstract boolean pushDir (File localDir, 
                    String deviceFilePath)

    將目錄內容遞歸推送到裝置。

    參數
    localDir File :要推送的本機目錄

    deviceFilePath String : 遠端目標的絕對檔案路徑

    退貨
    boolean如果檔案推送成功則為true 。否則為false

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

    推播檔案

    public abstract boolean pushFile (File localFile, 
                    String deviceFilePath, 
                    boolean evaluateContentProviderNeeded)

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

    參數
    localFile File :要推送的本機文件

    deviceFilePath String : 遠端目標絕對檔路徑

    evaluateContentProviderNeeded boolean : 是否檢查我們是否需要內容提供者

    退貨
    boolean如果檔案推送成功則為true 。否則為false

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

    推播檔案

    public abstract boolean pushFile (File localFile, 
                    String deviceFilePath)

    將檔案推送到裝置。預設使用內容提供者。

    參數
    localFile File :要推送的本機文件

    deviceFilePath String : 遠端目標絕對檔路徑

    退貨
    boolean如果檔案推送成功則為true 。否則為false

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

    推串

    public abstract boolean pushString (String contents, 
                    String deviceFilePath)

    將根據字串建立的檔案推送到設備

    參數
    contents String : 要推送的檔案的內容

    deviceFilePath String : 遠端目標絕對檔路徑

    退貨
    boolean true如果字串已成功推送。否則為false

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

    重啟

    public abstract void reboot ()

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

    阻塞直到設備變得可用。

    投擲
    DeviceNotAvailableException如果設備在重新啟動後不可用

    重啟

    public abstract void reboot (String reason)

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

    阻塞直到設備變得可用。

    上次重啟原因可以透過查詢sys.boot.reason屬性來取得。

    參數
    reason String :此次重新啟動的原因,如果未指定原因則為null

    投擲
    DeviceNotAvailableException如果設備在重新啟動後不可用

    重新啟動進入引導程式

    public abstract void rebootIntoBootloader ()

    將裝置重新啟動至引導程式模式。

    阻塞直到裝置處於引導程式模式。

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

    重新啟動進入Fastbootd

    public abstract void rebootIntoFastbootd ()

    將裝置重新啟動至 fastbootd 模式。

    阻塞直到裝置處於 fastbootd 模式。

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

    重新啟動進入恢復

    public abstract void rebootIntoRecovery ()

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

    阻塞直到設備進入恢復狀態

    投擲
    DeviceNotAvailableException如果設備在重新啟動後不可用

    重新啟動進入旁載

    public abstract void rebootIntoSideload (boolean autoReboot)

    重新啟動裝置進入 adb sideload 模式(請注意,這是恢復下的特殊模式)

    阻塞直到設備進入旁加載模式

    參數
    autoReboot boolean : 側載後是否自動重新啟動設備

    投擲
    DeviceNotAvailableException如果裝置在重新啟動後未處於旁加載狀態

    重新啟動進入旁載

    public abstract void rebootIntoSideload ()

    重新啟動裝置進入 adb sideload 模式(請注意,這是恢復下的特殊模式)

    阻塞直到設備進入旁加載模式

    投擲
    DeviceNotAvailableException如果裝置在重新啟動後未處於旁加載狀態

    重新啟動直到上線

    public abstract void rebootUntilOnline ()

    reboot()的替代方法,僅在裝置線上(即對 adb 可見)之前阻塞。

    投擲
    DeviceNotAvailableException如果設備在重新啟動後不可用

    重新啟動直到上線

    public abstract void rebootUntilOnline (String reason)

    reboot()的替代方法,僅在裝置線上(即對 adb 可見)之前阻塞。

    參數
    reason String :此次重新啟動的原因,如果未指定原因則為null

    投擲
    DeviceNotAvailableException如果設備在重新啟動後不可用

    也可以看看:

    重新啟動使用者空間

    public abstract void rebootUserspace ()

    僅重新啟動裝置的使用者空間部分。

    阻塞直到設備變得可用。

    警告。用戶空間重啟目前正在積極開發中,使用它需要您自擔風險。

    投擲
    DeviceNotAvailableException如果設備在重新啟動後不可用

    重新啟動用戶空間直到上線

    public abstract void rebootUserspaceUntilOnline ()

    rebootUserspace() ()} 的替代方案,僅在裝置線上(即對 adb 可見)之前阻塞。

    投擲
    DeviceNotAvailableException如果設備在重新啟動後不可用

    重新掛載系統唯讀

    public abstract void remountSystemReadOnly ()

    將設備上的系統分區設定為唯讀。可能會重新啟動設備。

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

    重新掛載系統可寫

    public abstract void remountSystemWritable ()

    使設備上的系統分區可寫入。可能會重新啟動設備。

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

    重新掛載供應商只讀

    public abstract void remountVendorReadOnly ()

    將設備上的供應商分區設定為唯讀。可能會重新啟動設備。

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

    重新掛載VendorWritable

    public abstract void remountVendorWritable ()

    使設備上的供應商分區可寫入。可能會重新啟動設備。

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

    運行儀器測試

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

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

    參數
    runner IRemoteAndroidTestRunner :運行測試的IRemoteAndroidTestRunner

    listeners ITestLifeCycleReceiver :測試結果監聽器

    退貨
    boolean如果測試命令完成則為true 。若未能完成但恢復成功則為false

    投擲
    DeviceNotAvailableException如果與設備的連線遺失且無法恢復。即測試命令無法完成且恢復失敗。

    運行儀器測試

    public abstract boolean runInstrumentationTests (IRemoteAndroidTestRunner runner, 
                     listeners)

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

    如果在測試運行完成之前與裝置的連線遺失,並且恢復成功,則所有偵聽器將收到 testRunFailed 通知,並傳回「false」。測試命令將不會重新運行。如果需要,呼叫者可以重試。

    如果在測試運行完成之前與裝置的連線遺失,且復原失敗,則所有偵聽器將收到 testRunFailed 通知,並拋出 DeviceNotAvailableException。

    參數
    runner IRemoteAndroidTestRunner :運行測試的IRemoteAndroidTestRunner

    listeners :測試結果監聽器

    退貨
    boolean如果測試命令完成則為truefalse如果由於設備通訊異常而未能完成,但恢復成功

    投擲
    DeviceNotAvailableException如果與設備的連線遺失且無法恢復。即測試命令無法完成且恢復失敗。

    以使用者身分執行儀器測試

    public abstract boolean 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))運行測試對於給定的使用者。

    參數
    runner IRemoteAndroidTestRunner

    userId int

    listeners

    退貨
    boolean

    投擲
    DeviceNotAvailableException

    以使用者身分執行儀器測試

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

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

    參數
    runner IRemoteAndroidTestRunner

    userId int

    listeners ITestLifeCycleReceiver

    退貨
    boolean

    投擲
    DeviceNotAvailableException

    設定日期

    public abstract void setDate (Date date)

    設定設備上的日期

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

    參數
    date Date :指定特定日期;如果null將使用主機日期

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

    設定選項

    public abstract void setOptions (TestDeviceOptions options)

    設定設備的TestDeviceOptions

    參數
    options TestDeviceOptions

    設定屬性

    public abstract boolean setProperty (String propKey, 
                    String propValue)

    設定設備上給定的屬性值。需要 adb root 為真。

    參數
    propKey String : 要設定的目標鍵。

    propValue String :要設定的屬性值。

    退貨
    boolean如果 setprop 指令成功,則傳回True ,否則傳回 False。

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

    設定恢復

    public abstract void setRecovery (IDeviceRecovery recovery)

    設定用於此裝置的IDeviceRecovery 。應在首次分配設備時設定。

    參數
    recovery IDeviceRecoveryIDeviceRecovery

    設定恢復模式

    public abstract void setRecoveryMode (ITestDevice.RecoveryMode mode)

    設定設備使用的目前恢復模式。

    用於控制遇到設備通訊問題時使用何種恢復方法。建議僅在需要時謹慎使用此方法(例如,當框架關閉時等)

    參數
    mode ITestDevice.RecoveryMode :是否應開啟「僅還原至線上」模式。

    設定使用FastbootErase

    public abstract void setUseFastbootErase (boolean useFastbootErase)

    設定是否使用 fastboot 擦除或 fastboot 格式來擦除裝置上的分割區。

    參數
    useFastbootErase boolean :如果應使用 fastboot 擦除,則為true ;如果應使用 fastboot 格式,則為false

    也可以看看:

    啟動Logcat

    public abstract void startLogcat ()

    開始在背景擷取裝置的 logcat 輸出。

    如果 logcat 輸出已被捕獲,則不會產生任何影響。稍後可以透過 getLogcat 檢索資料。

    當設備不再使用時,必須呼叫stopLogcat()

    在 TF 呼叫上下文中,通常不需要呼叫startLogcat()stopLogcat() ,因為 TF 框架會啟動和停止 logcat。

    停止模擬器輸出

    public abstract void stopEmulatorOutput ()

    關閉並刪除模擬器輸出。

    停止Logcat

    public abstract void stopLogcat ()

    停止從裝置擷取 logcat 輸出,並丟棄目前儲存的 logcat 資料。

    如果未捕獲 logcat 輸出,則不會產生任何效果。

    切換到AdbTcp

    public abstract String switchToAdbTcp ()

    將設備切換到 adb-over-tcp 模式。

    退貨
    String TCP 序號,如果裝置無法切換,則為null

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

    切換到AdbUsb

    public abstract boolean switchToAdbUsb ()

    將設備切換到 adb over usb 模式。

    退貨
    boolean如果切換成功則為true ,否則為false

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

    同步文件

    public abstract boolean syncFiles (File localFileDir, 
                    String deviceFilePath)

    將本機檔案目錄的內容增量同步到裝置。

    透過將本機檔案的時間戳記與其遠端等效檔案的時間戳進行比較來決定推送哪些檔案。只有「較新」或不存在的檔案才會被推送到裝置。因此,如果設備上的文件集已經是最新的,開銷應該相對較小。

    隱藏檔案(名稱以“.”開頭)將被忽略。

    用法範例:syncFiles("/tmp/files", "/sdcard") 將建立一個 /sdcard/files 目錄(如果它尚不存在),並遞歸地將 /tmp/files 內容推送到 /sdcard/files。

    參數
    localFileDir File :包含要遞歸推送的檔案的本機檔案目錄。

    deviceFilePath String :遠端目標絕對檔案路徑根。檔案路徑中的所有目錄都必須可讀。即當 adb 不是 root 時推送到 /data/local/tmp 將會失敗

    退貨
    boolean如果檔案同步成功則為true 。否則為false

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

    解鎖裝置

    public abstract boolean unlockDevice ()

    如果裝置處於加密狀態,則解鎖裝置。

    此方法可能會重新啟動框架,但不會呼叫postBootSetup() 。因此,當此方法返回時,設備可能尚未完全準備好進行測試。

    退貨
    boolean如果成功或裝置未加密, true

    投擲
    DeviceNotAvailableException如果與設備的連線遺失且無法恢復。
    UnsupportedOperationException如果設備不支援加密。

    卸載調試文件

    public abstract void unmountDebugfs ()

    卸載 debugfs。

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

    等待啟動完成

    public abstract boolean waitForBootComplete (long timeOut)

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

    參數
    timeOut long :等待標誌設定的時間(以毫秒為單位)

    退貨
    boolean如果在逾時時間內設定了裝置的啟動完成標誌,則為 true

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

    等待設備可用

    public abstract boolean waitForDeviceAvailable ()

    等待設備響應並可用於測試。使用預設超時。

    退貨
    boolean如果設備可用,則為 True;如果恢復已停用且不可用,則為 False。

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

    等待設備可用

    public abstract boolean waitForDeviceAvailable (long waitTime)

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

    參數
    waitTime long :等待時間(以毫秒為單位)

    退貨
    boolean如果設備可用,則為 True;如果恢復已停用且不可用,則為 False。

    投擲
    DeviceNotAvailableException如果 waitTime 到期後裝置仍然沒有回應。

    waitForDeviceAvailableInRecoverPath

    public abstract boolean waitForDeviceAvailableInRecoverPath (long waitTime)

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

    參數
    waitTime long

    退貨
    boolean如果設備可用則為 True,如果不可用則為 False。

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

    等待設備引導程式

    public abstract void waitForDeviceBootloader ()

    阻塞直到裝置透過 fastboot 可見。使用預設超時。

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

    等待設備恢復

    public abstract boolean waitForDeviceInRecovery (long waitTime)

    阻止設備處於“adb recovery”狀態(請注意,這與IDeviceRecovery不同)。

    參數
    waitTime long :等待時間(以毫秒為單位)

    退貨
    boolean如果設備在時間到期之前啟動進入恢復, true 。否則為false

    waitForDeviceInSideload

    public abstract boolean waitForDeviceInSideload (long waitTime)

    阻止設備處於“adb sideload”狀態

    參數
    waitTime long :等待時間(以毫秒為單位)

    退貨
    boolean如果裝置在時間到期之前啟動到旁加載, true 。否則為false

    等待設備不可用

    public abstract boolean waitForDeviceNotAvailable (long waitTime)

    設備不可用的區塊,即 adb 中遺失的區塊

    參數
    waitTime long :等待時間(以毫秒為單位)

    退貨
    boolean如果設備在時間到期之前變得不可用,則為true 。否則為false

    等待設備在線

    public abstract void waitForDeviceOnline ()

    阻塞直到設備通過 adb 可見。使用預設超時

    請注意,設備不一定會在完成時回應命令。請改用waitForDeviceAvailable()

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

    等待設備在線

    public abstract void waitForDeviceOnline (long waitTime)

    阻塞直到設備通過 adb 可見。

    請注意,設備不一定會在完成時回應命令。請改用waitForDeviceAvailable()

    參數
    waitTime long :等待時間(以毫秒為單位)

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

    等待設備外殼

    public abstract boolean waitForDeviceShell (long waitTime)

    等待設備回應基本的 adb shell 命令。

    參數
    waitTime long :等待時間(以毫秒為單位)

    退貨
    boolean如果裝置在waitTime過去之前變得響應,則為true