Kể từ ngày 27 tháng 3 năm 2025, bạn nên sử dụng android-latest-release
thay vì aosp-main
để xây dựng và đóng góp cho AOSP. Để biết thêm thông tin, hãy xem phần Thay đổi đối với AOSP.
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
TestDevice
public
class
TestDevice
extends NativeDevice
Các lớp con trực tiếp đã biết
ManagedRemoteDevice |
Một thiết bị chạy bên trong máy ảo mà chúng tôi quản lý từ xa thông qua một thực thể Tradefed bên trong máy ảo.
|
NestedRemoteDevice |
Hình ảnh đại diện cho thiết bị đang chạy bên trong máy ảo Cuttlefish từ xa.
|
RemoteAndroidDevice |
Triển khai ITestDevice cho một thiết bị Android có đầy đủ ngăn xếp được kết nối thông qua adb connect.
|
|
Các lớp con gián tiếp đã biết
|
Triển khai ITestDevice
cho thiết bị Android toàn bộ ngăn xếp
Tóm tắt
Phương thức công khai |
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)
|
Trường
DISMISS_KEYGUARD_CMD
public static final String DISMISS_KEYGUARD_CMD
Các lệnh có thể dùng để đóng màn hình khoá.
Hàm khởi tạo công khai
TestDevice
public TestDevice (IDevice device,
IDeviceStateMonitor stateMonitor,
IDeviceMonitor allocationMonitor)
Phương thức công khai
clearErrorDialogs
public boolean clearErrorDialogs ()
Gửi |
DeviceNotAvailableException |
|
createUser
public int createUser (String name)
Gửi |
DeviceNotAvailableException |
|
createUser
public int createUser (String name,
boolean guest,
boolean ephemeral)
Tham số |
name |
String |
guest |
boolean |
ephemeral |
boolean |
Gửi |
DeviceNotAvailableException |
|
createUserNoThrow
public int createUserNoThrow (String name)
Gửi |
DeviceNotAvailableException |
|
disableKeyguard
public void disableKeyguard ()
Gửi |
DeviceNotAvailableException |
|
doesFileExist
public boolean doesFileExist (String deviceFilePath)
Tham số |
deviceFilePath |
String |
Gửi |
DeviceNotAvailableException |
|
dumpHeap
public File dumpHeap (String process,
String devicePath)
Tham số |
process |
String |
devicePath |
String |
Gửi |
DeviceNotAvailableException |
|
getActiveApexes
public getActiveApexes ()
Gửi |
DeviceNotAvailableException |
|
getAllSettings
public getAllSettings (String namespace)
Gửi |
DeviceNotAvailableException |
|
getAndroidId
public String getAndroidId (int userId)
Gửi |
DeviceNotAvailableException |
|
getAndroidIds
public getAndroidIds ()
Gửi |
DeviceNotAvailableException |
|
getAppPackageInfo
public PackageInfo getAppPackageInfo (String packageName)
Tham số |
packageName |
String |
Giá trị trả về |
PackageInfo |
|
Gửi |
DeviceNotAvailableException |
|
getAppPackageInfos
public getAppPackageInfos ()
Gửi |
DeviceNotAvailableException |
|
getCurrentFoldableState
public DeviceFoldableState getCurrentFoldableState ()
Giá trị trả về |
DeviceFoldableState |
|
Gửi |
DeviceNotAvailableException |
|
getCurrentUser
public int getCurrentUser ()
Gửi |
DeviceNotAvailableException |
|
getFoldableStates
public getFoldableStates ()
Gửi |
DeviceNotAvailableException |
|
getInstalledPackageNames
public getInstalledPackageNames ()
Gửi |
DeviceNotAvailableException |
|
getKeyguardState
public KeyguardControllerState getKeyguardState ()
Giá trị trả về |
KeyguardControllerState |
|
Gửi |
DeviceNotAvailableException |
|
getMainlineModuleInfo
public getMainlineModuleInfo ()
Gửi |
DeviceNotAvailableException |
|
public int getMaxNumberOfRunningUsersSupported ()
Gửi |
DeviceNotAvailableException |
|
public int getMaxNumberOfUsersSupported ()
Gửi |
DeviceNotAvailableException |
|
getPrimaryUserId
public Integer getPrimaryUserId ()
Gửi |
DeviceNotAvailableException |
|
getScreenshot
public InputStreamSource getScreenshot ()
Giá trị trả về |
InputStreamSource |
|
Gửi |
DeviceNotAvailableException |
|
getScreenshot
public InputStreamSource getScreenshot (String format,
boolean rescale)
Tham số |
format |
String |
rescale |
boolean |
Giá trị trả về |
InputStreamSource |
|
Gửi |
DeviceNotAvailableException |
|
getScreenshot
public InputStreamSource getScreenshot (String format)
Giá trị trả về |
InputStreamSource |
|
Gửi |
DeviceNotAvailableException |
|
getScreenshot
public InputStreamSource getScreenshot (long displayId)
Giá trị trả về |
InputStreamSource |
|
Gửi |
DeviceNotAvailableException |
|
getSetting
public String getSetting (String namespace,
String key)
Tham số |
namespace |
String |
key |
String |
Gửi |
DeviceNotAvailableException |
|
getSetting
public String getSetting (int userId,
String namespace,
String key)
Tham số |
userId |
int |
namespace |
String |
key |
String |
Gửi |
DeviceNotAvailableException |
|
getUninstallablePackageNames
public getUninstallablePackageNames ()
Gửi |
DeviceNotAvailableException |
|
getUserFlags
public int getUserFlags (int userId)
Gửi |
DeviceNotAvailableException |
|
getUserInfos
public getUserInfos ()
Gửi |
DeviceNotAvailableException |
|
getUserSerialNumber
public int getUserSerialNumber (int userId)
Gửi |
DeviceNotAvailableException |
|
hasFeature
public boolean hasFeature (String feature)
Gửi |
DeviceNotAvailableException |
|
installPackage
public String installPackage (File packageFile,
boolean reinstall,
String... extraArgs)
Tham số |
packageFile |
File |
reinstall |
boolean |
extraArgs |
String |
Gửi |
DeviceNotAvailableException |
|
installPackage
public String installPackage (File packageFile,
File certFile,
boolean reinstall,
String... extraArgs)
Tham số |
packageFile |
File |
certFile |
File |
reinstall |
boolean |
extraArgs |
String |
Gửi |
DeviceNotAvailableException |
|
installPackage
public String installPackage (File packageFile,
boolean reinstall,
boolean grantPermissions,
String... extraArgs)
Tham số |
packageFile |
File |
reinstall |
boolean |
grantPermissions |
boolean |
extraArgs |
String |
Gửi |
DeviceNotAvailableException |
|
installPackageForUser
public String installPackageForUser (File packageFile,
boolean reinstall,
boolean grantPermissions,
int userId,
String... extraArgs)
Tham số |
packageFile |
File |
reinstall |
boolean |
grantPermissions |
boolean |
userId |
int |
extraArgs |
String |
Gửi |
DeviceNotAvailableException |
|
installPackageForUser
public String installPackageForUser (File packageFile,
boolean reinstall,
int userId,
String... extraArgs)
Tham số |
packageFile |
File |
reinstall |
boolean |
userId |
int |
extraArgs |
String |
Gửi |
DeviceNotAvailableException |
|
installPackages
public String installPackages ( packageFiles,
boolean reinstall,
String... extraArgs)
Tham số |
packageFiles |
|
reinstall |
boolean |
extraArgs |
String |
Gửi |
DeviceNotAvailableException |
|
installPackages
public String installPackages ( packageFiles,
boolean reinstall,
boolean grantPermissions,
String... extraArgs)
Tham số |
packageFiles |
|
reinstall |
boolean |
grantPermissions |
boolean |
extraArgs |
String |
Gửi |
DeviceNotAvailableException |
|
installPackagesForUser
public String installPackagesForUser ( packageFiles,
boolean reinstall,
boolean grantPermissions,
int userId,
String... extraArgs)
Tham số |
packageFiles |
|
reinstall |
boolean |
grantPermissions |
boolean |
userId |
int |
extraArgs |
String |
Gửi |
DeviceNotAvailableException |
|
installPackagesForUser
public String installPackagesForUser ( packageFiles,
boolean reinstall,
int userId,
String... extraArgs)
Tham số |
packageFiles |
|
reinstall |
boolean |
userId |
int |
extraArgs |
String |
Gửi |
DeviceNotAvailableException |
|
installRemotePackages
public String installRemotePackages ( remoteApkPaths,
boolean reinstall,
boolean grantPermissions,
String... extraArgs)
Tham số |
remoteApkPaths |
|
reinstall |
boolean |
grantPermissions |
boolean |
extraArgs |
String |
Gửi |
DeviceNotAvailableException |
|
installRemotePackages
public String installRemotePackages ( remoteApkPaths,
boolean reinstall,
String... extraArgs)
Tham số |
remoteApkPaths |
|
reinstall |
boolean |
extraArgs |
String |
Gửi |
DeviceNotAvailableException |
|
isAppEnumerationSupported
public boolean isAppEnumerationSupported ()
Gửi |
DeviceNotAvailableException |
|
isMultiUserSupported
public boolean isMultiUserSupported ()
Gửi |
DeviceNotAvailableException |
|
isPackageInstalled
public boolean isPackageInstalled (String packageName)
Tham số |
packageName |
String |
Gửi |
DeviceNotAvailableException |
|
isPackageInstalled
public boolean isPackageInstalled (String packageName,
String userId)
Tham số |
packageName |
String |
userId |
String |
Gửi |
DeviceNotAvailableException |
|
isUserRunning
public boolean isUserRunning (int userId)
Gửi |
DeviceNotAvailableException |
|
isUserSecondary
public boolean isUserSecondary (int userId)
Gửi |
DeviceNotAvailableException |
|
listDisplayIds
public listDisplayIds ()
Gửi |
DeviceNotAvailableException |
|
listUsers
public listUsers ()
Gửi |
DeviceNotAvailableException |
|
postInvocationTearDown
public void postInvocationTearDown (Throwable exception)
Tham số |
exception |
Throwable |
removeAdmin
public boolean removeAdmin (String componentName,
int userId)
Tham số |
componentName |
String |
userId |
int |
Gửi |
DeviceNotAvailableException |
|
removeOwners
public void removeOwners ()
Gửi |
DeviceNotAvailableException |
|
removeUser
public boolean removeUser (int userId)
Gửi |
DeviceNotAvailableException |
|
setDeviceOwner
public boolean setDeviceOwner (String componentName,
int userId)
Tham số |
componentName |
String |
userId |
int |
Gửi |
DeviceNotAvailableException |
|
setSetting
public void setSetting (String namespace,
String key,
String value)
Tham số |
namespace |
String |
key |
String |
value |
String |
Gửi |
DeviceNotAvailableException |
|
setSetting
public void setSetting (int userId,
String namespace,
String key,
String value)
Tham số |
userId |
int |
namespace |
String |
key |
String |
value |
String |
Gửi |
DeviceNotAvailableException |
|
startUser
public boolean startUser (int userId)
Gửi |
DeviceNotAvailableException |
|
startUser
public boolean startUser (int userId,
boolean waitFlag)
Tham số |
userId |
int |
waitFlag |
boolean |
Gửi |
DeviceNotAvailableException |
|
stopUser
public boolean stopUser (int userId,
boolean waitFlag,
boolean forceFlag)
Tham số |
userId |
int |
waitFlag |
boolean |
forceFlag |
boolean |
Gửi |
DeviceNotAvailableException |
|
stopUser
public boolean stopUser (int userId)
Gửi |
DeviceNotAvailableException |
|
switchUser
public boolean switchUser (int userId)
Gửi |
DeviceNotAvailableException |
|
switchUser
public boolean switchUser (int userId,
long timeout)
Tham số |
userId |
int |
timeout |
long |
Gửi |
DeviceNotAvailableException |
|
uninstallPackage
public String uninstallPackage (String packageName)
Tham số |
packageName |
String |
Gửi |
DeviceNotAvailableException |
|
uninstallPackageForUser
public String uninstallPackageForUser (String packageName,
int userId)
Tham số |
packageName |
String |
userId |
int |
Gửi |
DeviceNotAvailableException |
|
Phương thức được bảo vệ
doAdbReboot
protected void doAdbReboot (NativeDevice.RebootMode rebootMode,
String reason)
Khởi động lại adb.
Tham số |
rebootMode |
NativeDevice.RebootMode : chế độ khởi động lại này. |
reason |
String : cho lần khởi động lại này. |
Gửi |
DeviceNotAvailableException |
|
getCheckNewUserSleep
protected long getCheckNewUserSleep ()
Được hiển thị để kiểm thử.
getHostCurrentTime
protected long getHostCurrentTime ()
Được hiển thị để kiểm thử
prePostBootSetup
protected void prePostBootSetup ()
Cho phép mỗi loại thiết bị (AndroidNativeDevice, TestDevice) ghi đè phương thức này để thiết lập cụ thể sau khi khởi động.
Gửi |
DeviceNotAvailableException |
|
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-03-26 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-03-26 UTC."],[],[]]