測試設備

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

從設備檢索錯誤報告。

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)

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

abstract boolean switchUser (int userId, long timeout)

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

abstract Bugreport takeBugreport ()

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

abstract String uninstallPackage (String packageName)

從裝置卸載 Android 軟體包。

abstract String uninstallPackageForUser (String packageName, int userId)

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

公共方法

可以切換到Headless系統用戶

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

如果需要連接到 Wifi 網路

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

如果需要連接到 Wifi 網路

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

創建用戶不拋出

public abstract int createUserNoThrow (String name)

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

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

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

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

註銷設備操作接收器

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

取得AndroidId

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

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

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

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

取得錯誤報告

public abstract InputStreamSource getBugreport ()

從設備檢索錯誤報告。

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

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

取得錯誤報告

public abstract InputStreamSource getBugreportz ()

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

僅支援“adb 版本”> 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

取得安裝包名稱

public abstract  getInstalledPackageNames ()

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

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

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

取得IP位址

public abstract String getIpAddress ()

取得設備的IP位址。

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

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

取得KeyguardState

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

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

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

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

getMaxNumberOfRunningUsersSupported

public abstract int getMaxNumberOfRunningUsersSupported ()

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

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

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

取得支援的最大用戶數

public abstract int getMaxNumberOfUsersSupported ()

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

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

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

取得選項

public abstract TestDeviceOptions getOptions ()

取得設備的測試選項。

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

取得主用戶ID

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:擴展上述實作以支援“格式”和“重新縮放”

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

取得UninstallablePackageNames

public abstract  getUninstallablePackageNames ()

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

退貨
裝置上目前安裝的可卸載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如果找到功能則為 true,否則為 false。

投擲
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帶有錯誤代碼的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帶有錯誤代碼的String ,如果成功則為null

投擲
DeviceNotAvailableException如果與設備的連線遺失且無法恢復。
UnsupportedOperationException如果設備上的平台不支援運行時權限。

為用戶安裝套件

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

投擲
DeviceNotAvailableException如果與設備的連線遺失且無法恢復。
UnsupportedOperationException如果設備上的平台不支援運行時權限。

為用戶安裝套件

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

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

安裝包

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

安裝由多個 APK 檔案(一個主包和額外的拆分包)組成的 Android 應用程式。請參閱「https://developer.android.com/studio/build/configure-apk-splits」以了解如何將 apk 拆分為多個檔案。

參數
packageFiles :本地apk文件

reinstall boolean : true如果要重新安裝

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

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

投擲
DeviceNotAvailableException如果與設備的連線遺失且無法恢復。
UnsupportedOperationException如果設備上的平台不支援運行時權限。

安裝包

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

安裝由 Android 裝置上的多個 APK 檔案(一個主包和額外的拆分包)組成的 Android 應用程式。請參閱「https://developer.android.com/studio/build/configure-apk-splits」以了解如何將 apk 拆分為多個檔案。

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

參數
packageFiles :要安裝的遠端apk檔案路徑

reinstall boolean : true如果要重新安裝

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

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

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

投擲
DeviceNotAvailableException如果與設備的連線遺失且無法恢復。
UnsupportedOperationException如果設備上的平台不支援運行時權限。

為用戶安裝套件

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

為給定用戶安裝由多個 APK 檔案(一個主套件和額外的拆分包)組成的 Android 應用程式。請參閱「https://developer.android.com/studio/build/configure-apk-splits」以了解如何將 apk 拆分為多個檔案。

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

參數
packageFiles :本地apk文件

reinstall boolean : true如果要重新安裝

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

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

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

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

投擲
DeviceNotAvailableException如果與設備的連線遺失且無法恢復。
UnsupportedOperationException如果設備上的平台不支援運行時權限。

為用戶安裝套件

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

為給定用戶安裝由多個 APK 檔案(一個主套件和額外的拆分包)組成的 Android 應用程式。請參閱「https://developer.android.com/studio/build/configure-apk-splits」以了解如何將 apk 拆分為多個檔案。

參數
packageFiles :本地apk文件

reinstall boolean : true如果要重新安裝

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

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

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

投擲
DeviceNotAvailableException如果與設備的連線遺失且無法恢復。
UnsupportedOperationException如果設備上的平台不支援運行時權限。

安裝遠端包

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

安裝由 Android 裝置上的多個 APK 檔案(一個主包和額外的拆分包)組成的 Android 應用程式。請參閱「https://developer.android.com/studio/build/configure-apk-splits」以了解如何將 apk 拆分為多個檔案。

參數
remoteApkPaths :遠端apk檔案路徑

reinstall boolean : true如果要重新安裝

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

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

投擲
DeviceNotAvailableException如果與設備的連線遺失且無法恢復。
UnsupportedOperationException如果設備上的平台不支援運行時權限。

安裝遠端包

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

安裝由 Android 裝置上的多個 APK 檔案(一個主包和額外的拆分包)組成的 Android 應用程式。請參閱「https://developer.android.com/studio/build/configure-apk-splits」以了解如何將 apk 拆分為多個檔案。

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

參數
remoteApkPaths :遠端apk檔案路徑

reinstall boolean : true如果要重新安裝

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

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

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

投擲
DeviceNotAvailableException如果與設備的連線遺失且無法恢復。
UnsupportedOperationException如果設備上的平台不支援運行時權限。

isHeadlessSystemUserMode

public abstract boolean isHeadlessSystemUserMode ()

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

退貨
boolean

投擲
DeviceNotAvailableException

是主用戶永久管理員

public abstract boolean isMainUserPermanentAdmin ()

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

退貨
boolean

投擲
DeviceNotAvailableException

是否支援多用戶

public abstract boolean isMultiUserSupported ()

確定是否支援多用戶。

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

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

軟體包已安裝

public abstract boolean isPackageInstalled (String packageName)

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

參數
packageName String

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

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

軟體包已安裝

public abstract boolean isPackageInstalled (String packageName, 
                String userId)

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

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

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

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

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

正在運行

public abstract boolean isUserRunning (int userId)

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

參數
userId int

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

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

是用戶次要的

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

清單顯示 ID

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如果記錄成功則為 true,否則為 false。

註冊設備動作接收器

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如果成功則為 true,否則為 false。

投擲
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如果成功則為 true,否則為 false。

投擲
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如果使用者在背景成功啟動,則為 true。

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

啟動使用者

public abstract boolean startUser (int userId, 
                boolean waitFlag)

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

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

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

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

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

啟動可見背景用戶

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如果使用者已成功停止,則為 true。

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

停止用戶

public abstract boolean stopUser (int userId)

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

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

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

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

切換用戶

public abstract boolean switchUser (int userId)

切換到另一個具有預設逾時的使用者 ID。 switchUser(int, long)

參數
userId int

退貨
boolean如果新的 userId 與 userId 提供者匹配,則為 true。否則為假。

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

切換用戶

public abstract boolean switchUser (int userId, 
                long timeout)

切換到另一個使用者 ID,並以提供的逾時為截止時間。用戶更改成功後嘗試停用鍵盤保護。

參數
userId int

timeout long :在切換用戶失敗返回 false 之前等待。

退貨
boolean如果新的 userId 與 userId 提供者匹配,則為 true。否則為假。

投擲
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帶有錯誤代碼的String ,如果成功則為null

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

解除安裝用戶包

public abstract String uninstallPackageForUser (String packageName, 
                int userId)

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

參數
packageName String : 要卸載的 Android 套件

userId int :要卸載的整數使用者 ID。

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

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