本地設備

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

執行指令重試的預設次數

領域

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

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

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)

領域

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 IShellOutputReceiverIShellOutputReceiver將shell輸出轉到。

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

maxTimeToOutputShellResponse long :允許命令不輸出任何回應的最大時間; timeUnit指定的單位

timeUnit TimeUnitmaxTimeToOutputShellResponse的單位

retryAttempts int :如果因異常而失敗,則重試指令的最大次數。如果在沒有成功的情況下執行retryAttempts deviceNotresponsiveException,則將投擲。

投擲
DeviceNotAvailableException

executeshellCommand

public void executeShellCommand (String command, 
                IShellOutputReceiver receiver)

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

具有預設值的executeShellCommand(String, com.android.ddmlib.IShellOutputReceiver, long, TimeUnit, int)的更簡單形式。

參數
command String :運行的ADB shell命令

receiver IShellOutputReceiverIShellOutputReceiver將shell輸出轉到。

投擲
DeviceNotAvailableException

executeshellv2Command

public CommandResult executeShellV2Command (String cmd)

執行ADB shell指令並將結果傳回的助手方法作為指令狀態輸出,stdout和stderr正確填入的CommandResult重點。

參數
cmd String :應運行的命令。

退貨
CommandResult CommandResult的結果。

投擲
DeviceNotAvailableException

executeshellv2Command

public CommandResult executeShellV2Command (String cmd, 
                OutputStream pipeToOutput)

執行ADB shell命令並將結果傳回的助手方法作為命令狀態輸出和stderr正確填充的CommandResult 。 STDOUT定向到指定的流。

參數
cmd String :應運行的命令。

pipeToOutput OutputStreamERROR(/OutputStream)其中std輸出將會被重新導向或null。

退貨
CommandResult CommandResult的結果。

投擲
DeviceNotAvailableException

executeshellv2Command

public CommandResult executeShellV2Command (String cmd, 
                File pipeAsInput)

執行ADB shell指令並將結果傳回的助手方法作為指令狀態輸出,Stdout和stderr正確填入的CommandResult重點。

參數
cmd String :應運行的命令。

pipeAsInput File :將輸入輸入的ERROR(/File)

退貨
CommandResult CommandResult的結果。

投擲
DeviceNotAvailableException

executeshellv2Command

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

執行ADB Shell指令,其中有更多參數可以控制指令行為。

參數
cmd String :運行的ADB shell命令

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

timeUnit TimeUnitmaxTimeToOutputShellResponse的單位

retryAttempts int :如果因異常而失敗,則重試指令的最大次數。如果在沒有成功的情況下執行retryAttempts deviceNotresponsiveException,則將投擲。

退貨
CommandResult

投擲
DeviceNotAvailableException

executeshellv2Command

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

執行ADB Shell指令,其中有更多參數可以控制指令行為。

參數
cmd String :運行的ADB shell命令

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

timeUnit TimeUnitmaxTimeToOutputShellResponse的單位

退貨
CommandResult

投擲
DeviceNotAvailableException

executeshellv2Command

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 OutputStreamERROR(/OutputStream)其中std輸出將會被重新導向或null。

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

timeUnit TimeUnitmaxTimeToOutputShellResponse的單位

retryAttempts int :如果因異常而失敗,則重試指令的最大次數。如果在沒有成功的情況下執行retryAttempts deviceNotresponsiveException,則將投擲。

退貨
CommandResult

投擲
DeviceNotAvailableException

executeshellv2Command

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 OutputStreamERROR(/OutputStream)其中std輸出將會被重新導向或null。

pipeToError OutputStreamERROR(/OutputStream)其中將重定向性std錯誤或null。

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

timeUnit TimeUnitmaxTimeToOutputShellResponse的單位

retryAttempts int :如果因異常而失敗,則重試指令的最大次數。如果在沒有成功的情況下執行retryAttempts deviceNotresponsiveException,則將投擲。

退貨
CommandResult

投擲
DeviceNotAvailableException

FastBootWiPepartition

public CommandResult fastbootWipePartition (String partition)

助理方法擦除設備的分區。

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

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

參數
partition String :擦除的分割區

退貨
CommandResult包含命令輸出的命令重點

投擲
DeviceNotAvailableException

取得活動頂點

public  getActiveApexes ()

取得有關在裝置上啟動的頂點的資訊。

退貨
目前在設備上啟動的ApexInfoERROR(/Set)

投擲
DeviceNotAvailableException

取得所有設定

public  getAllSettings (String namespace)

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

參數
namespace String :必須是{“系統”,“安全”,“全域”}之一

退貨
鑰匙值對的地圖。 null如果不支援名稱空間。

投擲
DeviceNotAvailableException

getallocationstate

public DeviceAllocationState getAllocationState ()

傳回目前設備的分配狀態

退貨
DeviceAllocationState

取得AndroidId

public String getAndroidId (int userId)

尋找並返回與用戶ID相關的Android-ID,如果找不到的(找不到)。

參數
userId int

退貨
String

投擲
DeviceNotAvailableException

取得AndroidId

public  getAndroidIds ()

建立一個符合使用者ID的Android ID的地圖。每個使用者ID都不會在此功能中找到關聯的Android ID,因此某些使用者ID可能與NULL相符。

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

投擲
DeviceNotAvailableException

getapilevel

public int getApiLevel ()

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

退貨
int一個表示設備API等級的整數

投擲
DeviceNotAvailableException

獲取應用程式包信息

public PackageInfo getAppPackageInfo (String packageName)

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

參數
packageName String

退貨
PackageInfo如果null PackageInfo資訊

投擲
DeviceNotAvailableException

獲取應用程式包信息

public  getAppPackageInfos ()

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

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

投擲
DeviceNotAvailableException

取得基頻版本

public String getBasebandVersion ()

取得此設備基頻(無線電)版本的便利方法。取得廣播版本是特定於裝置的,因此它可能不會傳回所有裝置的正確資訊。此方法依賴gsm.version.baseband Propery傳回正確的版本資訊。對於某些CDMA設備而言,這是不準確的,此處傳回的版本可能與FastBoot報告的版本不匹配,也可能無法返回CDMA Radio的版本。 TL; DR此方法僅在gsm.version.baseband屬性與fastboot getvar version-baseband傳回的版本相同時才報告準確的版本。

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

投擲
DeviceNotAvailableException

GetBattery

public Integer getBattery ()

如果電池電量不可用,將返回裝置的當前電池電量或無效的電池電量。

退貨
Integer

getBooleanproperty

public boolean getBooleanProperty (String name, 
                boolean defaultValue)

傳回給定屬性的布林值。

參數
name String :屬性名稱

defaultValue boolean值:如果屬性為空或不存在,將傳回的預設值。

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

投擲
DeviceNotAvailableException

GetBoothistory

public  getBootHistory ()

助手方法透過引導時間和啟動原因收集引導歷史圖。

退貨
啟動時間的地圖(自時代以來為第二個UTC時間)和引導原因

投擲
DeviceNotAvailableException

GetBoothistorys

public  getBootHistorySince (long utcEpochTime, 
                TimeUnit timeUnit)

助手方法以啟動時間和啟動原因收集啟動歷史圖以來,自設備時期以來的給定時間和指定的時間單元。目前的設備utcepochtime以毫秒為單位,可以透過方法getDeviceDate()取得。

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

timeUnit TimeUnit :Time單元時間TimeUnit

退貨
啟動時間的地圖(自時代以來為第二個UTC時間)和引導原因

投擲
DeviceNotAvailableException

取得Bootloader版本

public String getBootloaderVersion ()

取得此裝置的引導程式版本的便利方法。

將嘗試從裝置的目前狀態檢索Bootloader版本。 (即,如果裝置處於fastboot模式,它將嘗試從fastboot檢索版本)

退貨
String String引導程式版本或null如果找不到

投擲
DeviceNotAvailableException

GetBugreport

public InputStreamSource getBugreport ()

從設備檢索BugReport。

保證的實作可以繼續在沒有SDCARD的裝置上運作(或尚未安裝SDCARD)。

退貨
InputStreamSource InputStreamSource將按需生產BugReport內容。如果發生故障, InputStreamSource將產生一個空ERROR(/InputStream)

GetBugreportz

public InputStreamSource getBugreportz ()

從裝置檢索Bugreportz。 zip格式BugReport包含用於偵錯的主要BugReport和其他日誌檔案。

僅支援“ ADB版本”> 1.0.36

退貨
InputStreamSource包含bugreportz的zip檔的InputStreamSource ,在失敗的情況下傳回null。

GetBuildalias

public String getBuildAlias ()

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

建構別名通常比建構ID(通常是Nexus建構的數字)更可讀的字串。例如,Final Android 4.2發行版已建置別名JDQ39,並建置ID 573038

退貨
String建立別名或倒退以建立ID(如果無法檢索)

投擲
DeviceNotAvailableException

獲取BuildFlavor

public String getBuildFlavor ()

檢索設備的製造風味。

退貨
String如果無法檢索的建構風味或無效

投擲
DeviceNotAvailableException

取得建置ID

public String getBuildId ()

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

退貨
String如果無法IBuildInfo#UNKNOWN_BUILD_ID

投擲
DeviceNotAvailableException

GetBuildSigningKeys

public String getBuildSigningKeys ()

傳回用於簽署設備影像的金鑰類型

通常,Android設備可以用測試鍵(例如AOSP)或釋放鍵(由單一設備製造商控制)簽名

退貨
String簽署金鑰如果發現,則否則為空。

投擲
DeviceNotAvailableException

GetCachedDevicedScriptor

public DeviceDescriptor getCachedDeviceDescriptor ()

如果指派了設備,則傳回快取的DeviceDescriptor ,否則將傳回目前的DeviceDescriptor

退貨
DeviceDescriptor

GetCachedDevicedScriptor

public DeviceDescriptor getCachedDeviceDescriptor (boolean shortDescriptor)

如果指派了設備,則傳回快取的DeviceDescriptor ,否則將傳回目前的DeviceDescriptor

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

退貨
DeviceDescriptor

get子

public String[] getChildren (String path)

替代使用IFileEntry ,有時由於權限而無法運作。

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

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

投擲
DeviceNotAvailableException

getConnection

public AbstractConnection getConnection ()

與裝置關聯的目前連線。

退貨
AbstractConnection

取得當前可折疊狀態

public DeviceFoldableState getCurrentFoldableState ()

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

退貨
DeviceFoldableState

投擲
DeviceNotAvailableException

取得目前用戶

public int getCurrentUser ()

返回目前運行用戶的ID。如果發生錯誤,請返回-10000。

退貨
int

投擲
DeviceNotAvailableException

GetDeviceClass

public String getDeviceClass ()

取得設備類。

退貨
String String設備類別。

GetDevedate

public long getDeviceDate ()

自時代以來,以毫秒為單位返回設備的日期。

退貨
long設備以時期格式的日期。

投擲
DeviceNotAvailableException

getDevicedScriptor

public DeviceDescriptor getDeviceDescriptor ()

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

退貨
DeviceDescriptor

getDevicedScriptor

public DeviceDescriptor getDeviceDescriptor (boolean shortDescriptor)

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

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

退貨
DeviceDescriptor

GetDevicestate

public TestDeviceState getDeviceState ()

獲取設備的狀態。

退貨
TestDeviceState

getDevicEtimeOffset

public long getDeviceTimeOffset (Date date)

助手以獲得設備和給定ERROR(/Date)之間的時差。內部使用時代時間。

參數
date Date

退貨
long毫秒的差異

投擲
DeviceNotAvailableException

geteMulatorOutput

public InputStreamSource getEmulatorOutput ()

取得模擬器Stdout和stderr的串流

退貨
InputStreamSource模擬器輸出

GeteMulatorProcess

public Process getEmulatorProcess ()

傳回與此模擬器相對應的Process

退貨
Process Processnull

getExecuteshellCommandLog

public final File getExecuteShellCommandLog ()

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

退貨
File

getExternalStoreFreeSpace

public long getExternalStoreFreeSpace ()

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

退貨
long KB中的自由空間數量

投擲
DeviceNotAvailableException

GetFastBootPath

public String getFastbootPath ()

返回使用快速啟動二進制的路徑。仍然需要isFastbootEnabled()為真,以啟用FastBoot函數。

退貨
String

GetFastBootProductType

public String getFastbootProductType ()

在快速啟動模式下,以取得該裝置的產品類型的便利方法。

僅當設備應在FastBoot中時,才應使用此方法。在這種情況下,它比通用getProductType()方法更安全,因為如果裝置處於不正確狀態或無回應措施,則iTestDevice將知道將裝置恢復到FastBoot。

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

投擲
DeviceNotAvailableException

GetFastBootProductVariant

public String getFastbootProductVariant ()

在快速啟動模式下,以取得該裝置的產品類型的便利方法。

僅當設備應在FastBoot中時,才應使用此方法。在這種情況下,它比通用getProductType()方法更安全,因為如果裝置處於不正確狀態或無回應措施,則iTestDevice將知道將裝置恢復到FastBoot。

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

投擲
DeviceNotAvailableException

GetFastBootSerialnumber

public String getFastbootSerialNumber ()

返回FastBoot模式序號。

退貨
String

GetFastBootVaria

public String getFastbootVariable (String variableName)

從設備中檢索給定的FastBoot變數值。

參數
variableName String :變數名稱

退貨
String屬性值或null (如果不存在)

投擲
DeviceNotAvailableException

GetFastBootversion

public String getFastbootVersion ()

傳回使用的FastBoot二進位的版本字串。或如果出現問題,則無效。

退貨
String

getfileentry

public IFileEntry getFileEntry (String path)

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

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

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

投擲
DeviceNotAvailableException

getfileentry

public IFileEntry getFileEntry (FileListingService.FileEntry entry)

非正式的助手可以從非根路徑獲得FileEntry 。 FIXME:重構Fileentry系統將其從任何路徑可用。 (甚至非根)。

參數
entry FileListingService.FileEntryFileEntry不一定是依照DDMLIB的要求。

退貨
IFileEntry代表fileentry的fileentrywrapper。

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

取得可折疊狀態

public  getFoldableStates ()

返回設備上可折疊狀態的清單。可以使用“ CMD Device_state列印狀態”獲得。

退貨

投擲
DeviceNotAvailableException

GetIdevice

public IDevice getIDevice ()

傳回關聯的DDMLIB IDevice參考。

每當裝置斷開並重新連接ADB時,DDM都可以透過DDMS分配新的IDevice 。因此,呼叫者不應對IDevice進行引用,因為該參考可能會變成陳舊。

退貨
IDevice IDevice

取得安裝包名稱

public  getInstalledPackageNames ()

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

退貨
目前在裝置上安裝的String軟體包名稱的ERROR(/Set)

投擲
DeviceNotAvailableException

getintproperty

public long getIntProperty (String name, 
                long defaultValue)

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

參數
name String :屬性名稱

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

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

投擲
DeviceNotAvailableException

getipaddress

public String getIpAddress ()

取得設備的IP位址。

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

投擲
DeviceNotAvailableException

取得KeyguardState

public KeyguardControllerState getKeyguardState ()

傳回物件以取得鑰匙守衛或null的目前狀態,如果不支援。

退貨
KeyguardControllerState一個包含金鑰守衛狀態的快照的KeyguardControllerState ,如果不支援金鑰守衛查詢,則傳回null。

投擲
DeviceNotAvailableException

getlasteppedReboottimemillis

public long getLastExpectedRebootTimeMillis ()

自從System.currentTimeMillis()返回以來,傳回最後一次交易的API觸發了一次以毫秒為單位的重新啟動。

退貨
long

getlaunchapilevel

public int getLaunchApiLevel ()

取得裝置的第一個啟動API等級。預設為UNKNOWN_API_LEVEL

退貨
int一個整數,指示第一個啟動的API設備級別

投擲
DeviceNotAvailableException

getlogcat

public InputStreamSource getLogcat ()

抓住LogCat資料的快照流。

以兩種模式工作:

  • 如果目前在背景擷取了logcat,則會傳回TestDeviceOptions.getMaxLogcatDataSize()位元組,該位元組的目前內容的目前內容capture capture的目前內容
  • 否則,如果設備目前響應,將傳回LogCat資料的靜態轉儲

    退貨
    InputStreamSource

  • getlogcat

    public InputStreamSource getLogcat (int maxBytes)

    抓住捕獲的logcat資料的最後一個maxBytes的快照流。

    對於您想要捕獲捕獲的LogCat資料的頻繁快照而不產生可能的大磁碟空間罰款,即獲取整個getLogcat()快照時,很有用。

    參數
    maxBytes int :要傳回的最大資料量。應該是可以舒適地適合記憶的數量

    退貨
    InputStreamSource

    getlogcatdump

    public InputStreamSource getLogcatDump ()

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

    缺點是,如果無法到達設備,則不會返回。

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

    getlogcatsince

    public InputStreamSource getLogcatSince (long date)

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

    參數
    date long :自何時啟動快照直到現在的時期格式以來,以毫秒為單位。 (可以使用“日期 +%s”獲得)

    退貨
    InputStreamSource

    getmacaddress

    public String getMacAddress ()

    傳回設備的MAC位址,如果無法從設備查詢。

    退貨
    String

    GetMainuserid

    public Integer getMainUserId ()

    返回主要用戶ID。

    退貨
    Integer如果有一個,則主要用戶的用戶ID,如果沒有主要用戶,則為空。

    投擲
    DeviceNotAvailableException

    獲取主線模組信息

    public  getMainlineModuleInfo ()

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

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

    投擲
    DeviceNotAvailableException

    getMaxNumberOfRunningUsersSupported

    public int getMaxNumberOfRunningUsersSupported ()

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

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

    投擲
    DeviceNotAvailableException

    取得支援的最大用戶數

    public int getMaxNumberOfUsersSupported ()

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

    退貨
    int一個指示支援使用者數量的整數

    投擲
    DeviceNotAvailableException

    getmicrodroidprocess

    public Process getMicrodroidProcess ()

    退貨
    Process返回微吸收VM的過程。如果TestDevice不是微糖,請返回空。

    GetMonitor

    public IDeviceStateMonitor getMonitor ()

    傳回與裝置關聯的IDeviceStateMonitor

    退貨
    IDeviceStateMonitor

    getmountpoint

    public String getMountPoint (String mountName)

    返回安裝點。

    如果沒有IDevice中的快取訊息,請直接查詢設備。

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

    參數
    mountName String :安裝點的名稱

    退貨
    String安裝點或null

    getmountpointinfo

    public ITestDevice.MountPointInfo getMountPointInfo (String mountpoint)

    傳回對應於指定的安裝點路徑的MountPointInfo ,如果路徑沒有安裝或以其他方式沒有出現在 /proc /安裝端作為安裝點,則null

    參數
    mountpoint String

    退貨
    ITestDevice.MountPointInfo MountPointInfoERROR(/List)其中包含“/proc/mounts”中的信息

    投擲
    DeviceNotAvailableException

    getmountpointinfo

    public  getMountPointInfo ()

    傳回裝置上 /proc /安裝的資訊的解析版本

    退貨
    MountPointInfoERROR(/List)其中包含“/proc/mounts”中的信息

    投擲
    DeviceNotAvailableException

    取得選項

    public TestDeviceOptions getOptions ()

    取得設備的測試選項。

    退貨
    TestDeviceOptions與正在測試的設備有關的TestDeviceOptions

    getPartitionFreespace

    public long getPartitionFreeSpace (String partition)

    助手方法決定設備分區上的可用空間數量。

    參數
    partition String

    退貨
    long KB中的自由空間數量

    投擲
    DeviceNotAvailableException

    取得主用戶ID

    public Integer getPrimaryUserId ()

    返回主要用戶ID。

    退貨
    Integer主用戶(如果有)的用戶ID,如果沒有主用戶,則為null。

    投擲
    DeviceNotAvailableException

    getProcessbyName

    public ProcessInfo getProcessByName (String processName)

    助手方法運行“ pidof”和“ stat”命令,並使用PID返回ProcessInfo對象,並在給定過程的開始時間和過程開始時間。

    參數
    processName String :proces name string。

    退貨
    ProcessInfo給定ProcessName的ProcessInfo

    投擲
    DeviceNotAvailableException

    getProcesspid

    public String getProcessPid (String process)

    如果出現問題,將傳回服務的PID或無效。

    參數
    process String :proces name string。

    退貨
    String

    投擲
    DeviceNotAvailableException

    getProductType

    public String getProductType ()

    取得此設備產品類型的便利方法。

    如果設備處於ADB或FastBoot模式,此方法將會起作用。

    退貨
    String String產品類型名稱。不會無效

    投擲
    DeviceNotAvailableException

    GetProductVariant

    public String getProductVariant ()

    取得此設備產品變體的便利方法。

    如果設備處於ADB或FastBoot模式,此方法將會起作用。

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

    投擲
    DeviceNotAvailableException

    取得屬性

    public String getProperty (String name)

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

    參數
    name String :屬性名稱

    退貨
    String屬性值或null (如果不存在)

    投擲
    DeviceNotAvailableException

    GetRecoveryMode

    public ITestDevice.RecoveryMode getRecoveryMode ()

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

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

    取得螢幕截圖

    public InputStreamSource getScreenshot (String format)

    從裝置上擷取螢幕截圖。建議使用getscreenshot(格式)來取代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格式的螢幕截圖或null InputStreamSource

    投擲
    DeviceNotAvailableException

    取得序號

    public String getSerialNumber ()

    取得此設備序號的便利方法。

    退貨
    String String序號

    取得設定

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

    傳回請求的設定的值。名稱空間必須是:{“系統”,“安全”,“全域”}之一

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

    getemoperator

    public String getSimOperator ()

    返回SIM卡操作員或NULL(如果不可用),或設備不可用。

    退貨
    String

    getSimstate

    public String getSimState ()

    傳回SIM卡狀態或null(如果不可用,或設備不可用)。

    退貨
    String

    GetTombstones

    public  getTombstones ()

    從裝置中取得並返回墓碑清單。需要根。

    方法是最好的效果,因此,如果由於任何原因將一個墓碑未能拉出,則它將缺少清單中的墓碑。只有DeviceNotAvailableException才能儘早終止此方法。

    退貨
    墓碑文件列表,如果沒有墓碑,則空。

    投擲
    DeviceNotAvailableException

    getTotalMemory

    public long getTotalMemory ()

    在內部錯誤時傳回位元組中的總物理記憶體大小或-1

    退貨
    long

    取得UninstallablePackageNames

    public  getUninstallablePackageNames ()

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

    退貨
    目前在裝置上安裝的非安裝String軟體包名稱的ERROR(/Set)

    投擲
    DeviceNotAvailableException

    GetUseStfastbooterase

    public boolean getUseFastbootErase ()

    取得是使用FastBoot Erase還是FastBoot格式來擦除裝置上的分割區。

    退貨
    boolean如果使用FastBoot擦除,則如果使用FastBoot格式, false true

    取得用戶標誌

    public int getUserFlags (int userId)

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

    參數
    userId int

    退貨
    int如果發現,則與使用者ID相關的標誌在任何其他情況下都可以-10000。

    投擲
    DeviceNotAvailableException

    獲取用戶資訊

    public  getUserInfos ()

    取得在裝置上使用UserInfo的useID地圖。如果設備的輸出不如預期,將拋出DeviceRuntimeException

    退貨
    UserInfo物件列表。

    投擲
    DeviceNotAvailableException

    取得用戶序號

    public int getUserSerialNumber (int userId)

    在任何其他情況下,返回與用戶ID相關的序號,-10000。

    參數
    userId int

    退貨
    int

    投擲
    DeviceNotAvailableException

    HandlealLocationEvent

    public IManagedTestDevice.DeviceEventResponse handleAllocationEvent (DeviceEvent event)

    處理給定的設備Event。可以過渡設備到新狀態。將告知IDeviceMonitor任何國家過渡。

    處理設備Event,該設備Event可能會或可能不會將該設備轉換為新的分配狀態。

    參數
    event DeviceEvent

    退貨
    IManagedTestDevice.DeviceEventResponse

    有特徵

    public boolean hasFeature (String feature)

    檢查設備上是否有功能。

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

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

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

    無效的propertycache

    public void invalidatePropertyCache ()

    Isadbroot

    public boolean isAdbRoot ()

    退貨
    boolean

    投擲
    DeviceNotAvailableException

    ISADBTCP

    public boolean isAdbTcp ()

    退貨
    boolean

    isAppEnumerationSupported 是否支持

    public boolean isAppEnumerationSupported ()

    檢查裝置上的平台是否支援應用程式枚舉

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

    投擲
    DeviceNotAvailableException

    ISBYPASSLOWTARGETSDKBLOCKSUPTORPORTED

    public boolean isBypassLowTargetSdkBlockSupported ()

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

    退貨
    boolean如果支援旁路低目標SDK區塊,則為false,否則為否則

    投擲
    DeviceNotAvailableException

    ISDEVICEENCHECTPTED

    public boolean isDeviceEncrypted ()

    如果裝置加密,則傳回。

    退貨
    boolean如果對裝置進行了加密,則為true

    投擲
    DeviceNotAvailableException

    ISDIRECTORY

    public boolean isDirectory (String path)

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

    參數
    path String

    退貨
    boolean

    投擲
    DeviceNotAvailableException

    iSenableAdbroot

    public boolean isEnableAdbRoot ()

    退貨
    boolean true在裝置上啟用了ADB根

    Isencryptionsupport

    public boolean isEncryptionSupported ()

    如果在裝置上支援加密,則傳回。

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

    投擲
    DeviceNotAvailableException

    可以確定

    public boolean isExecutable (String fullPath)

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

    參數
    fullPath String

    退貨
    boolean

    投擲
    DeviceNotAvailableException

    ISFastBooteNabled

    public boolean isFastbootEnabled ()

    如果裝置可用於FastBoot,請返回。

    退貨
    boolean

    無頭

    public boolean isHeadless ()

    如果裝置無頭(沒有螢幕),則傳回true,否則為false。

    退貨
    boolean

    投擲
    DeviceNotAvailableException

    IsheadlessSystemusermode

    public boolean isHeadlessSystemUserMode ()

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

    退貨
    boolean

    投擲
    DeviceNotAvailableException

    Ismainuserpermanentadmin

    public boolean isMainUserPermanentAdmin ()

    傳回主要使用者是否為永久管理員,無法刪除或降級為非ADMIN狀態。

    退貨
    boolean

    投擲
    DeviceNotAvailableException

    是否支援多用戶

    public boolean isMultiUserSupported ()

    確定是否支援多用戶。

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

    投擲
    DeviceNotAvailableException

    軟體包已安裝

    public boolean isPackageInstalled (String packageName, 
                    String userId)

    查詢該設備的給定軟體包名稱和給定的用戶ID以檢查該設備目前是否針對該用戶安裝。

    參數
    packageName String :我們正在檢查是否已安裝的軟體包。

    userId String :我們正在檢查軟體包的使用者ID。如果為null,則將使用主用戶零。

    退貨
    boolean如果將包裝報告為已安裝,則為the。否則為假。

    投擲
    DeviceNotAvailableException

    軟體包已安裝

    public boolean isPackageInstalled (String packageName)

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

    參數
    packageName String

    退貨
    boolean如果將包裝報告為已安裝,則為the。否則為假。

    投擲
    DeviceNotAvailableException

    IsruntimePermissionsupport

    public boolean isRuntimePermissionSupported ()

    檢查設備上的平台是否支援運行時許可授予

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

    投擲
    DeviceNotAvailableException

    isstatebootloaderorfastbootd

    public boolean isStateBootloaderOrFastbootd ()

    如果裝置位於TestDeviceState#FASTBOOTTestDeviceState.FASTBOOTD中,則傳回true。

    退貨
    boolean

    正在運行

    public boolean isUserRunning (int userId)

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

    參數
    userId int

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

    投擲
    DeviceNotAvailableException

    是用戶次要的

    public boolean isUserSecondary (int userId)

    根據其標誌,傳回指定的用戶是否為二級用戶。

    參數
    userId int

    退貨
    boolean是的,如果使用者是次要的,則為false否則。

    投擲
    DeviceNotAvailableException

    可以維修

    public boolean isUserVisible (int userId)

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

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

    參數
    userId int

    退貨
    boolean

    投擲
    DeviceNotAvailableException

    Inservisible display

    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

    Isvisiblebackgroundusersporport

    public boolean isVisibleBackgroundUsersSupported ()

    返回該設備是否允許在後台看到使用者。

    如果是這樣,您可以致電startVisibleBackgroundUser(int, int, boolean) ,傳遞由listDisplayIdsForStartingVisibleBackgroundUsers()

    退貨
    boolean

    投擲
    DeviceNotAvailableException

    iSwifienabled

    public boolean isWifiEnabled ()

    測試是否啟用了WiFi。

    檢查是否在裝置上啟用了WiFi。對於在不應該使用WiFi(例如行動數據測試)進行測試之前主張WiFi狀態。

    退貨
    boolean如果啟用了wifi,則為truefalse如果禁用

    投擲
    DeviceNotAvailableException

    清單顯示 ID

    public  listDisplayIds ()

    收集裝置上可用顯示ID的列表,如「 Dumpsys SurfaceFlinger」報告。

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

    投擲
    DeviceNotAvailableException

    ListDisplayidsforStartingVisibleBackgrounduser

    public  listDisplayIdsForStartingVisibleBackgroundUsers ()

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

    退貨

    投擲
    DeviceNotAvailableException

    列出用戶

    public  listUsers ()

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

    退貨
    用戶ID列表。

    投擲
    DeviceNotAvailableException

    Loganrs

    public boolean logAnrs (ITestLogger logger)

    從設備收集並記錄ANRS。

    參數
    logger ITestLoggerITestLogger記錄ANRS。

    退貨
    boolean如果記錄成功,則是真的,否則為錯誤。

    投擲
    DeviceNotAvailableException

    logbugreport

    public boolean logBugreport (String dataName, 
                    ITestLogger listener)

    輔助方法將BugReport並將其記錄到記者。

    參數
    dataName String :將在其報告的名稱中報告。

    listener ITestLoggerITestLogger記錄bugreport。

    退貨
    boolean如果記錄成功,則是真的,否則為錯誤。

    logondevice

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

    在裝置的對數貓中記錄一則訊息。這是一個安全的電話,即使登入失敗也不會投擲。

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

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

    format String :訊息格式。

    args Object :透過string.format()替換的args。

    非BlockingReboot

    public void nonBlockingReboot ()

    發出重新啟動設備並在命令上返回的命令以及ADB不再可見設備時。

    投擲
    DeviceNotAvailableException

    addbrootaction

    public void postAdbRootAction ()

    如果裝置需要在ADB root之後和裝置重新線上之前採取一些特定的操作,則覆蓋。預設實作不包括任何加法操作。在此階段,不能保證啟用ADB根。

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

    後刺激性

    public void postAdbUnrootAction ()

    如果裝置需要在ADB Unroot之後以及裝置返回線上之前,則覆蓋裝置是否需要採取一些特定的操作。預設實作不包括任何其他操作。在此階段,不能保證ADB root被停用。

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

    後啟動

    public void postBootSetup ()

    執行指令以配置每個引導後測試設備。

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

    在正常情況下,此方法無需明確調用,因為執行重新啟動時的實作應自動執行這些步驟。

    可能需要呼叫的地方是當裝置重新啟動其他事件時(例如,何時快速啟動更新命令完成)

    投擲
    DeviceNotAvailableException

    調用後拆卸

    public void postInvocationTearDown (Throwable exception)

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

    參數
    exception Throwable :如果有的話,最終例外是由呼叫失敗提出的。

    啟動前

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

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

    參數
    info IBuildInfo :設備的IBuildInfo

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

    投擲
    DeviceNotAvailableException
    TargetSetupError

    plldir

    public boolean pullDir (String deviceFilePath, 
                    File localDir)

    從設備中遞歸從設備中提取目錄內容。

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

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

    退貨
    boolean如果成功拉出文件,則為true 。否則為false

    投擲
    DeviceNotAvailableException

    plullfile

    public boolean pullFile (String remoteFilePath, 
                    File localFile)

    檢索文件設備的文件。

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

    localFile File :要將內容儲存在中的本機檔案。如果非空,將更換內容。

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

    投擲
    DeviceNotAvailableException

    plullfile

    public File pullFile (String remoteFilePath, 
                    int userId)

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

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

    userId int :要從

    退貨
    File一個包含裝置檔案內容的ERROR(/File) ,如果因任何原因副本失敗(包括主機檔案系統的問題),則null

    投擲
    DeviceNotAvailableException

    plullfile

    public File pullFile (String remoteFilePath)

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

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

    退貨
    File一個包含裝置檔案內容的ERROR(/File) ,如果因任何原因副本失敗(包括主機檔案系統的問題),則null

    投擲
    DeviceNotAvailableException

    plullfile

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

    檢索文件設備的文件。

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

    localFile File :要將內容儲存在中的本機檔案。如果非空,將更換內容。

    userId int :要從

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

    投擲
    DeviceNotAvailableException

    Pullfilectents

    public String pullFileContents (String remoteFilePath)

    檢索從裝置上的文件,然後返回內容。

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

    退貨
    String一個包含裝置檔案內容的String ,如果出於任何原因副本失敗(包括主機檔案系統的問題),則null

    投擲
    DeviceNotAvailableException

    pullfilefromexternal

    public File pullFileFromExternal (String remoteFilePath)

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

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

    退貨
    File一個包含裝置檔案內容的ERROR(/File) ,如果因任何原因副本失敗(包括主機檔案系統的問題),則null

    投擲
    DeviceNotAvailableException

    pushdir

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

    遞歸將目錄的目錄推向設備,同時排除了一些已過濾的目錄。

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

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

    excludedDirectories :一組不應推動的目錄名稱。

    退貨
    boolean如果成功推動文件,則為true 。否則為false

    投擲
    DeviceNotAvailableException

    pushdir

    public boolean pushDir (File localFileDir, 
                    String deviceFilePath)

    遞歸將目錄內容的內容推向裝置。

    參數
    localFileDir File : the local directory to push

    deviceFilePath String : the absolute file path of the remote destination

    退貨
    boolean true if file was pushed successfully.否則為false

    投擲
    DeviceNotAvailableException

    pushFile

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

    Variant of pushFile(File, String) which can optionally consider evaluating the need for the content provider.

    參數
    localFile File : the local file to push

    remoteFilePath String : the remote destination absolute file path

    evaluateContentProviderNeeded boolean : whether to check if we need the content provider

    退貨
    boolean true if file was pushed successfully.否則為false

    投擲
    DeviceNotAvailableException

    pushFile

    public boolean pushFile (File localFile, 
                    String remoteFilePath)

    Push a file to device. By default using a content provider.

    參數
    localFile File : the local file to push

    remoteFilePath String : the remote destination absolute file path

    退貨
    boolean true if file was pushed successfully.否則為false

    投擲
    DeviceNotAvailableException

    pushString

    public boolean pushString (String contents, 
                    String remoteFilePath)

    Push file created from a string to device

    參數
    contents String : the contents of the file to push

    remoteFilePath String : the remote destination absolute file path

    退貨
    boolean true if string was pushed successfully.否則為false

    投擲
    DeviceNotAvailableException

    重啟

    public void reboot (String reason)

    Reboots the device into adb mode with given reason to be persisted across reboot.

    Blocks until device becomes available.

    Last reboot reason can be obtained by querying sys.boot.reason propety.

    參數
    reason String : a reason for this reboot, or null if no reason is specified.

    投擲
    DeviceNotAvailableException

    重啟

    public void reboot ()

    Reboots the device into adb mode.

    Blocks until device becomes available.

    投擲
    DeviceNotAvailableException

    rebootIntoBootloader

    public void rebootIntoBootloader ()

    Reboots the device into bootloader mode.

    Blocks until device is in bootloader mode.

    投擲
    DeviceNotAvailableException

    rebootIntoFastbootd

    public void rebootIntoFastbootd ()

    Reboots the device into fastbootd mode.

    Blocks until device is in fastbootd mode.

    投擲
    DeviceNotAvailableException

    rebootIntoRecovery

    public void rebootIntoRecovery ()

    Reboots the device into adb recovery mode.

    Blocks until device enters recovery

    投擲
    DeviceNotAvailableException

    rebootIntoSideload

    public void rebootIntoSideload ()

    Reboots the device into adb sideload mode (note that this is a special mode under recovery)

    Blocks until device enters sideload mode

    投擲
    DeviceNotAvailableException

    rebootIntoSideload

    public void rebootIntoSideload (boolean autoReboot)

    Reboots the device into adb sideload mode (note that this is a special mode under recovery)

    Blocks until device enters sideload mode

    參數
    autoReboot boolean : whether to automatically reboot the device after sideload

    投擲
    DeviceNotAvailableException

    rebootUntilOnline

    public void rebootUntilOnline ()

    An alternate to reboot() that only blocks until device is online ie visible to adb.

    投擲
    DeviceNotAvailableException

    rebootUntilOnline

    public void rebootUntilOnline (String reason)

    An alternate to reboot() that only blocks until device is online ie visible to adb.

    參數
    reason String : a reason for this reboot, or null if no reason is specified.

    投擲
    DeviceNotAvailableException

    rebootUserspace

    public void rebootUserspace ()

    Reboots only userspace part of device.

    Blocks until device becomes available.

    警告。 Userspace reboot is currently under active development, use it on your own risk.

    投擲
    DeviceNotAvailableException

    rebootUserspaceUntilOnline

    public void rebootUserspaceUntilOnline ()

    An alternate to rebootUserspace() ()} that only blocks until device is online ie visible to adb.

    投擲
    DeviceNotAvailableException

    recoverDevice

    public boolean recoverDevice ()

    Attempts to recover device communication.

    退貨
    boolean True if recovery attempted and successful, returns False if recovery was skipped

    投擲
    DeviceNotAvailableException if device is no longer available

    registerDeviceActionReceiver

    public void registerDeviceActionReceiver (IDeviceActionReceiver deviceActionReceiver)

    Registers a IDeviceActionReceiver for this device.

    All registered IDeviceActionReceiver s will be notified before a device action starts and after the device action ends.

    參數
    deviceActionReceiver IDeviceActionReceiver : A IDeviceActionReceiver which will be registered.

    remountSystemReadOnly

    public void remountSystemReadOnly ()

    Make the system partition on the device read-only. May reboot the device.

    投擲
    DeviceNotAvailableException

    remountSystemWritable

    public void remountSystemWritable ()

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

    投擲
    DeviceNotAvailableException

    remountVendorReadOnly

    public void remountVendorReadOnly ()

    Make the vendor partition on the device read-only. May reboot the device.

    投擲
    DeviceNotAvailableException

    remountVendorWritable

    public void remountVendorWritable ()

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

    投擲
    DeviceNotAvailableException

    刪除管理員

    public boolean removeAdmin (String componentName, 
                    int userId)

    Remove given device admin in given user and return true if it is successful, false otherwise.

    參數
    componentName String : of device admin to be removed.

    userId int : of user that the device admin lives in.

    退貨
    boolean True if it is successful, false otherwise.

    投擲
    DeviceNotAvailableException

    刪除所有者

    public void removeOwners ()

    Remove all existing device profile owners with the best effort.

    投擲
    DeviceNotAvailableException

    刪除用戶

    public boolean removeUser (int userId)

    Remove a given user from the device.

    參數
    userId int : of the user to remove

    退貨
    boolean true if we were successful in removing the user, false otherwise.

    投擲
    DeviceNotAvailableException

    resetContentProviderSetup

    public void resetContentProviderSetup ()

    Reset the flag for content provider setup in order to trigger it again.

    runInstrumentationTests

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

    Convenience method for performing ERROR(/#runInstrumentationTests(com.android.ddmlib.testrunner.IRemoteAndroidTestRunner,Collection)) with one or more listeners passed as parameters.

    參數
    runner IRemoteAndroidTestRunner : the IRemoteAndroidTestRunner which runs the tests

    listeners ITestLifeCycleReceiver : the test result listener(s)

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

    投擲
    DeviceNotAvailableException

    runInstrumentationTests

    public boolean runInstrumentationTests (IRemoteAndroidTestRunner runner, 
                     listeners)

    Runs instrumentation tests, and provides device recovery.

    If connection with device is lost before test run completes, and recovery succeeds, all listeners will be informed of testRunFailed and "false" will be returned. The test command will not be rerun. It is left to callers to retry if necessary.

    If connection with device is lost before test run completes, and recovery fails, all listeners will be informed of testRunFailed and DeviceNotAvailableException will be thrown.

    參數
    runner IRemoteAndroidTestRunner : the IRemoteAndroidTestRunner which runs the tests

    listeners : the test result listeners

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

    投擲
    DeviceNotAvailableException

    runInstrumentationTestsAsUser

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

    Same as ERROR(ITestDevice#runInstrumentationTests(IRemoteAndroidTestRunner, Collection)/com.android.tradefed.device.ITestDevice#runInstrumentationTests(com.android.ddmlib.testrunner.IRemoteAndroidTestRunner,Collection) ITestDevice#runInstrumentationTests(IRemoteAndroidTestRunner, Collection)) but runs the test for the given user.

    參數
    runner IRemoteAndroidTestRunner

    userId int

    listeners

    退貨
    boolean

    投擲
    DeviceNotAvailableException

    runInstrumentationTestsAsUser

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

    Same as ITestDevice#runInstrumentationTests(IRemoteAndroidTestRunner, ITestLifeCycleReceiver...) but runs the test for a given user.

    參數
    runner IRemoteAndroidTestRunner

    userId int

    listeners ITestLifeCycleReceiver

    退貨
    boolean

    投擲
    DeviceNotAvailableException

    設定配置

    public void setConfiguration (IConfiguration configuration)

    注入正在使用的IConfiguration

    參數
    configuration IConfiguration

    setConnectionAvdInfo

    public final void setConnectionAvdInfo (GceAvdInfo avdInfo)

    參數
    avdInfo GceAvdInfo

    設定日期

    public void setDate (Date date)

    Sets the date on device

    Note: setting date on device requires root

    參數
    date Date : specify a particular date; will use host date if null

    投擲
    DeviceNotAvailableException

    設定設備所有者

    public boolean setDeviceOwner (String componentName, 
                    int userId)

    Set a device admin component as device owner in given user.

    參數
    componentName String : of device admin to be device owner.

    userId int : of the user that the device owner lives in.

    退貨
    boolean True if it is successful, false otherwise.

    投擲
    DeviceNotAvailableException

    setDeviceState

    public void setDeviceState (TestDeviceState deviceState)

    Update the device's state.

    參數
    deviceState TestDeviceState : the TestDeviceState

    setEmulatorOutputStream

    public void setEmulatorOutputStream (SizeLimitedOutputStream output)

    For emulator set SizeLimitedOutputStream to log output

    參數
    output SizeLimitedOutputStream : to log the output

    setEmulatorProcess

    public void setEmulatorProcess (Process p)

    Sets the Process , when this device is an emulator.

    參數
    p Process

    setFastbootEnabled

    public void setFastbootEnabled (boolean fastbootEnabled)

    Set the fastboot option for the device. Should be set when device is first allocated.

    參數
    fastbootEnabled boolean : whether fastboot is available for the device or not

    setFastbootPath

    public void setFastbootPath (String fastbootPath)

    Sets the path to the fastboot binary that should be used. Still requires isFastbootEnabled() to be true, to have fastboot functions enabled.

    參數
    fastbootPath String

    setIDevice

    public void setIDevice (IDevice newDevice)

    Update the IDevice associated with this ITestDevice.

    The new IDevice must refer the same physical device as the current reference. This method will be called if DDMS has allocated a new IDevice

    參數
    newDevice IDeviceIDevice

    setLogStartDelay

    public void setLogStartDelay (int delay)

    Sets the time in ms to wait before starting logcat capture for a online device.

    參數
    delay int : the delay in ms

    設定選項

    public void setOptions (TestDeviceOptions options)

    Set the TestDeviceOptions for the device

    參數
    options TestDeviceOptions

    設定屬性

    public boolean setProperty (String propKey, 
                    String propValue)

    Sets the given property value on the device. Requires adb root is true.

    參數
    propKey String : The key targeted to be set.

    propValue String : The property value to be set.

    退貨
    boolean returns True if the setprop command was successful, False otherwise.

    投擲
    DeviceNotAvailableException

    setRecovery

    public void setRecovery (IDeviceRecovery recovery)

    Set the IDeviceRecovery to use for this device. Should be set when device is first allocated.

    參數
    recovery IDeviceRecovery : the IDeviceRecovery

    setRecoveryMode

    public void setRecoveryMode (ITestDevice.RecoveryMode mode)

    Set the current recovery mode to use for the device.

    Used to control what recovery method to use when a device communication problem is encountered. Its recommended to only use this method sparingly when needed (for example, when framework is down, etc

    參數
    mode ITestDevice.RecoveryMode : whether 'recover till online only' mode should be on or not.

    設定設定

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

    See setSetting(int, String, String, String) and performed on system user.

    參數
    namespace String

    key String

    value String

    投擲
    DeviceNotAvailableException

    設定設定

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

    Add a setting value to the namespace of a given user. Some settings will only be available after a reboot. namespace must be one of: {"system", "secure", "global"}

    參數
    userId int

    namespace String

    key String

    value String

    投擲
    DeviceNotAvailableException

    setTestLogger

    public void setTestLogger (ITestLogger testLogger)

    Injects the ITestLogger instance

    參數
    testLogger ITestLogger

    setUseFastbootErase

    public void setUseFastbootErase (boolean useFastbootErase)

    Set whether to use fastboot erase or fastboot format to wipe a partition on the device.

    參數
    useFastbootErase boolean : true if fastboot erase should be used or false if fastboot format should be used.

    startLogcat

    public void startLogcat ()

    Start capturing logcat output from device in the background.

    Will have no effect if logcat output is already being captured. Data can be later retrieved via getLogcat.

    When the device is no longer in use, stopLogcat() must be called.

    startLogcat() and stopLogcat() do not normally need to be called when within a TF invocation context, as the TF framework will start and stop logcat.

    啟動使用者

    public boolean startUser (int userId)

    Starts a given user in the background if it is currently stopped. If the user is already running in the background, this method is a NOOP.

    參數
    userId int : of the user to start in the background

    退貨
    boolean true if the user was successfully started in the background.

    投擲
    DeviceNotAvailableException

    啟動使用者

    public boolean startUser (int userId, 
                    boolean waitFlag)

    Starts a given user in the background if it is currently stopped. If the user is already running in the background, this method is a NOOP. Possible to provide extra flag to wait for the operation to have effect.

    參數
    userId int : of the user to start in the background

    waitFlag boolean : will make the command wait until user is started and unlocked.

    退貨
    boolean true if the user was successfully started in the background.

    投擲
    DeviceNotAvailableException

    startVisibleBackgroundUser

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

    Starts a given user in the background, visible in the given display (ie, allowing the user to launch activities in that display).

    NOTE: this command doesn't check if the user exists, display is available, device supports such feature , etc.

    參數
    userId int : of the user to start in the background

    displayId int : display to start user visible on

    waitFlag boolean : will make the command wait until user is started and unlocked.

    退貨
    boolean true if the user was successfully started visible in the background.

    投擲
    DeviceNotAvailableException

    stopEmulatorOutput

    public void stopEmulatorOutput ()

    Close and delete the emulator output.

    stopLogcat

    public void stopLogcat ()

    Stop capturing logcat output from device, and discard currently saved logcat data.

    Will have no effect if logcat output is not being captured.

    停止用戶

    public boolean stopUser (int userId)

    Stops a given user. If the user is already stopped, this method is a NOOP. Cannot stop current and system user.

    參數
    userId int : of the user to stop.

    退貨
    boolean true if the user was successfully stopped.

    投擲
    DeviceNotAvailableException

    停止用戶

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

    Stop a given user. Possible to provide extra flags to wait for the operation to have effect, and force terminate the user. Cannot stop current and system user.

    參數
    userId int : of the user to stop.

    waitFlag boolean : will make the command wait until user is stopped.

    forceFlag boolean : will force stop the user.

    退貨
    boolean true if the user was successfully stopped.

    投擲
    DeviceNotAvailableException

    switchToAdbTcp

    public String switchToAdbTcp ()

    Switch device to adb-over-tcp mode.

    退貨
    String the tcp serial number or null if device could not be switched

    投擲
    DeviceNotAvailableException

    switchToAdbUsb

    public boolean switchToAdbUsb ()

    Switch device to adb over usb mode.

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

    投擲
    DeviceNotAvailableException

    切換用戶

    public boolean switchUser (int userId)

    Switch to another userId with a default timeout. switchUser(int, long) .

    參數
    userId int

    退貨
    boolean True if the new userId matches the userId provider.否則為假。

    投擲
    DeviceNotAvailableException

    切換用戶

    public boolean switchUser (int userId, 
                    long timeout)

    Switch to another userId with the provided timeout as deadline. Attempt to disable keyguard after user change is successful.

    參數
    userId int

    timeout long : to wait before returning false for switch-user failed.

    退貨
    boolean True if the new userId matches the userId provider.否則為假。

    投擲
    DeviceNotAvailableException

    syncFiles

    public boolean syncFiles (File localFileDir, 
                    String deviceFilePath)

    Incrementally syncs the contents of a local file directory to device.

    Decides which files to push by comparing timestamps of local files with their remote equivalents. Only 'newer' or non-existent files will be pushed to device. Thus overhead should be relatively small if file set on device is already up to date.

    Hidden files (with names starting with ".") will be ignored.

    Example usage: syncFiles("/tmp/files", "/sdcard") will created a /sdcard/files directory if it doesn't already exist, and recursively push the /tmp/files contents to /sdcard/files.

    參數
    localFileDir File : the local file directory containing files to recursively push.

    deviceFilePath String : the remote destination absolute file path root. All directories in thos file path must be readable. ie pushing to /data/local/tmp when adb is not root will fail

    退貨
    boolean true if files were synced successfully.否則為false

    投擲
    DeviceNotAvailableException

    takeBugreport

    public Bugreport takeBugreport ()

    Take a bugreport and returns it inside a Bugreport object to handle it. Return null in case of issue. File referenced in the Bugreport object need to be cleaned via Bugreport.close() .

    退貨
    Bugreport

    解除安裝包

    public String uninstallPackage (String packageName)

    Uninstall an Android package from device.

    參數
    packageName String : the Android package to uninstall

    退貨
    String a String with an error code, or null if success.

    投擲
    DeviceNotAvailableException

    解除安裝用戶包

    public String uninstallPackageForUser (String packageName, 
                    int userId)

    Uninstall an Android package from device for a given user.

    參數
    packageName String : the Android package to uninstall

    userId int : the integer user id to uninstall for.

    退貨
    String a String with an error code, or null if success.

    投擲
    DeviceNotAvailableException

    unlockDevice

    public boolean unlockDevice ()

    Unlocks the device if the device is in an encrypted state.

    This method may restart the framework but will not call postBootSetup() . Therefore, the device might not be fully ready to be tested when this method returns.

    退貨
    boolean true if successful or if the device is unencrypted.

    投擲
    DeviceNotAvailableException

    waitForBootComplete

    public boolean waitForBootComplete (long timeOut)

    Blocks until the device's boot complete flag is set.

    參數
    timeOut long : time in msecs to wait for the flag to be set

    退貨
    boolean true if device's boot complete flag is set within the timeout

    投擲
    DeviceNotAvailableException

    waitForDeviceAvailable

    public boolean waitForDeviceAvailable ()

    Waits for the device to be responsive and available for testing. Uses default timeout.

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

    投擲
    DeviceNotAvailableException

    waitForDeviceAvailable

    public boolean waitForDeviceAvailable (long waitTime)

    Waits for the device to be responsive and available for testing.

    參數
    waitTime long : the time in ms to wait

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

    投擲
    DeviceNotAvailableException

    waitForDeviceAvailableInRecoverPath

    public boolean waitForDeviceAvailableInRecoverPath (long waitTime)

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

    參數
    waitTime long

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

    投擲
    DeviceNotAvailableException

    waitForDeviceBootloader

    public void waitForDeviceBootloader ()

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

    投擲
    DeviceNotAvailableException

    waitForDeviceInRecovery

    public boolean waitForDeviceInRecovery (long waitTime)

    Blocks for the device to be in the 'adb recovery' state (note this is distinct from IDeviceRecovery ).

    參數
    waitTime long : the time in ms to wait

    退貨
    boolean true if device boots into recovery before time expires.否則為false

    waitForDeviceInSideload

    public boolean waitForDeviceInSideload (long waitTime)

    Blocks for the device to be in the 'adb sideload' state

    參數
    waitTime long : the time in ms to wait

    退貨
    boolean true if device boots into sideload before time expires.否則為false

    waitForDeviceNotAvailable

    public boolean waitForDeviceNotAvailable (long waitTime)

    Blocks for the device to be not available ie missing from adb

    參數
    waitTime long : the time in ms to wait

    退貨
    boolean true if device becomes not available before time expires.否則為false

    waitForDeviceOnline

    public void waitForDeviceOnline ()

    Blocks until device is visible via adb. Uses default timeout

    Note the device may not necessarily be responsive to commands on completion. Use waitForDeviceAvailable() instead.

    投擲
    DeviceNotAvailableException

    waitForDeviceOnline

    public void waitForDeviceOnline (long waitTime)

    Blocks until device is visible via adb.

    Note the device may not necessarily be responsive to commands on completion. Use waitForDeviceAvailable() instead.

    參數
    waitTime long : the time in ms to wait

    投擲
    DeviceNotAvailableException

    waitForDeviceShell

    public boolean waitForDeviceShell (long waitTime)

    Waits for device to be responsive to a basic adb shell command.

    參數
    waitTime long : the time in ms to wait

    退貨
    boolean true if device becomes responsive before waitTime elapses.

    受保護的方法

    addExtraConnectionBuilderArgs

    protected void addExtraConnectionBuilderArgs (DefaultConnection.ConnectionBuilder builder)

    參數
    builder DefaultConnection.ConnectionBuilder

    buildAdbShellCommand

    protected String[] buildAdbShellCommand (String command, 
                    boolean forceExitStatusDetection)

    Builds the OS command for the given adb shell command session and args

    參數
    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)

    Create a RebootDeviceAction to be used when performing a reboot action.

    參數
    rebootMode NativeDevice.RebootMode :重啟的一種模式。

    reason String :用於此次重新啟動。

    退貨
    NativeDevice.RebootDeviceAction the created RebootDeviceAction .

    createRunUtil

    protected IRunUtil createRunUtil ()

    退貨
    IRunUtil

    執行AdbReboot

    protected void doAdbReboot (NativeDevice.RebootMode rebootMode, 
                    String reason)

    執行 adb 重啟。

    參數
    rebootMode NativeDevice.RebootMode :重啟的一種模式。

    reason String :用於此次重新啟動。

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

    ensureRuntimePermissionSupported

    protected void ensureRuntimePermissionSupported ()

    helper method to throw exception if runtime permission isn't supported

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

    getApiLevelSafe

    protected int getApiLevelSafe ()

    退貨
    int

    getLogger

    protected ITestLogger getLogger ()

    退貨
    ITestLogger

    取得運行工具

    protected IRunUtil getRunUtil ()

    Get the RunUtil instance to use.

    退貨
    IRunUtil

    initializeConnection

    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)

    Fetch a device property, from the ddmlib cache by default, and falling back to either `adb shell getprop` or `fastboot getvar` depending on whether the device is in Fastboot or not.

    參數
    propName String : The name of the device property as returned by `adb shell getprop`

    fastbootVar String : The name of the equivalent fastboot variable to query. if null , fastboot query will not be attempted

    description String : A simple description of the variable. First letter should be capitalized.

    退貨
    String A string, possibly null or empty, containing the value of the given property

    投擲
    DeviceNotAvailableException

    isInRebootCallback

    protected boolean isInRebootCallback ()

    Returns whether reboot callbacks is currently being executed or not. All public api's for reboot should be disabled if true.

    退貨
    boolean

    isNewer

    protected boolean isNewer (File localFile, 
                    IFileEntry entry)

    Return true if local file is newer than remote file. IFileEntry being accurate to the minute, in case of equal times, the file will be considered newer.

    參數
    localFile File

    entry IFileEntry

    退貨
    boolean

    notifyRebootEnded

    protected void notifyRebootEnded ()

    Notifies all IDeviceActionReceiver about reboot end event.

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

    notifyRebootStarted

    protected void notifyRebootStarted ()

    Notifies all IDeviceActionReceiver about reboot start event.

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

    performDeviceAction

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

    Performs an action on this device. Attempts to recover device and optionally retry command if action fails.

    參數
    actionDescription String : a short description of action to be performed. Used for logging purposes only.

    action NativeDevice.DeviceAction : the action to be performed

    retryAttempts int : the retry attempts to make for action if it fails but recovery succeeds

    退貨
    boolean true if action was performed successfully

    投擲
    DeviceNotAvailableException if recovery attempt fails or max attempts done without success

    postAdbReboot

    protected void postAdbReboot ()

    Possible extra actions that can be taken after a reboot.

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

    啟動後設定前

    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)

    Set the Clock instance to use.

    參數
    clock Clock

    setMicrodroidProcess

    protected void setMicrodroidProcess (Process process)

    Marks the TestDevice as microdroid and sets its CID.

    參數
    process Process : Process of the Microdroid VM.

    setTestDeviceOptions

    protected void setTestDeviceOptions ( deviceOptions)

    參數
    deviceOptions

    simpleFastbootCommand

    protected CommandResult simpleFastbootCommand (long timeout, 
                     envVarMap, 
                    String[] fullCmd)

    Executes a simple fastboot command with environment variables and report the status of the command.

    參數
    timeout long

    envVarMap

    fullCmd String

    退貨
    CommandResult

    simpleFastbootCommand

    protected CommandResult simpleFastbootCommand (long timeout, 
                    String[] fullCmd)

    Executes a simple fastboot command and report the status of the command.

    參數
    timeout long

    fullCmd String

    退貨
    CommandResult

    waitForDeviceNotAvailable

    protected boolean waitForDeviceNotAvailable (String operationDesc, 
                    long time)

    Wait to see the device going unavailable (stop reporting to adb).

    參數
    operationDesc String : The name of the operation that is waiting for unavailable.

    time long : The time to wait for unavailable to occur.

    退貨
    boolean True if device did become unavailable.