A partir de 27 de março de 2025, recomendamos usar android-latest-release
em vez de aosp-main
para criar e contribuir com o AOSP. Para mais informações, consulte Mudanças no AOSP.
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
TestDevice
public
class
TestDevice
extends NativeDevice
Subclasses diretas conhecidas
ManagedRemoteDevice |
Um dispositivo em execução em uma máquina virtual que gerenciamos remotamente por uma instância do Tradefed na
VM.
|
NestedRemoteDevice |
Representação do dispositivo em execução em uma VM Cuttlefish remota.
|
RemoteAndroidDevice |
Implementação de um ITestDevice para um dispositivo Android de pilha completa conectado por
adb connect.
|
|
Subclasses indiretas conhecidas
|
Implementação de um ITestDevice
para um dispositivo Android de pilha completa
Resumo
Campos |
public
static
final
String |
DISMISS_KEYGUARD_CMD
Comandos que podem ser usados para dispensar a tela de bloqueio.
|
Métodos públicos |
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)
|
Campos
DISMISS_KEYGUARD_CMD
public static final String DISMISS_KEYGUARD_CMD
Comandos que podem ser usados para dispensar a tela de bloqueio.
Construtores públicos
TestDevice
public TestDevice (IDevice device,
IDeviceStateMonitor stateMonitor,
IDeviceMonitor allocationMonitor)
Métodos públicos
clearErrorDialogs
public boolean clearErrorDialogs ()
Gera |
DeviceNotAvailableException |
|
createUser
public int createUser (String name)
Gera |
DeviceNotAvailableException |
|
createUser
public int createUser (String name,
boolean guest,
boolean ephemeral)
Parâmetros |
name |
String |
guest |
boolean |
ephemeral |
boolean |
Gera |
DeviceNotAvailableException |
|
createUserNoThrow
public int createUserNoThrow (String name)
Gera |
DeviceNotAvailableException |
|
disableKeyguard
public void disableKeyguard ()
Gera |
DeviceNotAvailableException |
|
doesFileExist
public boolean doesFileExist (String deviceFilePath)
Parâmetros |
deviceFilePath |
String |
Gera |
DeviceNotAvailableException |
|
dumpHeap
public File dumpHeap (String process,
String devicePath)
Parâmetros |
process |
String |
devicePath |
String |
Gera |
DeviceNotAvailableException |
|
getActiveApexes
public getActiveApexes ()
Gera |
DeviceNotAvailableException |
|
getAllSettings
public getAllSettings (String namespace)
Parâmetros |
namespace |
String |
Gera |
DeviceNotAvailableException |
|
getAndroidId
public String getAndroidId (int userId)
Gera |
DeviceNotAvailableException |
|
getAndroidIds
public getAndroidIds ()
Gera |
DeviceNotAvailableException |
|
getAppPackageInfo
public PackageInfo getAppPackageInfo (String packageName)
Parâmetros |
packageName |
String |
Gera |
DeviceNotAvailableException |
|
getAppPackageInfos
public getAppPackageInfos ()
Gera |
DeviceNotAvailableException |
|
getCurrentFoldableState
public DeviceFoldableState getCurrentFoldableState ()
Retorna |
DeviceFoldableState |
|
Gera |
DeviceNotAvailableException |
|
getCurrentUser
public int getCurrentUser ()
Gera |
DeviceNotAvailableException |
|
getFoldableStates
public getFoldableStates ()
Gera |
DeviceNotAvailableException |
|
getInstalledPackageNames
public getInstalledPackageNames ()
Gera |
DeviceNotAvailableException |
|
getKeyguardState
public KeyguardControllerState getKeyguardState ()
Retorna |
KeyguardControllerState |
|
Gera |
DeviceNotAvailableException |
|
getMainlineModuleInfo
public getMainlineModuleInfo ()
Gera |
DeviceNotAvailableException |
|
public int getMaxNumberOfRunningUsersSupported ()
Gera |
DeviceNotAvailableException |
|
public int getMaxNumberOfUsersSupported ()
Gera |
DeviceNotAvailableException |
|
getPrimaryUserId
public Integer getPrimaryUserId ()
Gera |
DeviceNotAvailableException |
|
getScreenshot
public InputStreamSource getScreenshot ()
Retorna |
InputStreamSource |
|
Gera |
DeviceNotAvailableException |
|
getScreenshot
public InputStreamSource getScreenshot (String format,
boolean rescale)
Parâmetros |
format |
String |
rescale |
boolean |
Retorna |
InputStreamSource |
|
Gera |
DeviceNotAvailableException |
|
getScreenshot
public InputStreamSource getScreenshot (String format)
Retorna |
InputStreamSource |
|
Gera |
DeviceNotAvailableException |
|
getScreenshot
public InputStreamSource getScreenshot (long displayId)
Parâmetros |
displayId |
long |
Retorna |
InputStreamSource |
|
Gera |
DeviceNotAvailableException |
|
getSetting
public String getSetting (String namespace,
String key)
Parâmetros |
namespace |
String |
key |
String |
Gera |
DeviceNotAvailableException |
|
getSetting
public String getSetting (int userId,
String namespace,
String key)
Parâmetros |
userId |
int |
namespace |
String |
key |
String |
Gera |
DeviceNotAvailableException |
|
getUninstallablePackageNames
public getUninstallablePackageNames ()
Gera |
DeviceNotAvailableException |
|
getUserFlags
public int getUserFlags (int userId)
Gera |
DeviceNotAvailableException |
|
getUserInfos
public getUserInfos ()
Gera |
DeviceNotAvailableException |
|
getUserSerialNumber
public int getUserSerialNumber (int userId)
Gera |
DeviceNotAvailableException |
|
hasFeature
public boolean hasFeature (String feature)
Parâmetros |
feature |
String |
Gera |
DeviceNotAvailableException |
|
installPackage
public String installPackage (File packageFile,
boolean reinstall,
String... extraArgs)
Parâmetros |
packageFile |
File |
reinstall |
boolean |
extraArgs |
String |
Gera |
DeviceNotAvailableException |
|
installPackage
public String installPackage (File packageFile,
File certFile,
boolean reinstall,
String... extraArgs)
Parâmetros |
packageFile |
File |
certFile |
File |
reinstall |
boolean |
extraArgs |
String |
Gera |
DeviceNotAvailableException |
|
installPackage
public String installPackage (File packageFile,
boolean reinstall,
boolean grantPermissions,
String... extraArgs)
Parâmetros |
packageFile |
File |
reinstall |
boolean |
grantPermissions |
boolean |
extraArgs |
String |
Gera |
DeviceNotAvailableException |
|
installPackageForUser
public String installPackageForUser (File packageFile,
boolean reinstall,
boolean grantPermissions,
int userId,
String... extraArgs)
Parâmetros |
packageFile |
File |
reinstall |
boolean |
grantPermissions |
boolean |
userId |
int |
extraArgs |
String |
Gera |
DeviceNotAvailableException |
|
installPackageForUser
public String installPackageForUser (File packageFile,
boolean reinstall,
int userId,
String... extraArgs)
Parâmetros |
packageFile |
File |
reinstall |
boolean |
userId |
int |
extraArgs |
String |
Gera |
DeviceNotAvailableException |
|
installPackages
public String installPackages ( packageFiles,
boolean reinstall,
String... extraArgs)
Parâmetros |
packageFiles |
|
reinstall |
boolean |
extraArgs |
String |
Gera |
DeviceNotAvailableException |
|
installPackages
public String installPackages ( packageFiles,
boolean reinstall,
boolean grantPermissions,
String... extraArgs)
Parâmetros |
packageFiles |
|
reinstall |
boolean |
grantPermissions |
boolean |
extraArgs |
String |
Gera |
DeviceNotAvailableException |
|
installPackagesForUser
public String installPackagesForUser ( packageFiles,
boolean reinstall,
boolean grantPermissions,
int userId,
String... extraArgs)
Parâmetros |
packageFiles |
|
reinstall |
boolean |
grantPermissions |
boolean |
userId |
int |
extraArgs |
String |
Gera |
DeviceNotAvailableException |
|
installPackagesForUser
public String installPackagesForUser ( packageFiles,
boolean reinstall,
int userId,
String... extraArgs)
Parâmetros |
packageFiles |
|
reinstall |
boolean |
userId |
int |
extraArgs |
String |
Gera |
DeviceNotAvailableException |
|
installRemotePackages
public String installRemotePackages ( remoteApkPaths,
boolean reinstall,
boolean grantPermissions,
String... extraArgs)
Parâmetros |
remoteApkPaths |
|
reinstall |
boolean |
grantPermissions |
boolean |
extraArgs |
String |
Gera |
DeviceNotAvailableException |
|
installRemotePackages
public String installRemotePackages ( remoteApkPaths,
boolean reinstall,
String... extraArgs)
Parâmetros |
remoteApkPaths |
|
reinstall |
boolean |
extraArgs |
String |
Gera |
DeviceNotAvailableException |
|
isAppEnumerationSupported
public boolean isAppEnumerationSupported ()
Gera |
DeviceNotAvailableException |
|
isMultiUserSupported
public boolean isMultiUserSupported ()
Gera |
DeviceNotAvailableException |
|
isPackageInstalled
public boolean isPackageInstalled (String packageName)
Parâmetros |
packageName |
String |
Gera |
DeviceNotAvailableException |
|
isPackageInstalled
public boolean isPackageInstalled (String packageName,
String userId)
Parâmetros |
packageName |
String |
userId |
String |
Gera |
DeviceNotAvailableException |
|
isUserRunning
public boolean isUserRunning (int userId)
Gera |
DeviceNotAvailableException |
|
isUserSecondary
public boolean isUserSecondary (int userId)
Gera |
DeviceNotAvailableException |
|
listDisplayIds
public listDisplayIds ()
Gera |
DeviceNotAvailableException |
|
listUsers
public listUsers ()
Gera |
DeviceNotAvailableException |
|
postInvocationTearDown
public void postInvocationTearDown (Throwable exception)
Parâmetros |
exception |
Throwable |
removeAdmin
public boolean removeAdmin (String componentName,
int userId)
Parâmetros |
componentName |
String |
userId |
int |
Gera |
DeviceNotAvailableException |
|
removeOwners
public void removeOwners ()
Gera |
DeviceNotAvailableException |
|
removeUser
public boolean removeUser (int userId)
Gera |
DeviceNotAvailableException |
|
setDeviceOwner
public boolean setDeviceOwner (String componentName,
int userId)
Parâmetros |
componentName |
String |
userId |
int |
Gera |
DeviceNotAvailableException |
|
setSetting
public void setSetting (String namespace,
String key,
String value)
Parâmetros |
namespace |
String |
key |
String |
value |
String |
Gera |
DeviceNotAvailableException |
|
setSetting
public void setSetting (int userId,
String namespace,
String key,
String value)
Parâmetros |
userId |
int |
namespace |
String |
key |
String |
value |
String |
Gera |
DeviceNotAvailableException |
|
startUser
public boolean startUser (int userId)
Gera |
DeviceNotAvailableException |
|
startUser
public boolean startUser (int userId,
boolean waitFlag)
Parâmetros |
userId |
int |
waitFlag |
boolean |
Gera |
DeviceNotAvailableException |
|
stopUser
public boolean stopUser (int userId,
boolean waitFlag,
boolean forceFlag)
Parâmetros |
userId |
int |
waitFlag |
boolean |
forceFlag |
boolean |
Gera |
DeviceNotAvailableException |
|
stopUser
public boolean stopUser (int userId)
Gera |
DeviceNotAvailableException |
|
switchUser
public boolean switchUser (int userId)
Gera |
DeviceNotAvailableException |
|
switchUser
public boolean switchUser (int userId,
long timeout)
Parâmetros |
userId |
int |
timeout |
long |
Gera |
DeviceNotAvailableException |
|
uninstallPackage
public String uninstallPackage (String packageName)
Parâmetros |
packageName |
String |
Gera |
DeviceNotAvailableException |
|
uninstallPackageForUser
public String uninstallPackageForUser (String packageName,
int userId)
Parâmetros |
packageName |
String |
userId |
int |
Gera |
DeviceNotAvailableException |
|
Métodos protegidos
doAdbReboot
protected void doAdbReboot (NativeDevice.RebootMode rebootMode,
String reason)
Faça uma reinicialização do adb.
Parâmetros |
rebootMode |
NativeDevice.RebootMode : um modo dessa reinicialização. |
reason |
String : para esta reinicialização. |
Gera |
DeviceNotAvailableException |
|
getCheckNewUserSleep
protected long getCheckNewUserSleep ()
Exposto para testes.
getHostCurrentTime
protected long getHostCurrentTime ()
Exposto para testes
prePostBootSetup
protected void prePostBootSetup ()
Permite que cada tipo de dispositivo (AndroidNativeDevice, TestDevice) substitua esse método para
uma configuração específica após a inicialização.
Gera |
DeviceNotAvailableException |
|
O conteúdo e os exemplos de código nesta página estão sujeitos às licenças descritas na Licença de conteúdo. Java e OpenJDK são marcas registradas da Oracle e/ou suas afiliadas.
Última atualização 2025-03-26 UTC.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Não contém as informações de que eu preciso","missingTheInformationINeed","thumb-down"],["Muito complicado / etapas demais","tooComplicatedTooManySteps","thumb-down"],["Desatualizado","outOfDate","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Problema com as amostras / o código","samplesCodeIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-03-26 UTC."],[],[]]