TestDevice

public class TestDevice
extends NativeDevice

java.lang.Object
   ↳ com.android.tradefed.device.NativeDevice
     ↳ com.android.tradefed.device.TestDevice


为完整堆栈 Android 设备实现 ITestDevice

摘要

字段

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)

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

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

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

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

String 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

可用于关闭屏幕锁定的命令。

公共构造函数

TestDevice

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

公共方法

clearErrorDialogs

public boolean clearErrorDialogs ()

返回
boolean

抛出
DeviceNotAvailableException

createUser

public int createUser (String name)

参数
name String

返回
int

抛出
DeviceNotAvailableException

createUser

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

disableKeyguard

public void disableKeyguard ()

抛出
DeviceNotAvailableException

doesFileExist

public boolean doesFileExist (String deviceFilePath)

参数
deviceFilePath String

返回
boolean

抛出
DeviceNotAvailableException

dumpHeap

public File dumpHeap (String process, 
                String devicePath)

参数
process String

devicePath String

返回
File

抛出
DeviceNotAvailableException

getActiveApexes

public  getActiveApexes ()

返回

抛出
DeviceNotAvailableException

getAllSettings

public  getAllSettings (String namespace)

参数
namespace String

返回

抛出
DeviceNotAvailableException

getAndroidId

public String getAndroidId (int userId)

参数
userId int

返回
String

抛出
DeviceNotAvailableException

getAndroidIds

public  getAndroidIds ()

返回

抛出
DeviceNotAvailableException

getAppPackageInfo

public PackageInfo getAppPackageInfo (String packageName)

参数
packageName String

返回
PackageInfo

抛出
DeviceNotAvailableException

getAppPackageInfos

public  getAppPackageInfos ()

返回

抛出
DeviceNotAvailableException

getCurrentFoldableState

public DeviceFoldableState getCurrentFoldableState ()

返回
DeviceFoldableState

抛出
DeviceNotAvailableException

getCurrentUser

public int getCurrentUser ()

返回
int

抛出
DeviceNotAvailableException

getFoldableStates

public  getFoldableStates ()

返回

抛出
DeviceNotAvailableException

getInstalledPackageNames

public  getInstalledPackageNames ()

返回

抛出
DeviceNotAvailableException

getKeyguardState

public KeyguardControllerState getKeyguardState ()

返回
KeyguardControllerState

抛出
DeviceNotAvailableException

getMainlineModuleInfo

public  getMainlineModuleInfo ()

返回

抛出
DeviceNotAvailableException

getMaxNumberOfRunningUsersSupported

public int getMaxNumberOfRunningUsersSupported ()

返回
int

抛出
DeviceNotAvailableException

getMaxNumberOfUsersSupported

public int getMaxNumberOfUsersSupported ()

返回
int

抛出
DeviceNotAvailableException

getPrimaryUserId

public Integer getPrimaryUserId ()

返回
Integer

抛出
DeviceNotAvailableException

getScreenshot

public InputStreamSource getScreenshot ()

返回
InputStreamSource

抛出
DeviceNotAvailableException

getScreenshot

public InputStreamSource getScreenshot (String format, 
                boolean rescale)

参数
format String

rescale boolean

返回
InputStreamSource

抛出
DeviceNotAvailableException

getScreenshot

public InputStreamSource getScreenshot (String format)

参数
format String

返回
InputStreamSource

抛出
DeviceNotAvailableException

getScreenshot

public InputStreamSource getScreenshot (long displayId)

参数
displayId long

返回
InputStreamSource

抛出
DeviceNotAvailableException

getSetting

public String getSetting (String namespace, 
                String key)

参数
namespace String

key String

返回
String

抛出
DeviceNotAvailableException

getSetting

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

参数
userId int

namespace String

key String

返回
String

抛出
DeviceNotAvailableException

getUninstallablePackageNames

public  getUninstallablePackageNames ()

返回

抛出
DeviceNotAvailableException

getUserFlags

public int getUserFlags (int userId)

参数
userId int

返回
int

抛出
DeviceNotAvailableException

getUserInfos

public  getUserInfos ()

返回

抛出
DeviceNotAvailableException

getUserSerialNumber

public int getUserSerialNumber (int userId)

参数
userId int

返回
int

抛出
DeviceNotAvailableException

hasFeature

public boolean hasFeature (String feature)

参数
feature String

返回
boolean

抛出
DeviceNotAvailableException

installPackage

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

参数
packageFile File

reinstall boolean

extraArgs String

返回
String

抛出
DeviceNotAvailableException

installPackage

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

参数
packageFile File

certFile File

reinstall boolean

extraArgs String

返回
String

抛出
DeviceNotAvailableException

installPackage

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

参数
packageFile File

reinstall boolean

grantPermissions boolean

extraArgs String

返回
String

抛出
DeviceNotAvailableException

installPackageForUser

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

installPackageForUser

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

参数
packageFile File

reinstall boolean

userId int

extraArgs String

返回
String

抛出
DeviceNotAvailableException

installPackages

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

参数
packageFiles

reinstall boolean

extraArgs String

返回
String

抛出
DeviceNotAvailableException

installPackages

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

参数
packageFiles

reinstall boolean

grantPermissions boolean

extraArgs String

返回
String

抛出
DeviceNotAvailableException

installPackagesForUser

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

参数
packageFiles

reinstall boolean

grantPermissions boolean

userId int

extraArgs String

返回
String

抛出
DeviceNotAvailableException

installPackagesForUser

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

参数
packageFiles

reinstall boolean

userId int

extraArgs String

返回
String

抛出
DeviceNotAvailableException

installRemotePackages

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

参数
remoteApkPaths

reinstall boolean

grantPermissions boolean

extraArgs String

返回
String

抛出
DeviceNotAvailableException

installRemotePackages

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

isUserRunning

public boolean isUserRunning (int userId)

参数
userId int

返回
boolean

抛出
DeviceNotAvailableException

isUserSecondary

public boolean isUserSecondary (int userId)

参数
userId int

返回
boolean

抛出
DeviceNotAvailableException

listDisplayIds

public  listDisplayIds ()

返回

抛出
DeviceNotAvailableException

listUsers

public  listUsers ()

返回

抛出
DeviceNotAvailableException

postInvocationTearDown

public void postInvocationTearDown (Throwable exception)

参数
exception Throwable

removeAdmin

public boolean removeAdmin (String componentName, 
                int userId)

参数
componentName String

userId int

返回
boolean

抛出
DeviceNotAvailableException

removeOwners

public void removeOwners ()

抛出
DeviceNotAvailableException

removeUser

public boolean removeUser (int userId)

参数
userId int

返回
boolean

抛出
DeviceNotAvailableException

setDeviceOwner

public boolean setDeviceOwner (String componentName, 
                int userId)

参数
componentName String

userId int

返回
boolean

抛出
DeviceNotAvailableException

setSetting

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

参数
namespace String

key String

value String

抛出
DeviceNotAvailableException

setSetting

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

参数
userId int

namespace String

key String

value String

抛出
DeviceNotAvailableException

startUser

public boolean startUser (int userId)

参数
userId int

返回
boolean

抛出
DeviceNotAvailableException

startUser

public boolean startUser (int userId, 
                boolean waitFlag)

参数
userId int

waitFlag boolean

返回
boolean

抛出
DeviceNotAvailableException

stopUser

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

参数
userId int

waitFlag boolean

forceFlag boolean

返回
boolean

抛出
DeviceNotAvailableException

stopUser

public boolean stopUser (int userId)

参数
userId int

返回
boolean

抛出
DeviceNotAvailableException

switchUser

public boolean switchUser (int userId)

参数
userId int

返回
boolean

抛出
DeviceNotAvailableException

switchUser

public boolean switchUser (int userId, 
                long timeout)

参数
userId int

timeout long

返回
boolean

抛出
DeviceNotAvailableException

uninstallPackage

public String uninstallPackage (String packageName)

参数
packageName String

返回
String

抛出
DeviceNotAvailableException

uninstallPackageForUser

public String uninstallPackageForUser (String packageName, 
                int userId)

参数
packageName String

userId int

返回
String

抛出
DeviceNotAvailableException

受保护的方法

doAdbReboot

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

执行 adb reboot。

参数
rebootMode NativeDevice.RebootMode:此重新启动的模式。

reason String:针对此次重新启动。

抛出
DeviceNotAvailableException

getCheckNewUserSleep

protected long getCheckNewUserSleep ()

公开以供测试。

返回
long

getHostCurrentTime

protected long getHostCurrentTime ()

公开以供测试

返回
long

prePostBootSetup

protected void prePostBootSetup ()

允许每种设备类型(AndroidNativeDevice、TestDevice)替换此方法以进行特定的启动后设置。

抛出
DeviceNotAvailableException