TestDevice
public
class
TestDevice
extends NativeDevice
| java.lang.Object | ||
| ↳ | com.android.tradefed.device.NativeDevice | |
| ↳ | com.android.tradefed.device.TestDevice | |
為完整堆疊 Android 裝置實作 ITestDevice
摘要
欄位 | |
|---|---|
public
static
final
String |
DISMISS_KEYGUARD_CMD
可用來關閉螢幕鎖定畫面的指令。 |
公用建構函式 | |
|---|---|
TestDevice(IDevice device, IDeviceStateMonitor stateMonitor, IDeviceMonitor allocationMonitor)
|
|
公用方法 | |
|---|---|
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(
|
String
|
installPackages(
|
String
|
installPackagesForUser(
|
String
|
installPackagesForUser(
|
String
|
installRemotePackages(
|
String
|
installRemotePackages(
|
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)
|
受保護的方法 | |
|---|---|
void
|
doAdbReboot(NativeDevice.RebootMode rebootMode, String reason)
執行 ADB 重新啟動。 |
long
|
getCheckNewUserSleep()
供測試使用。 |
long
|
getHostCurrentTime()
已公開測試 |
void
|
prePostBootSetup()
允許每個裝置類型 (AndroidNativeDevice、TestDevice) 針對特定的開機後設定覆寫此方法。 |
欄位
DISMISS_KEYGUARD_CMD
public static final String DISMISS_KEYGUARD_CMD
可用來關閉螢幕鎖定畫面的指令。
公用建構函式
TestDevice
public TestDevice (IDevice device,
IDeviceStateMonitor stateMonitor,
IDeviceMonitor allocationMonitor)公用方法
clearErrorDialogs
public boolean clearErrorDialogs ()
| 傳回 | |
|---|---|
boolean |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
createUser
public int createUser (String name)
| 參數 | |
|---|---|
name |
String |
| 傳回 | |
|---|---|
int |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
createUser
public int createUser (String name,
boolean guest,
boolean ephemeral)
| 參數 | |
|---|---|
name |
String |
guest |
boolean |
ephemeral |
boolean |
| 傳回 | |
|---|---|
int |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
createUserNoThrow
public int createUserNoThrow (String name)
| 參數 | |
|---|---|
name |
String |
| 傳回 | |
|---|---|
int |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
disableKeyguard
public void disableKeyguard ()
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
doesFileExist
public boolean doesFileExist (String deviceFilePath)
| 參數 | |
|---|---|
deviceFilePath |
String |
| 傳回 | |
|---|---|
boolean |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
dumpHeap
public File dumpHeap (String process,
String devicePath)
| 參數 | |
|---|---|
process |
String |
devicePath |
String |
| 傳回 | |
|---|---|
File |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
getActiveApexes
publicgetActiveApexes ()
| 傳回 | |
|---|---|
|
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
getAllSettings
publicgetAllSettings (String namespace)
| 參數 | |
|---|---|
namespace |
String |
| 傳回 | |
|---|---|
|
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
getAndroidId
public String getAndroidId (int userId)
| 參數 | |
|---|---|
userId |
int |
| 傳回 | |
|---|---|
String |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
getAndroidIds
publicgetAndroidIds ()
| 傳回 | |
|---|---|
|
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
getAppPackageInfo
public PackageInfo getAppPackageInfo (String packageName)
| 參數 | |
|---|---|
packageName |
String |
| 傳回 | |
|---|---|
PackageInfo |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
getAppPackageInfos
publicgetAppPackageInfos ()
| 傳回 | |
|---|---|
|
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
getCurrentFoldableState
public DeviceFoldableState getCurrentFoldableState ()
| 傳回 | |
|---|---|
DeviceFoldableState |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
getCurrentUser
public int getCurrentUser ()
| 傳回 | |
|---|---|
int |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
getFoldableStates
publicgetFoldableStates ()
| 傳回 | |
|---|---|
|
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
getInstalledPackageNames
publicgetInstalledPackageNames ()
| 傳回 | |
|---|---|
|
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
getKeyguardState
public KeyguardControllerState getKeyguardState ()
| 傳回 | |
|---|---|
KeyguardControllerState |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
getMainlineModuleInfo
publicgetMainlineModuleInfo ()
| 傳回 | |
|---|---|
|
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
getMaxNumberOfRunningUsersSupported
public int getMaxNumberOfRunningUsersSupported ()
| 傳回 | |
|---|---|
int |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
getMaxNumberOfUsersSupported
public int getMaxNumberOfUsersSupported ()
| 傳回 | |
|---|---|
int |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
getPrimaryUserId
public Integer getPrimaryUserId ()
| 傳回 | |
|---|---|
Integer |
|
| 擲回 | |
|---|---|
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 |
| 傳回 | |
|---|---|
String |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
getSetting
public String getSetting (int userId,
String namespace,
String key)
| 參數 | |
|---|---|
userId |
int |
namespace |
String |
key |
String |
| 傳回 | |
|---|---|
String |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
getUninstallablePackageNames
publicgetUninstallablePackageNames ()
| 傳回 | |
|---|---|
|
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
getUserFlags
public int getUserFlags (int userId)
| 參數 | |
|---|---|
userId |
int |
| 傳回 | |
|---|---|
int |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
getUserInfos
publicgetUserInfos ()
| 傳回 | |
|---|---|
|
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
getUserSerialNumber
public int getUserSerialNumber (int userId)
| 參數 | |
|---|---|
userId |
int |
| 傳回 | |
|---|---|
int |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
hasFeature
public boolean hasFeature (String feature)
| 參數 | |
|---|---|
feature |
String |
| 傳回 | |
|---|---|
boolean |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
installPackage
public String installPackage (File packageFile,
boolean reinstall,
String... extraArgs)
| 參數 | |
|---|---|
packageFile |
File |
reinstall |
boolean |
extraArgs |
String |
| 傳回 | |
|---|---|
String |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
installPackage
public String installPackage (File packageFile,
File certFile,
boolean reinstall,
String... extraArgs)
| 參數 | |
|---|---|
packageFile |
File |
certFile |
File |
reinstall |
boolean |
extraArgs |
String |
| 傳回 | |
|---|---|
String |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
installPackage
public String installPackage (File packageFile,
boolean reinstall,
boolean grantPermissions,
String... extraArgs)
| 參數 | |
|---|---|
packageFile |
File |
reinstall |
boolean |
grantPermissions |
boolean |
extraArgs |
String |
| 傳回 | |
|---|---|
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 |
| 傳回 | |
|---|---|
String |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
installPackageForUser
public String installPackageForUser (File packageFile,
boolean reinstall,
int userId,
String... extraArgs)
| 參數 | |
|---|---|
packageFile |
File |
reinstall |
boolean |
userId |
int |
extraArgs |
String |
| 傳回 | |
|---|---|
String |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
installPackages
public String installPackages (packageFiles, boolean reinstall, String... extraArgs)
| 參數 | |
|---|---|
packageFiles |
|
reinstall |
boolean |
extraArgs |
String |
| 傳回 | |
|---|---|
String |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
installPackages
public String installPackages (packageFiles, boolean reinstall, boolean grantPermissions, String... extraArgs)
| 參數 | |
|---|---|
packageFiles |
|
reinstall |
boolean |
grantPermissions |
boolean |
extraArgs |
String |
| 傳回 | |
|---|---|
String |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
installPackagesForUser
public String installPackagesForUser (packageFiles, boolean reinstall, boolean grantPermissions, int userId, String... extraArgs)
| 參數 | |
|---|---|
packageFiles |
|
reinstall |
boolean |
grantPermissions |
boolean |
userId |
int |
extraArgs |
String |
| 傳回 | |
|---|---|
String |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
installPackagesForUser
public String installPackagesForUser (packageFiles, boolean reinstall, int userId, String... extraArgs)
| 參數 | |
|---|---|
packageFiles |
|
reinstall |
boolean |
userId |
int |
extraArgs |
String |
| 傳回 | |
|---|---|
String |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
installRemotePackages
public String installRemotePackages (remoteApkPaths, boolean reinstall, boolean grantPermissions, String... extraArgs)
| 參數 | |
|---|---|
remoteApkPaths |
|
reinstall |
boolean |
grantPermissions |
boolean |
extraArgs |
String |
| 傳回 | |
|---|---|
String |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
installRemotePackages
public String installRemotePackages (remoteApkPaths, boolean reinstall, String... extraArgs)
| 參數 | |
|---|---|
remoteApkPaths |
|
reinstall |
boolean |
extraArgs |
String |
| 傳回 | |
|---|---|
String |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
isAppEnumerationSupported
public boolean isAppEnumerationSupported ()
| 傳回 | |
|---|---|
boolean |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
isMultiUserSupported
public boolean isMultiUserSupported ()
| 傳回 | |
|---|---|
boolean |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
isPackageInstalled
public boolean isPackageInstalled (String packageName)
| 參數 | |
|---|---|
packageName |
String |
| 傳回 | |
|---|---|
boolean |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
isPackageInstalled
public boolean isPackageInstalled (String packageName,
String userId)
| 參數 | |
|---|---|
packageName |
String |
userId |
String |
| 傳回 | |
|---|---|
boolean |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
isUserRunning
public boolean isUserRunning (int userId)
| 參數 | |
|---|---|
userId |
int |
| 傳回 | |
|---|---|
boolean |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
isUserSecondary
public boolean isUserSecondary (int userId)
| 參數 | |
|---|---|
userId |
int |
| 傳回 | |
|---|---|
boolean |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
listDisplayIds
publiclistDisplayIds ()
| 傳回 | |
|---|---|
|
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
listUsers
publiclistUsers ()
| 傳回 | |
|---|---|
|
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
postInvocationTearDown
public void postInvocationTearDown (Throwable exception)
| 參數 | |
|---|---|
exception |
Throwable |
removeAdmin
public boolean removeAdmin (String componentName,
int userId)
| 參數 | |
|---|---|
componentName |
String |
userId |
int |
| 傳回 | |
|---|---|
boolean |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
removeOwners
public void removeOwners ()
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
removeUser
public boolean removeUser (int userId)
| 參數 | |
|---|---|
userId |
int |
| 傳回 | |
|---|---|
boolean |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
setDeviceOwner
public boolean setDeviceOwner (String componentName,
int userId)
| 參數 | |
|---|---|
componentName |
String |
userId |
int |
| 傳回 | |
|---|---|
boolean |
|
| 擲回 | |
|---|---|
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)
| 參數 | |
|---|---|
userId |
int |
| 傳回 | |
|---|---|
boolean |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
startUser
public boolean startUser (int userId,
boolean waitFlag)
| 參數 | |
|---|---|
userId |
int |
waitFlag |
boolean |
| 傳回 | |
|---|---|
boolean |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
stopUser
public boolean stopUser (int userId,
boolean waitFlag,
boolean forceFlag)
| 參數 | |
|---|---|
userId |
int |
waitFlag |
boolean |
forceFlag |
boolean |
| 傳回 | |
|---|---|
boolean |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
stopUser
public boolean stopUser (int userId)
| 參數 | |
|---|---|
userId |
int |
| 傳回 | |
|---|---|
boolean |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
switchUser
public boolean switchUser (int userId)
| 參數 | |
|---|---|
userId |
int |
| 傳回 | |
|---|---|
boolean |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
switchUser
public boolean switchUser (int userId,
long timeout)
| 參數 | |
|---|---|
userId |
int |
timeout |
long |
| 傳回 | |
|---|---|
boolean |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
uninstallPackage
public String uninstallPackage (String packageName)
| 參數 | |
|---|---|
packageName |
String |
| 傳回 | |
|---|---|
String |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
uninstallPackageForUser
public String uninstallPackageForUser (String packageName,
int userId)
| 參數 | |
|---|---|
packageName |
String |
userId |
int |
| 傳回 | |
|---|---|
String |
|
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
受保護的方法
doAdbReboot
protected void doAdbReboot (NativeDevice.RebootMode rebootMode, String reason)
執行 ADB 重新啟動。
| 參數 | |
|---|---|
rebootMode |
NativeDevice.RebootMode:此重新啟動模式。 |
reason |
String:針對這次重新啟動。 |
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
getCheckNewUserSleep
protected long getCheckNewUserSleep ()
已公開供測試。
| 傳回 | |
|---|---|
long |
|
getHostCurrentTime
protected long getHostCurrentTime ()
已公開測試
| 傳回 | |
|---|---|
long |
|
prePostBootSetup
protected void prePostBootSetup ()
允許每個裝置類型 (AndroidNativeDevice、TestDevice) 針對特定的開機後設定覆寫此方法。
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|