ตั้งแต่วันที่ 27 มีนาคม 2025 เป็นต้นไป เราขอแนะนำให้ใช้ android-latest-release
แทน aosp-main
เพื่อสร้างและมีส่วนร่วมใน AOSP โปรดดูข้อมูลเพิ่มเติมที่หัวข้อการเปลี่ยนแปลงใน AOSP
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
TestDevice
public
class
TestDevice
extends NativeDevice
การติดตั้งใช้งาน ITestDevice
สําหรับอุปกรณ์ Android แบบสแต็กเต็ม
สรุป
เมธอดสาธารณะ |
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)
|
ช่อง
DISMISS_KEYGUARD_CMD
public static final String DISMISS_KEYGUARD_CMD
คำสั่งที่ใช้ปิดโปรแกรมป้องกันหน้าจอได้
ตัวสร้างแบบสาธารณะ
TestDevice
public TestDevice (IDevice device,
IDeviceStateMonitor stateMonitor,
IDeviceMonitor allocationMonitor)
เมธอดสาธารณะ
clearErrorDialogs
public boolean clearErrorDialogs ()
การโยน |
DeviceNotAvailableException |
|
createUser
public int createUser (String name)
การโยน |
DeviceNotAvailableException |
|
createUser
public int createUser (String name,
boolean guest,
boolean ephemeral)
พารามิเตอร์ |
name |
String |
guest |
boolean |
ephemeral |
boolean |
การโยน |
DeviceNotAvailableException |
|
createUserNoThrow
public int createUserNoThrow (String name)
การโยน |
DeviceNotAvailableException |
|
disableKeyguard
public void disableKeyguard ()
การโยน |
DeviceNotAvailableException |
|
doesFileExist
public boolean doesFileExist (String deviceFilePath)
พารามิเตอร์ |
deviceFilePath |
String |
การโยน |
DeviceNotAvailableException |
|
dumpHeap
public File dumpHeap (String process,
String devicePath)
พารามิเตอร์ |
process |
String |
devicePath |
String |
การโยน |
DeviceNotAvailableException |
|
getActiveApexes
public getActiveApexes ()
การโยน |
DeviceNotAvailableException |
|
getAllSettings
public getAllSettings (String namespace)
พารามิเตอร์ |
namespace |
String |
การโยน |
DeviceNotAvailableException |
|
getAndroidId
public String getAndroidId (int userId)
การโยน |
DeviceNotAvailableException |
|
getAndroidIds
public getAndroidIds ()
การโยน |
DeviceNotAvailableException |
|
getAppPackageInfo
public PackageInfo getAppPackageInfo (String packageName)
พารามิเตอร์ |
packageName |
String |
การโยน |
DeviceNotAvailableException |
|
getAppPackageInfos
public getAppPackageInfos ()
การโยน |
DeviceNotAvailableException |
|
getCurrentFoldableState
public DeviceFoldableState getCurrentFoldableState ()
คิกรีเทิร์น |
DeviceFoldableState |
|
การโยน |
DeviceNotAvailableException |
|
getCurrentUser
public int getCurrentUser ()
การโยน |
DeviceNotAvailableException |
|
getFoldableStates
public getFoldableStates ()
การโยน |
DeviceNotAvailableException |
|
getInstalledPackageNames
public getInstalledPackageNames ()
การโยน |
DeviceNotAvailableException |
|
getKeyguardState
public KeyguardControllerState getKeyguardState ()
คิกรีเทิร์น |
KeyguardControllerState |
|
การโยน |
DeviceNotAvailableException |
|
getMainlineModuleInfo
public getMainlineModuleInfo ()
การโยน |
DeviceNotAvailableException |
|
public int getMaxNumberOfRunningUsersSupported ()
การโยน |
DeviceNotAvailableException |
|
public int getMaxNumberOfUsersSupported ()
การโยน |
DeviceNotAvailableException |
|
getPrimaryUserId
public Integer getPrimaryUserId ()
การโยน |
DeviceNotAvailableException |
|
getScreenshot
public InputStreamSource getScreenshot ()
คิกรีเทิร์น |
InputStreamSource |
|
การโยน |
DeviceNotAvailableException |
|
getScreenshot
public InputStreamSource getScreenshot (String format,
boolean rescale)
พารามิเตอร์ |
format |
String |
rescale |
boolean |
คิกรีเทิร์น |
InputStreamSource |
|
การโยน |
DeviceNotAvailableException |
|
getScreenshot
public InputStreamSource getScreenshot (String format)
พารามิเตอร์ |
format |
String |
คิกรีเทิร์น |
InputStreamSource |
|
การโยน |
DeviceNotAvailableException |
|
getScreenshot
public InputStreamSource getScreenshot (long displayId)
พารามิเตอร์ |
displayId |
long |
คิกรีเทิร์น |
InputStreamSource |
|
การโยน |
DeviceNotAvailableException |
|
getSetting
public String getSetting (String namespace,
String key)
พารามิเตอร์ |
namespace |
String |
key |
String |
การโยน |
DeviceNotAvailableException |
|
getSetting
public String getSetting (int userId,
String namespace,
String key)
พารามิเตอร์ |
userId |
int |
namespace |
String |
key |
String |
การโยน |
DeviceNotAvailableException |
|
getUninstallablePackageNames
public getUninstallablePackageNames ()
การโยน |
DeviceNotAvailableException |
|
getUserFlags
public int getUserFlags (int userId)
การโยน |
DeviceNotAvailableException |
|
getUserInfos
public getUserInfos ()
การโยน |
DeviceNotAvailableException |
|
getUserSerialNumber
public int getUserSerialNumber (int userId)
การโยน |
DeviceNotAvailableException |
|
hasFeature
public boolean hasFeature (String feature)
พารามิเตอร์ |
feature |
String |
การโยน |
DeviceNotAvailableException |
|
installPackage
public String installPackage (File packageFile,
boolean reinstall,
String... extraArgs)
พารามิเตอร์ |
packageFile |
File |
reinstall |
boolean |
extraArgs |
String |
การโยน |
DeviceNotAvailableException |
|
installPackage
public String installPackage (File packageFile,
File certFile,
boolean reinstall,
String... extraArgs)
พารามิเตอร์ |
packageFile |
File |
certFile |
File |
reinstall |
boolean |
extraArgs |
String |
การโยน |
DeviceNotAvailableException |
|
installPackage
public String installPackage (File packageFile,
boolean reinstall,
boolean grantPermissions,
String... extraArgs)
พารามิเตอร์ |
packageFile |
File |
reinstall |
boolean |
grantPermissions |
boolean |
extraArgs |
String |
การโยน |
DeviceNotAvailableException |
|
installPackageForUser
public String installPackageForUser (File packageFile,
boolean reinstall,
boolean grantPermissions,
int userId,
String... extraArgs)
พารามิเตอร์ |
packageFile |
File |
reinstall |
boolean |
grantPermissions |
boolean |
userId |
int |
extraArgs |
String |
การโยน |
DeviceNotAvailableException |
|
installPackageForUser
public String installPackageForUser (File packageFile,
boolean reinstall,
int userId,
String... extraArgs)
พารามิเตอร์ |
packageFile |
File |
reinstall |
boolean |
userId |
int |
extraArgs |
String |
การโยน |
DeviceNotAvailableException |
|
installPackages
public String installPackages ( packageFiles,
boolean reinstall,
String... extraArgs)
พารามิเตอร์ |
packageFiles |
|
reinstall |
boolean |
extraArgs |
String |
การโยน |
DeviceNotAvailableException |
|
installPackages
public String installPackages ( packageFiles,
boolean reinstall,
boolean grantPermissions,
String... extraArgs)
พารามิเตอร์ |
packageFiles |
|
reinstall |
boolean |
grantPermissions |
boolean |
extraArgs |
String |
การโยน |
DeviceNotAvailableException |
|
installPackagesForUser
public String installPackagesForUser ( packageFiles,
boolean reinstall,
boolean grantPermissions,
int userId,
String... extraArgs)
พารามิเตอร์ |
packageFiles |
|
reinstall |
boolean |
grantPermissions |
boolean |
userId |
int |
extraArgs |
String |
การโยน |
DeviceNotAvailableException |
|
installPackagesForUser
public String installPackagesForUser ( packageFiles,
boolean reinstall,
int userId,
String... extraArgs)
พารามิเตอร์ |
packageFiles |
|
reinstall |
boolean |
userId |
int |
extraArgs |
String |
การโยน |
DeviceNotAvailableException |
|
installRemotePackages
public String installRemotePackages ( remoteApkPaths,
boolean reinstall,
boolean grantPermissions,
String... extraArgs)
พารามิเตอร์ |
remoteApkPaths |
|
reinstall |
boolean |
grantPermissions |
boolean |
extraArgs |
String |
การโยน |
DeviceNotAvailableException |
|
installRemotePackages
public String installRemotePackages ( remoteApkPaths,
boolean reinstall,
String... extraArgs)
พารามิเตอร์ |
remoteApkPaths |
|
reinstall |
boolean |
extraArgs |
String |
การโยน |
DeviceNotAvailableException |
|
isAppEnumerationSupported
public boolean isAppEnumerationSupported ()
การโยน |
DeviceNotAvailableException |
|
isMultiUserSupported
public boolean isMultiUserSupported ()
การโยน |
DeviceNotAvailableException |
|
isPackageInstalled
public boolean isPackageInstalled (String packageName)
พารามิเตอร์ |
packageName |
String |
การโยน |
DeviceNotAvailableException |
|
isPackageInstalled
public boolean isPackageInstalled (String packageName,
String userId)
พารามิเตอร์ |
packageName |
String |
userId |
String |
การโยน |
DeviceNotAvailableException |
|
isUserRunning
public boolean isUserRunning (int userId)
การโยน |
DeviceNotAvailableException |
|
isUserSecondary
public boolean isUserSecondary (int userId)
การโยน |
DeviceNotAvailableException |
|
listDisplayIds
public listDisplayIds ()
การโยน |
DeviceNotAvailableException |
|
listUsers
public listUsers ()
การโยน |
DeviceNotAvailableException |
|
postInvocationTearDown
public void postInvocationTearDown (Throwable exception)
พารามิเตอร์ |
exception |
Throwable |
removeAdmin
public boolean removeAdmin (String componentName,
int userId)
พารามิเตอร์ |
componentName |
String |
userId |
int |
การโยน |
DeviceNotAvailableException |
|
removeOwners
public void removeOwners ()
การโยน |
DeviceNotAvailableException |
|
removeUser
public boolean removeUser (int userId)
การโยน |
DeviceNotAvailableException |
|
setDeviceOwner
public boolean setDeviceOwner (String componentName,
int userId)
พารามิเตอร์ |
componentName |
String |
userId |
int |
การโยน |
DeviceNotAvailableException |
|
setSetting
public void setSetting (String namespace,
String key,
String value)
พารามิเตอร์ |
namespace |
String |
key |
String |
value |
String |
การโยน |
DeviceNotAvailableException |
|
setSetting
public void setSetting (int userId,
String namespace,
String key,
String value)
พารามิเตอร์ |
userId |
int |
namespace |
String |
key |
String |
value |
String |
การโยน |
DeviceNotAvailableException |
|
startUser
public boolean startUser (int userId)
การโยน |
DeviceNotAvailableException |
|
startUser
public boolean startUser (int userId,
boolean waitFlag)
พารามิเตอร์ |
userId |
int |
waitFlag |
boolean |
การโยน |
DeviceNotAvailableException |
|
stopUser
public boolean stopUser (int userId,
boolean waitFlag,
boolean forceFlag)
พารามิเตอร์ |
userId |
int |
waitFlag |
boolean |
forceFlag |
boolean |
การโยน |
DeviceNotAvailableException |
|
stopUser
public boolean stopUser (int userId)
การโยน |
DeviceNotAvailableException |
|
switchUser
public boolean switchUser (int userId)
การโยน |
DeviceNotAvailableException |
|
switchUser
public boolean switchUser (int userId,
long timeout)
พารามิเตอร์ |
userId |
int |
timeout |
long |
การโยน |
DeviceNotAvailableException |
|
uninstallPackage
public String uninstallPackage (String packageName)
พารามิเตอร์ |
packageName |
String |
การโยน |
DeviceNotAvailableException |
|
uninstallPackageForUser
public String uninstallPackageForUser (String packageName,
int userId)
พารามิเตอร์ |
packageName |
String |
userId |
int |
การโยน |
DeviceNotAvailableException |
|
วิธีการที่มีการป้องกัน
doAdbReboot
protected void doAdbReboot (NativeDevice.RebootMode rebootMode,
String reason)
รีบูต adb
พารามิเตอร์ |
rebootMode |
NativeDevice.RebootMode : โหมดของการรีบูตนี้ |
reason |
String : สำหรับการรีบูตครั้งนี้ |
การโยน |
DeviceNotAvailableException |
|
getCheckNewUserSleep
protected long getCheckNewUserSleep ()
แสดงเพื่อทดสอบ
getHostCurrentTime
protected long getHostCurrentTime ()
แสดงในการทดสอบ
prePostBootSetup
protected void prePostBootSetup ()
อนุญาตให้อุปกรณ์แต่ละประเภท (AndroidNativeDevice, TestDevice) ลบล้างวิธีการนี้สำหรับการตั้งค่าหลังการบูตที่เฉพาะเจาะจง
การโยน |
DeviceNotAvailableException |
|
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-03-26 UTC
[[["เข้าใจง่าย","easyToUnderstand","thumb-up"],["แก้ปัญหาของฉันได้","solvedMyProblem","thumb-up"],["อื่นๆ","otherUp","thumb-up"]],[["ไม่มีข้อมูลที่ฉันต้องการ","missingTheInformationINeed","thumb-down"],["ซับซ้อนเกินไป/มีหลายขั้นตอนมากเกินไป","tooComplicatedTooManySteps","thumb-down"],["ล้าสมัย","outOfDate","thumb-down"],["ปัญหาเกี่ยวกับการแปล","translationIssue","thumb-down"],["ตัวอย่าง/ปัญหาเกี่ยวกับโค้ด","samplesCodeIssue","thumb-down"],["อื่นๆ","otherDown","thumb-down"]],["อัปเดตล่าสุด 2025-03-26 UTC"],[],[]]