Od 27 marca 2025 r. zalecamy używanie android-latest-release
zamiast aosp-main
do kompilowania i wspołtworzenia AOSP. Więcej informacji znajdziesz w artykule o zmianach w AOSP.
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
TestDevice
public
class
TestDevice
extends NativeDevice
Znane bezpośrednie podklasy
ManagedRemoteDevice |
Urządzenie działające w maszynie wirtualnej, którą zarządzamy zdalnie za pomocą instancji Tradefed w maszynie wirtualnej.
|
NestedRemoteDevice |
Przykład urządzenia działającego w ramach zdalnej maszyny wirtualnej Cuttlefish.
|
RemoteAndroidDevice |
Wdrożenie ITestDevice na urządzeniu z Androidem z pełnym stosem połączonym za pomocą adb connect.
|
|
Implementacja ITestDevice
na urządzeniu z pełnym zestawem Androida
Podsumowanie
Fieldsem |
public
static
final
String |
DISMISS_KEYGUARD_CMD
Polecenia, których można używać do zamykania ekranu blokady.
|
Metody publiczne |
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)
|
Fieldsem
DISMISS_KEYGUARD_CMD
public static final String DISMISS_KEYGUARD_CMD
Polecenia, których można używać do zamykania ekranu blokady.
Konstruktory publiczne
TestDevice
public TestDevice (IDevice device,
IDeviceStateMonitor stateMonitor,
IDeviceMonitor allocationMonitor)
Metody publiczne
clearErrorDialogs
public boolean clearErrorDialogs ()
Rzuty |
DeviceNotAvailableException |
|
createUser
public int createUser (String name)
Rzuty |
DeviceNotAvailableException |
|
createUser
public int createUser (String name,
boolean guest,
boolean ephemeral)
Parametry |
name |
String |
guest |
boolean |
ephemeral |
boolean |
Rzuty |
DeviceNotAvailableException |
|
createUserNoThrow
public int createUserNoThrow (String name)
Rzuty |
DeviceNotAvailableException |
|
disableKeyguard
public void disableKeyguard ()
Rzuty |
DeviceNotAvailableException |
|
doesFileExist
public boolean doesFileExist (String deviceFilePath)
Parametry |
deviceFilePath |
String |
Rzuty |
DeviceNotAvailableException |
|
dumpHeap
public File dumpHeap (String process,
String devicePath)
Parametry |
process |
String |
devicePath |
String |
Rzuty |
DeviceNotAvailableException |
|
getActiveApexes
public getActiveApexes ()
Rzuty |
DeviceNotAvailableException |
|
getAllSettings
public getAllSettings (String namespace)
Parametry |
namespace |
String |
Rzuty |
DeviceNotAvailableException |
|
getAndroidId
public String getAndroidId (int userId)
Rzuty |
DeviceNotAvailableException |
|
getAndroidIds
public getAndroidIds ()
Rzuty |
DeviceNotAvailableException |
|
getAppPackageInfo
public PackageInfo getAppPackageInfo (String packageName)
Parametry |
packageName |
String |
Rzuty |
DeviceNotAvailableException |
|
getAppPackageInfos
public getAppPackageInfos ()
Rzuty |
DeviceNotAvailableException |
|
getCurrentFoldableState
public DeviceFoldableState getCurrentFoldableState ()
Zwroty |
DeviceFoldableState |
|
Rzuty |
DeviceNotAvailableException |
|
getCurrentUser
public int getCurrentUser ()
Rzuty |
DeviceNotAvailableException |
|
getFoldableStates
public getFoldableStates ()
Rzuty |
DeviceNotAvailableException |
|
getInstalledPackageNames
public getInstalledPackageNames ()
Rzuty |
DeviceNotAvailableException |
|
getKeyguardState
public KeyguardControllerState getKeyguardState ()
Zwroty |
KeyguardControllerState |
|
Rzuty |
DeviceNotAvailableException |
|
getMainlineModuleInfo
public getMainlineModuleInfo ()
Rzuty |
DeviceNotAvailableException |
|
public int getMaxNumberOfRunningUsersSupported ()
Rzuty |
DeviceNotAvailableException |
|
public int getMaxNumberOfUsersSupported ()
Rzuty |
DeviceNotAvailableException |
|
getPrimaryUserId
public Integer getPrimaryUserId ()
Rzuty |
DeviceNotAvailableException |
|
getScreenshot
public InputStreamSource getScreenshot ()
Rzuty |
DeviceNotAvailableException |
|
getScreenshot
public InputStreamSource getScreenshot (String format,
boolean rescale)
Parametry |
format |
String |
rescale |
boolean |
Rzuty |
DeviceNotAvailableException |
|
getScreenshot
public InputStreamSource getScreenshot (String format)
Rzuty |
DeviceNotAvailableException |
|
getScreenshot
public InputStreamSource getScreenshot (long displayId)
Rzuty |
DeviceNotAvailableException |
|
getSetting
public String getSetting (String namespace,
String key)
Parametry |
namespace |
String |
key |
String |
Rzuty |
DeviceNotAvailableException |
|
getSetting
public String getSetting (int userId,
String namespace,
String key)
Parametry |
userId |
int |
namespace |
String |
key |
String |
Rzuty |
DeviceNotAvailableException |
|
getUninstallablePackageNames
public getUninstallablePackageNames ()
Rzuty |
DeviceNotAvailableException |
|
getUserFlags
public int getUserFlags (int userId)
Rzuty |
DeviceNotAvailableException |
|
getUserInfos
public getUserInfos ()
Rzuty |
DeviceNotAvailableException |
|
getUserSerialNumber
public int getUserSerialNumber (int userId)
Rzuty |
DeviceNotAvailableException |
|
hasFeature
public boolean hasFeature (String feature)
Rzuty |
DeviceNotAvailableException |
|
installPackage
public String installPackage (File packageFile,
boolean reinstall,
String... extraArgs)
Parametry |
packageFile |
File |
reinstall |
boolean |
extraArgs |
String |
Rzuty |
DeviceNotAvailableException |
|
installPackage
public String installPackage (File packageFile,
File certFile,
boolean reinstall,
String... extraArgs)
Parametry |
packageFile |
File |
certFile |
File |
reinstall |
boolean |
extraArgs |
String |
Rzuty |
DeviceNotAvailableException |
|
installPackage
public String installPackage (File packageFile,
boolean reinstall,
boolean grantPermissions,
String... extraArgs)
Parametry |
packageFile |
File |
reinstall |
boolean |
grantPermissions |
boolean |
extraArgs |
String |
Rzuty |
DeviceNotAvailableException |
|
installPackageForUser
public String installPackageForUser (File packageFile,
boolean reinstall,
boolean grantPermissions,
int userId,
String... extraArgs)
Parametry |
packageFile |
File |
reinstall |
boolean |
grantPermissions |
boolean |
userId |
int |
extraArgs |
String |
Rzuty |
DeviceNotAvailableException |
|
installPackageForUser
public String installPackageForUser (File packageFile,
boolean reinstall,
int userId,
String... extraArgs)
Parametry |
packageFile |
File |
reinstall |
boolean |
userId |
int |
extraArgs |
String |
Rzuty |
DeviceNotAvailableException |
|
installPackages
public String installPackages ( packageFiles,
boolean reinstall,
String... extraArgs)
Parametry |
packageFiles |
|
reinstall |
boolean |
extraArgs |
String |
Rzuty |
DeviceNotAvailableException |
|
installPackages
public String installPackages ( packageFiles,
boolean reinstall,
boolean grantPermissions,
String... extraArgs)
Parametry |
packageFiles |
|
reinstall |
boolean |
grantPermissions |
boolean |
extraArgs |
String |
Rzuty |
DeviceNotAvailableException |
|
installPackagesForUser
public String installPackagesForUser ( packageFiles,
boolean reinstall,
boolean grantPermissions,
int userId,
String... extraArgs)
Parametry |
packageFiles |
|
reinstall |
boolean |
grantPermissions |
boolean |
userId |
int |
extraArgs |
String |
Rzuty |
DeviceNotAvailableException |
|
installPackagesForUser
public String installPackagesForUser ( packageFiles,
boolean reinstall,
int userId,
String... extraArgs)
Parametry |
packageFiles |
|
reinstall |
boolean |
userId |
int |
extraArgs |
String |
Rzuty |
DeviceNotAvailableException |
|
installRemotePackages
public String installRemotePackages ( remoteApkPaths,
boolean reinstall,
boolean grantPermissions,
String... extraArgs)
Parametry |
remoteApkPaths |
|
reinstall |
boolean |
grantPermissions |
boolean |
extraArgs |
String |
Rzuty |
DeviceNotAvailableException |
|
installRemotePackages
public String installRemotePackages ( remoteApkPaths,
boolean reinstall,
String... extraArgs)
Parametry |
remoteApkPaths |
|
reinstall |
boolean |
extraArgs |
String |
Rzuty |
DeviceNotAvailableException |
|
isAppEnumerationSupported
public boolean isAppEnumerationSupported ()
Rzuty |
DeviceNotAvailableException |
|
isMultiUserSupported
public boolean isMultiUserSupported ()
Rzuty |
DeviceNotAvailableException |
|
isPackageInstalled
public boolean isPackageInstalled (String packageName)
Parametry |
packageName |
String |
Rzuty |
DeviceNotAvailableException |
|
isPackageInstalled
public boolean isPackageInstalled (String packageName,
String userId)
Parametry |
packageName |
String |
userId |
String |
Rzuty |
DeviceNotAvailableException |
|
isUserRunning
public boolean isUserRunning (int userId)
Rzuty |
DeviceNotAvailableException |
|
isUserSecondary
public boolean isUserSecondary (int userId)
Rzuty |
DeviceNotAvailableException |
|
listDisplayIds
public listDisplayIds ()
Rzuty |
DeviceNotAvailableException |
|
listUsers
public listUsers ()
Rzuty |
DeviceNotAvailableException |
|
postInvocationTearDown
public void postInvocationTearDown (Throwable exception)
Parametry |
exception |
Throwable |
removeAdmin
public boolean removeAdmin (String componentName,
int userId)
Parametry |
componentName |
String |
userId |
int |
Rzuty |
DeviceNotAvailableException |
|
removeOwners
public void removeOwners ()
Rzuty |
DeviceNotAvailableException |
|
removeUser
public boolean removeUser (int userId)
Rzuty |
DeviceNotAvailableException |
|
setDeviceOwner
public boolean setDeviceOwner (String componentName,
int userId)
Parametry |
componentName |
String |
userId |
int |
Rzuty |
DeviceNotAvailableException |
|
setSetting
public void setSetting (String namespace,
String key,
String value)
Parametry |
namespace |
String |
key |
String |
value |
String |
Rzuty |
DeviceNotAvailableException |
|
setSetting
public void setSetting (int userId,
String namespace,
String key,
String value)
Parametry |
userId |
int |
namespace |
String |
key |
String |
value |
String |
Rzuty |
DeviceNotAvailableException |
|
startUser
public boolean startUser (int userId)
Rzuty |
DeviceNotAvailableException |
|
startUser
public boolean startUser (int userId,
boolean waitFlag)
Parametry |
userId |
int |
waitFlag |
boolean |
Rzuty |
DeviceNotAvailableException |
|
stopUser
public boolean stopUser (int userId,
boolean waitFlag,
boolean forceFlag)
Parametry |
userId |
int |
waitFlag |
boolean |
forceFlag |
boolean |
Rzuty |
DeviceNotAvailableException |
|
stopUser
public boolean stopUser (int userId)
Rzuty |
DeviceNotAvailableException |
|
switchUser
public boolean switchUser (int userId)
Rzuty |
DeviceNotAvailableException |
|
switchUser
public boolean switchUser (int userId,
long timeout)
Parametry |
userId |
int |
timeout |
long |
Rzuty |
DeviceNotAvailableException |
|
uninstallPackage
public String uninstallPackage (String packageName)
Parametry |
packageName |
String |
Rzuty |
DeviceNotAvailableException |
|
uninstallPackageForUser
public String uninstallPackageForUser (String packageName,
int userId)
Parametry |
packageName |
String |
userId |
int |
Rzuty |
DeviceNotAvailableException |
|
Chronione metody
doAdbReboot
protected void doAdbReboot (NativeDevice.RebootMode rebootMode,
String reason)
Uruchom ponownie urządzenie za pomocą adb.
Parametry |
rebootMode |
NativeDevice.RebootMode : tryb ponownego uruchamiania. |
reason |
String : w przypadku tego restartu. |
Rzuty |
DeviceNotAvailableException |
|
getCheckNewUserSleep
protected long getCheckNewUserSleep ()
Wyeksponowane do testowania.
getHostCurrentTime
protected long getHostCurrentTime ()
Udostępnione do testowania
prePostBootSetup
protected void prePostBootSetup ()
Umożliwia każdemu typowi urządzenia (AndroidNativeDevice, TestDevice) zastąpienie tej metody w przypadku określonej konfiguracji po uruchomieniu.
Rzuty |
DeviceNotAvailableException |
|
Treść strony i umieszczone na niej fragmenty kodu podlegają licencjom opisanym w Licencji na treści. Java i OpenJDK są znakami towarowymi lub zastrzeżonymi znakami towarowymi należącymi do firmy Oracle lub jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-03-26 UTC.
[[["Łatwo zrozumieć","easyToUnderstand","thumb-up"],["Rozwiązało to mój problem","solvedMyProblem","thumb-up"],["Inne","otherUp","thumb-up"]],[["Brak potrzebnych mi informacji","missingTheInformationINeed","thumb-down"],["Zbyt skomplikowane / zbyt wiele czynności do wykonania","tooComplicatedTooManySteps","thumb-down"],["Nieaktualne treści","outOfDate","thumb-down"],["Problem z tłumaczeniem","translationIssue","thumb-down"],["Problem z przykładami/kodem","samplesCodeIssue","thumb-down"],["Inne","otherDown","thumb-down"]],["Ostatnia aktualizacja: 2025-03-26 UTC."],[],[]]