测试装置
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 | |