À partir du 27 mars 2025, nous vous recommandons d'utiliser android-latest-release
au lieu de aosp-main
pour créer et contribuer à AOSP. Pour en savoir plus, consultez la section Modifications apportées à AOSP.
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
TestDevice
public
class
TestDevice
extends NativeDevice
Sous-classes directes connues
ManagedRemoteDevice |
Appareil exécuté dans une machine virtuelle que nous gérons à distance via une instance Tradefed dans la VM.
|
NestedRemoteDevice |
Représentation de l'appareil exécuté dans une VM Cuttlefish distante.
|
RemoteAndroidDevice |
Implémentation d'un ITestDevice pour un appareil Android à pile complète connecté via une connexion ADB.
|
|
Sous-classes indirectes connues
|
Implémentation d'un ITestDevice
pour un appareil Android full stack
Résumé
Champs |
public
static
final
String |
DISMISS_KEYGUARD_CMD
Commandes permettant de fermer le clavier de verrouillage.
|
Méthodes publiques |
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)
|
Champs
DISMISS_KEYGUARD_CMD
public static final String DISMISS_KEYGUARD_CMD
Commandes permettant de fermer le clavier de verrouillage.
Constructeurs publics
TestDevice
public TestDevice (IDevice device,
IDeviceStateMonitor stateMonitor,
IDeviceMonitor allocationMonitor)
Méthodes publiques
clearErrorDialogs
public boolean clearErrorDialogs ()
Génère |
DeviceNotAvailableException |
|
createUser
public int createUser (String name)
Génère |
DeviceNotAvailableException |
|
createUser
public int createUser (String name,
boolean guest,
boolean ephemeral)
Paramètres |
name |
String |
guest |
boolean |
ephemeral |
boolean |
Génère |
DeviceNotAvailableException |
|
createUserNoThrow
public int createUserNoThrow (String name)
Génère |
DeviceNotAvailableException |
|
disableKeyguard
public void disableKeyguard ()
Génère |
DeviceNotAvailableException |
|
doesFileExist
public boolean doesFileExist (String deviceFilePath)
Paramètres |
deviceFilePath |
String |
Génère |
DeviceNotAvailableException |
|
dumpHeap
public File dumpHeap (String process,
String devicePath)
Paramètres |
process |
String |
devicePath |
String |
Génère |
DeviceNotAvailableException |
|
getActiveApexes
public getActiveApexes ()
Génère |
DeviceNotAvailableException |
|
getAllSettings
public getAllSettings (String namespace)
Paramètres |
namespace |
String |
Génère |
DeviceNotAvailableException |
|
getAndroidId
public String getAndroidId (int userId)
Génère |
DeviceNotAvailableException |
|
getAndroidIds
public getAndroidIds ()
Génère |
DeviceNotAvailableException |
|
getAppPackageInfo
public PackageInfo getAppPackageInfo (String packageName)
Paramètres |
packageName |
String |
Génère |
DeviceNotAvailableException |
|
getAppPackageInfos
public getAppPackageInfos ()
Génère |
DeviceNotAvailableException |
|
getCurrentFoldableState
public DeviceFoldableState getCurrentFoldableState ()
Renvoie |
DeviceFoldableState |
|
Génère |
DeviceNotAvailableException |
|
getCurrentUser
public int getCurrentUser ()
Génère |
DeviceNotAvailableException |
|
getFoldableStates
public getFoldableStates ()
Génère |
DeviceNotAvailableException |
|
getInstalledPackageNames
public getInstalledPackageNames ()
Génère |
DeviceNotAvailableException |
|
getKeyguardState
public KeyguardControllerState getKeyguardState ()
Renvoie |
KeyguardControllerState |
|
Génère |
DeviceNotAvailableException |
|
getMainlineModuleInfo
public getMainlineModuleInfo ()
Génère |
DeviceNotAvailableException |
|
public int getMaxNumberOfRunningUsersSupported ()
Génère |
DeviceNotAvailableException |
|
public int getMaxNumberOfUsersSupported ()
Génère |
DeviceNotAvailableException |
|
getPrimaryUserId
public Integer getPrimaryUserId ()
Génère |
DeviceNotAvailableException |
|
getScreenshot
public InputStreamSource getScreenshot ()
Renvoie |
InputStreamSource |
|
Génère |
DeviceNotAvailableException |
|
getScreenshot
public InputStreamSource getScreenshot (String format,
boolean rescale)
Paramètres |
format |
String |
rescale |
boolean |
Renvoie |
InputStreamSource |
|
Génère |
DeviceNotAvailableException |
|
getScreenshot
public InputStreamSource getScreenshot (String format)
Renvoie |
InputStreamSource |
|
Génère |
DeviceNotAvailableException |
|
getScreenshot
public InputStreamSource getScreenshot (long displayId)
Paramètres |
displayId |
long |
Renvoie |
InputStreamSource |
|
Génère |
DeviceNotAvailableException |
|
getSetting
public String getSetting (String namespace,
String key)
Paramètres |
namespace |
String |
key |
String |
Génère |
DeviceNotAvailableException |
|
getSetting
public String getSetting (int userId,
String namespace,
String key)
Paramètres |
userId |
int |
namespace |
String |
key |
String |
Génère |
DeviceNotAvailableException |
|
getUninstallablePackageNames
public getUninstallablePackageNames ()
Génère |
DeviceNotAvailableException |
|
getUserFlags
public int getUserFlags (int userId)
Génère |
DeviceNotAvailableException |
|
getUserInfos
public getUserInfos ()
Génère |
DeviceNotAvailableException |
|
getUserSerialNumber
public int getUserSerialNumber (int userId)
Génère |
DeviceNotAvailableException |
|
hasFeature
public boolean hasFeature (String feature)
Paramètres |
feature |
String |
Génère |
DeviceNotAvailableException |
|
installPackage
public String installPackage (File packageFile,
boolean reinstall,
String... extraArgs)
Paramètres |
packageFile |
File |
reinstall |
boolean |
extraArgs |
String |
Génère |
DeviceNotAvailableException |
|
installPackage
public String installPackage (File packageFile,
File certFile,
boolean reinstall,
String... extraArgs)
Paramètres |
packageFile |
File |
certFile |
File |
reinstall |
boolean |
extraArgs |
String |
Génère |
DeviceNotAvailableException |
|
installPackage
public String installPackage (File packageFile,
boolean reinstall,
boolean grantPermissions,
String... extraArgs)
Paramètres |
packageFile |
File |
reinstall |
boolean |
grantPermissions |
boolean |
extraArgs |
String |
Génère |
DeviceNotAvailableException |
|
installPackageForUser
public String installPackageForUser (File packageFile,
boolean reinstall,
boolean grantPermissions,
int userId,
String... extraArgs)
Paramètres |
packageFile |
File |
reinstall |
boolean |
grantPermissions |
boolean |
userId |
int |
extraArgs |
String |
Génère |
DeviceNotAvailableException |
|
installPackageForUser
public String installPackageForUser (File packageFile,
boolean reinstall,
int userId,
String... extraArgs)
Paramètres |
packageFile |
File |
reinstall |
boolean |
userId |
int |
extraArgs |
String |
Génère |
DeviceNotAvailableException |
|
installPackages
public String installPackages ( packageFiles,
boolean reinstall,
String... extraArgs)
Paramètres |
packageFiles |
|
reinstall |
boolean |
extraArgs |
String |
Génère |
DeviceNotAvailableException |
|
installPackages
public String installPackages ( packageFiles,
boolean reinstall,
boolean grantPermissions,
String... extraArgs)
Paramètres |
packageFiles |
|
reinstall |
boolean |
grantPermissions |
boolean |
extraArgs |
String |
Génère |
DeviceNotAvailableException |
|
installPackagesForUser
public String installPackagesForUser ( packageFiles,
boolean reinstall,
boolean grantPermissions,
int userId,
String... extraArgs)
Paramètres |
packageFiles |
|
reinstall |
boolean |
grantPermissions |
boolean |
userId |
int |
extraArgs |
String |
Génère |
DeviceNotAvailableException |
|
installPackagesForUser
public String installPackagesForUser ( packageFiles,
boolean reinstall,
int userId,
String... extraArgs)
Paramètres |
packageFiles |
|
reinstall |
boolean |
userId |
int |
extraArgs |
String |
Génère |
DeviceNotAvailableException |
|
installRemotePackages
public String installRemotePackages ( remoteApkPaths,
boolean reinstall,
boolean grantPermissions,
String... extraArgs)
Paramètres |
remoteApkPaths |
|
reinstall |
boolean |
grantPermissions |
boolean |
extraArgs |
String |
Génère |
DeviceNotAvailableException |
|
installRemotePackages
public String installRemotePackages ( remoteApkPaths,
boolean reinstall,
String... extraArgs)
Paramètres |
remoteApkPaths |
|
reinstall |
boolean |
extraArgs |
String |
Génère |
DeviceNotAvailableException |
|
isAppEnumerationSupported
public boolean isAppEnumerationSupported ()
Génère |
DeviceNotAvailableException |
|
isMultiUserSupported
public boolean isMultiUserSupported ()
Génère |
DeviceNotAvailableException |
|
isPackageInstalled
public boolean isPackageInstalled (String packageName)
Paramètres |
packageName |
String |
Génère |
DeviceNotAvailableException |
|
isPackageInstalled
public boolean isPackageInstalled (String packageName,
String userId)
Paramètres |
packageName |
String |
userId |
String |
Génère |
DeviceNotAvailableException |
|
isUserRunning
public boolean isUserRunning (int userId)
Génère |
DeviceNotAvailableException |
|
isUserSecondary
public boolean isUserSecondary (int userId)
Génère |
DeviceNotAvailableException |
|
listDisplayIds
public listDisplayIds ()
Génère |
DeviceNotAvailableException |
|
listUsers
public listUsers ()
Génère |
DeviceNotAvailableException |
|
postInvocationTearDown
public void postInvocationTearDown (Throwable exception)
Paramètres |
exception |
Throwable |
removeAdmin
public boolean removeAdmin (String componentName,
int userId)
Paramètres |
componentName |
String |
userId |
int |
Génère |
DeviceNotAvailableException |
|
removeOwners
public void removeOwners ()
Génère |
DeviceNotAvailableException |
|
removeUser
public boolean removeUser (int userId)
Génère |
DeviceNotAvailableException |
|
setDeviceOwner
public boolean setDeviceOwner (String componentName,
int userId)
Paramètres |
componentName |
String |
userId |
int |
Génère |
DeviceNotAvailableException |
|
setSetting
public void setSetting (String namespace,
String key,
String value)
Paramètres |
namespace |
String |
key |
String |
value |
String |
Génère |
DeviceNotAvailableException |
|
setSetting
public void setSetting (int userId,
String namespace,
String key,
String value)
Paramètres |
userId |
int |
namespace |
String |
key |
String |
value |
String |
Génère |
DeviceNotAvailableException |
|
startUser
public boolean startUser (int userId)
Génère |
DeviceNotAvailableException |
|
startUser
public boolean startUser (int userId,
boolean waitFlag)
Paramètres |
userId |
int |
waitFlag |
boolean |
Génère |
DeviceNotAvailableException |
|
stopUser
public boolean stopUser (int userId,
boolean waitFlag,
boolean forceFlag)
Paramètres |
userId |
int |
waitFlag |
boolean |
forceFlag |
boolean |
Génère |
DeviceNotAvailableException |
|
stopUser
public boolean stopUser (int userId)
Génère |
DeviceNotAvailableException |
|
switchUser
public boolean switchUser (int userId)
Génère |
DeviceNotAvailableException |
|
switchUser
public boolean switchUser (int userId,
long timeout)
Paramètres |
userId |
int |
timeout |
long |
Génère |
DeviceNotAvailableException |
|
uninstallPackage
public String uninstallPackage (String packageName)
Paramètres |
packageName |
String |
Génère |
DeviceNotAvailableException |
|
uninstallPackageForUser
public String uninstallPackageForUser (String packageName,
int userId)
Paramètres |
packageName |
String |
userId |
int |
Génère |
DeviceNotAvailableException |
|
Méthodes protégées
doAdbReboot
protected void doAdbReboot (NativeDevice.RebootMode rebootMode,
String reason)
Effectuez un redémarrage ADB.
Paramètres |
rebootMode |
NativeDevice.RebootMode : mode de ce redémarrage. |
reason |
String : pour ce redémarrage. |
Génère |
DeviceNotAvailableException |
|
getCheckNewUserSleep
protected long getCheckNewUserSleep ()
Exposé à des fins de test.
getHostCurrentTime
protected long getHostCurrentTime ()
Exposé à des fins de test
prePostBootSetup
protected void prePostBootSetup ()
Permet à chaque type d'appareil (AndroidNativeDevice, TestDevice) de remplacer cette méthode pour une configuration spécifique après le démarrage.
Génère |
DeviceNotAvailableException |
|
Le contenu et les exemples de code de cette page sont soumis aux licences décrites dans la Licence de contenu. Java et OpenJDK sont des marques ou des marques déposées d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/03/26 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Il n'y a pas l'information dont j'ai besoin","missingTheInformationINeed","thumb-down"],["Trop compliqué/Trop d'étapes","tooComplicatedTooManySteps","thumb-down"],["Obsolète","outOfDate","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Mauvais exemple/Erreur de code","samplesCodeIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/03/26 (UTC)."],[],[]]