I測試設備

public interface ITestDevice
implements INativeDevice

com.android.tradefed.device.ITestDevice


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

重試可配置數量的設備命令,並為無響應的設備提供設備恢復界面。

概括

嵌套類

class ITestDevice.ApexInfo

一個簡單的結構類,用於存儲有關單個 APEX 的信息

class ITestDevice.MountPointInfo

一個簡單的結構類,用於存儲有關單個安裝點的信息

公共方法

abstract boolean canSwitchToHeadlessSystemUser ()

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

abstract boolean checkConnectivity ()

檢查設備是否具有網絡連接。

abstract boolean clearErrorDialogs ()

嘗試關閉當前顯示在設備 UI 上的任何錯誤對話框。

abstract void clearLastConnectedWifiNetwork ()

清除上次連接的 wifi 網絡。

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

連接到 wifi 網絡。

abstract boolean connectToWifiNetwork ( wifiSsidToPsk) connectToWifiNetwork ( wifiSsidToPsk)

連接到 wifi 網絡。

abstract boolean connectToWifiNetwork (String wifiSsid, String wifiPsk)

連接到 wifi 網絡。

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

連接到 wifi 網絡。

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

connectToWifiNetwork(String, String)的一種變體,僅當設備當前沒有網絡連接時才連接。

abstract boolean connectToWifiNetworkIfNeeded (String wifiSsid, String wifiPsk)

connectToWifiNetwork(String, String)的一種變體,僅當設備當前沒有網絡連接時才連接。

abstract int createUser (String name)

創建一個具有給定名稱和默認標誌 0 的用戶。

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

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

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

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

abstract int createUserNoThrow (String name)

創建一個具有給定名稱和默認標誌 0 的用戶。

abstract void deregisterDeviceActionReceiver ( IDeviceActionReceiver deviceActionReceiver)

刪除已註冊的IDeviceActionReceiver

abstract void disableKeyguard ()

嘗試禁用鍵盤鎖。

abstract boolean disableNetworkMonitor ()

禁用設備上的網絡監控。

abstract boolean disconnectFromWifi ()

斷開與 wifi 網絡的連接。

abstract boolean doesFileExist (String deviceFilePath, int userId)

確定給定用戶設備上的文件是否存在的輔助方法。

abstract File dumpHeap (String process, String devicePath)

嘗試從 system_server 轉儲堆。

abstract boolean enableNetworkMonitor ()

在設備上啟用網絡監控。

abstract getActiveApexes ()

獲取有關設備上激活的 APEX 的信息。

abstract getAllSettings (String namespace)

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

abstract String getAndroidId (int userId)

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

abstract getAndroidIds ()

創建一個找到匹配用戶 ID 的 Android ID 地圖。

abstract PackageInfo getAppPackageInfo (String packageName)

獲取有關安裝在設備上的包的信息。

abstract getAppPackageInfos ()

獲取設備上安裝的包的信息。

abstract InputStreamSource getBugreport ()

從設備中檢索錯誤報告。

abstract InputStreamSource getBugreportz ()

從設備中檢索 bugreportz。

abstract DeviceFoldableState getCurrentFoldableState ()

返回設備的當前可折疊狀態,如果出現某些問題則返回 null。

abstract int getCurrentUser ()

返回當前運行用戶的 id。

abstract getFoldableStates ()

返回設備上的可折疊狀態列表。

abstract getInstalledPackageNames ()

獲取設備上存在的應用程序包名稱。

abstract String getIpAddress ()

獲取設備的 IP 地址。

abstract KeyguardControllerState getKeyguardState ()

返回一個對像以獲取鍵盤鎖的當前狀態,如果不支持則返回 null。

abstract Integer getMainUserId ()

返回主用戶 ID。

abstract getMainlineModuleInfo ()

獲取有關設備上安裝的主線模塊的信息。

abstract int getMaxNumberOfRunningUsersSupported ()

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

abstract int getMaxNumberOfUsersSupported ()

獲取支持的最大用戶數。

abstract TestDeviceOptions getOptions ()

獲取設備的測試選項。

abstract Integer getPrimaryUserId ()

返回主用戶 ID。

abstract InputStreamSource getScreenshot ()

從設備抓取屏幕截圖。

abstract InputStreamSource getScreenshot (String format, boolean rescale)

從設備抓取屏幕截圖。

abstract InputStreamSource getScreenshot (String format)

從設備抓取屏幕截圖。

abstract InputStreamSource getScreenshot (long displayId)

從給定顯示 ID 的設備抓取屏幕截圖。

abstract String getSetting (String namespace, String key)

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

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

返回請求設置的值。

abstract getUninstallablePackageNames ()

獲取可卸載的應用程序包名稱。

abstract int getUserFlags (int userId)

查找並返回給定用戶的標誌。

abstract getUserInfos ()

獲取設備上useId到UserInfo的Map。

abstract int getUserSerialNumber (int userId)

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

abstract boolean hasFeature (String feature)

檢查某項功能是否在設備上可用。

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

在設備上安裝 Android 包。

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

在設備上安裝 Android 包。

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

為給定用戶在設備上安裝 Android 包。

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

為給定用戶在設備上安裝 Android 包。

default String installPackages ( packageFiles, boolean reinstall, String... extraArgs) installPackages ( packageFiles, boolean reinstall, String... extraArgs)

安裝由多個 APK 文件(一個主要和額外的拆分包)組成的 Android 應用程序。

default String installPackages ( packageFiles, boolean reinstall, boolean grantPermissions, String... extraArgs) installPackages ( packageFiles, boolean reinstall, boolean grantPermissions, String... extraArgs)

安裝一個由位於 Android 設備上的多個 APK 文件(一個主要的和額外的拆分包)組成的 Android 應用程序。

default String installPackagesForUser ( packageFiles, boolean reinstall, boolean grantPermissions, int userId, String... extraArgs) installPackagesForUser ( packageFiles, boolean reinstall, boolean grantPermissions, int userId, String... extraArgs)

為給定用戶安裝一個由多個 APK 文件(一個主要的和額外的拆分包)組成的 Android 應用程序。

default String installPackagesForUser ( packageFiles, boolean reinstall, int userId, String... extraArgs) installPackagesForUser ( packageFiles, boolean reinstall, int userId, String... extraArgs)

為給定用戶安裝一個由多個 APK 文件(一個主要的和額外的拆分包)組成的 Android 應用程序。

default String installRemotePackages ( remoteApkPaths, boolean reinstall, String... extraArgs) installRemotePackages ( remoteApkPaths, boolean reinstall, String... extraArgs)

安裝一個由位於 Android 設備上的多個 APK 文件(一個主要的和額外的拆分包)組成的 Android 應用程序。

default String installRemotePackages ( remoteApkPaths, boolean reinstall, boolean grantPermissions, String... extraArgs) installRemotePackages ( remoteApkPaths, boolean reinstall, boolean grantPermissions, String... extraArgs)

安裝一個由位於 Android 設備上的多個 APK 文件(一個主要的和額外的拆分包)組成的 Android 應用程序。

abstract boolean isHeadlessSystemUserMode ()

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

abstract boolean isMainUserPermanentAdmin ()

返回主用戶是否是永久管理員並且不能被刪除或降級為非管理員狀態。

abstract boolean isMultiUserSupported ()

確定是否支持多用戶。

abstract boolean isPackageInstalled (String packageName)

在設備上查詢給定的包名稱以檢查它當前是否已安裝。

abstract boolean isPackageInstalled (String packageName, String userId)

查詢設備以獲取給定的包名稱和給定的用戶 ID,以檢查當前是否為該用戶安裝了它。

abstract boolean isUserRunning (int userId)

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

abstract boolean isUserSecondary (int userId)

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

abstract boolean isUserVisible (int userId)

檢查給定用戶是否可見。

abstract boolean isUserVisibleOnDisplay (int userId, int displayId)

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

abstract boolean isVisibleBackgroundUsersOnDefaultDisplaySupported ()

ERROR(/java.android.view.Display#DEFAULT_DISPLAY)中返回設備是否允許用戶在後台可見。

abstract boolean isVisibleBackgroundUsersSupported ()

返回設備是否允許用戶在後台可見啟動。

abstract boolean isWifiEnabled ()

測試wifi是否開啟。

abstract listDisplayIds ()

收集“dumpsys SurfaceFlinger”報告的設備上可用顯示 ID 的列表。

abstract listDisplayIdsForStartingVisibleBackgroundUsers ()

獲取可用於start a user visible in the background的顯示列表。

abstract listUsers ()

獲取設備上的用戶列表。

abstract boolean logBugreport (String dataName, ITestLogger listener)

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

abstract void registerDeviceActionReceiver ( IDeviceActionReceiver deviceActionReceiver)

為此設備註冊一個IDeviceActionReceiver

abstract boolean removeAdmin (String componentName, int userId)

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

abstract void removeOwners ()

盡最大努力刪除所有現有的設備配置文件所有者。

abstract boolean removeUser (int userId)

從設備中刪除給定的用戶。

abstract boolean setDeviceOwner (String componentName, int userId)

將設備管理組件設置為給定用戶的設備所有者。

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

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

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

將設置值添加到給定用戶的名稱空間。

abstract boolean startUser (int userId)

如果當前已停止,則在後台啟動給定用戶。

abstract boolean startUser (int userId, boolean waitFlag)

如果當前已停止,則在後台啟動給定用戶。

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

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

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

停止給定的用戶。

abstract boolean stopUser (int userId)

停止給定的用戶。

abstract boolean switchUser (int userId)

切換到另一個具有默認超時的 userId。

abstract boolean switchUser (int userId, long timeout)

以提供的超時為截止日期切換到另一個 userId。

abstract Bugreport takeBugreport ()

獲取錯誤報告並將其返回到Bugreport對像中以進行處理。

abstract String uninstallPackage (String packageName)

從設備卸載 Android 包。

abstract String uninstallPackageForUser (String packageName, int userId)

從給定用戶的設備中卸載 Android 包。

公共方法

可以切換到無頭系統用戶

public abstract boolean canSwitchToHeadlessSystemUser ()

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

退貨
boolean

投擲
DeviceNotAvailableException

檢查連通性

public abstract boolean checkConnectivity ()

檢查設備是否具有網絡連接。

退貨
boolean如果設備具有有效的網絡連接, true ,否則為false

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

清除錯誤對話框

public abstract boolean clearErrorDialogs ()

嘗試關閉當前顯示在設備 UI 上的任何錯誤對話框。

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

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

清除上次連接的 Wifi 網絡

public abstract void clearLastConnectedWifiNetwork ()

清除上次連接的 wifi 網絡。這應該在開始新調用時調用,以避免在設備重啟後連接到先前測試中使用的 wifi 網絡。

連接到 Wifi 網絡

public abstract 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 abstract boolean connectToWifiNetwork ( wifiSsidToPsk)

連接到 wifi 網絡。

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

參數
wifiSsidToPsk :wifi SSID 到密碼的映射。

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

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

連接到 Wifi 網絡

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

connectToWifiNetworkIfNeeded

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

connectToWifiNetwork(String, String)的一種變體,僅當設備當前沒有網絡連接時才連接。

參數
scanSsid boolean : 是否為此網絡掃描隱藏的 SSID

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

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

connectToWifiNetworkIfNeeded

public abstract boolean connectToWifiNetworkIfNeeded (String wifiSsid, 
                String wifiPsk)

connectToWifiNetwork(String, String)的一種變體,僅當設備當前沒有網絡連接時才連接。

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

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

創建用戶

public abstract int createUser (String name)

創建一個具有給定名稱和默認標誌 0 的用戶。

參數
name String : 要在設備上創建的用戶

退貨
int創建的用戶 ID 的整數

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

創建用戶

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

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

參數
name String : 要在設備上創建的用戶

guest boolean :在創建期間啟用用戶標誌 --guest

ephemeral boolean :在創建期間啟用用戶標誌 --ephemeral

forTesting boolean :在創建期間啟用測試標誌 --for-testing

退貨
int創建的用戶id

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

創建用戶

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

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

參數
name String : 要在設備上創建的用戶

guest boolean :在創建期間啟用用戶標誌 --guest

ephemeral boolean :在創建期間啟用用戶標誌 --ephemeral

退貨
int創建的用戶id

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

createUserNoThrow

public abstract int createUserNoThrow (String name)

創建一個具有給定名稱和默認標誌 0 的用戶。

參數
name String : 要在設備上創建的用戶

退貨
int創建的用戶 ID 的整數或 -1 表示錯誤。

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

註銷DeviceActionReceiver

public abstract void deregisterDeviceActionReceiver (IDeviceActionReceiver deviceActionReceiver)

刪除已註冊的IDeviceActionReceiver

參數
deviceActionReceiver IDeviceActionReceiver :將被刪除的IDeviceActionReceiver

禁用鍵盤鎖

public abstract void disableKeyguard ()

嘗試禁用鍵盤鎖。

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

投擲
DeviceNotAvailableException

禁用網絡監視器

public abstract boolean disableNetworkMonitor ()

禁用設備上的網絡監控。

退貨
boolean如果成功禁用監視,則為true 。如果失敗則false

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

斷開與 Wifi 的連接

public abstract boolean disconnectFromWifi ()

斷開與 wifi 網絡的連接。

從已知網絡列表中刪除所有網絡並禁用 wifi。

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

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

文件是否存在

public abstract boolean doesFileExist (String deviceFilePath, 
                int userId)

確定給定用戶設備上的文件是否存在的輔助方法。

參數
deviceFilePath String : 要檢查的設備上文件的絕對路徑

userId int :用於檢查文件是否存在的用戶 ID

退貨
boolean如果文件存在true ,否則為false

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

轉儲堆

public abstract File dumpHeap (String process, 
                String devicePath)

嘗試從 system_server 轉儲堆。清理轉儲文件是調用者的責任。

參數
process String :要轉儲到的設備進程的名稱。

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

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

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

啟用網絡監控器

public abstract boolean enableNetworkMonitor ()

在設備上啟用網絡監控。

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

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

獲取活動頂點

public abstract  getActiveApexes ()

獲取有關設備上激活的 APEX 的信息。

退貨
當前在設備上激活的ApexInfoERROR(/Set)

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

獲取所有設置

public abstract  getAllSettings (String namespace)

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

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

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

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

獲取AndroidId

public abstract String getAndroidId (int userId)

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

參數
userId int

退貨
String

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

獲取AndroidIds

public abstract  getAndroidIds ()

創建一個找到匹配用戶 ID 的 Android ID 地圖。無法保證每個用戶 ID 都會找到一個與此函數關聯的 Android ID,因此某些用戶 ID 可能匹配 null。

退貨
android id 映射找到匹配的用戶 id。

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

獲取應用程序包信息

public abstract PackageInfo getAppPackageInfo (String packageName)

獲取有關安裝在設備上的包的信息。

參數
packageName String

退貨
PackageInfo PackageInfonull (如果無法檢索到信息)

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

獲取應用程序包信息

public abstract  getAppPackageInfos ()

獲取設備上安裝的包的信息。

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

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

獲取錯誤報告

public abstract InputStreamSource getBugreport ()

從設備中檢索錯誤報告。

此實現保證在沒有 sdcard 的設備(或尚未安裝 sdcard 的設備)上繼續工作。

退貨
InputStreamSource InputStreamSource將按需生成錯誤報告內容。萬一失敗, InputStreamSource將產生一個空的ERROR(/InputStream)

getBugreportz

public abstract InputStreamSource getBugreportz ()

從設備中檢索 bugreportz。 Zip 格式的 bugreport 包含主要的 bugreport 和其他對調試有用的日誌文件。

僅支持 'adb version' > 1.0.36

退貨
InputStreamSource包含 bugreportz 的 zip 文件的InputStreamSource ,如果失敗則返回 null。

獲取當前可折疊狀態

public abstract DeviceFoldableState getCurrentFoldableState ()

返回設備的當前可折疊狀態,如果出現某些問題則返回 null。

退貨
DeviceFoldableState

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

獲取當前用戶

public abstract int getCurrentUser ()

返回當前運行用戶的 id。如果出錯,返回 -10000。

退貨
int

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

獲取可折疊狀態

public abstract  getFoldableStates ()

返回設備上的可折疊狀態列表。可以通過“cmd device_state print-states”獲得。

退貨

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

getInstalledPackageNames

public abstract  getInstalledPackageNames ()

獲取設備上存在的應用程序包名稱。

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

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

獲取IP地址

public abstract String getIpAddress ()

獲取設備的 IP 地址。

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

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

獲取鍵盤鎖狀態

public abstract KeyguardControllerState getKeyguardState ()

返回一個對像以獲取鍵盤鎖的當前狀態,如果不支持則返回 null。

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

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

獲取主用戶Id

public abstract Integer getMainUserId ()

返回主用戶 ID。

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

投擲
com.android.tradefed.device.DeviceNotAvailableException
DeviceRuntimeException如果設備的輸出不符合預期。
DeviceNotAvailableException

獲取主線模塊信息

public abstract  getMainlineModuleInfo ()

獲取有關設備上安裝的主線模塊的信息。

退貨
當前安裝在設備上的ERROR(/String)主線模塊的ERROR(/Set)

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

getMaxNumberOfRunningUsersSupported

public abstract int getMaxNumberOfRunningUsersSupported ()

獲取支持的同時運行用戶的最大數量。默認為 0。

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

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

getMaxNumberOfUsersSupported

public abstract int getMaxNumberOfUsersSupported ()

獲取支持的最大用戶數。默認為 0。

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

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

獲取選項

public abstract TestDeviceOptions getOptions ()

獲取設備的測試選項。

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

獲取PrimaryUserId

public abstract Integer getPrimaryUserId ()

返回主用戶 ID。

退貨
Integer如果有主用戶,則為主用戶的 userId;如果沒有主用戶,則為 null。

投擲
com.android.tradefed.device.DeviceNotAvailableException
DeviceRuntimeException如果設備的輸出不符合預期。
DeviceNotAvailableException

截屏

public abstract InputStreamSource getScreenshot ()

從設備抓取屏幕截圖。

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

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

截屏

public abstract InputStreamSource getScreenshot (String format, 
                boolean rescale)

從設備抓取屏幕截圖。建議使用getScreenshot(String)而不是 JPEG 編碼以獲得更小的尺寸。

參數
format String :支持的 PNG、JPEG

rescale boolean :是否應重新縮放屏幕截圖以減小生成圖像的大小

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

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

截屏

public abstract InputStreamSource getScreenshot (String format)

從設備抓取屏幕截圖。建議使用 getScreenshot(format) 而不是 JPEG 編碼以獲得更小的尺寸

參數
format String :支持的 PNG、JPEG

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

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

截屏

public abstract InputStreamSource getScreenshot (long displayId)

從給定顯示 ID 的設備抓取屏幕截圖。格式為 PNG。

TODO:擴展上面的實現以支持'format'和'rescale'

參數
displayId long :要從中獲取屏幕截圖的屏幕的顯示 ID。

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

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

獲取設置

public abstract String getSetting (String namespace, 
                String key)

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

參數
namespace String

key String

退貨
String

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

獲取設置

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

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

參數
userId int

namespace String

key String

退貨
String與名稱空間關聯的值:用戶的鍵。如果找不到則為空。

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

getUninstallablePackageNames

public abstract  getUninstallablePackageNames ()

獲取可卸載的應用程序包名稱。這目前被定義為非系統包和更新的系統包。

退貨
當前安裝在設備上的可卸載ERROR(/String)包名稱的ERROR(/Set)

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

獲取用戶標誌

public abstract int getUserFlags (int userId)

查找並返回給定用戶的標誌。標誌在 Android 開源項目的“android.content.pm.UserInfo”類中定義。

參數
userId int

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

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

獲取用戶信息

public abstract  getUserInfos ()

獲取設備上useId到UserInfo的Map。如果設備的輸出不符合預期,將拋出DeviceRuntimeException

退貨
UserInfo 對象列表。

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

獲取用戶序列號

public abstract int getUserSerialNumber (int userId)

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

參數
userId int

退貨
int

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

有特徵

public abstract boolean hasFeature (String feature)

檢查某項功能是否在設備上可用。

參數
feature String : 哪種格式應該是 "feature: “ 或者 ” “ 直接地。

退貨
boolean如果找到特徵則為真,否則為假。

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

安裝包

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

在設備上安裝 Android 包。

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

reinstall boolean : true如果應該執行重新安裝

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

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

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

安裝包

public abstract 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帶有錯誤代碼的ERROR(/String) ,如果成功則為null

投擲
DeviceNotAvailableException如果與設備的連接丟失且無法恢復。
如果設備上的平台不支持運行時權限。

installPackageForUser

public abstract 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帶有錯誤代碼的ERROR(/String) ,如果成功則為null

投擲
DeviceNotAvailableException如果與設備的連接丟失且無法恢復。
如果設備上的平台不支持運行時權限。

installPackageForUser

public abstract 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帶有錯誤代碼的ERROR(/String) ,如果成功則為null

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

安裝包

public String installPackages ( packageFiles, 
                boolean reinstall, 
                String... extraArgs)

安裝由多個 APK 文件(一個主要和額外的拆分包)組成的 Android 應用程序。有關如何將 apk 拆分為多個文件的信息,請參閱“https://developer.android.com/studio/build/configure-apk-splits”。

參數
packageFiles : 本地apk文件

reinstall boolean : true如果應該執行重新安裝

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

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

投擲
DeviceNotAvailableException如果與設備的連接丟失且無法恢復。
如果設備上的平台不支持運行時權限。

安裝包

public String installPackages ( packageFiles, 
                boolean reinstall, 
                boolean grantPermissions, 
                String... extraArgs)

安裝一個由位於 Android 設備上的多個 APK 文件(一個主要的和額外的拆分包)組成的 Android 應用程序。有關如何將 apk 拆分為多個文件的信息,請參閱“https://developer.android.com/studio/build/configure-apk-splits”。

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

參數
packageFiles : 要安裝的遠程 apk 文件路徑

reinstall boolean : true如果應該執行重新安裝

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

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

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

投擲
DeviceNotAvailableException如果與設備的連接丟失且無法恢復。
如果設備上的平台不支持運行時權限。

installPackagesForUser

public String installPackagesForUser ( packageFiles, 
                boolean reinstall, 
                boolean grantPermissions, 
                int userId, 
                String... extraArgs)

為給定用戶安裝一個由多個 APK 文件(一個主要的和額外的拆分包)組成的 Android 應用程序。有關如何將 apk 拆分為多個文件的信息,請參閱“https://developer.android.com/studio/build/configure-apk-splits”。

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

參數
packageFiles : 本地apk文件

reinstall boolean : true如果應該執行重新安裝

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

userId int :要為其安裝的整數用戶 ID。

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

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

投擲
DeviceNotAvailableException如果與設備的連接丟失且無法恢復。
如果設備上的平台不支持運行時權限。

installPackagesForUser

public String installPackagesForUser ( packageFiles, 
                boolean reinstall, 
                int userId, 
                String... extraArgs)

為給定用戶安裝一個由多個 APK 文件(一個主要的和額外的拆分包)組成的 Android 應用程序。有關如何將 apk 拆分為多個文件的信息,請參閱“https://developer.android.com/studio/build/configure-apk-splits”。

參數
packageFiles : 本地apk文件

reinstall boolean : true如果應該執行重新安裝

userId int :要為其安裝的整數用戶 ID。

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

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

投擲
DeviceNotAvailableException如果與設備的連接丟失且無法恢復。
如果設備上的平台不支持運行時權限。

安裝遠程包

public String installRemotePackages ( remoteApkPaths, 
                boolean reinstall, 
                String... extraArgs)

安裝一個由位於 Android 設備上的多個 APK 文件(一個主要的和額外的拆分包)組成的 Android 應用程序。有關如何將 apk 拆分為多個文件的信息,請參閱“https://developer.android.com/studio/build/configure-apk-splits”。

參數
remoteApkPaths : 遠程apk文件路徑

reinstall boolean : true如果應該執行重新安裝

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

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

投擲
DeviceNotAvailableException如果與設備的連接丟失且無法恢復。
如果設備上的平台不支持運行時權限。

安裝遠程包

public String installRemotePackages ( remoteApkPaths, 
                boolean reinstall, 
                boolean grantPermissions, 
                String... extraArgs)

安裝一個由位於 Android 設備上的多個 APK 文件(一個主要的和額外的拆分包)組成的 Android 應用程序。有關如何將 apk 拆分為多個文件的信息,請參閱“https://developer.android.com/studio/build/configure-apk-splits”。

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

參數
remoteApkPaths : 遠程apk文件路徑

reinstall boolean : true如果應該執行重新安裝

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

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

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

投擲
DeviceNotAvailableException如果與設備的連接丟失且無法恢復。
如果設備上的平台不支持運行時權限。

isHeadlessSystemUserMode

public abstract boolean isHeadlessSystemUserMode ()

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

退貨
boolean

投擲
DeviceNotAvailableException

isMainUserPermanentAdmin

public abstract boolean isMainUserPermanentAdmin ()

返回主用戶是否是永久管理員並且不能被刪除或降級為非管理員狀態。

退貨
boolean

投擲
DeviceNotAvailableException

isMultiUserSupported

public abstract boolean isMultiUserSupported ()

確定是否支持多用戶。

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

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

isPackageInstalled

public abstract boolean isPackageInstalled (String packageName)

在設備上查詢給定的包名稱以檢查它當前是否已安裝。

參數
packageName String

退貨
boolean如果包被報告為已安裝則為真。否則為假。

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

isPackageInstalled

public abstract boolean isPackageInstalled (String packageName, 
                String userId)

查詢設備以獲取給定的包名稱和給定的用戶 ID,以檢查當前是否為該用戶安裝了它。

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

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

退貨
boolean如果包被報告為已安裝則為真。否則為假。

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

isUserRunning

public abstract boolean isUserRunning (int userId)

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

參數
userId int

退貨
boolean如果用戶正在運行則為真,其他情況下為假。

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

isUserSecondary

public abstract boolean isUserSecondary (int userId)

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

參數
userId int

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

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

用戶可見

public abstract boolean isUserVisible (int userId)

檢查給定用戶是否可見。

“可見”用戶是與“人類”用戶交互的用戶,因此能夠啟動啟動活動(通常在默認顯示中)。

參數
userId int

退貨
boolean

投擲
DeviceNotAvailableException

isUserVisibleOnDisplay

public abstract boolean isUserVisibleOnDisplay (int userId, 
                int displayId)

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

“可見”用戶是與“人類”用戶交互並因此能夠在該顯示中啟動啟動活動的用戶。

參數
userId int

displayId int

退貨
boolean

投擲
DeviceNotAvailableException

isVisibleBackgroundUsersOnDefaultDisplaySupported

public abstract boolean isVisibleBackgroundUsersOnDefaultDisplaySupported ()

ERROR(/java.android.view.Display#DEFAULT_DISPLAY)中返回設備是否允許用戶在後台可見。

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

退貨
boolean

投擲
DeviceNotAvailableException

isVisibleBackgroundUsersSupported

public abstract boolean isVisibleBackgroundUsersSupported ()

返回設備是否允許用戶在後台可見啟動。

如果是,您可以調用startVisibleBackgroundUser(int, int, boolean) ,傳遞由listDisplayIdsForStartingVisibleBackgroundUsers()返回的顯示。

退貨
boolean

投擲
DeviceNotAvailableException

啟用Wifi

public abstract boolean isWifiEnabled ()

測試wifi是否開啟。

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

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

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

listDisplayIds

public abstract  listDisplayIds ()

收集“dumpsys SurfaceFlinger”報告的設備上可用顯示 ID 的列表。

退貨
顯示列表。默認始終返回默認顯示 0。

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

listDisplayIdsForStartingVisibleBackgroundUsers

public abstract  listDisplayIdsForStartingVisibleBackgroundUsers ()

獲取可用於start a user visible in the background的顯示列表。

退貨

投擲
DeviceNotAvailableException

列出用戶

public abstract  listUsers ()

獲取設備上的用戶列表。如果設備的輸出不符合預期,將拋出DeviceRuntimeException

退貨
用戶 ID 列表。

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

日誌錯誤報告

public abstract boolean logBugreport (String dataName, 
                ITestLogger listener)

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

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

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

退貨
boolean如果記錄成功則為真,否則為假。

註冊設備動作接收器

public abstract void registerDeviceActionReceiver (IDeviceActionReceiver deviceActionReceiver)

為此設備註冊一個IDeviceActionReceiver

所有已註冊的IDeviceActionReceiver都會在設備操作開始之前和設備操作結束之後收到通知。

參數
deviceActionReceiver IDeviceActionReceiver :將註冊的IDeviceActionReceiver

刪除管理員

public abstract boolean removeAdmin (String componentName, 
                int userId)

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

參數
componentName String :要刪除的設備管理員。

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

退貨
boolean如果成功則為真,否則為假。

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

刪除所有者

public abstract void removeOwners ()

盡最大努力刪除所有現有的設備配置文件所有者。

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

刪除用戶

public abstract boolean removeUser (int userId)

從設備中刪除給定的用戶。

參數
userId int : 要刪除的用戶

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

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

設置設備所有者

public abstract boolean setDeviceOwner (String componentName, 
                int userId)

將設備管理組件設置為給定用戶的設備所有者。

參數
componentName String :設備管理員的設備所有者。

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

退貨
boolean如果成功則為真,否則為假。

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

設定設定

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

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

參數
namespace String

key String

value String

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

設定設定

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

將設置值添加到給定用戶的名稱空間。某些設置僅在重新啟動後可用。命名空間必須是以下之一:{"system", "secure", "global"}

參數
userId int

namespace String

key String

value String

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

啟動用戶

public abstract boolean startUser (int userId)

如果當前已停止,則在後台啟動給定用戶。如果用戶已經在後台運行,則此方法是 NOOP。

參數
userId int : 在後台啟動的用戶

退貨
boolean如果用戶在後台成功啟動,則為真。

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

啟動用戶

public abstract boolean startUser (int userId, 
                boolean waitFlag)

如果當前已停止,則在後台啟動給定用戶。如果用戶已經在後台運行,則此方法是 NOOP。可以提供額外的標誌以等待操作生效。

參數
userId int : 在後台啟動的用戶

waitFlag boolean :將使命令等待,直到用戶啟動並解鎖。

退貨
boolean如果用戶在後台成功啟動,則為真。

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

startVisibleBackgroundUser

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

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

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

參數
userId int : 在後台啟動的用戶

displayId int : 顯示開始用戶可見

waitFlag boolean :將使命令等待,直到用戶啟動並解鎖。

退貨
boolean如果用戶成功啟動並在後台可見, true

投擲
DeviceNotAvailableException

停止用戶

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

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

參數
userId int :要停止的用戶。

waitFlag boolean :將使命令等待,直到用戶停止。

forceFlag boolean :將強制停止用戶。

退貨
boolean如果用戶已成功停止,則為真。

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

停止用戶

public abstract boolean stopUser (int userId)

停止給定的用戶。如果用戶已經停止,則此方法是 NOOP。無法停止當前和系統用戶。

參數
userId int :要停止的用戶。

退貨
boolean如果用戶已成功停止,則為真。

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

切換用戶

public abstract boolean switchUser (int userId)

切換到另一個具有默認超時的 userId。 switchUser(int, long)

參數
userId int

退貨
boolean如果新的 userId 與 userId 提供程序匹配,則為真。否則為假。

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

切換用戶

public abstract boolean switchUser (int userId, 
                long timeout)

以提供的超時為截止日期切換到另一個 userId。用戶更改成功後嘗試禁用鍵盤鎖。

參數
userId int

timeout long :在為 switch-user 失敗返回 false 之前等待。

退貨
boolean如果新的 userId 與 userId 提供程序匹配,則為真。否則為假。

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

採取錯誤報告

public abstract Bugreport takeBugreport ()

獲取錯誤報告並將其返回到Bugreport對像中以進行處理。出現問題時返回 null。 Bugreport 對像中引用的文件需要通過Bugreport.close()清理。

退貨
Bugreport

卸載包

public abstract String uninstallPackage (String packageName)

從設備卸載 Android 包。

參數
packageName String : 要卸載的 Android 包

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

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

uninstallPackageForUser

public abstract String uninstallPackageForUser (String packageName, 
                int userId)

從給定用戶的設備中卸載 Android 包。

參數
packageName String : 要卸載的 Android 包

userId int :要為其卸載的整數用戶 ID。

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

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