本地設備

public class NativeDevice
extends Object implements IManagedTestDevice , IConfigurationReceiver , ITestLoggerReceiver

java.lang.Object
com.android.tradefed.device.NativeDevice


ITestDevice非全端 Android 裝置的預設實作。

概括

嵌套類

class NativeDevice.AdbAction

執行作業系統「adb ....」指令時ERROR(DeviceAction/com.android.tradefed.device.NativeDevice.DeviceAction DeviceAction)

class NativeDevice.AdbShellAction

class NativeDevice.RebootDeviceAction

重新啟動裝置時ERROR(DeviceAction/com.android.tradefed.device.NativeDevice.DeviceAction DeviceAction)

常數

int INVALID_USER_ID

為任何無效/未找到的使用者 ID 傳回的值:UserHandle 定義了 -10000 值

long MAX_HOST_DEVICE_TIME_OFFSET

int MAX_RETRY_ATTEMPTS

執行指令重試的預設次數

領域

public static final String DEBUGFS_PATH

protected static final String SD_CARD

protected static final String STORAGE_EMULATED

protected TestDeviceOptions mOptions

protected final IDeviceStateMonitor mStateMonitor

公共構造函數

NativeDevice (IDevice device, IDeviceStateMonitor stateMonitor, IDeviceMonitor allocationMonitor)

建立一個TestDevice

公共方法

void batchPrefetchStartupBuildProps ()

透過預取我們需要的所有道具而不是為每個道具呼叫「adb getprop」來進行微最佳化(大約 400 毫秒)。

boolean canSwitchToHeadlessSystemUser ()

返回是否允許切換到無頭SYSTEM用戶。

boolean checkApiLevelAgainstNextRelease (int strictMinLevel)

檢查目前是否支援給定最低支援等級的功能。

boolean checkConnectivity ()

檢查設備是否具有網路連線。

boolean clearErrorDialogs ()

嘗試關閉裝置 UI 上目前顯示的任何錯誤對話框。

void clearLastConnectedWifiNetwork ()

清除上次連線的 wifi 網路。

void clearLogcat ()

刪除所有累積的 logcat 資料。

boolean connectToWifiNetwork ( wifiSsidToPsk, boolean scanSsid) connectToWifiNetwork ( wifiSsidToPsk, boolean scanSsid)

連接到 wifi 網路。

boolean connectToWifiNetwork (String wifiSsid, String wifiPsk)

連接到 wifi 網路。

boolean connectToWifiNetwork ( wifiSsidToPsk) connectToWifiNetwork ( wifiSsidToPsk)

連接 wifi 網路.f

boolean connectToWifiNetwork (String wifiSsid, String wifiPsk, boolean scanSsid)

連接到 wifi 網路。

boolean connectToWifiNetworkIfNeeded (String wifiSsid, String wifiPsk, boolean scanSsid)

connectToWifiNetwork(String, String)的變體,僅當裝置目前沒有網路連線時才進行連線。

boolean connectToWifiNetworkIfNeeded (String wifiSsid, String wifiPsk)

connectToWifiNetwork(String, String)的變體,僅當裝置目前沒有網路連線時才進行連線。

int createUser (String name, boolean guest, boolean ephemeral)

使用給定名稱和提供的標誌建立用戶

int createUser (String name, boolean guest, boolean ephemeral, boolean forTesting)

使用給定名稱和提供的標誌建立用戶

int createUser (String name)

建立一個具有給定名稱和預設標誌 0 的使用者。

int createUserNoThrow (String name)

建立一個具有給定名稱和預設標誌 0 的使用者。

void deleteFile (String deviceFilePath)

用於刪除裝置上的檔案或目錄的幫助程式方法。

void deregisterDeviceActionReceiver ( IDeviceActionReceiver deviceActionReceiver)

刪除已註冊的IDeviceActionReceiver

boolean deviceSoftRestarted ( ProcessInfo prevSystemServerProcess)

透過將目前 system_server 與先前的 system_server ProcessInfo進行比較來檢查裝置是否軟重啟的幫助程式方法。

boolean deviceSoftRestartedSince (long utcEpochTime, TimeUnit timeUnit)

用於檢查設備是否自 UTC 時間以來設備及其ERROR(/TimeUnit)軟重啟的方法。

boolean disableAdbRoot ()

關閉 adb root。

void disableKeyguard ()

嘗試停用鍵盤保護。

boolean disableNetworkMonitor ()

停用裝置上的網路監控。

boolean disconnectFromWifi ()

與 WiFi 網路斷開連線。

boolean doesFileExist (String deviceFilePath, int userId)

用於確定給定使用者的裝置上的檔案是否存在的幫助程序方法。

boolean doesFileExist (String deviceFilePath)

確定裝置上的檔案是否存在的幫助程序方法。

File dumpHeap (String process, String devicePath)

嘗試從 system_server 轉儲堆。

boolean enableAdbRoot ()

打開 adb root。

boolean enableNetworkMonitor ()

啟用設備上的網路監控。

String executeAdbCommand (long timeout, String... cmdArgs)

將 adb 命令作為具有指定逾時的系統命令執行的幫助程序方法。

String executeAdbCommand (long timeout, envMap, String... cmdArgs) executeAdbCommand (long timeout, envMap, String... cmdArgs)

將 adb 命令作為具有指定逾時的系統命令執行的幫助程序方法。

String executeAdbCommand (String... cmdArgs)

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

CommandResult executeFastbootCommand (String... cmdArgs)

將 fastboot 指令作為系統指令執行的幫助程序方法,預設逾時為 2 分鐘。

CommandResult executeFastbootCommand (long timeout, String... cmdArgs)

將 fastboot 指令作為系統指令執行的幫助程序方法。

CommandResult executeLongFastbootCommand (String... cmdArgs)

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

CommandResult executeLongFastbootCommand ( envVarMap, String... cmdArgs) executeLongFastbootCommand ( envVarMap, String... cmdArgs)

幫助程序方法,將長時間運行的 fastboot 命令作為具有系統環境變數的系統命令執行。

String executeShellCommand (String command)

執行 adb shell 指令並以String形式傳回輸出的 Helper 方法。

void executeShellCommand (String command, IShellOutputReceiver receiver, long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts)

執行 adb shell 指令,使用更多參數來控制指令行為。

void executeShellCommand (String command, IShellOutputReceiver receiver, long maxTimeoutForCommand, long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts)

執行 adb shell 指令,使用更多參數來控制指令行為。

void executeShellCommand (String command, IShellOutputReceiver receiver)

執行給定的 adb shell 命令,如果命令失敗則重試多次。

CommandResult executeShellV2Command (String cmd)

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

CommandResult executeShellV2Command (String cmd, OutputStream pipeToOutput)

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

CommandResult executeShellV2Command (String cmd, File pipeAsInput)

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

CommandResult executeShellV2Command (String cmd, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts)

執行 adb shell 指令,使用更多參數來控制指令行為。

CommandResult executeShellV2Command (String cmd, long maxTimeoutForCommand, TimeUnit timeUnit)

執行 adb shell 指令,使用更多參數來控制指令行為。

CommandResult executeShellV2Command (String cmd, File pipeAsInput, OutputStream pipeToOutput, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts)

執行 adb shell 指令,使用更多參數來控制指令行為。

CommandResult executeShellV2Command (String cmd, File pipeAsInput, OutputStream pipeToOutput, OutputStream pipeToError, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts)

執行 adb shell 指令,使用更多參數來控制指令行為。

CommandResult fastbootWipePartition (String partition)

擦除設備分割區的輔助方法。

getActiveApexes ()

取得有關裝置上已啟動的 APEX 的資訊。

getAllSettings (String namespace)

傳回請求的命名空間的鍵值對。

DeviceAllocationState getAllocationState ()

返回設備目前的分配狀態

String getAndroidId (int userId)

尋找並傳回與 userId 關聯的 android-id,如果找不到則傳回 null。

getAndroidIds ()

建立一個找到符合使用者 ID 的 Android ID 地圖。

int getApiLevel ()

取得設備 API 等級。

PackageInfo getAppPackageInfo (String packageName)

取得有關裝置上安裝的軟體包的資訊。

getAppPackageInfos ()

取得裝置上安裝的軟體包的資訊。

String getBasebandVersion ()

取得該設備的基頻(無線電)版本的便捷方法。

Integer getBattery ()

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

boolean getBooleanProperty (String name, boolean defaultValue)

傳回給定屬性的布林值。

getBootHistory ()

Helper 方法收集帶有啟動時間和啟動原因的啟動歷史記錄圖。

getBootHistorySince (long utcEpochTime, TimeUnit timeUnit)

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

String getBootloaderVersion ()

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

InputStreamSource getBugreport ()

從設備檢索錯誤報告。

InputStreamSource getBugreportz ()

從設備檢索錯誤報告。

String getBuildAlias ()

檢索設備目前正在運行的建置的別名。

String getBuildFlavor ()

檢索設備的建構風格。

String getBuildId ()

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

String getBuildSigningKeys ()

傳回用於簽署裝置映像的金鑰類型

通常,Android 裝置可以使用測試金鑰(如 AOSP 中)或發布金鑰(由各個裝置製造商控制)進行簽名

DeviceDescriptor getCachedDeviceDescriptor ()

如果裝置已分配,則傳回快取的DeviceDescriptor ,否則傳回目前的DeviceDescriptor

DeviceDescriptor getCachedDeviceDescriptor (boolean shortDescriptor)

如果裝置已分配,則傳回快取的DeviceDescriptor ,否則傳回目前的DeviceDescriptor

String[] getChildren (String path)

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

AbstractConnection getConnection ()

與裝置關聯的目前連線。

DeviceFoldableState getCurrentFoldableState ()

傳回裝置目前的可折疊狀態,如果發生某些問題,則傳回 null。

int getCurrentUser ()

傳回目前運行使用者的id。

String getDeviceClass ()

取得設備類別。

long getDeviceDate ()

返回設備的日期(自紀元以來的毫秒數)。

DeviceDescriptor getDeviceDescriptor ()

從設備資訊中返回DeviceDescriptor以獲取其訊息,而無需傳遞實際的設備物件。

DeviceDescriptor getDeviceDescriptor (boolean shortDescriptor)

從設備資訊中返回DeviceDescriptor以獲取其訊息,而無需傳遞實際的設備物件。

TestDeviceState getDeviceState ()

獲取設備的狀態。

long getDeviceTimeOffset (Date date)

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

InputStreamSource getEmulatorOutput ()

取得模擬器stdout和stderr的串流

Process getEmulatorProcess ()

傳回該模擬器對應的Process

final File getExecuteShellCommandLog ()

包含所有executeShellCommand(String)日誌的日誌。

long getExternalStoreFreeSpace ()

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

String getFastbootPath ()

傳回正在使用的 fastboot 二進位檔案的路徑。

String getFastbootProductType ()

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

String getFastbootProductVariant ()

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

String getFastbootSerialNumber ()

返回快速啟動模式序號。

String getFastbootVariable (String variableName)

從裝置檢索給定的 fastboot 變數值。

String getFastbootVersion ()

傳回正在使用的 fastboot 二進位檔案的版本字串。

IFileEntry getFileEntry (String path)

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

IFileEntry getFileEntry (FileListingService.FileEntry entry)

從非根路徑取得FileEntry非官方幫助程式。

getFoldableStates ()

返回設備上可折疊狀態的清單。

IDevice getIDevice ()

傳回關聯 ddmlib IDevice的參考。

getInstalledPackageNames ()

取得裝置上存在的應用程式套件名稱。

long getIntProperty (String name, long defaultValue)

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

String getIpAddress ()

取得設備的IP位址。

KeyguardControllerState getKeyguardState ()

傳回一個物件以取得鍵盤保護的目前狀態,如果不支持,則傳回 null。

long getLastExpectedRebootTimeMillis ()

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

int getLaunchApiLevel ()

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

InputStreamSource getLogcat ()

取得 logcat 資料的快照流。

InputStreamSource getLogcat (int maxBytes)

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

InputStreamSource getLogcatDump ()

取得設備目前 logcat 的轉儲。

InputStreamSource getLogcatSince (long date)

取得從提供的日期開始擷取的 logcat 資料的快照流。

String getMacAddress ()

傳回設備的MAC位址,如果向設備查詢失敗則傳回null。

Integer getMainUserId ()

返回主用戶 ID。

getMainlineModuleInfo ()

取得有關設備上安裝的主線模組的資訊。

int getMaxNumberOfRunningUsersSupported ()

獲取支援的同時運行用戶的最大數量。

int getMaxNumberOfUsersSupported ()

取得支援的最大用戶數。

Process getMicrodroidProcess ()
IDeviceStateMonitor getMonitor ()

傳回與裝置關聯的IDeviceStateMonitor

String getMountPoint (String mountName)

傳回一個掛載點。

ITestDevice.MountPointInfo getMountPointInfo (String mountpoint)

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

getMountPointInfo ()

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

TestDeviceOptions getOptions ()

取得設備的測試選項。

long getPartitionFreeSpace (String partition)

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

Integer getPrimaryUserId ()

返回主要用戶 ID。

ProcessInfo getProcessByName (String processName)

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

String getProcessPid (String process)

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

String getProductType ()

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

String getProductVariant ()

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

String getProperty (String name)

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

ITestDevice.RecoveryMode getRecoveryMode ()

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

InputStreamSource getScreenshot (String format)

從裝置擷取螢幕截圖。

InputStreamSource getScreenshot (long displayId)

從給定顯示 ID 的裝置擷取螢幕截圖。

InputStreamSource getScreenshot (String format, boolean rescale)

從裝置擷取螢幕截圖。

InputStreamSource getScreenshot ()

從裝置擷取螢幕截圖。

String getSerialNumber ()

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

String getSetting (int userId, String namespace, String key)

傳回所請求設定的值。

String getSetting (String namespace, String key)

請參閱getSetting(int, String, String)並在系統使用者上執行。

String getSimOperator ()

傳回 SIM 卡運營商,如果不可用或設備不可用,則傳回 null。

String getSimState ()

傳回 SIM 卡狀態,如果不可用或裝置不可用,則傳回 null。

getTombstones ()

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

long getTotalMemory ()

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

getUninstallablePackageNames ()

取得可卸載的應用程式套件名稱。

boolean getUseFastbootErase ()

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

int getUserFlags (int userId)

尋找並返回給定使用者的標誌。

getUserInfos ()

取得裝置上 useId 到UserInfo的 Map。

int getUserSerialNumber (int userId)

如果找到,則傳回與 userId 關聯的序號,在任何其他情況下傳回 -10000。

IManagedTestDevice.DeviceEventResponse handleAllocationEvent (DeviceEvent event)

處理給定的DeviceEvent。

處理 DeviceEvent,這可能會也可能不會將該設備轉換到新的分配狀態。

boolean hasFeature (String feature)

檢查設備上是否有可用的功能。

String installPackage (File packageFile, boolean reinstall, String... extraArgs)

在裝置上安裝 Android 軟體套件。

String installPackage (File packageFile, boolean reinstall, boolean grantPermissions, String... extraArgs)

在裝置上安裝 Android 軟體套件。

String installPackageForUser (File packageFile, boolean reinstall, int userId, String... extraArgs)

在裝置上為給定使用者安裝 Android 軟體包。

String installPackageForUser (File packageFile, boolean reinstall, boolean grantPermissions, int userId, String... extraArgs)

在裝置上為給定使用者安裝 Android 軟體包。

void invalidatePropertyCache ()
boolean isAdbRoot ()

boolean isAdbTcp ()
boolean isAppEnumerationSupported ()

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

boolean isBypassLowTargetSdkBlockSupported ()

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

boolean isDebugfsMounted ()

檢查 debugfs 是否已安裝。

boolean isDeviceEncrypted ()

返回裝置是否已加密。

boolean isDirectory (String path)

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

boolean isEnableAdbRoot ()
boolean isEncryptionSupported ()

返回裝置是否支援加密。

boolean isExecutable (String fullPath)

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

boolean isFastbootEnabled ()

返回裝置是否可以使用 fastboot。

boolean isHeadless ()

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

boolean isHeadlessSystemUserMode ()

返回設備是否使用無頭系統使用者模式。

boolean isMainUserPermanentAdmin ()

返回主用戶是否為永久管理員且無法刪除或降級為非管理員狀態。

boolean isMultiUserSupported ()

確定是否支援多用戶。

boolean isPackageInstalled (String packageName, String userId)

查詢裝置中給定的軟體包名稱和給定的使用者 ID,以檢查目前是否已為該使用者安裝。

boolean isPackageInstalled (String packageName)

查詢設備中給定的軟體包名稱,以檢查它目前是否已安裝。

boolean isRuntimePermissionSupported ()

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

boolean isStateBootloaderOrFastbootd ()

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

boolean isUserRunning (int userId)

檢查給定使用者是否正在運行。

boolean isUserSecondary (int userId)

根據其標誌傳回指定使用者是否為次要使用者。

boolean isUserVisible (int userId)

檢查給定使用者是否可見。

boolean isUserVisibleOnDisplay (int userId, int displayId)

檢查給定使用者在給定顯示中是否可見。

boolean isVisibleBackgroundUsersOnDefaultDisplaySupported ()

返回設備是否允許使用者在ERROR(/java.android.view.Display#DEFAULT_DISPLAY)中在背景啟動可見。

boolean isVisibleBackgroundUsersSupported ()

返回設備是否允許使用者在背景啟動可見。

boolean isWifiEnabled ()

測試 wifi 是否已啟用。

listDisplayIds ()

收集「dumpsys SurfaceFlinger」報告的裝置上可用顯示器 ID 的清單。

listDisplayIdsForStartingVisibleBackgroundUsers ()

取得可用於start a user visible in the background顯示清單。

listUsers ()

取得裝置上的使用者清單。

boolean logAnrs ( ITestLogger logger)

從設備收集並記錄 ANR。

boolean logBugreport (String dataName, ITestLogger listener)

取得錯誤報告並將其記錄給報告者的協助方法。

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

在設備的 logcat 中記錄訊息。

void mountDebugfs ()

掛載調試檔案。

void nonBlockingReboot ()

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

void postAdbRootAction ()

如果裝置需要在 adb root 之後和裝置重新上線之前執行某些特定操作,則會覆蓋。

void postAdbUnrootAction ()

如果裝置需要在 adb unroot 之後和裝置重新上線之前執行某些特定操作,則會覆蓋。

void postBootSetup ()

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

void postInvocationTearDown (Throwable exception)

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

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

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

boolean pullDir (String deviceFilePath, File localDir)

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

boolean pullFile (String remoteFilePath, File localFile)

從設備上檢索文件。

File pullFile (String remoteFilePath, int userId)

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

File pullFile (String remoteFilePath)

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

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

從設備上檢索文件。

String pullFileContents (String remoteFilePath)

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

File pullFileFromExternal (String remoteFilePath)

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

boolean pushDir (File localFileDir, String deviceFilePath, excludedDirectories) pushDir (File localFileDir, String deviceFilePath, excludedDirectories)

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

boolean pushDir (File localFileDir, String deviceFilePath)

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

boolean pushFile (File localFile, String remoteFilePath, boolean evaluateContentProviderNeeded)

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

boolean pushFile (File localFile, String remoteFilePath)

將檔案推送到裝置。

boolean pushString (String contents, String remoteFilePath)

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

void reboot (String reason)

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

void reboot ()

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

void rebootIntoBootloader ()

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

void rebootIntoFastbootd ()

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

void rebootIntoRecovery ()

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

void rebootIntoSideload ()

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

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

void rebootIntoSideload (boolean autoReboot)

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

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

void rebootUntilOnline ()

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

void rebootUntilOnline (String reason)

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

void rebootUserspace ()

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

void rebootUserspaceUntilOnline ()

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

boolean recoverDevice ()

嘗試恢復設備通訊。

void registerDeviceActionReceiver ( IDeviceActionReceiver deviceActionReceiver)

為此設備註冊一個IDeviceActionReceiver

void remountSystemReadOnly ()

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

void remountSystemWritable ()

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

void remountVendorReadOnly ()

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

void remountVendorWritable ()

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

boolean removeAdmin (String componentName, int userId)

刪除給定使用者中的給定設備管理員,如果成功則傳回true ,否則傳回false

void removeOwners ()

盡最大努力刪除所有現有的設備設定檔擁有者。

boolean removeUser (int userId)

從設備中刪除給定用戶。

void resetContentProviderSetup ()

重置內容提供者設定的標誌以便再次觸發它。

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

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

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

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

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

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

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

void setConfiguration ( IConfiguration configuration)

注入正在使用的IConfiguration

final void setConnectionAvdInfo ( GceAvdInfo avdInfo)
void setDate (Date date)

設定設備上的日期

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

boolean setDeviceOwner (String componentName, int userId)

將設備管理元件設定為給定使用者的設備擁有者。

void setDeviceState ( TestDeviceState deviceState)

更新設備的狀態。

void setEmulatorOutputStream ( SizeLimitedOutputStream output)

對於模擬器,設定SizeLimitedOutputStream來記錄輸出

void setEmulatorProcess (Process p)

當設備是模擬器時,設定Process

void setFastbootEnabled (boolean fastbootEnabled)

設定設備的快速啟動選項。

void setFastbootPath (String fastbootPath)

設定應使用的 fastboot 二進位檔案的路徑。

void setIDevice (IDevice newDevice)

更新與此 ITestDevice 關聯的 IDevice。

void setLogStartDelay (int delay)

設定線上設備開始 logcat 捕獲之前等待的時間(以毫秒為單位)。

void setOptions ( TestDeviceOptions options)

設定設備的TestDeviceOptions

boolean setProperty (String propKey, String propValue)

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

void setRecovery ( IDeviceRecovery recovery)

設定用於此裝置的IDeviceRecovery

void setRecoveryMode ( ITestDevice.RecoveryMode mode)

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

void setSetting (String namespace, String key, String value)

請參閱setSetting(int, String, String, String)並在系統使用者上執行。

void setSetting (int userId, String namespace, String key, String value)

將設定值新增至給定使用者的命名空間。

void setTestLogger ( ITestLogger testLogger)

注入ITestLogger實例

void setUseFastbootErase (boolean useFastbootErase)

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

void startLogcat ()

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

boolean startUser (int userId)

如果給定使用者目前已停止,則在背景啟動該使用者。

boolean startUser (int userId, boolean waitFlag)

如果給定使用者目前已停止,則在背景啟動該使用者。

boolean startVisibleBackgroundUser (int userId, int displayId, boolean waitFlag)

在背景啟動給定用戶,在給定顯示中可見(即允許用戶在該顯示中啟動活動)。

void stopEmulatorOutput ()

關閉並刪除模擬器輸出。

void stopLogcat ()

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

boolean stopUser (int userId)

停止給定使用者。

boolean stopUser (int userId, boolean waitFlag, boolean forceFlag)

停止給定使用者。

String switchToAdbTcp ()

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

boolean switchToAdbUsb ()

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

boolean switchUser (int userId)

切換到另一個具有預設逾時的使用者 ID。

boolean switchUser (int userId, long timeout)

切換到另一個使用者 ID,並以提供的逾時為截止時間。

boolean syncFiles (File localFileDir, String deviceFilePath)

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

Bugreport takeBugreport ()

取得錯誤報告並將其返回Bugreport物件中以進行處理。

String uninstallPackage (String packageName)

從裝置卸載 Android 軟體包。

String uninstallPackageForUser (String packageName, int userId)

從裝置上為給定使用者卸載 Android 軟體包。

boolean unlockDevice ()

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

void unmountDebugfs ()

卸載 debugfs。

boolean waitForBootComplete (long timeOut)

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

boolean waitForDeviceAvailable ()

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

boolean waitForDeviceAvailable (long waitTime)

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

boolean waitForDeviceAvailableInRecoverPath (long waitTime)

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

void waitForDeviceBootloader ()

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

boolean waitForDeviceInRecovery (long waitTime)

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

boolean waitForDeviceInSideload (long waitTime)

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

boolean waitForDeviceNotAvailable (long waitTime)

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

void waitForDeviceOnline ()

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

void waitForDeviceOnline (long waitTime)

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

boolean waitForDeviceShell (long waitTime)

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

受保護的方法

void addExtraConnectionBuilderArgs ( DefaultConnection.ConnectionBuilder builder)
String[] buildAdbShellCommand (String command, boolean forceExitStatusDetection)

為給定的 adb shell 命令會話和參數建立作業系統命令

void checkApiLevelAgainst (String feature, int strictMinLevel)
NativeDevice.RebootDeviceAction createRebootDeviceAction ( NativeDevice.RebootMode rebootMode, String reason)

建立要在執行重新啟動操作時使用的RebootDeviceAction

IRunUtil createRunUtil ()
void doAdbReboot ( NativeDevice.RebootMode rebootMode, String reason)

執行 adb 重啟。

void ensureRuntimePermissionSupported ()

如果不支援運行時權限,則拋出異常的輔助方法

int getApiLevelSafe ()
ITestLogger getLogger ()
IRunUtil getRunUtil ()

取得要使用的RunUtil實例。

void initializeConnection ( IBuildInfo info, MultiMap <String, String> attributes)
String internalGetProperty (String propName, String fastbootVar, String description)

預設情況下,從 ddmlib 快取中取得裝置屬性,然後根據裝置是否處於 Fastboot 狀態,返回「adb shell getprop」或「fastboot getvar」。

boolean isInRebootCallback ()

傳回目前是否正在執行重新啟動回呼。

boolean isNewer (File localFile, IFileEntry entry)

如果本機檔案比遠端檔案新,則傳回true

void notifyRebootEnded ()

通知所有IDeviceActionReceiver有關重新啟動結束事件的資訊。

void notifyRebootStarted ()

通知所有IDeviceActionReceiver有關重新啟動開始事件。

boolean performDeviceAction (String actionDescription, NativeDevice.DeviceAction action, int retryAttempts)

在此設備上執行操作。

void postAdbReboot ()

重新啟動後可能採取的額外操作。

void prePostBootSetup ()

允許每種裝置類型(AndroidNativeDevice、TestDevice)覆寫此方法以進行特定的啟動後設定。

boolean pullFileInternal (String remoteFilePath, File localFile)
void setClock (Clock clock)

設定要使用的 Clock 實例。

void setMicrodroidProcess (Process process)

將 TestDevice 標記為 microdroid 並設定其 CID。

void setTestDeviceOptions ( deviceOptions) setTestDeviceOptions ( deviceOptions)
CommandResult simpleFastbootCommand (long timeout, envVarMap, String[] fullCmd) simpleFastbootCommand (long timeout, envVarMap, String[] fullCmd)

使用環境變數執行簡單的 fastboot 命令並報告命令的狀態。

CommandResult simpleFastbootCommand (long timeout, String[] fullCmd)

執行簡單的 fastboot 指令並報告指令的狀態。

boolean waitForDeviceNotAvailable (String operationDesc, long time)

等待看到設備變得不可用(停止向 adb 報告)。

常數

INVALID_USER_ID

public static final int INVALID_USER_ID

為任何無效/未找到的使用者 ID 傳回的值:UserHandle 定義了 -10000 值

常數值:-10000 (0xffffd8f0)

MAX_HOST_DEVICE_TIME_OFFSET

protected static final long MAX_HOST_DEVICE_TIME_OFFSET

常數值:5000 (0x0000000000001388)

最多重試次數

protected static final int MAX_RETRY_ATTEMPTS

執行指令重試的預設次數

常量值:2 (0x00000002)

領域

偵錯路徑

public static final String DEBUGFS_PATH

SD卡

protected static final String SD_CARD

儲存_模擬

protected static final String STORAGE_EMULATED

m選項

protected TestDeviceOptions mOptions

狀態監視器

protected final IDeviceStateMonitor mStateMonitor

公共構造函數

本地設備

public NativeDevice (IDevice device, 
                IDeviceStateMonitor stateMonitor, 
                IDeviceMonitor allocationMonitor)

建立一個TestDevice

參數
device IDevice :關聯的IDevice

stateMonitor IDeviceStateMonitor :要使用的IDeviceStateMonitor機制

allocationMonitor IDeviceMonitor :通知指派狀態變更的IDeviceMonitor 。可以為空

公共方法

batchPrefetchStartupBuildProps

public void batchPrefetchStartupBuildProps ()

透過預取我們需要的所有道具而不是為每個道具呼叫「adb getprop」來進行微最佳化(大約 400 毫秒)。即,取得所有屬性與取得一個屬性一樣快。像 device.getApiLevel()、checkApiLevelAgainstNextRelease 和 getBuildAlias 這樣的東西都在底層呼叫「adb getprop」。我們透過一次呼叫來獲取它們並呼叫 NativeDevice.setProperty。即使我們不這樣做,NativeDevice 本身也會呼叫 setProperty 並快取結果以供將來呼叫。我們只是稍微提前了一點。如果設備處於恢復狀態或在獲取道具時出現其他錯誤,我們將忽略它們。

可以切換到Headless系統用戶

public boolean canSwitchToHeadlessSystemUser ()

返回是否允許切換到無頭SYSTEM用戶。

退貨
boolean

投擲
DeviceNotAvailableException

檢查 ApiLevelAgainstNextRelease

public boolean checkApiLevelAgainstNextRelease (int strictMinLevel)

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

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

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

投擲
DeviceNotAvailableException

檢查連接性

public boolean checkConnectivity ()

檢查設備是否具有網路連線。

退貨
boolean如果裝置有有效的網路連接, true ,否則為false

投擲
DeviceNotAvailableException

清除錯誤對話框

public boolean clearErrorDialogs ()

嘗試關閉裝置 UI 上目前顯示的任何錯誤對話框。

退貨
boolean如果不存在對話方塊或對話方塊已成功清除, true 。否則為false

投擲
DeviceNotAvailableException

清除上次連線的 Wifi 網路

public void clearLastConnectedWifiNetwork ()

清除上次連線的 wifi 網路。應在開始新呼叫時呼叫此函數,以避免在裝置重新啟動後連接到先前測試中使用的 wifi 網路。

清除Logcat

public void clearLogcat ()

刪除所有累積的 logcat 資料。

當您想要確保ITestDevice#getLogcat()僅傳回在某個點之後(例如刷新新裝置版本後等)產生的日誌資料時,這非常有用。

連接到Wifi網絡

public boolean connectToWifiNetwork ( wifiSsidToPsk, 
                boolean scanSsid)

連接到 wifi 網路。

開啟 wifi 並阻止,直到與 wifiSsidToPsk 對映中給出的 wifi 網路之一成功連線。建立連接後,實例將在每次重新啟動後嘗試恢復連接,直到呼叫ITestDevice#disconnectFromWifi()ITestDevice#clearLastConnectedWifiNetwork()為止。

參數
wifiSsidToPsk :wifi SSID 到密碼的對應。

scanSsid boolean :是否掃描該網路的隱藏 SSID。

退貨
boolean如果成功連接到 wifi 網路則為true 。否則為false

投擲
DeviceNotAvailableException

連接到Wifi網絡

public boolean connectToWifiNetwork (String wifiSsid, 
                String wifiPsk)

連接到 wifi 網路。

開啟 wifi 並阻止,直到成功連接到指定的 wifi 網路。建立連接後,實例將在每次重新啟動後嘗試恢復連接,直到呼叫ITestDevice#disconnectFromWifi()ITestDevice#clearLastConnectedWifiNetwork()為止。

參數
wifiSsid String : 要連線的 wifi ssid

wifiPsk String : PSK 密碼,如果未加密則為 null

退貨
boolean如果成功連接到 wifi 網路則為true 。否則為false

投擲
DeviceNotAvailableException

連接到Wifi網絡

public boolean connectToWifiNetwork ( wifiSsidToPsk)

連接到 wifi 網路。

開啟 wifi 並阻止,直到與 wifiSsidToPsk 對映中給出的 wifi 網路之一成功連線。一旦建立連接,實例將在每次重新啟動後嘗試恢復連接,直到調用ITestDevice#disconnectFromWifi()ITestDevice#clearLastConnectedWifiNetwork()

參數
wifiSsidToPsk :wifi SSID 到密碼的對應。

退貨
boolean如果成功連接到 wifi 網路則為true 。否則為false

投擲
DeviceNotAvailableException

連接到Wifi網絡

public boolean connectToWifiNetwork (String wifiSsid, 
                String wifiPsk, 
                boolean scanSsid)

連接到 wifi 網路。

開啟 wifi 並阻止,直到成功連接到指定的 wifi 網路。建立連接後,實例將在每次重新啟動後嘗試恢復連接,直到呼叫ITestDevice#disconnectFromWifi()ITestDevice#clearLastConnectedWifiNetwork()為止。

參數
wifiSsid String : 要連線的 wifi ssid

wifiPsk String : PSK 密碼,如果未加密則為 null

scanSsid boolean :是否掃描該網路的隱藏 SSID。

退貨
boolean如果成功連接到 wifi 網路則為true 。否則為false

投擲
DeviceNotAvailableException

如果需要連接到 Wifi 網路

public boolean connectToWifiNetworkIfNeeded (String wifiSsid, 
                String wifiPsk, 
                boolean scanSsid)

connectToWifiNetwork(String, String)的變體,僅當裝置目前沒有網路連線時才進行連線。

參數
scanSsid boolean : 是否掃描該網路的隱藏 SSID

退貨
boolean如果成功連接到 wifi 網路則為true 。否則為false

投擲
DeviceNotAvailableException

如果需要連接到 Wifi 網路

public boolean connectToWifiNetworkIfNeeded (String wifiSsid, 
                String wifiPsk)

connectToWifiNetwork(String, String)的變體,僅當裝置目前沒有網路連線時才進行連線。

退貨
boolean如果成功連接到 wifi 網路則為true 。否則為false

投擲
DeviceNotAvailableException

創建用戶

public int createUser (String name, 
                boolean guest, 
                boolean ephemeral)

使用給定名稱和提供的標誌建立用戶

參數
name String :要在裝置上建立的用戶

guest boolean : 在建立過程中啟用使用者標誌 --guest

ephemeral boolean :在建立過程中啟用使用者標誌 --ephemeral

退貨
int建立使用者的id

投擲
DeviceNotAvailableException

創建用戶

public int createUser (String name, 
                boolean guest, 
                boolean ephemeral, 
                boolean forTesting)

使用給定名稱和提供的標誌建立用戶

參數
name String :要在裝置上建立的用戶

guest boolean : 在建立過程中啟用使用者標誌 --guest

ephemeral boolean :在建立過程中啟用使用者標誌 --ephemeral

forTesting boolean :在建立過程中啟用測試標誌 --for-testing

退貨
int建立使用者的id

投擲
DeviceNotAvailableException

創建用戶

public int createUser (String name)

建立一個具有給定名稱和預設標誌 0 的使用者。

參數
name String :要在裝置上建立的用戶

退貨
int建立的使用者 ID 的整數

投擲
DeviceNotAvailableException

創建用戶不拋出

public int createUserNoThrow (String name)

建立一個具有給定名稱和預設標誌 0 的使用者。

參數
name String :要在裝置上建立的用戶

退貨
int建立的使用者 ID 的整數或 -1 表示錯誤。

投擲
DeviceNotAvailableException

刪除文件

public void deleteFile (String deviceFilePath)

用於刪除裝置上的檔案或目錄的幫助程式方法。

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

投擲
DeviceNotAvailableException

註銷設備操作接收器

public void deregisterDeviceActionReceiver (IDeviceActionReceiver deviceActionReceiver)

刪除已註冊的IDeviceActionReceiver

參數
deviceActionReceiver IDeviceActionReceiver :將刪除的IDeviceActionReceiver

設備軟重啟

public boolean deviceSoftRestarted (ProcessInfo prevSystemServerProcess)

透過將目前 system_server 與先前的 system_server ProcessInfo進行比較來檢查裝置是否軟重啟的幫助程式方法。使用getProcessByName(String)取得ProcessInfo

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

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

投擲
DeviceNotAvailableException

設備軟重啟以來

public boolean deviceSoftRestartedSince (long utcEpochTime, 
                TimeUnit timeUnit)

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

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

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

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

投擲
DeviceNotAvailableException

禁用AdbRoot

public boolean disableAdbRoot ()

關閉 adb root。

停用 adb root 可能會導致裝置與 adb 斷開連線。此方法將阻塞,直到設備可用。

退貨
boolean如果成功則為true

投擲
DeviceNotAvailableException

禁用鍵盤鎖

public void disableKeyguard ()

嘗試停用鍵盤保護。

首先等待輸入調度準備就緒,這大約在設備報告 BOOT_COMPLETE 的同時發生,顯然是非同步的,因為當前的框架實作偶爾會出現競爭條件。然後發送命令以解除鍵盤保護(僅適用於非安全鍵盤)

投擲
DeviceNotAvailableException

停用網路監視器

public boolean disableNetworkMonitor ()

停用裝置上的網路監控。

退貨
boolean如果成功停用監控則為true 。如果失敗則為false

投擲
DeviceNotAvailableException

斷開與Wifi的連接

public boolean disconnectFromWifi ()

與 WiFi 網路斷開連線。

從已知網路清單中刪除所有網路並停用 wifi。

退貨
boolean如果成功斷開與 wifi 網路的連接,則為true 。如果斷開連線失敗,則false

投擲
DeviceNotAvailableException

文件是否存在

public boolean doesFileExist (String deviceFilePath, 
                int userId)

用於確定給定使用者的裝置上的檔案是否存在的幫助程序方法。

參數
deviceFilePath String : 要檢查的裝置上檔案的絕對路徑

userId int :用於檢查檔案存在的使用者 ID

退貨
boolean如果檔案存在true ,否則為false

投擲
DeviceNotAvailableException

文件是否存在

public boolean doesFileExist (String deviceFilePath)

確定裝置上的檔案是否存在的幫助程序方法。

參數
deviceFilePath String : 要檢查的裝置上檔案的絕對路徑

退貨
boolean如果檔案存在true ,否則為false

投擲
DeviceNotAvailableException

轉儲堆

public File dumpHeap (String process, 
                String devicePath)

嘗試從 system_server 轉儲堆。呼叫者有責任清理轉儲的檔案。

參數
process String :轉儲堆的裝置程序的名稱。

devicePath String :裝置上放置轉儲的路徑。這必須是權限允許的位置。

退貨
File包含報告的ERROR(/File) 。如果某件事失敗則為空。

投擲
DeviceNotAvailableException

啟用AdbRoot

public boolean enableAdbRoot ()

打開 adb root。如果“enable-root”設定為“false”,則會記錄一則訊息並傳回而不啟用 root。

啟用 adb root 可能會導致裝置與 adb 斷開連線。此方法將阻塞,直到設備可用。

退貨
boolean如果成功則為true

投擲
DeviceNotAvailableException

啟用網路監視器

public boolean enableNetworkMonitor ()

啟用設備上的網路監控。

退貨
boolean true如果監控啟用成功。如果失敗則為false

投擲
DeviceNotAvailableException

執行Adb指令

public String executeAdbCommand (long timeout, 
                String... cmdArgs)

將 adb 命令作為具有指定逾時的系統命令執行的幫助程序方法。

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

參數
timeout long :裝置被視為無回應之前的時間(以毫秒為單位),0L 表示無逾時

cmdArgs String :要執行的 adb 指令和參數

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

投擲
DeviceNotAvailableException

執行Adb指令

public String executeAdbCommand (long timeout, 
                 envMap, 
                String... cmdArgs)

將 adb 命令作為具有指定逾時的系統命令執行的幫助程序方法。

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

參數
timeout long :裝置被視為無回應之前的時間(以毫秒為單位),0L 表示無逾時

envMap :為指令設定的環境

cmdArgs String :要執行的 adb 指令和參數

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

投擲
DeviceNotAvailableException

執行Adb指令

public String executeAdbCommand (String... cmdArgs)

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

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

參數
cmdArgs String :要執行的 adb 指令和參數

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

投擲
DeviceNotAvailableException

執行Fastboot命令

public CommandResult executeFastbootCommand (String... cmdArgs)

將 fastboot 指令作為系統指令執行的幫助程序方法,預設逾時為 2 分鐘。

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

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

退貨
CommandResult包含指令輸出的 CommandResult

投擲
DeviceNotAvailableException

執行Fastboot命令

public CommandResult executeFastbootCommand (long timeout, 
                String... cmdArgs)

將 fastboot 指令作為系統指令執行的幫助程序方法。

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

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

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

退貨
CommandResult包含指令輸出的 CommandResult

投擲
DeviceNotAvailableException

執行LongFastboot命令

public CommandResult executeLongFastbootCommand (String... cmdArgs)

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

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

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

退貨
CommandResult包含指令輸出的 CommandResult

投擲
DeviceNotAvailableException

執行LongFastboot命令

public CommandResult executeLongFastbootCommand ( envVarMap, 
                String... cmdArgs)

幫助程序方法,將長時間運行的 fastboot 命令作為具有系統環境變數的系統命令執行。

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

參數
envVarMap :fastboot命令運行時使用的系統環境變數

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

退貨
CommandResult包含指令輸出的 CommandResult

投擲
DeviceNotAvailableException

執行Shell命令

public String executeShellCommand (String command)

執行 adb shell 指令並以String形式傳回輸出的 Helper 方法。

參數
command String : 要執行的 adb shell 指令

退貨
String外殼輸出

投擲
DeviceNotAvailableException

執行Shell命令

public 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 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 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 CommandResult executeShellV2Command (String cmd)

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

參數
cmd String :應該執行的命令。

退貨
CommandResult結果在CommandResult

投擲
DeviceNotAvailableException

執行ShellV2命令

public CommandResult executeShellV2Command (String cmd, 
                OutputStream pipeToOutput)

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

參數
cmd String :應該執行的命令。

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

退貨
CommandResult結果在CommandResult

投擲
DeviceNotAvailableException

執行ShellV2命令

public CommandResult executeShellV2Command (String cmd, 
                File pipeAsInput)

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

參數
cmd String :應該執行的命令。

pipeAsInput File :將作為命令的輸入透過管道傳輸的ERROR(/File) ,或為空。

退貨
CommandResult結果在CommandResult

投擲
DeviceNotAvailableException

執行ShellV2命令

public CommandResult executeShellV2Command (String cmd, 
                long maxTimeoutForCommand, 
                TimeUnit timeUnit, 
                int retryAttempts)

執行 adb shell 指令,使用更多參數來控制指令行為。

參數
cmd String : 要執行的 adb shell 指令

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

timeUnit TimeUnit : maxTimeToOutputShellResponse的單位

retryAttempts int :如果因為異常而失敗,重試指令的最大次數。如果執行retryAttempts沒有成功,將會拋出 DeviceNotResponsiveException。

退貨
CommandResult

投擲
DeviceNotAvailableException

執行ShellV2命令

public CommandResult executeShellV2Command (String cmd, 
                long maxTimeoutForCommand, 
                TimeUnit timeUnit)

執行 adb shell 指令,使用更多參數來控制指令行為。

參數
cmd String : 要執行的 adb shell 指令

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

timeUnit TimeUnit : maxTimeToOutputShellResponse的單位

退貨
CommandResult

投擲
DeviceNotAvailableException

執行ShellV2命令

public CommandResult executeShellV2Command (String cmd, 
                File pipeAsInput, 
                OutputStream pipeToOutput, 
                long maxTimeoutForCommand, 
                TimeUnit timeUnit, 
                int retryAttempts)

執行 adb shell 指令,使用更多參數來控制指令行為。

參數
cmd 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 CommandResult executeShellV2Command (String cmd, 
                File pipeAsInput, 
                OutputStream pipeToOutput, 
                OutputStream pipeToError, 
                long maxTimeoutForCommand, 
                TimeUnit timeUnit, 
                int retryAttempts)

執行 adb shell 指令,使用更多參數來控制指令行為。

參數
cmd 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 CommandResult fastbootWipePartition (String partition)

擦除設備分割區的輔助方法。

如果getUseFastbootErase()true ,則將使用 fastboot Erase 來擦除分區。然後,設備必須在下次啟動時建立檔案系統。否則,將使用 fastboot 格式,這將在裝置上建立新的檔案系統。

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

參數
partition String : 要清除的分區

退貨
CommandResult包含指令輸出的 CommandResult

投擲
DeviceNotAvailableException

取得活動頂點

public  getActiveApexes ()

取得有關裝置上已啟動的 APEX 的資訊。

退貨
裝置上目前已啟動的ApexInfoERROR(/Set)

投擲
DeviceNotAvailableException

取得所有設定

public  getAllSettings (String namespace)

傳回請求的命名空間的鍵值對。

參數
namespace String :必須是 {"system", "secure", "global"} 之一

退貨
鍵值對的映射。如果不支援命名空間,則為空。

投擲
DeviceNotAvailableException

取得分配狀態

public DeviceAllocationState getAllocationState ()

返回設備目前的分配狀態

退貨
DeviceAllocationState

取得AndroidId

public String getAndroidId (int userId)

尋找並傳回與 userId 關聯的 android-id,如果找不到則傳回 null。

參數
userId int

退貨
String

投擲
DeviceNotAvailableException

取得AndroidId

public  getAndroidIds ()

建立一個找到符合使用者 ID 的 Android ID 地圖。無法保證每個使用者 ID 都會在此函數中找到關聯的 Android ID,因此某些使用者 ID 可能會符合 null。

退貨
Android ID 地圖找到符合的使用者 ID。

投擲
DeviceNotAvailableException

取得API等級

public int getApiLevel ()

取得設備 API 等級。預設為UNKNOWN_API_LEVEL

退貨
int指示設備 API 等級的整數

投擲
DeviceNotAvailableException

獲取應用程式包信息

public PackageInfo getAppPackageInfo (String packageName)

取得有關裝置上安裝的軟體包的資訊。

參數
packageName String

退貨
PackageInfo如果無法檢索訊息,則為PackageInfonull

投擲
DeviceNotAvailableException

獲取應用程式包信息

public  getAppPackageInfos ()

取得裝置上安裝的軟體包的資訊。

退貨
設備上安裝的PackageInfo ERROR(/List)

投擲
DeviceNotAvailableException

取得基頻版本

public String getBasebandVersion ()

取得該設備的基頻(無線電)版本的便捷方法。取得無線電版本是特定於裝置的,因此它可能無法傳回所有裝置的正確資訊。此方法依賴 gsm.version.baseband 屬性來傳回正確的版本資訊。這對於某些 CDMA 裝置來說並不準確,且此處傳回的版本可能與 fastboot 報告的版本不匹配,並且可能不會傳回 CDMA 無線電的版本。 TL;DR 如果 gsm.version.baseband 屬性與fastboot getvar version-baseband傳回的版本相同,則此方法僅報告準確的版本。

退貨
String String基頻版本,如果無法確定則為null (裝置沒有無線電或無法讀取版本字串)

投擲
DeviceNotAvailableException

取得電池

public Integer getBattery ()

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

退貨
Integer

取得布爾屬性

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

Helper 方法收集帶有啟動時間和啟動原因的啟動歷史記錄圖。

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

投擲
DeviceNotAvailableException

取得啟動歷史記錄

public  getBootHistorySince (long utcEpochTime, 
                TimeUnit timeUnit)

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

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

timeUnit TimeUnit :時間單位TimeUnit

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

投擲
DeviceNotAvailableException

取得Bootloader版本

public String getBootloaderVersion ()

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

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

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

投擲
DeviceNotAvailableException

取得錯誤報告

public InputStreamSource getBugreport ()

從設備檢索錯誤報告。

這個實作保證在沒有 SD 卡的裝置上(或尚未安裝 SD 卡的裝置)繼續運作。

退貨
InputStreamSource一個InputStreamSource ,它將根據需要產生錯誤報告內容。如果失敗, InputStreamSource將產生一個空的ERROR(/InputStream)

取得錯誤報告

public InputStreamSource getBugreportz ()

從設備檢索錯誤報告。 Zip 格式的錯誤報告包含主要錯誤報告和其他對偵錯有用的日誌檔案。

僅支援“adb 版本”> 1.0.36

退貨
InputStreamSource包含 bugreportz 的 zip 檔案的InputStreamSource ,如果失敗則傳回 null。

取得建置別名

public String getBuildAlias ()

檢索設備目前正在運行的建置的別名。

建構別名通常是比建構 ID(通常是 Nexus 建構的數字)更可讀的字串。例如,最終的 Android 4.2 版本的建置別名為 JDQ39,建置 ID 為 573038

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

投擲
DeviceNotAvailableException

獲取BuildFlavor

public String getBuildFlavor ()

檢索設備的建構風格。

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

投擲
DeviceNotAvailableException

取得建置ID

public String getBuildId ()

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

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

投擲
DeviceNotAvailableException

取得建置簽署金鑰

public String getBuildSigningKeys ()

傳回用於簽署裝置映像的金鑰類型

通常,Android 裝置可以使用測試金鑰(如 AOSP 中)或發布金鑰(由各個裝置製造商控制)進行簽名

退貨
String如果找到則為簽章金鑰,否則為 null。

投擲
DeviceNotAvailableException

取得快取設備描述符

public DeviceDescriptor getCachedDeviceDescriptor ()

如果裝置已分配,則傳回快取的DeviceDescriptor ,否則傳回目前的DeviceDescriptor

退貨
DeviceDescriptor

取得快取設備描述符

public DeviceDescriptor getCachedDeviceDescriptor (boolean shortDescriptor)

如果裝置已分配,則傳回快取的DeviceDescriptor ,否則傳回目前的DeviceDescriptor

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

退貨
DeviceDescriptor

獲取孩子

public String[] getChildren (String path)

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

參數
path String :是裝置上進行搜尋的路徑

退貨
String[]包含裝置上路徑中的所有檔案的字串陣列。

投擲
DeviceNotAvailableException

取得連接

public AbstractConnection getConnection ()

與裝置關聯的目前連線。

退貨
AbstractConnection

取得當前可折疊狀態

public DeviceFoldableState getCurrentFoldableState ()

傳回裝置目前的可折疊狀態,如果發生某些問題,則傳回 null。

退貨
DeviceFoldableState

投擲
DeviceNotAvailableException

取得目前用戶

public int getCurrentUser ()

傳回目前運行使用者的id。如果發生錯誤,則傳回-10000。

退貨
int

投擲
DeviceNotAvailableException

取得設備類

public String getDeviceClass ()

取得設備類別。

退貨
String String設備類別。

取得設備日期

public long getDeviceDate ()

返回設備的日期(自紀元以來的毫秒數)。

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

投擲
DeviceNotAvailableException

取得設備描述符

public DeviceDescriptor getDeviceDescriptor ()

從設備資訊中返回DeviceDescriptor以獲取其訊息,而無需傳遞實際的設備物件。

退貨
DeviceDescriptor

取得設備描述符

public DeviceDescriptor getDeviceDescriptor (boolean shortDescriptor)

從設備資訊中返回DeviceDescriptor以獲取其訊息,而無需傳遞實際的設備物件。

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

退貨
DeviceDescriptor

取得設備狀態

public TestDeviceState getDeviceState ()

獲取設備的狀態。

退貨
TestDeviceState

取得設備時間偏移

public long getDeviceTimeOffset (Date date)

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

參數
date Date

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

投擲
DeviceNotAvailableException

取得模擬器輸出

public InputStreamSource getEmulatorOutput ()

取得模擬器stdout和stderr的串流

退貨
InputStreamSource仿真器輸出

取得模擬器進程

public Process getEmulatorProcess ()

傳回該模擬器對應的Process

退貨
Process Processnull

取得執行Shell命令日誌

public final File getExecuteShellCommandLog ()

包含所有executeShellCommand(String)日誌的日誌。

退貨
File

取得外部儲存空閒空間

public long getExternalStoreFreeSpace ()

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

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

投擲
DeviceNotAvailableException

取得快速啟動路徑

public String getFastbootPath ()

傳回正在使用的 fastboot 二進位檔案的路徑。仍然需要isFastbootEnabled()為 true,才能啟用 fastboot 功能。

退貨
String

取得FastbootProductType

public String getFastbootProductType ()

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

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

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

投擲
DeviceNotAvailableException

取得FastbootProductVariant

public String getFastbootProductVariant ()

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

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

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

投擲
DeviceNotAvailableException

取得Fastboot序號

public String getFastbootSerialNumber ()

返回快速啟動模式序號。

退貨
String

取得Fastboot變數

public String getFastbootVariable (String variableName)

從裝置檢索給定的 fastboot 變數值。

參數
variableName String :變數名

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

投擲
DeviceNotAvailableException

取得Fastboot版本

public String getFastbootVersion ()

傳回正在使用的 fastboot 二進位檔案的版本字串。如果出現問題則為 null。

退貨
String

取得文件條目

public IFileEntry getFileEntry (String path)

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

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

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

投擲
DeviceNotAvailableException

取得文件條目

public IFileEntry getFileEntry (FileListingService.FileEntry entry)

從非根路徑取得FileEntry非官方幫助程式。 FIXME:重構 FileEntry 系統,使其可以從任何路徑存取。 (即使是非根)。

參數
entry FileListingService.FileEntryFileEntry不一定是 Ddmlib 所要求的 root。

退貨
IFileEntry代表 FileEntry 的 FileEntryWrapper。

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

取得可折疊狀態

public  getFoldableStates ()

返回設備上可折疊狀態的清單。可以透過“cmd device_state print-states”獲得。

退貨

投擲
DeviceNotAvailableException

取得設備

public IDevice getIDevice ()

傳回關聯 ddmlib IDevice的參考。

每次裝置與 adb 斷開連線並重新連線時,DDMS 可能會指派新的IDevice 。因此,呼叫者不應保留對IDevice引用,因為該引用可能會變得過時。

退貨
IDevice IDevice

取得安裝包名稱

public  getInstalledPackageNames ()

取得裝置上存在的應用程式套件名稱。

退貨
設備上目前安裝的String包名稱ERROR(/Set)

投擲
DeviceNotAvailableException

取得整數屬性

public long getIntProperty (String name, 
                long defaultValue)

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

參數
name String : 屬性名稱

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

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

投擲
DeviceNotAvailableException

取得IP位址

public String getIpAddress ()

取得設備的IP位址。

退貨
String設備的 IP 位址,如果設備沒有 IP 位址,則為null

投擲
DeviceNotAvailableException

取得KeyguardState

public KeyguardControllerState getKeyguardState ()

傳回一個物件以取得鍵盤保護的目前狀態,如果不支持,則傳回 null。

退貨
KeyguardControllerState包含鍵盤鎖定狀態快照的KeyguardControllerState ,如果不支援鍵盤鎖定查詢,則傳回 Null。

投擲
DeviceNotAvailableException

getLastExpectedRebootTimeMillis

public long getLastExpectedRebootTimeMillis ()

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

退貨
long

取得LaunchApiLevel

public int getLaunchApiLevel ()

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

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

投擲
DeviceNotAvailableException

取得Logcat

public InputStreamSource getLogcat ()

取得 logcat 資料的快照流。

有兩種工作模式:

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

    退貨
    InputStreamSource

  • 取得Logcat

    public InputStreamSource getLogcat (int maxBytes)

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

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

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

    退貨
    InputStreamSource

    取得LogcatDump

    public InputStreamSource getLogcatDump ()

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

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

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

    取得LogcatSince

    public InputStreamSource getLogcatSince (long date)

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

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

    退貨
    InputStreamSource

    取得Mac位址

    public String getMacAddress ()

    傳回設備的MAC位址,如果向設備查詢失敗則傳回null。

    退貨
    String

    取得主用戶ID

    public Integer getMainUserId ()

    返回主用戶 ID。

    退貨
    Integer有主用戶則為主用戶的userId,無主用戶則為null。

    投擲
    DeviceNotAvailableException

    獲取主線模組信息

    public  getMainlineModuleInfo ()

    取得有關設備上安裝的主線模組的資訊。

    退貨
    裝置上目前安裝的String主線模組ERROR(/Set)

    投擲
    DeviceNotAvailableException

    getMaxNumberOfRunningUsersSupported

    public int getMaxNumberOfRunningUsersSupported ()

    獲取支援的同時運行用戶的最大數量。預設為 0。

    退貨
    int一個整數,表示同時運行的使用者數

    投擲
    DeviceNotAvailableException

    取得支援的最大用戶數

    public int getMaxNumberOfUsersSupported ()

    取得支援的最大用戶數。預設為 0。

    退貨
    int一個整數,表示支援的用戶數

    投擲
    DeviceNotAvailableException

    取得MicrodroidProcess

    public Process getMicrodroidProcess ()

    退貨
    Process返回 Microdroid VM 的進程。如果 TestDevice 不是 Microdroid,則傳回 null。

    取得監視器

    public IDeviceStateMonitor getMonitor ()

    傳回與裝置關聯的IDeviceStateMonitor

    退貨
    IDeviceStateMonitor

    取得掛載點

    public String getMountPoint (String mountName)

    傳回一個掛載點。

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

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

    參數
    mountName String : 掛載點的名稱

    退貨
    String掛載點或null

    取得掛載點資訊

    public ITestDevice.MountPointInfo getMountPointInfo (String mountpoint)

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

    參數
    mountpoint String

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

    投擲
    DeviceNotAvailableException

    取得掛載點資訊

    public  getMountPointInfo ()

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

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

    投擲
    DeviceNotAvailableException

    取得選項

    public TestDeviceOptions getOptions ()

    取得設備的測試選項。

    退貨
    TestDeviceOptions TestDeviceOptions與被測設備相關。

    取得分區空閒空間

    public long getPartitionFreeSpace (String partition)

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

    參數
    partition String

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

    投擲
    DeviceNotAvailableException

    取得主用戶ID

    public Integer getPrimaryUserId ()

    返回主要用戶 ID。

    退貨
    Integer有主用戶則為主用戶的userId,無主用戶則為null。

    投擲
    DeviceNotAvailableException

    按名稱取得進程

    public ProcessInfo getProcessByName (String processName)

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

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

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

    投擲
    DeviceNotAvailableException

    取得進程Pid

    public String getProcessPid (String process)

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

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

    退貨
    String

    投擲
    DeviceNotAvailableException

    取得產品類型

    public String getProductType ()

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

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

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

    投擲
    DeviceNotAvailableException

    取得產品變體

    public String getProductVariant ()

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

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

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

    投擲
    DeviceNotAvailableException

    取得屬性

    public String getProperty (String name)

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

    參數
    name String : 屬性名稱

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

    投擲
    DeviceNotAvailableException

    取得恢復模式

    public ITestDevice.RecoveryMode getRecoveryMode ()

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

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

    取得螢幕截圖

    public InputStreamSource getScreenshot (String format)

    從裝置擷取螢幕截圖。建議使用 getScreenshot(format) 取代 JPEG 編碼以獲得較小的尺寸

    參數
    format String :支援PNG、JPEG

    退貨
    InputStreamSource螢幕截圖的InputStreamSource格式,如果螢幕截圖不成功,則傳回null

    投擲
    DeviceNotAvailableException

    取得螢幕截圖

    public InputStreamSource getScreenshot (long displayId)

    從給定顯示 ID 的裝置擷取螢幕截圖。格式為PNG。

    TODO:擴展上述實作以支援“格式”和“重新縮放”

    參數
    displayId long :要從中取得螢幕截圖的畫面的顯示 ID。

    退貨
    InputStreamSource螢幕截圖的InputStreamSource格式,如果螢幕截圖不成功,則傳回null

    投擲
    DeviceNotAvailableException

    取得螢幕截圖

    public InputStreamSource getScreenshot (String format, 
                    boolean rescale)

    從裝置擷取螢幕截圖。建議使用getScreenshot(String)代替 JPEG 編碼以獲得較小的尺寸。

    參數
    format String :支援PNG、JPEG

    rescale boolean :是否應重新縮放螢幕截圖以減少結果影像的大小

    退貨
    InputStreamSource螢幕截圖的InputStreamSource格式,如果螢幕截圖不成功,則傳回null

    投擲
    DeviceNotAvailableException

    取得螢幕截圖

    public InputStreamSource getScreenshot ()

    從裝置擷取螢幕截圖。

    退貨
    InputStreamSource png 格式的螢幕截圖的InputStreamSource ,如果螢幕截圖不成功則為null

    投擲
    DeviceNotAvailableException

    取得序號

    public String getSerialNumber ()

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

    退貨
    String String序號

    取得設定

    public String getSetting (int userId, 
                    String namespace, 
                    String key)

    傳回所請求設定的值。命名空間必須是以下之一:{"system", "secure", "global"}

    參數
    userId int

    namespace String

    key String

    退貨
    String與使用者的命名空間:鍵關聯的值。如果沒有找到則為空。

    投擲
    DeviceNotAvailableException

    取得設定

    public String getSetting (String namespace, 
                    String key)

    請參閱getSetting(int, String, String)並在系統使用者上執行。

    參數
    namespace String

    key String

    退貨
    String

    投擲
    DeviceNotAvailableException

    取得Sim算子

    public String getSimOperator ()

    傳回 SIM 卡運營商,如果不可用或設備不可用,則傳回 null。

    退貨
    String

    取得模擬狀態

    public String getSimState ()

    傳回 SIM 卡狀態,如果不可用或裝置不可用,則傳回 null。

    退貨
    String

    取得墓碑

    public  getTombstones ()

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

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

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

    投擲
    DeviceNotAvailableException

    取得總記憶體

    public long getTotalMemory ()

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

    退貨
    long

    取得UninstallablePackageNames

    public  getUninstallablePackageNames ()

    取得可卸載的應用程式套件名稱。目前將其定義為非系統包和更新的系統包。

    退貨
    裝置上目前安裝的可卸載String包名稱ERROR(/Set)

    投擲
    DeviceNotAvailableException

    getUseFastbootErase

    public boolean getUseFastbootErase ()

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

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

    取得用戶標誌

    public int getUserFlags (int userId)

    尋找並返回給定使用者的標誌。標誌在 Android 開源專案的「android.content.pm.UserInfo」類別中定義。

    參數
    userId int

    退貨
    int如果找到,則提供與 userId 關聯的標誌,在任何其他情況下為 -10000。

    投擲
    DeviceNotAvailableException

    獲取用戶資訊

    public  getUserInfos ()

    取得裝置上 useId 到UserInfo的 Map。如果裝置的輸出不符合預期,將會拋出DeviceRuntimeException

    退貨
    UserInfo 物件的列表。

    投擲
    DeviceNotAvailableException

    取得用戶序號

    public int getUserSerialNumber (int userId)

    如果找到,則傳回與 userId 關聯的序號,在任何其他情況下傳回 -10000。

    參數
    userId int

    退貨
    int

    投擲
    DeviceNotAvailableException

    處理分配事件

    public IManagedTestDevice.DeviceEventResponse handleAllocationEvent (DeviceEvent event)

    處理給定的DeviceEvent。可以將設備轉換到新狀態。將通知IDeviceMonitor任何狀態轉換。

    處理 DeviceEvent,這可能會也可能不會將該設備轉換到新的分配狀態。

    參數
    event DeviceEvent

    退貨
    IManagedTestDevice.DeviceEventResponse

    有特徵

    public boolean hasFeature (String feature)

    檢查設備上是否有可用的功能。

    參數
    feature String :格式應為「feature: “ 或者 ” 「 直接地。

    退貨
    boolean如果找到功能則為 true,否則為 false。

    投擲
    DeviceNotAvailableException

    安裝包

    public String installPackage (File packageFile, 
                    boolean reinstall, 
                    String... extraArgs)

    在裝置上安裝 Android 軟體套件。

    參數
    packageFile File :要安裝的apk文件

    reinstall boolean : true如果要重新安裝

    extraArgs String :要傳遞的可選額外參數。有關可用選項,請參閱“adb shell pm -h”。

    退貨
    String帶有錯誤代碼的String ,如果成功則為null

    投擲
    DeviceNotAvailableException

    安裝包

    public String installPackage (File packageFile, 
                    boolean reinstall, 
                    boolean grantPermissions, 
                    String... extraArgs)

    在裝置上安裝 Android 軟體套件。

    注意:只有需要在安裝時明確控制授予執行時間權限的用例才應呼叫此函數。

    參數
    packageFile File :要安裝的apk文件

    reinstall boolean : true如果要重新安裝

    grantPermissions boolean :是否應在安裝時授予所有執行時間權限

    extraArgs String :要傳遞的可選額外參數。有關可用選項,請參閱“adb shell pm -h”。

    退貨
    String帶有錯誤代碼的String ,如果成功則為null

    投擲
    DeviceNotAvailableException

    為用戶安裝套件

    public String installPackageForUser (File packageFile, 
                    boolean reinstall, 
                    int userId, 
                    String... extraArgs)

    在裝置上為給定使用者安裝 Android 軟體包。

    參數
    packageFile File :要安裝的apk文件

    reinstall boolean : true如果要重新安裝

    userId int :要安裝的整數使用者 ID。

    extraArgs String :要傳遞的可選額外參數。有關可用選項,請參閱“adb shell pm -h”。

    退貨
    String帶有錯誤代碼的String ,如果成功則為null

    投擲
    DeviceNotAvailableException

    為用戶安裝套件

    public String installPackageForUser (File packageFile, 
                    boolean reinstall, 
                    boolean grantPermissions, 
                    int userId, 
                    String... extraArgs)

    在裝置上為給定使用者安裝 Android 軟體包。

    注意:只有需要在安裝時明確控制授予執行時間權限的用例才應呼叫此函數。

    參數
    packageFile File :要安裝的apk文件

    reinstall boolean : true如果要重新安裝

    grantPermissions boolean :是否應在安裝時授予所有執行時間權限

    userId int :要安裝的整數使用者 ID。

    extraArgs String :要傳遞的可選額外參數。有關可用選項,請參閱“adb shell pm -h”。

    退貨
    String帶有錯誤代碼的String ,如果成功則為null

    投擲
    DeviceNotAvailableException

    無效屬性緩存

    public void invalidatePropertyCache ()

    是AdbRoot

    public boolean isAdbRoot ()

    退貨
    boolean

    投擲
    DeviceNotAvailableException

    是AdbTcp

    public boolean isAdbTcp ()

    退貨
    boolean

    isAppEnumerationSupported 是否支持

    public boolean isAppEnumerationSupported ()

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

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

    投擲
    DeviceNotAvailableException

    isBypassLowTargetSdkBlockSupported

    public boolean isBypassLowTargetSdkBlockSupported ()

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

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

    投擲
    DeviceNotAvailableException

    已安裝偵錯工具

    public boolean isDebugfsMounted ()

    檢查 debugfs 是否已安裝。

    退貨
    boolean true如果 debugfs 已安裝

    投擲
    DeviceNotAvailableException

    裝置已加密

    public boolean isDeviceEncrypted ()

    返回裝置是否已加密。

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

    投擲
    DeviceNotAvailableException

    是目錄

    public boolean isDirectory (String path)

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

    參數
    path String

    退貨
    boolean

    投擲
    DeviceNotAvailableException

    isEnableAdbRoot

    public boolean isEnableAdbRoot ()

    退貨
    boolean true如果應在裝置上啟用 adb root

    是否支援加密

    public boolean isEncryptionSupported ()

    返回裝置是否支援加密。

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

    投擲
    DeviceNotAvailableException

    是執行檔

    public boolean isExecutable (String fullPath)

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

    參數
    fullPath String

    退貨
    boolean

    投擲
    DeviceNotAvailableException

    是否啟用快速啟動

    public boolean isFastbootEnabled ()

    返回裝置是否可以使用 fastboot。

    退貨
    boolean

    是無頭的

    public boolean isHeadless ()

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

    退貨
    boolean

    投擲
    DeviceNotAvailableException

    isHeadlessSystemUserMode

    public boolean isHeadlessSystemUserMode ()

    返回設備是否使用無頭系統使用者模式。

    退貨
    boolean

    投擲
    DeviceNotAvailableException

    是主用戶永久管理員

    public boolean isMainUserPermanentAdmin ()

    返回主用戶是否為永久管理員且無法刪除或降級為非管理員狀態。

    退貨
    boolean

    投擲
    DeviceNotAvailableException

    是否支援多用戶

    public boolean isMultiUserSupported ()

    確定是否支援多用戶。

    退貨
    boolean如果支援多用戶則為 true,否則為 false

    投擲
    DeviceNotAvailableException

    軟體包已安裝

    public boolean isPackageInstalled (String packageName, 
                    String userId)

    查詢裝置中給定的軟體包名稱和給定的使用者 ID,以檢查目前是否已為該使用者安裝。

    參數
    packageName String :我們正在檢查是否已安裝的套件。

    userId String :我們正在檢查安裝套件的使用者 ID。如果為空,則將使用主用戶零。

    退貨
    boolean如果報告軟體包已安裝,則為 True。否則為假。

    投擲
    DeviceNotAvailableException

    軟體包已安裝

    public boolean isPackageInstalled (String packageName)

    查詢設備中給定的軟體包名稱,以檢查它目前是否已安裝。

    參數
    packageName String

    退貨
    boolean如果報告軟體包已安裝,則為 True。否則為假。

    投擲
    DeviceNotAvailableException

    isRuntimePermissionSupported

    public boolean isRuntimePermissionSupported ()

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

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

    投擲
    DeviceNotAvailableException

    isStateBootloaderOrFastbootd

    public boolean isStateBootloaderOrFastbootd ()

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

    退貨
    boolean

    正在運行

    public boolean isUserRunning (int userId)

    檢查給定使用者是否正在運行。

    參數
    userId int

    退貨
    boolean如果使用者正在運行,則為 true;在其他情況下為 false。

    投擲
    DeviceNotAvailableException

    是用戶次要的

    public boolean isUserSecondary (int userId)

    根據其標誌傳回指定使用者是否為次要使用者。

    參數
    userId int

    退貨
    boolean如果用戶是次要用戶,則為 true,否則為 false。

    投擲
    DeviceNotAvailableException

    是否使用者可見

    public boolean isUserVisible (int userId)

    檢查給定使用者是否可見。

    「可見」用戶是與「人類」用戶互動的用戶,因此能夠啟動啟動活動(通常在預設顯示中)。

    參數
    userId int

    退貨
    boolean

    投擲
    DeviceNotAvailableException

    isUserVisibleOnDisplay

    public boolean isUserVisibleOnDisplay (int userId, 
                    int displayId)

    檢查給定使用者在給定顯示中是否可見。

    「可見」用戶是與「人類」用戶互動的用戶,因此能夠在該顯示中啟動啟動活動。

    參數
    userId int

    displayId int

    退貨
    boolean

    投擲
    DeviceNotAvailableException

    isVisibleBackgroundUsersOnDefaultDisplaySupported

    public boolean isVisibleBackgroundUsersOnDefaultDisplaySupported ()

    返回設備是否允許使用者在ERROR(/java.android.view.Display#DEFAULT_DISPLAY)中在背景啟動可見。

    如果是這樣,您可以呼叫startVisibleBackgroundUser(int, int, boolean) ,傳遞listDisplayIdsForStartingVisibleBackgroundUsers()傳回的顯示(其中應包括ERROR(/java.android.view.Display#DEFAULT_DISPLAY) )。

    退貨
    boolean

    投擲
    DeviceNotAvailableException

    isVisibleBackgroundUsersSupported

    public boolean isVisibleBackgroundUsersSupported ()

    返回設備是否允許使用者在背景啟動可見。

    如果是這樣,您可以呼叫startVisibleBackgroundUser(int, int, boolean) ,傳遞listDisplayIdsForStartingVisibleBackgroundUsers()傳回的顯示。

    退貨
    boolean

    投擲
    DeviceNotAvailableException

    是否啟用Wifi

    public boolean isWifiEnabled ()

    測試 wifi 是否已啟用。

    檢查設備上是否啟用了 wifi。對於在不應使用 wifi 運行的測試(例如行動數據測試)之前斷言 wifi 狀態很有用。

    退貨
    boolean如果啟用了 wifi,則為true 。如果禁用則為false

    投擲
    DeviceNotAvailableException

    清單顯示 ID

    public  listDisplayIds ()

    收集「dumpsys SurfaceFlinger」報告的裝置上可用顯示器 ID 的清單。

    退貨
    顯示列表。預設值始終傳回預設顯示 0。

    投擲
    DeviceNotAvailableException

    listDisplayIdsForStartingVisibleBackgroundUsers

    public  listDisplayIdsForStartingVisibleBackgroundUsers ()

    取得可用於start a user visible in the background顯示清單。

    退貨

    投擲
    DeviceNotAvailableException

    列出用戶

    public  listUsers ()

    取得裝置上的使用者清單。如果裝置的輸出不符合預期,將會拋出DeviceRuntimeException

    退貨
    使用者 ID 列表。

    投擲
    DeviceNotAvailableException

    對數

    public boolean logAnrs (ITestLogger logger)

    從設備收集並記錄 ANR。

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

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

    投擲
    DeviceNotAvailableException

    日誌錯誤報告

    public boolean logBugreport (String dataName, 
                    ITestLogger listener)

    取得錯誤報告並將其記錄給報告者的協助方法。

    參數
    dataName String :將報告錯誤報告的名稱。

    listener ITestLogger :用於記錄錯誤報告的ITestLogger

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

    登入裝置

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

    掛載調試檔案。

    投擲
    DeviceNotAvailableException

    非阻塞重啟

    public void nonBlockingReboot ()

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

    投擲
    DeviceNotAvailableException

    postAdbRoot 操作

    public void postAdbRootAction ()

    如果裝置需要在 adb root 之後和裝置重新上線之前執行某些特定操作,則會覆蓋。預設實作不包括任何附加操作。在此階段不保證啟用 adb root。

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

    postAdbUnrootAction

    public void postAdbUnrootAction ()

    如果裝置需要在 adb unroot 之後和裝置重新上線之前執行某些特定操作,則會覆蓋。預設實作不包含任何其他操作。在此階段不保證 adb root 被停用。

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

    啟動後設定

    public void postBootSetup ()

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

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

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

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

    投擲
    DeviceNotAvailableException

    調用後拆卸

    public void postInvocationTearDown (Throwable exception)

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

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

    調用前設定

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

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

    參數
    info IBuildInfo :設備的IBuildInfo

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

    投擲
    DeviceNotAvailableException
    TargetSetupError

    拉目錄

    public boolean pullDir (String deviceFilePath, 
                    File localDir)

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

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

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

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

    投擲
    DeviceNotAvailableException

    拉文件

    public boolean pullFile (String remoteFilePath, 
                    File localFile)

    從設備上檢索文件。

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

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

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

    投擲
    DeviceNotAvailableException

    拉文件

    public File pullFile (String remoteFilePath, 
                    int userId)

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

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

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

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

    投擲
    DeviceNotAvailableException

    拉文件

    public File pullFile (String remoteFilePath)

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

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

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

    投擲
    DeviceNotAvailableException

    拉文件

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

    從設備上檢索文件。

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

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

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

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

    投擲
    DeviceNotAvailableException

    拉取文件內容

    public String pullFileContents (String remoteFilePath)

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

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

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

    投擲
    DeviceNotAvailableException

    從外部拉文件

    public File pullFileFromExternal (String remoteFilePath)

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

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

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

    投擲
    DeviceNotAvailableException

    推目錄

    public boolean pushDir (File localFileDir, 
                    String deviceFilePath, 
                     excludedDirectories)

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

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

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

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

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

    投擲
    DeviceNotAvailableException

    推目錄

    public boolean pushDir (File localFileDir, 
                    String deviceFilePath)

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

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

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

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

    投擲
    DeviceNotAvailableException

    推播檔案

    public boolean pushFile (File localFile, 
                    String remoteFilePath, 
                    boolean evaluateContentProviderNeeded)

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

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

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

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

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

    投擲
    DeviceNotAvailableException

    推播檔案

    public boolean pushFile (File localFile, 
                    String remoteFilePath)

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

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

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

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

    投擲
    DeviceNotAvailableException

    推串

    public boolean pushString (String contents, 
                    String remoteFilePath)

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

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

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

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

    投擲
    DeviceNotAvailableException

    重啟

    public void reboot (String reason)

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

    阻塞直到設備變得可用。

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

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

    投擲
    DeviceNotAvailableException

    重啟

    public void reboot ()

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

    阻塞直到設備變得可用。

    投擲
    DeviceNotAvailableException

    重新啟動進入引導程式

    public void rebootIntoBootloader ()

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

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

    投擲
    DeviceNotAvailableException

    重新啟動進入Fastbootd

    public void rebootIntoFastbootd ()

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

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

    投擲
    DeviceNotAvailableException

    重新啟動進入恢復

    public void rebootIntoRecovery ()

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

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

    投擲
    DeviceNotAvailableException

    重新啟動進入旁載

    public void rebootIntoSideload ()

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

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

    投擲
    DeviceNotAvailableException

    重新啟動進入旁載

    public void rebootIntoSideload (boolean autoReboot)

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

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

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

    投擲
    DeviceNotAvailableException

    重新啟動直到上線

    public void rebootUntilOnline ()

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

    投擲
    DeviceNotAvailableException

    重新啟動直到上線

    public void rebootUntilOnline (String reason)

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

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

    投擲
    DeviceNotAvailableException

    重新啟動使用者空間

    public void rebootUserspace ()

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

    阻塞直到設備變得可用。

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

    投擲
    DeviceNotAvailableException

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

    public void rebootUserspaceUntilOnline ()

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

    投擲
    DeviceNotAvailableException

    恢復設備

    public boolean recoverDevice ()

    嘗試恢復設備通訊。

    退貨
    boolean如果嘗試復原並成功則傳回 True,如果跳過復原則傳回 False

    投擲
    DeviceNotAvailableException如果設備不再可用

    註冊設備動作接收器

    public void registerDeviceActionReceiver (IDeviceActionReceiver deviceActionReceiver)

    為此設備註冊一個IDeviceActionReceiver

    所有已註冊的IDeviceActionReceiver將在裝置操作開始前和裝置操作結束之後收到通知。

    參數
    deviceActionReceiver IDeviceActionReceiver :將註冊的IDeviceActionReceiver

    重新掛載系統唯讀

    public void remountSystemReadOnly ()

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

    投擲
    DeviceNotAvailableException

    重新掛載系統可寫

    public void remountSystemWritable ()

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

    投擲
    DeviceNotAvailableException

    重新掛載供應商只讀

    public void remountVendorReadOnly ()

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

    投擲
    DeviceNotAvailableException

    重新掛載VendorWritable

    public void remountVendorWritable ()

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

    投擲
    DeviceNotAvailableException

    刪除管理員

    public boolean removeAdmin (String componentName, 
                    int userId)

    刪除給定使用者中的給定設備管理員,如果成功則傳回true ,否則傳回false

    參數
    componentName String :要刪除的裝置管理員。

    userId int :設備管理員所在的使用者。

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

    投擲
    DeviceNotAvailableException

    刪除所有者

    public void removeOwners ()

    盡最大努力刪除所有現有的設備設定檔擁有者。

    投擲
    DeviceNotAvailableException

    刪除用戶

    public boolean removeUser (int userId)

    從設備中刪除給定用戶。

    參數
    userId int : 要刪除的用戶

    退貨
    boolean如果我們成功刪除用戶,則為 true,否則為 false。

    投擲
    DeviceNotAvailableException

    重置ContentProvider設定

    public void resetContentProviderSetup ()

    重置內容提供者設定的標誌以便再次觸發它。

    運行儀器測試

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

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

    參數
    runner IRemoteAndroidTestRunner :運行測試的IRemoteAndroidTestRunner

    listeners ITestLifeCycleReceiver :測試結果監聽器

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

    投擲
    DeviceNotAvailableException

    運行儀器測試

    public boolean runInstrumentationTests (IRemoteAndroidTestRunner runner, 
                     listeners)

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

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

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

    參數
    runner IRemoteAndroidTestRunner :運行測試的IRemoteAndroidTestRunner

    listeners :測試結果監聽器

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

    投擲
    DeviceNotAvailableException

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

    public 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 boolean runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, 
                    int userId, 
                    ITestLifeCycleReceiver... listeners)

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

    參數
    runner IRemoteAndroidTestRunner

    userId int

    listeners ITestLifeCycleReceiver

    退貨
    boolean

    投擲
    DeviceNotAvailableException

    設定配置

    public void setConfiguration (IConfiguration configuration)

    注入正在使用的IConfiguration

    參數
    configuration IConfiguration

    設定ConnectionAvdInfo

    public final void setConnectionAvdInfo (GceAvdInfo avdInfo)

    參數
    avdInfo GceAvdInfo

    設定日期

    public void setDate (Date date)

    設定設備上的日期

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

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

    投擲
    DeviceNotAvailableException

    設定設備所有者

    public boolean setDeviceOwner (String componentName, 
                    int userId)

    將設備管理元件設定為給定使用者的設備擁有者。

    參數
    componentName String :裝置管理員成為裝置擁有者。

    userId int :設備擁有者所在的使用者。

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

    投擲
    DeviceNotAvailableException

    設定設備狀態

    public void setDeviceState (TestDeviceState deviceState)

    更新設備的狀態。

    參數
    deviceState TestDeviceStateTestDeviceState

    設定模擬器輸出流

    public void setEmulatorOutputStream (SizeLimitedOutputStream output)

    對於模擬器,設定SizeLimitedOutputStream來記錄輸出

    參數
    output SizeLimitedOutputStream :記錄輸出

    設定模擬器進程

    public void setEmulatorProcess (Process p)

    當設備是模擬器時,設定Process

    參數
    p Process

    設定快速啟動啟用

    public void setFastbootEnabled (boolean fastbootEnabled)

    設定設備的快速啟動選項。應在首次分配設備時設定。

    參數
    fastbootEnabled boolean : 裝置是否可以使用 fastboot

    設定快速啟動路徑

    public void setFastbootPath (String fastbootPath)

    設定應使用的 fastboot 二進位檔案的路徑。仍然需要isFastbootEnabled()為 true,才能啟用 fastboot 功能。

    參數
    fastbootPath String

    設定設備

    public void setIDevice (IDevice newDevice)

    更新與此 ITestDevice 關聯的 IDevice。

    新的 IDevice 必須引用與目前引用相同的實體設備。如果 DDMS 指派了新的 IDevice,則會呼叫此方法

    參數
    newDevice IDeviceIDevice

    設定日誌開始延遲

    public void setLogStartDelay (int delay)

    設定線上設備開始 logcat 捕獲之前等待的時間(以毫秒為單位)。

    參數
    delay int : 延遲(以毫秒為單位)

    設定選項

    public void setOptions (TestDeviceOptions options)

    設定設備的TestDeviceOptions

    參數
    options TestDeviceOptions

    設定屬性

    public boolean setProperty (String propKey, 
                    String propValue)

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

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

    propValue String :要設定的屬性值。

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

    投擲
    DeviceNotAvailableException

    設定恢復

    public void setRecovery (IDeviceRecovery recovery)

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

    參數
    recovery IDeviceRecoveryIDeviceRecovery

    設定恢復模式

    public void setRecoveryMode (ITestDevice.RecoveryMode mode)

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

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

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

    設定設定

    public void setSetting (String namespace, 
                    String key, 
                    String value)

    請參閱setSetting(int, String, String, String)並在系統使用者上執行。

    參數
    namespace String

    key String

    value String

    投擲
    DeviceNotAvailableException

    設定設定

    public void setSetting (int userId, 
                    String namespace, 
                    String key, 
                    String value)

    將設定值新增至給定使用者的命名空間。某些設定僅在重新啟動後才可用。命名空間必須是以下之一:{"system", "secure", "global"}

    參數
    userId int

    namespace String

    key String

    value String

    投擲
    DeviceNotAvailableException

    設定測試記錄器

    public void setTestLogger (ITestLogger testLogger)

    注入ITestLogger實例

    參數
    testLogger ITestLogger

    設定使用FastbootErase

    public void setUseFastbootErase (boolean useFastbootErase)

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

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

    啟動Logcat

    public void startLogcat ()

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

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

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

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

    啟動使用者

    public boolean startUser (int userId)

    如果給定使用者目前已停止,則在背景啟動該使用者。如果使用者已經在背景運行,則此方法是 NOOP。

    參數
    userId int : 在背景啟動的用戶

    退貨
    boolean如果使用者在背景成功啟動,則為 true。

    投擲
    DeviceNotAvailableException

    啟動使用者

    public boolean startUser (int userId, 
                    boolean waitFlag)

    如果給定使用者目前已停止,則在背景啟動該使用者。如果使用者已經在背景運行,則此方法是 NOOP。可以提供額外的標誌來等待操作生效。

    參數
    userId int : 在背景啟動的用戶

    waitFlag boolean :將使指令等待,直到使用者啟動解鎖。

    退貨
    boolean如果使用者在背景成功啟動,則為 true。

    投擲
    DeviceNotAvailableException

    啟動可見背景用戶

    public boolean startVisibleBackgroundUser (int userId, 
                    int displayId, 
                    boolean waitFlag)

    在背景啟動給定用戶,在給定顯示中可見(即允許用戶在該顯示中啟動活動)。

    注意:此命令不會檢查使用者是否存在、顯示是否可用、 device supports such feature等。

    參數
    userId int : 在背景啟動的用戶

    displayId int : 顯示開始使用者可見

    waitFlag boolean :將使指令等待,直到使用者啟動解鎖。

    退貨
    boolean true如果使用者成功啟動並在後台可見。

    投擲
    DeviceNotAvailableException

    停止模擬器輸出

    public void stopEmulatorOutput ()

    關閉並刪除模擬器輸出。

    停止Logcat

    public void stopLogcat ()

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

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

    停止用戶

    public boolean stopUser (int userId)

    停止給定使用者。如果使用者已經停止,則此方法是 NOOP。無法停止目前使用者和系統使用者。

    參數
    userId int :要停止的使用者。

    退貨
    boolean如果使用者已成功停止,則為 true。

    投擲
    DeviceNotAvailableException

    停止用戶

    public boolean stopUser (int userId, 
                    boolean waitFlag, 
                    boolean forceFlag)

    停止給定使用者。可以提供額外的標誌來等待操作生效,並強制終止使用者。無法停止目前使用者和系統使用者。

    參數
    userId int :要停止的使用者。

    waitFlag boolean :將使指令等待,直到使用者停止。

    forceFlag boolean :將強制停止使用者。

    退貨
    boolean如果使用者已成功停止,則為 true。

    投擲
    DeviceNotAvailableException

    切換到AdbTcp

    public String switchToAdbTcp ()

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

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

    投擲
    DeviceNotAvailableException

    切換到AdbUsb

    public boolean switchToAdbUsb ()

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

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

    投擲
    DeviceNotAvailableException

    切換用戶

    public boolean switchUser (int userId)

    切換到另一個具有預設逾時的使用者 ID。 switchUser(int, long)

    參數
    userId int

    退貨
    boolean如果新的 userId 與 userId 提供者匹配,則為 True。否則為假。

    投擲
    DeviceNotAvailableException

    切換用戶

    public boolean switchUser (int userId, 
                    long timeout)

    切換到另一個使用者 ID,並以提供的逾時為截止時間。用戶更改成功後嘗試停用鍵盤保護。

    參數
    userId int

    timeout long :在切換用戶失敗返回 false 之前等待。

    退貨
    boolean如果新的 userId 與 userId 提供者匹配,則為 True。否則為假。

    投擲
    DeviceNotAvailableException

    同步文件

    public 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 Bugreport takeBugreport ()

    取得錯誤報告並將其返回Bugreport物件中以進行處理。如果出現問題,則傳回 null。 Bugreport 物件中引用的文件需要透過Bugreport.close()進行清理。

    退貨
    Bugreport

    解除安裝包

    public String uninstallPackage (String packageName)

    從裝置卸載 Android 軟體包。

    參數
    packageName String : 要卸載的 Android 套件

    退貨
    String帶有錯誤代碼的String ,如果成功則為null

    投擲
    DeviceNotAvailableException

    解除安裝用戶包

    public String uninstallPackageForUser (String packageName, 
                    int userId)

    從裝置上為給定使用者卸載 Android 軟體包。

    參數
    packageName String : 要卸載的 Android 套件

    userId int :要卸載的整數使用者 ID。

    退貨
    String帶有錯誤代碼的String ,如果成功則為null

    投擲
    DeviceNotAvailableException

    解鎖裝置

    public boolean unlockDevice ()

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

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

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

    投擲
    DeviceNotAvailableException

    卸載調試文件

    public void unmountDebugfs ()

    卸載 debugfs。

    投擲
    DeviceNotAvailableException

    等待啟動完成

    public boolean waitForBootComplete (long timeOut)

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

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

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

    投擲
    DeviceNotAvailableException

    等待設備可用

    public boolean waitForDeviceAvailable ()

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

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

    投擲
    DeviceNotAvailableException

    等待設備可用

    public boolean waitForDeviceAvailable (long waitTime)

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

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

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

    投擲
    DeviceNotAvailableException

    waitForDeviceAvailableInRecoverPath

    public boolean waitForDeviceAvailableInRecoverPath (long waitTime)

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

    參數
    waitTime long

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

    投擲
    DeviceNotAvailableException

    等待設備引導程式

    public void waitForDeviceBootloader ()

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

    投擲
    DeviceNotAvailableException

    等待設備恢復

    public boolean waitForDeviceInRecovery (long waitTime)

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

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

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

    waitForDeviceInSideload

    public boolean waitForDeviceInSideload (long waitTime)

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

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

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

    等待設備不可用

    public boolean waitForDeviceNotAvailable (long waitTime)

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

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

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

    等待設備在線

    public void waitForDeviceOnline ()

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

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

    投擲
    DeviceNotAvailableException

    等待設備在線

    public void waitForDeviceOnline (long waitTime)

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

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

    參數
    waitTime long :MS等待的時間

    投擲
    DeviceNotAvailableException

    Waitfordeviceshell

    public boolean waitForDeviceShell (long waitTime)

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

    參數
    waitTime long :MS等待的時間

    退貨
    boolean如果裝置在waitTime播放之前反應迅速, true

    受保護的方法

    新增ExtraconnectionBuilderargs

    protected void addExtraConnectionBuilderArgs (DefaultConnection.ConnectionBuilder builder)

    參數
    builder DefaultConnection.ConnectionBuilder

    buildadbshel​​lcommand

    protected String[] buildAdbShellCommand (String command, 
                    boolean forceExitStatusDetection)

    為給定的 adb shell 命令會話和參數建立作業系統命令

    參數
    command String

    forceExitStatusDetection boolean

    退貨
    String[]

    CheckApileVelagainst

    protected void checkApiLevelAgainst (String feature, 
                    int strictMinLevel)

    參數
    feature String

    strictMinLevel int

    createrebootdeviceaction

    protected NativeDevice.RebootDeviceAction createRebootDeviceAction (NativeDevice.RebootMode rebootMode, 
                    String reason)

    建立要在執行重新啟動操作時使用的RebootDeviceAction

    參數
    rebootMode NativeDevice.RebootMode :此重新啟動的一種模式。

    reason String :為此重新啟動。

    退貨
    NativeDevice.RebootDeviceAction建立的RebootDeviceAction

    Createrunutil

    protected IRunUtil createRunUtil ()

    退貨
    IRunUtil

    doadbreboot

    protected void doAdbReboot (NativeDevice.RebootMode rebootMode, 
                    String reason)

    執行 adb 重啟。

    參數
    rebootMode NativeDevice.RebootMode :此重新啟動的一種模式。

    reason String :為此重新啟動。

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

    SenureruntimePermissionsupported

    protected void ensureRuntimePermissionSupported ()

    如果不支援運行時權限,則拋出異常的輔助方法

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

    getapilevelsafe

    protected int getApiLevelSafe ()

    退貨
    int

    GetLogger

    protected ITestLogger getLogger ()

    退貨
    ITestLogger

    GetRunutil

    protected IRunUtil getRunUtil ()

    取得要使用的RunUtil實例。

    退貨
    IRunUtil

    初始卵形連接

    protected void initializeConnection (IBuildInfo info, 
                    MultiMap<String, String> attributes)

    參數
    info IBuildInfo

    attributes MultiMap

    投擲
    DeviceNotAvailableException
    TargetSetupError

    InternalGetProperty

    protected String internalGetProperty (String propName, 
                    String fastbootVar, 
                    String description)

    預設情況下,從 ddmlib 快取中取得裝置屬性,然後根據裝置是否處於 Fastboot 狀態,返回「adb shell getprop」或「fastboot getvar」。

    參數
    propName String :「 ADB Shell GetProp」傳回的裝置屬性的名稱

    fastbootVar String :等效fastboot變數的名稱。如果null ,則不會嘗試fastboot查詢

    description String :變數的簡單描述。首字母應大寫。

    退貨
    String字串,可能是null或空的,包含給定屬性的值

    投擲
    DeviceNotAvailableException

    isinrebootCallback

    protected boolean isInRebootCallback ()

    傳回目前是否正在執行重新啟動回呼。如果為true,則應停用所有用於重新啟動的公用API。

    退貨
    boolean

    isnewer

    protected boolean isNewer (File localFile, 
                    IFileEntry entry)

    如果本機檔案比遠端檔案新,則傳回trueIFileEntry到了一分鐘,如果在等式的情況下,檔案將被視為更新。

    參數
    localFile File

    entry IFileEntry

    退貨
    boolean

    notifyrebooted

    protected void notifyRebootEnded ()

    通知所有IDeviceActionReceiver有關重新啟動結束事件的資訊。

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

    notifyrebootstarted

    protected void notifyRebootStarted ()

    通知所有IDeviceActionReceiver有關重新啟動開始事件。

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

    績效

    protected boolean performDeviceAction (String actionDescription, 
                    NativeDevice.DeviceAction action, 
                    int retryAttempts)

    在此設備上執行操作。如果操作失敗,請嘗試恢復裝置並選擇重試命令。

    參數
    actionDescription String :要執行的動作的簡短描述。僅用於記錄目的。

    action NativeDevice.DeviceAction :要執行的動作

    retryAttempts int :重試嘗試如果失敗但恢復成功,則試圖採取行動

    退貨
    boolean如果成功執行行動,則為true

    投擲
    DeviceNotAvailableException如果恢復嘗試失敗或最大嘗試而沒有成功

    adbreboot

    protected void postAdbReboot ()

    重新啟動後可能採取的額外操作。

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

    prepostbootsetup

    protected void prePostBootSetup ()

    允許每種裝置類型(AndroidNativeDevice、TestDevice)覆寫此方法以進行特定的啟動後設定。

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

    pullfileinternal

    protected boolean pullFileInternal (String remoteFilePath, 
                    File localFile)

    參數
    remoteFilePath String

    localFile File

    退貨
    boolean

    投擲
    DeviceNotAvailableException

    setClock

    protected void setClock (Clock clock)

    設定要使用的 Clock 實例。

    參數
    clock Clock

    setMicrodroidProcess

    protected void setMicrodroidProcess (Process process)

    將 TestDevice 標記為 microdroid 並設定其 CID。

    參數
    process Process :微吸收VM的過程。

    SettestDeviceOptions

    protected void setTestDeviceOptions ( deviceOptions)

    參數
    deviceOptions

    SimpleFastBootCommand

    protected CommandResult simpleFastbootCommand (long timeout, 
                     envVarMap, 
                    String[] fullCmd)

    使用環境變數執行簡單的 fastboot 命令並報告命令的狀態。

    參數
    timeout long

    envVarMap

    fullCmd String

    退貨
    CommandResult

    SimpleFastBootCommand

    protected CommandResult simpleFastbootCommand (long timeout, 
                    String[] fullCmd)

    執行簡單的 fastboot 指令並報告指令的狀態。

    參數
    timeout long

    fullCmd String

    退貨
    CommandResult

    WaitfordeviceNotavailable

    protected boolean waitForDeviceNotAvailable (String operationDesc, 
                    long time)

    等待看到設備變得不可用(停止向 adb 報告)。

    參數
    operationDesc String :正在等待不可用的操作的名稱。

    time long :等待無法發生的時間。

    退貨
    boolean如果設備確實不可用,則是真的。