測試裝置
public class TestDevice
extends NativeDevice
全端 Android 裝置的ITestDevice
實現
概括
公共方法 |
---|
boolean | clearErrorDialogs () |
int | createUser (String name) |
int | createUser (String name, boolean guest, boolean ephemeral) |
int | createUserNoThrow (String name) |
void | disableKeyguard () |
boolean | doesFileExist (String deviceFilePath) |
File | dumpHeap (String process, String devicePath) |
| getActiveApexes () |
| getAllSettings (String namespace) |
String | getAndroidId (int userId) |
| getAndroidIds () |
PackageInfo | getAppPackageInfo (String packageName) |
| getAppPackageInfos () |
DeviceFoldableState | getCurrentFoldableState () |
int | getCurrentUser () |
| getFoldableStates () |
| getInstalledPackageNames () |
KeyguardControllerState | getKeyguardState () |
| getMainlineModuleInfo () |
int | getMaxNumberOfRunningUsersSupported () |
int | getMaxNumberOfUsersSupported () |
Integer | getPrimaryUserId () |
InputStreamSource | getScreenshot () |
InputStreamSource | getScreenshot (String format, boolean rescale) |
InputStreamSource | getScreenshot (String format) |
InputStreamSource | getScreenshot (long displayId) |
String | getSetting (String namespace, String key) |
String | getSetting (int userId, String namespace, String key) |
| getUninstallablePackageNames () |
int | getUserFlags (int userId) |
| getUserInfos () |
int | getUserSerialNumber (int userId) |
boolean | hasFeature (String feature) |
String | installPackage (File packageFile, boolean reinstall, String... extraArgs) |
String | installPackage (File packageFile, File certFile, boolean reinstall, String... extraArgs) |
String | installPackage (File packageFile, boolean reinstall, boolean grantPermissions, String... extraArgs) |
String | installPackageForUser (File packageFile, boolean reinstall, boolean grantPermissions, int userId, String... extraArgs) |
String | installPackageForUser (File packageFile, boolean reinstall, int userId, String... extraArgs) |
String | installPackages ( packageFiles, boolean reinstall, String... extraArgs) installPackages ( packageFiles, boolean reinstall, String... extraArgs) |
String | installPackages ( packageFiles, boolean reinstall, boolean grantPermissions, String... extraArgs) installPackages ( packageFiles, boolean reinstall, boolean grantPermissions, String... extraArgs) |
String | installPackagesForUser ( packageFiles, boolean reinstall, boolean grantPermissions, int userId, String... extraArgs) installPackagesForUser ( packageFiles, boolean reinstall, boolean grantPermissions, int userId, String... extraArgs) |
String | installPackagesForUser ( packageFiles, boolean reinstall, int userId, String... extraArgs) installPackagesForUser ( packageFiles, boolean reinstall, int userId, String... extraArgs) |
String | installRemotePackages ( remoteApkPaths, boolean reinstall, boolean grantPermissions, String... extraArgs) installRemotePackages ( remoteApkPaths, boolean reinstall, boolean grantPermissions, String... extraArgs) |
String | installRemotePackages ( remoteApkPaths, boolean reinstall, String... extraArgs) installRemotePackages ( remoteApkPaths, boolean reinstall, String... extraArgs) |
boolean | isAppEnumerationSupported () |
boolean | isMultiUserSupported () |
boolean | isPackageInstalled (String packageName) |
boolean | isPackageInstalled (String packageName, String userId) |
boolean | isUserRunning (int userId) |
boolean | isUserSecondary (int userId) |
| listDisplayIds () |
| listUsers () |
void | postInvocationTearDown (Throwable exception) |
boolean | removeAdmin (String componentName, int userId) |
void | removeOwners () |
boolean | removeUser (int userId) |
boolean | setDeviceOwner (String componentName, int userId) |
void | setSetting (String namespace, String key, String value) |
void | setSetting (int userId, String namespace, String key, String value) |
boolean | startUser (int userId) |
boolean | startUser (int userId, boolean waitFlag) |
boolean | stopUser (int userId, boolean waitFlag, boolean forceFlag) |
boolean | stopUser (int userId) |
boolean | switchUser (int userId) |
boolean | switchUser (int userId, long timeout) |
String | uninstallPackage (String packageName) |
String | uninstallPackageForUser (String packageName, int userId) |
領域
DISMISS_KEYGUARD_CMD
public static final String DISMISS_KEYGUARD_CMD
可用於關閉鍵盤保護的命令。
公共構造函數
測試裝置
public TestDevice (IDevice device,
IDeviceStateMonitor stateMonitor,
IDeviceMonitor allocationMonitor)
公共方法
清除錯誤對話框
public boolean clearErrorDialogs ()
投擲 |
---|
DeviceNotAvailableException | |
創建用戶
public int createUser (String name)
投擲 |
---|
DeviceNotAvailableException | |
創建用戶
public int createUser (String name,
boolean guest,
boolean ephemeral)
參數 |
---|
name | String |
guest | boolean |
ephemeral | boolean |
投擲 |
---|
DeviceNotAvailableException | |
創建用戶不拋出
public int createUserNoThrow (String name)
投擲 |
---|
DeviceNotAvailableException | |
禁用鍵盤鎖
public void disableKeyguard ()
投擲 |
---|
DeviceNotAvailableException | |
文件是否存在
public boolean doesFileExist (String deviceFilePath)
投擲 |
---|
DeviceNotAvailableException | |
轉儲堆
public File dumpHeap (String process,
String devicePath)
參數 |
---|
process | String |
devicePath | String |
投擲 |
---|
DeviceNotAvailableException | |
取得活動頂點
public getActiveApexes ()
投擲 |
---|
DeviceNotAvailableException | |
取得所有設定
public getAllSettings (String namespace)
投擲 |
---|
DeviceNotAvailableException | |
取得AndroidId
public String getAndroidId (int userId)
投擲 |
---|
DeviceNotAvailableException | |
取得AndroidId
public getAndroidIds ()
投擲 |
---|
DeviceNotAvailableException | |
獲取應用程式包信息
public PackageInfo getAppPackageInfo (String packageName)
投擲 |
---|
DeviceNotAvailableException | |
獲取應用程式包信息
public getAppPackageInfos ()
投擲 |
---|
DeviceNotAvailableException | |
取得當前可折疊狀態
public DeviceFoldableState getCurrentFoldableState ()
投擲 |
---|
DeviceNotAvailableException | |
取得目前用戶
public int getCurrentUser ()
投擲 |
---|
DeviceNotAvailableException | |
取得可折疊狀態
public getFoldableStates ()
投擲 |
---|
DeviceNotAvailableException | |
取得安裝包名稱
public getInstalledPackageNames ()
投擲 |
---|
DeviceNotAvailableException | |
取得KeyguardState
public KeyguardControllerState getKeyguardState ()
退貨 |
---|
KeyguardControllerState | |
投擲 |
---|
DeviceNotAvailableException | |
獲取主線模組信息
public getMainlineModuleInfo ()
投擲 |
---|
DeviceNotAvailableException | |
public int getMaxNumberOfRunningUsersSupported ()
投擲 |
---|
DeviceNotAvailableException | |
public int getMaxNumberOfUsersSupported ()
投擲 |
---|
DeviceNotAvailableException | |
取得主用戶ID
public Integer getPrimaryUserId ()
投擲 |
---|
DeviceNotAvailableException | |
取得螢幕截圖
public InputStreamSource getScreenshot ()
投擲 |
---|
DeviceNotAvailableException | |
取得螢幕截圖
public InputStreamSource getScreenshot (String format,
boolean rescale)
參數 |
---|
format | String |
rescale | boolean |
投擲 |
---|
DeviceNotAvailableException | |
取得螢幕截圖
public InputStreamSource getScreenshot (String format)
投擲 |
---|
DeviceNotAvailableException | |
取得螢幕截圖
public InputStreamSource getScreenshot (long displayId)
投擲 |
---|
DeviceNotAvailableException | |
取得設定
public String getSetting (String namespace,
String key)
參數 |
---|
namespace | String |
key | String |
投擲 |
---|
DeviceNotAvailableException | |
取得設定
public String getSetting (int userId,
String namespace,
String key)
參數 |
---|
userId | int |
namespace | String |
key | String |
投擲 |
---|
DeviceNotAvailableException | |
取得UninstallablePackageNames
public getUninstallablePackageNames ()
投擲 |
---|
DeviceNotAvailableException | |
取得用戶標誌
public int getUserFlags (int userId)
投擲 |
---|
DeviceNotAvailableException | |
獲取用戶資訊
public getUserInfos ()
投擲 |
---|
DeviceNotAvailableException | |
取得用戶序號
public int getUserSerialNumber (int userId)
投擲 |
---|
DeviceNotAvailableException | |
有特徵
public boolean hasFeature (String feature)
投擲 |
---|
DeviceNotAvailableException | |
安裝包
public String installPackage (File packageFile,
boolean reinstall,
String... extraArgs)
參數 |
---|
packageFile | File |
reinstall | boolean |
extraArgs | String |
投擲 |
---|
DeviceNotAvailableException | |
安裝包
public String installPackage (File packageFile,
File certFile,
boolean reinstall,
String... extraArgs)
參數 |
---|
packageFile | File |
certFile | File |
reinstall | boolean |
extraArgs | String |
投擲 |
---|
DeviceNotAvailableException | |
安裝包
public String installPackage (File packageFile,
boolean reinstall,
boolean grantPermissions,
String... extraArgs)
參數 |
---|
packageFile | File |
reinstall | boolean |
grantPermissions | boolean |
extraArgs | String |
投擲 |
---|
DeviceNotAvailableException | |
為用戶安裝套件
public String installPackageForUser (File packageFile,
boolean reinstall,
boolean grantPermissions,
int userId,
String... extraArgs)
參數 |
---|
packageFile | File |
reinstall | boolean |
grantPermissions | boolean |
userId | int |
extraArgs | String |
投擲 |
---|
DeviceNotAvailableException | |
為用戶安裝套件
public String installPackageForUser (File packageFile,
boolean reinstall,
int userId,
String... extraArgs)
參數 |
---|
packageFile | File |
reinstall | boolean |
userId | int |
extraArgs | String |
投擲 |
---|
DeviceNotAvailableException | |
安裝包
public String installPackages ( packageFiles,
boolean reinstall,
String... extraArgs)
參數 |
---|
packageFiles | |
reinstall | boolean |
extraArgs | String |
投擲 |
---|
DeviceNotAvailableException | |
安裝包
public String installPackages ( packageFiles,
boolean reinstall,
boolean grantPermissions,
String... extraArgs)
參數 |
---|
packageFiles | |
reinstall | boolean |
grantPermissions | boolean |
extraArgs | String |
投擲 |
---|
DeviceNotAvailableException | |
為用戶安裝套件
public String installPackagesForUser ( packageFiles,
boolean reinstall,
boolean grantPermissions,
int userId,
String... extraArgs)
參數 |
---|
packageFiles | |
reinstall | boolean |
grantPermissions | boolean |
userId | int |
extraArgs | String |
投擲 |
---|
DeviceNotAvailableException | |
為用戶安裝套件
public String installPackagesForUser ( packageFiles,
boolean reinstall,
int userId,
String... extraArgs)
參數 |
---|
packageFiles | |
reinstall | boolean |
userId | int |
extraArgs | String |
投擲 |
---|
DeviceNotAvailableException | |
安裝遠端包
public String installRemotePackages ( remoteApkPaths,
boolean reinstall,
boolean grantPermissions,
String... extraArgs)
參數 |
---|
remoteApkPaths | |
reinstall | boolean |
grantPermissions | boolean |
extraArgs | String |
投擲 |
---|
DeviceNotAvailableException | |
安裝遠端包
public String installRemotePackages ( remoteApkPaths,
boolean reinstall,
String... extraArgs)
參數 |
---|
remoteApkPaths | |
reinstall | boolean |
extraArgs | String |
投擲 |
---|
DeviceNotAvailableException | |
isAppEnumerationSupported 是否支持
public boolean isAppEnumerationSupported ()
投擲 |
---|
DeviceNotAvailableException | |
是否支援多用戶
public boolean isMultiUserSupported ()
投擲 |
---|
DeviceNotAvailableException | |
軟體包已安裝
public boolean isPackageInstalled (String packageName)
投擲 |
---|
DeviceNotAvailableException | |
軟體包已安裝
public boolean isPackageInstalled (String packageName,
String userId)
參數 |
---|
packageName | String |
userId | String |
投擲 |
---|
DeviceNotAvailableException | |
正在運行
public boolean isUserRunning (int userId)
投擲 |
---|
DeviceNotAvailableException | |
是用戶次要的
public boolean isUserSecondary (int userId)
投擲 |
---|
DeviceNotAvailableException | |
清單顯示 ID
public listDisplayIds ()
投擲 |
---|
DeviceNotAvailableException | |
列出用戶
public listUsers ()
投擲 |
---|
DeviceNotAvailableException | |
調用後拆卸
public void postInvocationTearDown (Throwable exception)
刪除管理員
public boolean removeAdmin (String componentName,
int userId)
參數 |
---|
componentName | String |
userId | int |
投擲 |
---|
DeviceNotAvailableException | |
刪除所有者
public void removeOwners ()
投擲 |
---|
DeviceNotAvailableException | |
刪除用戶
public boolean removeUser (int userId)
投擲 |
---|
DeviceNotAvailableException | |
設定設備所有者
public boolean setDeviceOwner (String componentName,
int userId)
參數 |
---|
componentName | String |
userId | int |
投擲 |
---|
DeviceNotAvailableException | |
設定設定
public void setSetting (String namespace,
String key,
String value)
參數 |
---|
namespace | String |
key | String |
value | String |
投擲 |
---|
DeviceNotAvailableException | |
設定設定
public void setSetting (int userId,
String namespace,
String key,
String value)
參數 |
---|
userId | int |
namespace | String |
key | String |
value | String |
投擲 |
---|
DeviceNotAvailableException | |
啟動使用者
public boolean startUser (int userId)
投擲 |
---|
DeviceNotAvailableException | |
啟動使用者
public boolean startUser (int userId,
boolean waitFlag)
參數 |
---|
userId | int |
waitFlag | boolean |
投擲 |
---|
DeviceNotAvailableException | |
停止用戶
public boolean stopUser (int userId,
boolean waitFlag,
boolean forceFlag)
參數 |
---|
userId | int |
waitFlag | boolean |
forceFlag | boolean |
投擲 |
---|
DeviceNotAvailableException | |
停止用戶
public boolean stopUser (int userId)
投擲 |
---|
DeviceNotAvailableException | |
切換用戶
public boolean switchUser (int userId)
投擲 |
---|
DeviceNotAvailableException | |
切換用戶
public boolean switchUser (int userId,
long timeout)
參數 |
---|
userId | int |
timeout | long |
投擲 |
---|
DeviceNotAvailableException | |
解除安裝包
public String uninstallPackage (String packageName)
投擲 |
---|
DeviceNotAvailableException | |
解除安裝用戶包
public String uninstallPackageForUser (String packageName,
int userId)
參數 |
---|
packageName | String |
userId | int |
投擲 |
---|
DeviceNotAvailableException | |
受保護的方法
執行AdbReboot
protected void doAdbReboot (NativeDevice.RebootMode rebootMode,
String reason)
執行 adb 重啟。
參數 |
---|
rebootMode | NativeDevice.RebootMode :重啟的一種模式。 |
reason | String :用於此次重新啟動。 |
投擲 |
---|
DeviceNotAvailableException | |
取得檢查新用戶睡眠
protected long getCheckNewUserSleep ()
暴露進行測試。
取得主機目前時間
protected long getHostCurrentTime ()
暴露測試
啟動後設定前
protected void prePostBootSetup ()
允許每種裝置類型(AndroidNativeDevice、TestDevice)覆寫此方法以進行特定的啟動後設定。
投擲 |
---|
DeviceNotAvailableException | |