Google 致力于为黑人社区推动种族平等。查看具体举措

测试设备

public class TestDevice
extends NativeDevice

对象
com.android.tradefed.device.NativeDevice
com.android.tradefed.device.TestDevice


一个实施ITestDevice一个全栈的Android设备

概括

字段

public static final String DISMISS_KEYGUARD_CMD

可用于关闭键盘锁的命令。

公共构造函数

TestDevice (IDevice device, IDeviceStateMonitor stateMonitor, IDeviceMonitor allocationMonitor)

公共方法

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)

受保护的方法

void doAdbReboot ( NativeDevice.RebootMode rebootMode, String reason)

执行 adb 重启。

long getCheckNewUserSleep ()

暴露用于测试。

long getHostCurrentTime ()

暴露用于测试

void prePostBootSetup ()

允许每种设备类型(AndroidNativeDevice、TestDevice)为特定的启动后设置覆盖此方法。

字段

DISMISS_KEYGUARD_CMD

public static final String DISMISS_KEYGUARD_CMD

可用于关闭键盘锁的命令。

公共构造函数

测试设备

public TestDevice (IDevice device, 
                IDeviceStateMonitor stateMonitor, 
                IDeviceMonitor allocationMonitor)

公共方法

清除错误对话框

public boolean clearErrorDialogs ()

退货
boolean

投掷
DeviceNotAvailableException

创建用户

public int createUser (String name)

参数
name String

退货
int

投掷
DeviceNotAvailableException

创建用户

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

参数
name String

guest boolean

ephemeral boolean

退货
int

投掷
DeviceNotAvailableException

createUserNoThrow

public int createUserNoThrow (String name)

参数
name String

退货
int

投掷
DeviceNotAvailableException

禁用键盘保护

public void disableKeyguard ()

投掷
DeviceNotAvailableException

文件是否存在

public boolean doesFileExist (String deviceFilePath)

参数
deviceFilePath String

退货
boolean

投掷
DeviceNotAvailableException

转储堆

public File dumpHeap (String process, 
                String devicePath)

参数
process String

devicePath String

退货
File

投掷
DeviceNotAvailableException

获取活动顶点

public  getActiveApexes ()

退货

投掷
DeviceNotAvailableException

获取所有设置

public  getAllSettings (String namespace)

参数
namespace String

退货

投掷
DeviceNotAvailableException

获取AndroidId

public String getAndroidId (int userId)

参数
userId int

退货
String

投掷
DeviceNotAvailableException

获取AndroidIds

public  getAndroidIds ()

退货

投掷
DeviceNotAvailableException

获取应用程序包信息

public PackageInfo getAppPackageInfo (String packageName)

参数
packageName String

退货
PackageInfo

投掷
DeviceNotAvailableException

获取应用程序包信息

public  getAppPackageInfos ()

退货

投掷
DeviceNotAvailableException

获取当前折叠状态

public DeviceFoldableState getCurrentFoldableState ()

退货
DeviceFoldableState

投掷
DeviceNotAvailableException

获取当前用户

public int getCurrentUser ()

退货
int

投掷
DeviceNotAvailableException

获取可折叠状态

public  getFoldableStates ()

退货

投掷
DeviceNotAvailableException

getInstalledPackageNames

public  getInstalledPackageNames ()

退货

投掷
DeviceNotAvailableException

获取密钥保护状态

public KeyguardControllerState getKeyguardState ()

退货
KeyguardControllerState

投掷
DeviceNotAvailableException

获取主线模块信息

public  getMainlineModuleInfo ()

退货

投掷
DeviceNotAvailableException

getMaxNumberOfRunningUsersSupported

public int getMaxNumberOfRunningUsersSupported ()

退货
int

投掷
DeviceNotAvailableException

getMaxNumberOfUsersSupported

public int getMaxNumberOfUsersSupported ()

退货
int

投掷
DeviceNotAvailableException

获取主要用户 ID

public Integer getPrimaryUserId ()

退货
Integer

投掷
DeviceNotAvailableException

获取截图

public InputStreamSource getScreenshot ()

退货
InputStreamSource

投掷
DeviceNotAvailableException

获取截图

public InputStreamSource getScreenshot (String format, 
                boolean rescale)

参数
format String

rescale boolean

退货
InputStreamSource

投掷
DeviceNotAvailableException

获取截图

public InputStreamSource getScreenshot (String format)

参数
format String

退货
InputStreamSource

投掷
DeviceNotAvailableException

获取截图

public InputStreamSource getScreenshot (long displayId)

参数
displayId long

退货
InputStreamSource

投掷
DeviceNotAvailableException

获取设置

public String getSetting (String namespace, 
                String key)

参数
namespace String

key String

退货
String

投掷
DeviceNotAvailableException

获取设置

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

参数
userId int

namespace String

key String

退货
String

投掷
DeviceNotAvailableException

getUninstallablePackageNames

public  getUninstallablePackageNames ()

退货

投掷
DeviceNotAvailableException

获取用户标志

public int getUserFlags (int userId)

参数
userId int

退货
int

投掷
DeviceNotAvailableException

获取用户信息

public  getUserInfos ()

退货

投掷
DeviceNotAvailableException

获取用户序列号

public int getUserSerialNumber (int userId)

参数
userId int

退货
int

投掷
DeviceNotAvailableException

有特征

public boolean hasFeature (String feature)

参数
feature String

退货
boolean

投掷
DeviceNotAvailableException

安装包

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

参数
packageFile File

reinstall boolean

extraArgs String

退货
String

投掷
DeviceNotAvailableException

安装包

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

参数
packageFile File

certFile File

reinstall boolean

extraArgs String

退货
String

投掷
DeviceNotAvailableException

安装包

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

参数
packageFile File

reinstall boolean

grantPermissions boolean

extraArgs String

退货
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

退货
String

投掷
DeviceNotAvailableException

用户安装包

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

参数
packageFile File

reinstall boolean

userId int

extraArgs String

退货
String

投掷
DeviceNotAvailableException

安装包

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

参数
packageFiles

reinstall boolean

extraArgs String

退货
String

投掷
DeviceNotAvailableException

安装包

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

参数
packageFiles

reinstall boolean

grantPermissions boolean

extraArgs String

退货
String

投掷
DeviceNotAvailableException

为用户安装软件包

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

参数
packageFiles

reinstall boolean

grantPermissions boolean

userId int

extraArgs String

退货
String

投掷
DeviceNotAvailableException

为用户安装软件包

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

参数
packageFiles

reinstall boolean

userId int

extraArgs String

退货
String

投掷
DeviceNotAvailableException

安装远程包

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

参数
remoteApkPaths

reinstall boolean

grantPermissions boolean

extraArgs String

退货
String

投掷
DeviceNotAvailableException

安装远程包

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

参数
remoteApkPaths

reinstall boolean

extraArgs String

退货
String

投掷
DeviceNotAvailableException

isAppEnumerationSupported

public boolean isAppEnumerationSupported ()

退货
boolean

投掷
DeviceNotAvailableException

isMultiUserSupported

public boolean isMultiUserSupported ()

退货
boolean

投掷
DeviceNotAvailableException

isPackageInstalled

public boolean isPackageInstalled (String packageName)

参数
packageName String

退货
boolean

投掷
DeviceNotAvailableException

isPackageInstalled

public boolean isPackageInstalled (String packageName, 
                String userId)

参数
packageName String

userId String

退货
boolean

投掷
DeviceNotAvailableException

正在运行

public boolean isUserRunning (int userId)

参数
userId int

退货
boolean

投掷
DeviceNotAvailableException

isUserSecondary

public boolean isUserSecondary (int userId)

参数
userId int

退货
boolean

投掷
DeviceNotAvailableException

列表显示 ID

public  listDisplayIds ()

退货

投掷
DeviceNotAvailableException

列出用户

public  listUsers ()

退货

投掷
DeviceNotAvailableException

调用后拆解

public void postInvocationTearDown (Throwable exception)

参数
exception Throwable

删除管理员

public boolean removeAdmin (String componentName, 
                int userId)

参数
componentName String

userId int

退货
boolean

投掷
DeviceNotAvailableException

删除所有者

public void removeOwners ()

投掷
DeviceNotAvailableException

删除用户

public boolean removeUser (int userId)

参数
userId int

退货
boolean

投掷
DeviceNotAvailableException

设置设备所有者

public boolean setDeviceOwner (String componentName, 
                int userId)

参数
componentName String

userId int

退货
boolean

投掷
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)

参数
userId int

退货
boolean

投掷
DeviceNotAvailableException

开始用户

public boolean startUser (int userId, 
                boolean waitFlag)

参数
userId int

waitFlag boolean

退货
boolean

投掷
DeviceNotAvailableException

停止用户

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

参数
userId int

waitFlag boolean

forceFlag boolean

退货
boolean

投掷
DeviceNotAvailableException

停止用户

public boolean stopUser (int userId)

参数
userId int

退货
boolean

投掷
DeviceNotAvailableException

切换用户

public boolean switchUser (int userId)

参数
userId int

退货
boolean

投掷
DeviceNotAvailableException

切换用户

public boolean switchUser (int userId, 
                long timeout)

参数
userId int

timeout long

退货
boolean

投掷
DeviceNotAvailableException

卸载包

public String uninstallPackage (String packageName)

参数
packageName String

退货
String

投掷
DeviceNotAvailableException

卸载用户包

public String uninstallPackageForUser (String packageName, 
                int userId)

参数
packageName String

userId int

退货
String

投掷
DeviceNotAvailableException

受保护的方法

doAdb重启

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

执行 adb 重启。

参数
rebootMode NativeDevice.RebootMode :这个重启的模式。

reason String :此重新启动。

投掷
DeviceNotAvailableException

getCheckNewUserSleep

protected long getCheckNewUserSleep ()

暴露用于测试。

退货
long

获取主机当前时间

protected long getHostCurrentTime ()

暴露用于测试

退货
long

预启动设置

protected void prePostBootSetup ()

允许每种设备类型(AndroidNativeDevice、TestDevice)为特定的启动后设置覆盖此方法。

投掷
DeviceNotAvailableException