TestDevice

public class TestDevice
extends NativeDevice

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


Implementation of a ITestDevice for a full stack android device

Summary

Fields

public static final String DISMISS_KEYGUARD_CMD

Commands that can be used to dismiss the keyguard.

Public constructors

TestDevice(IDevice device, IDeviceStateMonitor stateMonitor, IDeviceMonitor allocationMonitor)

Public methods

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)

Protected methods

void doAdbReboot(NativeDevice.RebootMode rebootMode, String reason)

Perform a adb reboot.

long getCheckNewUserSleep()

Exposed for testing.

long getHostCurrentTime()

Exposed for testing

void prePostBootSetup()

Allows each device type (AndroidNativeDevice, TestDevice) to override this method for specific post boot setup.

Fields

DISMISS_KEYGUARD_CMD

public static final String DISMISS_KEYGUARD_CMD

Commands that can be used to dismiss the keyguard.

Public constructors

TestDevice

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

Public methods

clearErrorDialogs

public boolean clearErrorDialogs ()

Returns
boolean

Throws
DeviceNotAvailableException

createUser

public int createUser (String name)

Parameters
name String

Returns
int

Throws
DeviceNotAvailableException

createUser

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

Parameters
name String

guest boolean

ephemeral boolean

Returns
int

Throws
DeviceNotAvailableException

createUserNoThrow

public int createUserNoThrow (String name)

Parameters
name String

Returns
int

Throws
DeviceNotAvailableException

disableKeyguard

public void disableKeyguard ()

Throws
DeviceNotAvailableException

doesFileExist

public boolean doesFileExist (String deviceFilePath)

Parameters
deviceFilePath String

Returns
boolean

Throws
DeviceNotAvailableException

dumpHeap

public File dumpHeap (String process, 
                String devicePath)

Parameters
process String

devicePath String

Returns
File

Throws
DeviceNotAvailableException

getActiveApexes

public  getActiveApexes ()

Returns

Throws
DeviceNotAvailableException

getAllSettings

public  getAllSettings (String namespace)

Parameters
namespace String

Returns

Throws
DeviceNotAvailableException

getAndroidId

public String getAndroidId (int userId)

Parameters
userId int

Returns
String

Throws
DeviceNotAvailableException

getAndroidIds

public  getAndroidIds ()

Returns

Throws
DeviceNotAvailableException

getAppPackageInfo

public PackageInfo getAppPackageInfo (String packageName)

Parameters
packageName String

Returns
PackageInfo

Throws
DeviceNotAvailableException

getAppPackageInfos

public  getAppPackageInfos ()

Returns

Throws
DeviceNotAvailableException

getCurrentFoldableState

public DeviceFoldableState getCurrentFoldableState ()

Returns
DeviceFoldableState

Throws
DeviceNotAvailableException

getCurrentUser

public int getCurrentUser ()

Returns
int

Throws
DeviceNotAvailableException

getFoldableStates

public  getFoldableStates ()

Returns

Throws
DeviceNotAvailableException

getInstalledPackageNames

public  getInstalledPackageNames ()

Returns

Throws
DeviceNotAvailableException

getKeyguardState

public KeyguardControllerState getKeyguardState ()

Returns
KeyguardControllerState

Throws
DeviceNotAvailableException

getMainlineModuleInfo

public  getMainlineModuleInfo ()

Returns

Throws
DeviceNotAvailableException

getMaxNumberOfRunningUsersSupported

public int getMaxNumberOfRunningUsersSupported ()

Returns
int

Throws
DeviceNotAvailableException

getMaxNumberOfUsersSupported

public int getMaxNumberOfUsersSupported ()

Returns
int

Throws
DeviceNotAvailableException

getPrimaryUserId

public Integer getPrimaryUserId ()

Returns
Integer

Throws
DeviceNotAvailableException

getScreenshot

public InputStreamSource getScreenshot ()

Returns
InputStreamSource

Throws
DeviceNotAvailableException

getScreenshot

public InputStreamSource getScreenshot (String format, 
                boolean rescale)

Parameters
format String

rescale boolean

Returns
InputStreamSource

Throws
DeviceNotAvailableException

getScreenshot

public InputStreamSource getScreenshot (String format)

Parameters
format String

Returns
InputStreamSource

Throws
DeviceNotAvailableException

getScreenshot

public InputStreamSource getScreenshot (long displayId)

Parameters
displayId long

Returns
InputStreamSource

Throws
DeviceNotAvailableException

getSetting

public String getSetting (String namespace, 
                String key)

Parameters
namespace String

key String

Returns
String

Throws
DeviceNotAvailableException

getSetting

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

Parameters
userId int

namespace String

key String

Returns
String

Throws
DeviceNotAvailableException

getUninstallablePackageNames

public  getUninstallablePackageNames ()

Returns

Throws
DeviceNotAvailableException

getUserFlags

public int getUserFlags (int userId)

Parameters
userId int

Returns
int

Throws
DeviceNotAvailableException

getUserInfos

public  getUserInfos ()

Returns

Throws
DeviceNotAvailableException

getUserSerialNumber

public int getUserSerialNumber (int userId)

Parameters
userId int

Returns
int

Throws
DeviceNotAvailableException

hasFeature

public boolean hasFeature (String feature)

Parameters
feature String

Returns
boolean

Throws
DeviceNotAvailableException

installPackage

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

Parameters
packageFile File

reinstall boolean

extraArgs String

Returns
String

Throws
DeviceNotAvailableException

installPackage

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

Parameters
packageFile File

certFile File

reinstall boolean

extraArgs String

Returns
String

Throws
DeviceNotAvailableException

installPackage

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

Parameters
packageFile File

reinstall boolean

grantPermissions boolean

extraArgs String

Returns
String

Throws
DeviceNotAvailableException

installPackageForUser

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

Parameters
packageFile File

reinstall boolean

grantPermissions boolean

userId int

extraArgs String

Returns
String

Throws
DeviceNotAvailableException

installPackageForUser

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

Parameters
packageFile File

reinstall boolean

userId int

extraArgs String

Returns
String

Throws
DeviceNotAvailableException

installPackages

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

Parameters
packageFiles

reinstall boolean

extraArgs String

Returns
String

Throws
DeviceNotAvailableException

installPackages

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

Parameters
packageFiles

reinstall boolean

grantPermissions boolean

extraArgs String

Returns
String

Throws
DeviceNotAvailableException

installPackagesForUser

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

Parameters
packageFiles

reinstall boolean

grantPermissions boolean

userId int

extraArgs String

Returns
String

Throws
DeviceNotAvailableException

installPackagesForUser

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

Parameters
packageFiles

reinstall boolean

userId int

extraArgs String

Returns
String

Throws
DeviceNotAvailableException

installRemotePackages

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

Parameters
remoteApkPaths

reinstall boolean

grantPermissions boolean

extraArgs String

Returns
String

Throws
DeviceNotAvailableException

installRemotePackages

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

Parameters
remoteApkPaths

reinstall boolean

extraArgs String

Returns
String

Throws
DeviceNotAvailableException

isAppEnumerationSupported

public boolean isAppEnumerationSupported ()

Returns
boolean

Throws
DeviceNotAvailableException

isMultiUserSupported

public boolean isMultiUserSupported ()

Returns
boolean

Throws
DeviceNotAvailableException

isPackageInstalled

public boolean isPackageInstalled (String packageName)

Parameters
packageName String

Returns
boolean

Throws
DeviceNotAvailableException

isPackageInstalled

public boolean isPackageInstalled (String packageName, 
                String userId)

Parameters
packageName String

userId String

Returns
boolean

Throws
DeviceNotAvailableException

isUserRunning

public boolean isUserRunning (int userId)

Parameters
userId int

Returns
boolean

Throws
DeviceNotAvailableException

isUserSecondary

public boolean isUserSecondary (int userId)

Parameters
userId int

Returns
boolean

Throws
DeviceNotAvailableException

listDisplayIds

public  listDisplayIds ()

Returns

Throws
DeviceNotAvailableException

listUsers

public  listUsers ()

Returns

Throws
DeviceNotAvailableException

postInvocationTearDown

public void postInvocationTearDown (Throwable exception)

Parameters
exception Throwable

removeAdmin

public boolean removeAdmin (String componentName, 
                int userId)

Parameters
componentName String

userId int

Returns
boolean

Throws
DeviceNotAvailableException

removeOwners

public void removeOwners ()

Throws
DeviceNotAvailableException

removeUser

public boolean removeUser (int userId)

Parameters
userId int

Returns
boolean

Throws
DeviceNotAvailableException

setDeviceOwner

public boolean setDeviceOwner (String componentName, 
                int userId)

Parameters
componentName String

userId int

Returns
boolean

Throws
DeviceNotAvailableException

setSetting

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

Parameters
namespace String

key String

value String

Throws
DeviceNotAvailableException

setSetting

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

Parameters
userId int

namespace String

key String

value String

Throws
DeviceNotAvailableException

startUser

public boolean startUser (int userId)

Parameters
userId int

Returns
boolean

Throws
DeviceNotAvailableException

startUser

public boolean startUser (int userId, 
                boolean waitFlag)

Parameters
userId int

waitFlag boolean

Returns
boolean

Throws
DeviceNotAvailableException

stopUser

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

Parameters
userId int

waitFlag boolean

forceFlag boolean

Returns
boolean

Throws
DeviceNotAvailableException

stopUser

public boolean stopUser (int userId)

Parameters
userId int

Returns
boolean

Throws
DeviceNotAvailableException

switchUser

public boolean switchUser (int userId)

Parameters
userId int

Returns
boolean

Throws
DeviceNotAvailableException

switchUser

public boolean switchUser (int userId, 
                long timeout)

Parameters
userId int

timeout long

Returns
boolean

Throws
DeviceNotAvailableException

uninstallPackage

public String uninstallPackage (String packageName)

Parameters
packageName String

Returns
String

Throws
DeviceNotAvailableException

uninstallPackageForUser

public String uninstallPackageForUser (String packageName, 
                int userId)

Parameters
packageName String

userId int

Returns
String

Throws
DeviceNotAvailableException

Protected methods

doAdbReboot

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

Perform a adb reboot.

Parameters
rebootMode NativeDevice.RebootMode: a mode of this reboot.

reason String: for this reboot.

Throws
DeviceNotAvailableException

getCheckNewUserSleep

protected long getCheckNewUserSleep ()

Exposed for testing.

Returns
long

getHostCurrentTime

protected long getHostCurrentTime ()

Exposed for testing

Returns
long

prePostBootSetup

protected void prePostBootSetup ()

Allows each device type (AndroidNativeDevice, TestDevice) to override this method for specific post boot setup.

Throws
DeviceNotAvailableException