NativeDevice
public
class
NativeDevice
extends Object
implements
IManagedTestDevice,
IConfigurationReceiver
java.lang.Object | |
↳ | com.android.tradefed.device.NativeDevice |
ITestDevice
非完整堆栈 Android 设备的默认实现。
摘要
嵌套类 | |
---|---|
class |
NativeDevice.AdbAction
用于运行操作系统“adb ....”命令的 |
class |
NativeDevice.AdbShellAction
|
class |
NativeDevice.RebootDeviceAction
|
enum |
NativeDevice.RebootMode
重新启动模式。 |
常量 | |
---|---|
int |
INVALID_USER_ID
针对任何无效/未找到的用户 ID 返回的值:UserHandle 定义了 -10000 值 |
long |
MAX_HOST_DEVICE_TIME_OFFSET
|
int |
MAX_RETRY_ATTEMPTS
要执行的默认命令重试尝试次数 |
字段 | |
---|---|
protected
static
final
String |
SD_CARD
|
protected
static
final
String |
STORAGE_EMULATED
|
protected
TestDeviceOptions |
mOptions
|
protected
final
IDeviceStateMonitor |
mStateMonitor
|
公共构造函数 | |
---|---|
NativeDevice(IDevice device, IDeviceStateMonitor stateMonitor, IDeviceMonitor allocationMonitor)
创建 |
公共方法 | |
---|---|
boolean
|
checkApiLevelAgainstNextRelease(int strictMinLevel)
|
boolean
|
checkConnectivity()
|
boolean
|
clearErrorDialogs()
|
void
|
clearLastConnectedWifiNetwork()
|
void
|
clearLogcat()
|
boolean
|
connectToWifiNetwork(String wifiSsid, String wifiPsk)
|
boolean
|
connectToWifiNetwork(String wifiSsid, String wifiPsk, boolean scanSsid)
|
boolean
|
connectToWifiNetworkIfNeeded(String wifiSsid, String wifiPsk, boolean scanSsid)
|
boolean
|
connectToWifiNetworkIfNeeded(String wifiSsid, String wifiPsk)
|
int
|
createUser(String name, boolean guest, boolean ephemeral)
|
int
|
createUser(String name)
|
int
|
createUserNoThrow(String name)
|
void
|
deleteFile(String deviceFilePath)
|
boolean
|
deviceSoftRestarted(ProcessInfo prevSystemServerProcess)
|
boolean
|
deviceSoftRestartedSince(long utcEpochTime, TimeUnit timeUnit)
|
boolean
|
disableAdbRoot()
|
void
|
disableKeyguard()
|
boolean
|
disableNetworkMonitor()
|
boolean
|
disconnectFromWifi()
|
boolean
|
doesFileExist(String deviceFilePath)
|
File
|
dumpHeap(String process, String devicePath)
|
boolean
|
enableAdbRoot()
|
boolean
|
enableNetworkMonitor()
|
boolean
|
encryptDevice(boolean inplace)
|
String
|
executeAdbCommand(long timeout, String... cmdArgs)
|
String
|
executeAdbCommand(String... cmdArgs)
|
CommandResult
|
executeFastbootCommand(String... cmdArgs)
|
CommandResult
|
executeFastbootCommand(long timeout, String... cmdArgs)
|
CommandResult
|
executeLongFastbootCommand(String... cmdArgs)
|
String
|
executeShellCommand(String command)
|
void
|
executeShellCommand(String command, IShellOutputReceiver receiver, long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts)
|
void
|
executeShellCommand(String command, IShellOutputReceiver receiver, long maxTimeoutForCommand, long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts)
|
void
|
executeShellCommand(String command, IShellOutputReceiver receiver)
|
CommandResult
|
executeShellV2Command(String cmd)
|
CommandResult
|
executeShellV2Command(String cmd, OutputStream pipeToOutput)
|
CommandResult
|
executeShellV2Command(String cmd, File pipeAsInput)
|
CommandResult
|
executeShellV2Command(String cmd, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts)
|
CommandResult
|
executeShellV2Command(String cmd, long maxTimeoutForCommand, TimeUnit timeUnit)
|
CommandResult
|
executeShellV2Command(String cmd, File pipeAsInput, OutputStream pipeToOutput, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts)
|
CommandResult
|
executeShellV2Command(String cmd, File pipeAsInput, OutputStream pipeToOutput, OutputStream pipeToError, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts)
|
CommandResult
|
fastbootWipePartition(String partition)
|
|
getActiveApexes()
|
|
getAllSettings(String namespace)
|
DeviceAllocationState
|
getAllocationState()
|
String
|
getAndroidId(int userId)
|
|
getAndroidIds()
|
int
|
getApiLevel()
|
PackageInfo
|
getAppPackageInfo(String packageName)
|
|
getAppPackageInfos()
|
String
|
getBasebandVersion()
|
Integer
|
getBattery()
|
boolean
|
getBooleanProperty(String name, boolean defaultValue)
|
|
getBootHistory()
|
|
getBootHistorySince(long utcEpochTime, TimeUnit timeUnit)
|
String
|
getBootloaderVersion()
|
InputStreamSource
|
getBugreport()
|
InputStreamSource
|
getBugreportz()
|
String
|
getBuildAlias()
|
String
|
getBuildFlavor()
|
String
|
getBuildId()
|
String
|
getBuildSigningKeys()
|
DeviceDescriptor
|
getCachedDeviceDescriptor()
|
String[]
|
getChildren(String path)
|
DeviceFoldableState
|
getCurrentFoldableState()
|
int
|
getCurrentUser()
|
String
|
getDeviceClass()
|
long
|
getDeviceDate()
|
DeviceDescriptor
|
getDeviceDescriptor()
|
TestDeviceState
|
getDeviceState()
|
long
|
getDeviceTimeOffset(Date date)
|
InputStreamSource
|
getEmulatorOutput()
|
Process
|
getEmulatorProcess()
|
final
File
|
getExecuteShellCommandLog()
包含所有 |
long
|
getExternalStoreFreeSpace()
|
String
|
getFastbootPath()
|
String
|
getFastbootProductType()
|
String
|
getFastbootProductVariant()
|
String
|
getFastbootSerialNumber()
|
String
|
getFastbootVariable(String variableName)
|
String
|
getFastbootVersion()
|
IFileEntry
|
getFileEntry(String path)
|
IFileEntry
|
getFileEntry(FileListingService.FileEntry entry)
用于从非根路径获取 |
|
getFoldableStates()
|
IDevice
|
getIDevice()
|
|
getInstalledPackageNames()
|
long
|
getIntProperty(String name, long defaultValue)
|
String
|
getIpAddress()
|
KeyguardControllerState
|
getKeyguardState()
|
long
|
getLastExpectedRebootTimeMillis()
|
int
|
getLaunchApiLevel()
|
InputStreamSource
|
getLogcat()
|
InputStreamSource
|
getLogcat(int maxBytes)
|
InputStreamSource
|
getLogcatDump()
|
InputStreamSource
|
getLogcatSince(long date)
|
String
|
getMacAddress()
|
|
getMainlineModuleInfo()
|
int
|
getMaxNumberOfRunningUsersSupported()
|
int
|
getMaxNumberOfUsersSupported()
|
IDeviceStateMonitor
|
getMonitor()
|
String
|
getMountPoint(String mountName)
|
ITestDevice.MountPointInfo
|
getMountPointInfo(String mountpoint)
|
|
getMountPointInfo()
|
TestDeviceOptions
|
getOptions()
|
long
|
getPartitionFreeSpace(String partition)
|
Integer
|
getPrimaryUserId()
|
ProcessInfo
|
getProcessByName(String processName)
|
String
|
getProcessPid(String process)
|
String
|
getProductType()
|
String
|
getProductVariant()
|
String
|
getProperty(String name)
|
ITestDevice.RecoveryMode
|
getRecoveryMode()
|
InputStreamSource
|
getScreenshot(String format)
|
InputStreamSource
|
getScreenshot(long displayId)
|
InputStreamSource
|
getScreenshot(String format, boolean rescale)
|
InputStreamSource
|
getScreenshot()
|
String
|
getSerialNumber()
|
String
|
getSetting(int userId, String namespace, String key)
|
String
|
getSetting(String namespace, String key)
|
String
|
getSimOperator()
|
String
|
getSimState()
|
|
getTombstones()
|
long
|
getTotalMemory()
|
|
getUninstallablePackageNames()
|
boolean
|
getUseFastbootErase()
|
int
|
getUserFlags(int userId)
|
|
getUserInfos()
|
int
|
getUserSerialNumber(int userId)
|
IManagedTestDevice.DeviceEventResponse
|
handleAllocationEvent(DeviceEvent event)
处理 DeviceEvent,此操作可能会或可能不会将此设备转换为新的分配状态。 |
boolean
|
hasFeature(String feature)
|
String
|
installPackage(File packageFile, boolean reinstall, String... extraArgs)
|
String
|
installPackage(File packageFile, boolean reinstall, boolean grantPermissions, String... extraArgs)
|
String
|
installPackageForUser(File packageFile, boolean reinstall, int userId, String... extraArgs)
|
String
|
installPackageForUser(File packageFile, boolean reinstall, boolean grantPermissions, int userId, String... extraArgs)
|
boolean
|
isAdbRoot()
|
boolean
|
isAdbTcp()
|
boolean
|
isAppEnumerationSupported()
|
boolean
|
isDeviceEncrypted()
|
boolean
|
isDirectory(String path)
|
boolean
|
isEnableAdbRoot()
|
boolean
|
isEncryptionSupported()
|
boolean
|
isExecutable(String fullPath)
|
boolean
|
isFastbootEnabled()
|
boolean
|
isHeadless()
|
boolean
|
isMultiUserSupported()
|
boolean
|
isPackageInstalled(String packageName, String userId)
|
boolean
|
isPackageInstalled(String packageName)
|
boolean
|
isRuntimePermissionSupported()
|
boolean
|
isStateBootloaderOrFastbootd()
|
boolean
|
isUserRunning(int userId)
|
boolean
|
isUserSecondary(int userId)
|
boolean
|
isWifiEnabled()
|
|
listDisplayIds()
|
|
listUsers()
|
boolean
|
logBugreport(String dataName, ITestLogger listener)
|
void
|
logOnDevice(String tag, Log.LogLevel level, String format, Object... args)
|
void
|
nonBlockingReboot()
|
void
|
postAdbRootAction()
如果设备需要在 adb root 后和设备恢复在线之前执行一些特定操作,请替换此方法。 |
void
|
postAdbUnrootAction()
如果设备在 adb 取消 root 权限后,需要在重新上线之前执行一些特定操作,请替换此值。 |
void
|
postBootSetup()
|
void
|
postInvocationTearDown(Throwable exception)
|
void
|
preInvocationSetup(IBuildInfo info, MultiMap<String, String> attributes)
|
boolean
|
pullDir(String deviceFilePath, File localDir)
|
boolean
|
pullFile(String remoteFilePath, File localFile)
|
File
|
pullFile(String remoteFilePath)
|
String
|
pullFileContents(String remoteFilePath)
|
File
|
pullFileFromExternal(String remoteFilePath)
|
boolean
|
pushDir(File localFileDir, String deviceFilePath,
|
boolean
|
pushDir(File localFileDir, String deviceFilePath)
|
boolean
|
pushFile(File localFile, String remoteFilePath)
|
boolean
|
pushString(String contents, String remoteFilePath)
|
void
|
reboot(String reason)
|
void
|
reboot()
|
void
|
rebootIntoBootloader()
|
void
|
rebootIntoFastbootd()
|
void
|
rebootIntoRecovery()
|
void
|
rebootIntoSideload()
|
void
|
rebootIntoSideload(boolean autoReboot)
|
void
|
rebootUntilOnline()
|
void
|
rebootUntilOnline(String reason)
|
void
|
rebootUserspace()
|
void
|
rebootUserspaceUntilOnline()
|
void
|
recoverDevice()
尝试恢复设备通信。 |
void
|
remountSystemWritable()
|
void
|
remountVendorWritable()
|
boolean
|
removeAdmin(String componentName, int userId)
|
void
|
removeOwners()
|
boolean
|
removeUser(int userId)
|
void
|
resetContentProviderSetup()
重置内容提供方设置的标志,以便再次触发该设置。 |
boolean
|
runInstrumentationTests(IRemoteAndroidTestRunner runner, ITestLifeCycleReceiver... listeners)
|
boolean
|
runInstrumentationTests(IRemoteAndroidTestRunner runner,
|
boolean
|
runInstrumentationTestsAsUser(IRemoteAndroidTestRunner runner, int userId, ITestLifeCycleReceiver... listeners)
|
boolean
|
runInstrumentationTestsAsUser(IRemoteAndroidTestRunner runner, int userId,
|
void
|
setConfiguration(IConfiguration configuration)
注入正在使用的 |
void
|
setDate(Date date)
|
boolean
|
setDeviceOwner(String componentName, int userId)
|
void
|
setDeviceState(TestDeviceState deviceState)
|
void
|
setEmulatorOutputStream(SizeLimitedOutputStream output)
对于模拟器,将 |
void
|
setEmulatorProcess(Process p)
|
void
|
setFastbootEnabled(boolean fastbootEnabled)
|
void
|
setFastbootPath(String fastbootPath)
|
void
|
setIDevice(IDevice newDevice)
|
void
|
setOptions(TestDeviceOptions options)
|
boolean
|
setProperty(String propKey, String propValue)
|
void
|
setRecovery(IDeviceRecovery recovery)
|
void
|
setRecoveryMode(ITestDevice.RecoveryMode mode)
|
void
|
setSetting(String namespace, String key, String value)
|
void
|
setSetting(int userId, String namespace, String key, String value)
|
void
|
setUseFastbootErase(boolean useFastbootErase)
|
void
|
startLogcat()
|
boolean
|
startUser(int userId)
|
boolean
|
startUser(int userId, boolean waitFlag)
|
void
|
stopEmulatorOutput()
|
void
|
stopLogcat()
|
boolean
|
stopUser(int userId)
|
boolean
|
stopUser(int userId, boolean waitFlag, boolean forceFlag)
|
String
|
switchToAdbTcp()
|
boolean
|
switchToAdbUsb()
|
boolean
|
switchUser(int userId)
|
boolean
|
switchUser(int userId, long timeout)
|
boolean
|
syncFiles(File localFileDir, String deviceFilePath)
|
Bugreport
|
takeBugreport()
|
boolean
|
unencryptDevice()
|
String
|
uninstallPackage(String packageName)
|
String
|
uninstallPackageForUser(String packageName, int userId)
|
boolean
|
unlockDevice()
|
boolean
|
waitForBootComplete(long timeOut)
|
void
|
waitForDeviceAvailable()
|
void
|
waitForDeviceAvailable(long waitTime)
|
boolean
|
waitForDeviceInRecovery(long waitTime)
|
boolean
|
waitForDeviceInSideload(long waitTime)
|
boolean
|
waitForDeviceNotAvailable(long waitTime)
|
void
|
waitForDeviceOnline()
|
void
|
waitForDeviceOnline(long waitTime)
|
boolean
|
waitForDeviceShell(long waitTime)
|
受保护的方法 | |
---|---|
void
|
checkApiLevelAgainst(String feature, int strictMinLevel)
|
NativeDevice.RebootDeviceAction
|
createRebootDeviceAction(NativeDevice.RebootMode rebootMode, String reason)
创建一个 |
void
|
doAdbReboot(NativeDevice.RebootMode rebootMode, String reason)
执行 adb 重启。 |
void
|
ensureRuntimePermissionSupported()
辅助方法,用于在不支持运行时权限时抛出异常 |
InputStreamSource
|
getBugreportInternal()
|
File
|
getBugreportzInternal()
用于将 bugreportz ZIP 文件作为 |
IRunUtil
|
getRunUtil()
获取要使用的 |
String
|
internalGetProperty(String propName, String fastbootVar, String description)
默认情况下,从 ddmlib 缓存中提取设备属性,并回退到 `adb shell getprop` 或 `fastboot getvar`,具体取决于设备是否处于 Fastboot 模式。 |
boolean
|
isNewer(File localFile, IFileEntry entry)
如果本地文件比远程文件新,则返回 |
boolean
|
performDeviceAction(String actionDescription, com.android.tradefed.device.NativeDevice.DeviceAction action, int retryAttempts)
在此设备上执行操作。 |
void
|
postAdbReboot()
重新启动后可以执行的可能额外操作。 |
void
|
prePostBootSetup()
允许每种设备类型(AndroidNativeDevice、TestDevice)替换此方法以进行特定的启动后设置。 |
void
|
setClock(Clock clock)
设置要使用的 Clock 实例。 |
void
|
setLogStartDelay(int delay)
设置在开始为在线设备捕获 Logcat 数据之前等待的时间(以毫秒为单位)。 |
void
|
waitForDeviceNotAvailable(String operationDesc, long time)
|
常量
INVALID_USER_ID
public static final int INVALID_USER_ID
为任何无效/未找到的用户 ID 返回的值:UserHandle 定义了 -10000 值
常量值: -10000 (0xffffd8f0)
MAX_HOST_DEVICE_TIME_OFFSET
protected static final long MAX_HOST_DEVICE_TIME_OFFSET
常量值: 5000 (0x0000000000001388)
MAX_RETRY_ATTEMPTS
protected static final int MAX_RETRY_ATTEMPTS
要执行的默认命令重试尝试次数
常量值: 2 (0x00000002)
字段
SD_CARD
protected static final String SD_CARD
STORAGE_EMULATED
protected static final String STORAGE_EMULATED
mOptions
protected TestDeviceOptions mOptions
mStateMonitor
protected final IDeviceStateMonitor mStateMonitor
公共构造函数
NativeDevice
public NativeDevice (IDevice device, IDeviceStateMonitor stateMonitor, IDeviceMonitor allocationMonitor)
创建 TestDevice
。
参数 | |
---|---|
device |
IDevice :关联的 IDevice |
stateMonitor |
IDeviceStateMonitor :要使用的 IDeviceStateMonitor 机制 |
allocationMonitor |
IDeviceMonitor :用于通知分配状态变化的 IDeviceMonitor 。
可以为 null
|
公共方法
checkApiLevelAgainstNextRelease
public boolean checkApiLevelAgainstNextRelease (int strictMinLevel)
参数 | |
---|---|
strictMinLevel |
int |
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
checkConnectivity
public boolean checkConnectivity ()
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
clearErrorDialogs
public boolean clearErrorDialogs ()
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
clearLastConnectedWifiNetwork
public void clearLastConnectedWifiNetwork ()
clearLogcat
public void clearLogcat ()
connectToWifiNetwork
public boolean connectToWifiNetwork (String wifiSsid, String wifiPsk)
参数 | |
---|---|
wifiSsid |
String |
wifiPsk |
String |
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
connectToWifiNetwork
public boolean connectToWifiNetwork (String wifiSsid, String wifiPsk, boolean scanSsid)
参数 | |
---|---|
wifiSsid |
String |
wifiPsk |
String |
scanSsid |
boolean |
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
connectToWifiNetworkIfNeeded
public boolean connectToWifiNetworkIfNeeded (String wifiSsid, String wifiPsk, boolean scanSsid)
参数 | |
---|---|
wifiSsid |
String |
wifiPsk |
String |
scanSsid |
boolean |
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
connectToWifiNetworkIfNeeded
public boolean connectToWifiNetworkIfNeeded (String wifiSsid, String wifiPsk)
参数 | |
---|---|
wifiSsid |
String |
wifiPsk |
String |
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
createUser
public int createUser (String name, boolean guest, boolean ephemeral)
参数 | |
---|---|
name |
String |
guest |
boolean |
ephemeral |
boolean |
返回 | |
---|---|
int |
抛出 | |
---|---|
DeviceNotAvailableException |
createUser
public int createUser (String name)
参数 | |
---|---|
name |
String |
返回 | |
---|---|
int |
抛出 | |
---|---|
DeviceNotAvailableException |
createUserNoThrow
public int createUserNoThrow (String name)
参数 | |
---|---|
name |
String |
返回 | |
---|---|
int |
抛出 | |
---|---|
DeviceNotAvailableException |
deleteFile
public void deleteFile (String deviceFilePath)
参数 | |
---|---|
deviceFilePath |
String |
抛出 | |
---|---|
DeviceNotAvailableException |
deviceSoftRestarted
public boolean deviceSoftRestarted (ProcessInfo prevSystemServerProcess)
参数 | |
---|---|
prevSystemServerProcess |
ProcessInfo |
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
deviceSoftRestartedSince
public boolean deviceSoftRestartedSince (long utcEpochTime, TimeUnit timeUnit)
参数 | |
---|---|
utcEpochTime |
long |
timeUnit |
TimeUnit |
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
disableAdbRoot
public boolean disableAdbRoot ()
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
disableKeyguard
public void disableKeyguard ()
抛出 | |
---|---|
DeviceNotAvailableException |
disableNetworkMonitor
public boolean disableNetworkMonitor ()
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
disconnectFromWifi
public boolean disconnectFromWifi ()
返回 | |
---|---|
boolean |
抛出 | |
---|---|
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 |
enableAdbRoot
public boolean enableAdbRoot ()
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
enableNetworkMonitor
public boolean enableNetworkMonitor ()
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
encryptDevice
public boolean encryptDevice (boolean inplace)
参数 | |
---|---|
inplace |
boolean |
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
executeAdbCommand
public String executeAdbCommand (long timeout, String... cmdArgs)
参数 | |
---|---|
timeout |
long |
cmdArgs |
String |
返回 | |
---|---|
String |
抛出 | |
---|---|
DeviceNotAvailableException |
executeAdbCommand
public String executeAdbCommand (String... cmdArgs)
参数 | |
---|---|
cmdArgs |
String |
返回 | |
---|---|
String |
抛出 | |
---|---|
DeviceNotAvailableException |
executeFastbootCommand
public CommandResult executeFastbootCommand (String... cmdArgs)
参数 | |
---|---|
cmdArgs |
String |
返回 | |
---|---|
CommandResult |
抛出 | |
---|---|
DeviceNotAvailableException |
executeFastbootCommand
public CommandResult executeFastbootCommand (long timeout, String... cmdArgs)
参数 | |
---|---|
timeout |
long |
cmdArgs |
String |
返回 | |
---|---|
CommandResult |
抛出 | |
---|---|
DeviceNotAvailableException |
executeLongFastbootCommand
public CommandResult executeLongFastbootCommand (String... cmdArgs)
参数 | |
---|---|
cmdArgs |
String |
返回 | |
---|---|
CommandResult |
抛出 | |
---|---|
DeviceNotAvailableException |
executeShellCommand
public String executeShellCommand (String command)
参数 | |
---|---|
command |
String |
返回 | |
---|---|
String |
抛出 | |
---|---|
DeviceNotAvailableException |
executeShellCommand
public void executeShellCommand (String command, IShellOutputReceiver receiver, long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts)
参数 | |
---|---|
command |
String |
receiver |
IShellOutputReceiver |
maxTimeToOutputShellResponse |
long |
timeUnit |
TimeUnit |
retryAttempts |
int |
抛出 | |
---|---|
DeviceNotAvailableException |
executeShellCommand
public void executeShellCommand (String command, IShellOutputReceiver receiver, long maxTimeoutForCommand, long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts)
参数 | |
---|---|
command |
String |
receiver |
IShellOutputReceiver |
maxTimeoutForCommand |
long |
maxTimeToOutputShellResponse |
long |
timeUnit |
TimeUnit |
retryAttempts |
int |
抛出 | |
---|---|
DeviceNotAvailableException |
executeShellCommand
public void executeShellCommand (String command, IShellOutputReceiver receiver)
参数 | |
---|---|
command |
String |
receiver |
IShellOutputReceiver |
抛出 | |
---|---|
DeviceNotAvailableException |
executeShellV2Command
public CommandResult executeShellV2Command (String cmd)
参数 | |
---|---|
cmd |
String |
返回 | |
---|---|
CommandResult |
抛出 | |
---|---|
DeviceNotAvailableException |
executeShellV2Command
public CommandResult executeShellV2Command (String cmd, OutputStream pipeToOutput)
参数 | |
---|---|
cmd |
String |
pipeToOutput |
OutputStream |
返回 | |
---|---|
CommandResult |
抛出 | |
---|---|
DeviceNotAvailableException |
executeShellV2Command
public CommandResult executeShellV2Command (String cmd, File pipeAsInput)
参数 | |
---|---|
cmd |
String |
pipeAsInput |
File |
返回 | |
---|---|
CommandResult |
抛出 | |
---|---|
DeviceNotAvailableException |
executeShellV2Command
public CommandResult executeShellV2Command (String cmd, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts)
参数 | |
---|---|
cmd |
String |
maxTimeoutForCommand |
long |
timeUnit |
TimeUnit |
retryAttempts |
int |
返回 | |
---|---|
CommandResult |
抛出 | |
---|---|
DeviceNotAvailableException |
executeShellV2Command
public CommandResult executeShellV2Command (String cmd, long maxTimeoutForCommand, TimeUnit timeUnit)
参数 | |
---|---|
cmd |
String |
maxTimeoutForCommand |
long |
timeUnit |
TimeUnit |
返回 | |
---|---|
CommandResult |
抛出 | |
---|---|
DeviceNotAvailableException |
executeShellV2Command
public CommandResult executeShellV2Command (String cmd, File pipeAsInput, OutputStream pipeToOutput, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts)
参数 | |
---|---|
cmd |
String |
pipeAsInput |
File |
pipeToOutput |
OutputStream |
maxTimeoutForCommand |
long |
timeUnit |
TimeUnit |
retryAttempts |
int |
返回 | |
---|---|
CommandResult |
抛出 | |
---|---|
DeviceNotAvailableException |
executeShellV2Command
public CommandResult executeShellV2Command (String cmd, File pipeAsInput, OutputStream pipeToOutput, OutputStream pipeToError, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts)
参数 | |
---|---|
cmd |
String |
pipeAsInput |
File |
pipeToOutput |
OutputStream |
pipeToError |
OutputStream |
maxTimeoutForCommand |
long |
timeUnit |
TimeUnit |
retryAttempts |
int |
返回 | |
---|---|
CommandResult |
抛出 | |
---|---|
DeviceNotAvailableException |
fastbootWipePartition
public CommandResult fastbootWipePartition (String partition)
参数 | |
---|---|
partition |
String |
返回 | |
---|---|
CommandResult |
抛出 | |
---|---|
DeviceNotAvailableException |
getActiveApexes
publicgetActiveApexes ()
返回 | |
---|---|
|
抛出 | |
---|---|
DeviceNotAvailableException |
getAllSettings
publicgetAllSettings (String namespace)
参数 | |
---|---|
namespace |
String |
返回 | |
---|---|
|
抛出 | |
---|---|
DeviceNotAvailableException |
getAllocationState
public DeviceAllocationState getAllocationState ()
返回 | |
---|---|
DeviceAllocationState |
getAndroidId
public String getAndroidId (int userId)
参数 | |
---|---|
userId |
int |
返回 | |
---|---|
String |
抛出 | |
---|---|
DeviceNotAvailableException |
getAndroidIds
publicgetAndroidIds ()
返回 | |
---|---|
|
抛出 | |
---|---|
DeviceNotAvailableException |
getApiLevel
public int getApiLevel ()
返回 | |
---|---|
int |
抛出 | |
---|---|
DeviceNotAvailableException |
getAppPackageInfo
public PackageInfo getAppPackageInfo (String packageName)
参数 | |
---|---|
packageName |
String |
返回 | |
---|---|
PackageInfo |
抛出 | |
---|---|
DeviceNotAvailableException |
getAppPackageInfos
publicgetAppPackageInfos ()
返回 | |
---|---|
|
抛出 | |
---|---|
DeviceNotAvailableException |
getBasebandVersion
public String getBasebandVersion ()
返回 | |
---|---|
String |
抛出 | |
---|---|
DeviceNotAvailableException |
getBattery
public Integer getBattery ()
返回 | |
---|---|
Integer |
getBooleanProperty
public boolean getBooleanProperty (String name, boolean defaultValue)
参数 | |
---|---|
name |
String |
defaultValue |
boolean |
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
getBootHistory
publicgetBootHistory ()
返回 | |
---|---|
|
抛出 | |
---|---|
DeviceNotAvailableException |
getBootHistorySince
publicgetBootHistorySince (long utcEpochTime, TimeUnit timeUnit)
参数 | |
---|---|
utcEpochTime |
long |
timeUnit |
TimeUnit |
返回 | |
---|---|
|
抛出 | |
---|---|
DeviceNotAvailableException |
getBootloaderVersion
public String getBootloaderVersion ()
返回 | |
---|---|
String |
抛出 | |
---|---|
DeviceNotAvailableException |
getBugreport
public InputStreamSource getBugreport ()
返回 | |
---|---|
InputStreamSource |
getBugreportz
public InputStreamSource getBugreportz ()
返回 | |
---|---|
InputStreamSource |
getBuildAlias
public String getBuildAlias ()
返回 | |
---|---|
String |
抛出 | |
---|---|
DeviceNotAvailableException |
getBuildFlavor
public String getBuildFlavor ()
返回 | |
---|---|
String |
抛出 | |
---|---|
DeviceNotAvailableException |
getBuildId
public String getBuildId ()
返回 | |
---|---|
String |
抛出 | |
---|---|
DeviceNotAvailableException |
getBuildSigningKeys
public String getBuildSigningKeys ()
返回 | |
---|---|
String |
抛出 | |
---|---|
DeviceNotAvailableException |
getCachedDeviceDescriptor
public DeviceDescriptor getCachedDeviceDescriptor ()
返回 | |
---|---|
DeviceDescriptor |
getChildren
public String[] getChildren (String path)
参数 | |
---|---|
path |
String |
返回 | |
---|---|
String[] |
抛出 | |
---|---|
DeviceNotAvailableException |
getCurrentFoldableState
public DeviceFoldableState getCurrentFoldableState ()
返回 | |
---|---|
DeviceFoldableState |
抛出 | |
---|---|
DeviceNotAvailableException |
getCurrentUser
public int getCurrentUser ()
返回 | |
---|---|
int |
抛出 | |
---|---|
DeviceNotAvailableException |
getDeviceClass
public String getDeviceClass ()
返回 | |
---|---|
String |
getDeviceDate
public long getDeviceDate ()
返回 | |
---|---|
long |
抛出 | |
---|---|
DeviceNotAvailableException |
getDeviceDescriptor
public DeviceDescriptor getDeviceDescriptor ()
返回 | |
---|---|
DeviceDescriptor |
getDeviceState
public TestDeviceState getDeviceState ()
返回 | |
---|---|
TestDeviceState |
getDeviceTimeOffset
public long getDeviceTimeOffset (Date date)
参数 | |
---|---|
date |
Date |
返回 | |
---|---|
long |
抛出 | |
---|---|
DeviceNotAvailableException |
getEmulatorOutput
public InputStreamSource getEmulatorOutput ()
返回 | |
---|---|
InputStreamSource |
getEmulatorProcess
public Process getEmulatorProcess ()
返回 | |
---|---|
Process |
getExecuteShellCommandLog
public final File getExecuteShellCommandLog ()
包含所有 executeShellCommand(String)
日志的日志。
返回 | |
---|---|
File |
getExternalStoreFreeSpace
public long getExternalStoreFreeSpace ()
返回 | |
---|---|
long |
抛出 | |
---|---|
DeviceNotAvailableException |
getFastbootPath
public String getFastbootPath ()
返回 | |
---|---|
String |
getFastbootProductType
public String getFastbootProductType ()
返回 | |
---|---|
String |
抛出 | |
---|---|
DeviceNotAvailableException |
getFastbootProductVariant
public String getFastbootProductVariant ()
返回 | |
---|---|
String |
抛出 | |
---|---|
DeviceNotAvailableException |
getFastbootSerialNumber
public String getFastbootSerialNumber ()
返回 | |
---|---|
String |
getFastbootVariable
public String getFastbootVariable (String variableName)
参数 | |
---|---|
variableName |
String |
返回 | |
---|---|
String |
抛出 | |
---|---|
DeviceNotAvailableException |
getFastbootVersion
public String getFastbootVersion ()
返回 | |
---|---|
String |
getFileEntry
public IFileEntry getFileEntry (String path)
参数 | |
---|---|
path |
String |
返回 | |
---|---|
IFileEntry |
抛出 | |
---|---|
DeviceNotAvailableException |
getFileEntry
public IFileEntry getFileEntry (FileListingService.FileEntry entry)
用于从非根路径获取 FileEntry
的非官方辅助程序。FIXME:重构 FileEntry 系统,使其可从任何路径访问。(即使未启用 root 权限)。
参数 | |
---|---|
entry |
FileListingService.FileEntry :FileEntry 不一定是 Ddmlib 所要求的 root。 |
返回 | |
---|---|
IFileEntry |
表示 FileEntry 的 FileEntryWrapper 。 |
抛出 | |
---|---|
DeviceNotAvailableException |
getFoldableStates
publicgetFoldableStates ()
返回 | |
---|---|
|
抛出 | |
---|---|
DeviceNotAvailableException |
getIDevice
public IDevice getIDevice ()
返回 | |
---|---|
IDevice |
getInstalledPackageNames
publicgetInstalledPackageNames ()
返回 | |
---|---|
|
抛出 | |
---|---|
DeviceNotAvailableException |
getIntProperty
public long getIntProperty (String name, long defaultValue)
参数 | |
---|---|
name |
String |
defaultValue |
long |
返回 | |
---|---|
long |
抛出 | |
---|---|
DeviceNotAvailableException |
getIpAddress
public String getIpAddress ()
返回 | |
---|---|
String |
抛出 | |
---|---|
DeviceNotAvailableException |
getKeyguardState
public KeyguardControllerState getKeyguardState ()
返回 | |
---|---|
KeyguardControllerState |
抛出 | |
---|---|
DeviceNotAvailableException |
getLastExpectedRebootTimeMillis
public long getLastExpectedRebootTimeMillis ()
返回 | |
---|---|
long |
getLaunchApiLevel
public int getLaunchApiLevel ()
返回 | |
---|---|
int |
抛出 | |
---|---|
DeviceNotAvailableException |
getLogcat
public InputStreamSource getLogcat ()
返回 | |
---|---|
InputStreamSource |
getLogcat
public InputStreamSource getLogcat (int maxBytes)
参数 | |
---|---|
maxBytes |
int |
返回 | |
---|---|
InputStreamSource |
getLogcatDump
public InputStreamSource getLogcatDump ()
返回 | |
---|---|
InputStreamSource |
getLogcatSince
public InputStreamSource getLogcatSince (long date)
参数 | |
---|---|
date |
long |
返回 | |
---|---|
InputStreamSource |
getMacAddress
public String getMacAddress ()
返回 | |
---|---|
String |
getMainlineModuleInfo
publicgetMainlineModuleInfo ()
返回 | |
---|---|
|
抛出 | |
---|---|
DeviceNotAvailableException |
getMaxNumberOfRunningUsersSupported
public int getMaxNumberOfRunningUsersSupported ()
返回 | |
---|---|
int |
抛出 | |
---|---|
DeviceNotAvailableException |
getMaxNumberOfUsersSupported
public int getMaxNumberOfUsersSupported ()
返回 | |
---|---|
int |
抛出 | |
---|---|
DeviceNotAvailableException |
getMonitor
public IDeviceStateMonitor getMonitor ()
返回 | |
---|---|
IDeviceStateMonitor |
getMountPoint
public String getMountPoint (String mountName)
参数 | |
---|---|
mountName |
String |
返回 | |
---|---|
String |
getMountPointInfo
public ITestDevice.MountPointInfo getMountPointInfo (String mountpoint)
参数 | |
---|---|
mountpoint |
String |
返回 | |
---|---|
ITestDevice.MountPointInfo |
抛出 | |
---|---|
DeviceNotAvailableException |
getMountPointInfo
publicgetMountPointInfo ()
返回 | |
---|---|
|
抛出 | |
---|---|
DeviceNotAvailableException |
getOptions
public TestDeviceOptions getOptions ()
返回 | |
---|---|
TestDeviceOptions |
getPartitionFreeSpace
public long getPartitionFreeSpace (String partition)
参数 | |
---|---|
partition |
String |
返回 | |
---|---|
long |
抛出 | |
---|---|
DeviceNotAvailableException |
getPrimaryUserId
public Integer getPrimaryUserId ()
返回 | |
---|---|
Integer |
抛出 | |
---|---|
DeviceNotAvailableException |
getProcessByName
public ProcessInfo getProcessByName (String processName)
参数 | |
---|---|
processName |
String |
返回 | |
---|---|
ProcessInfo |
抛出 | |
---|---|
DeviceNotAvailableException |
getProcessPid
public String getProcessPid (String process)
参数 | |
---|---|
process |
String |
返回 | |
---|---|
String |
抛出 | |
---|---|
DeviceNotAvailableException |
getProductType
public String getProductType ()
返回 | |
---|---|
String |
抛出 | |
---|---|
DeviceNotAvailableException |
getProductVariant
public String getProductVariant ()
返回 | |
---|---|
String |
抛出 | |
---|---|
DeviceNotAvailableException |
getProperty
public String getProperty (String name)
参数 | |
---|---|
name |
String |
返回 | |
---|---|
String |
抛出 | |
---|---|
DeviceNotAvailableException |
getRecoveryMode
public ITestDevice.RecoveryMode getRecoveryMode ()
返回 | |
---|---|
ITestDevice.RecoveryMode |
getScreenshot
public InputStreamSource getScreenshot (String format)
参数 | |
---|---|
format |
String |
返回 | |
---|---|
InputStreamSource |
抛出 | |
---|---|
DeviceNotAvailableException |
getScreenshot
public InputStreamSource getScreenshot (long displayId)
参数 | |
---|---|
displayId |
long |
返回 | |
---|---|
InputStreamSource |
抛出 | |
---|---|
DeviceNotAvailableException |
getScreenshot
public InputStreamSource getScreenshot (String format, boolean rescale)
参数 | |
---|---|
format |
String |
rescale |
boolean |
返回 | |
---|---|
InputStreamSource |
抛出 | |
---|---|
DeviceNotAvailableException |
getScreenshot
public InputStreamSource getScreenshot ()
返回 | |
---|---|
InputStreamSource |
抛出 | |
---|---|
DeviceNotAvailableException |
getSerialNumber
public String getSerialNumber ()
返回 | |
---|---|
String |
getSetting
public String getSetting (int userId, String namespace, String key)
参数 | |
---|---|
userId |
int |
namespace |
String |
key |
String |
返回 | |
---|---|
String |
抛出 | |
---|---|
DeviceNotAvailableException |
getSetting
public String getSetting (String namespace, String key)
参数 | |
---|---|
namespace |
String |
key |
String |
返回 | |
---|---|
String |
抛出 | |
---|---|
DeviceNotAvailableException |
getSimOperator
public String getSimOperator ()
返回 | |
---|---|
String |
getSimState
public String getSimState ()
返回 | |
---|---|
String |
getTombstones
publicgetTombstones ()
返回 | |
---|---|
|
抛出 | |
---|---|
DeviceNotAvailableException |
getTotalMemory
public long getTotalMemory ()
返回 | |
---|---|
long |
getUninstallablePackageNames
publicgetUninstallablePackageNames ()
返回 | |
---|---|
|
抛出 | |
---|---|
DeviceNotAvailableException |
getUseFastbootErase
public boolean getUseFastbootErase ()
返回 | |
---|---|
boolean |
getUserFlags
public int getUserFlags (int userId)
参数 | |
---|---|
userId |
int |
返回 | |
---|---|
int |
抛出 | |
---|---|
DeviceNotAvailableException |
getUserInfos
publicgetUserInfos ()
返回 | |
---|---|
|
抛出 | |
---|---|
DeviceNotAvailableException |
getUserSerialNumber
public int getUserSerialNumber (int userId)
参数 | |
---|---|
userId |
int |
返回 | |
---|---|
int |
抛出 | |
---|---|
DeviceNotAvailableException |
handleAllocationEvent
public IManagedTestDevice.DeviceEventResponse handleAllocationEvent (DeviceEvent event)
处理 DeviceEvent,此操作可能会或可能不会将此设备转换为新的分配状态。
参数 | |
---|---|
event |
DeviceEvent |
返回 | |
---|---|
IManagedTestDevice.DeviceEventResponse |
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, boolean reinstall, boolean grantPermissions, String... extraArgs)
参数 | |
---|---|
packageFile |
File |
reinstall |
boolean |
grantPermissions |
boolean |
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 |
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 |
isAdbRoot
public boolean isAdbRoot ()
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
isAdbTcp
public boolean isAdbTcp ()
返回 | |
---|---|
boolean |
isAppEnumerationSupported
public boolean isAppEnumerationSupported ()
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
isDeviceEncrypted
public boolean isDeviceEncrypted ()
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
isDirectory
public boolean isDirectory (String path)
参数 | |
---|---|
path |
String |
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
isEnableAdbRoot
public boolean isEnableAdbRoot ()
返回 | |
---|---|
boolean |
true 是否应在设备上启用 adb root |
isEncryptionSupported
public boolean isEncryptionSupported ()
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
isExecutable
public boolean isExecutable (String fullPath)
参数 | |
---|---|
fullPath |
String |
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
isFastbootEnabled
public boolean isFastbootEnabled ()
返回 | |
---|---|
boolean |
isHeadless
public boolean isHeadless ()
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
isMultiUserSupported
public boolean isMultiUserSupported ()
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
isPackageInstalled
public boolean isPackageInstalled (String packageName, String userId)
参数 | |
---|---|
packageName |
String |
userId |
String |
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
isPackageInstalled
public boolean isPackageInstalled (String packageName)
参数 | |
---|---|
packageName |
String |
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
isRuntimePermissionSupported
public boolean isRuntimePermissionSupported ()
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
isStateBootloaderOrFastbootd
public boolean isStateBootloaderOrFastbootd ()
返回 | |
---|---|
boolean |
isUserRunning
public boolean isUserRunning (int userId)
参数 | |
---|---|
userId |
int |
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
isUserSecondary
public boolean isUserSecondary (int userId)
参数 | |
---|---|
userId |
int |
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
isWifiEnabled
public boolean isWifiEnabled ()
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
listDisplayIds
publiclistDisplayIds ()
返回 | |
---|---|
|
抛出 | |
---|---|
DeviceNotAvailableException |
listUsers
publiclistUsers ()
返回 | |
---|---|
|
抛出 | |
---|---|
DeviceNotAvailableException |
logBugreport
public boolean logBugreport (String dataName, ITestLogger listener)
参数 | |
---|---|
dataName |
String |
listener |
ITestLogger |
返回 | |
---|---|
boolean |
logOnDevice
public void logOnDevice (String tag, Log.LogLevel level, String format, Object... args)
参数 | |
---|---|
tag |
String |
level |
Log.LogLevel |
format |
String |
args |
Object |
nonBlockingReboot
public void nonBlockingReboot ()
抛出 | |
---|---|
DeviceNotAvailableException |
postAdbRootAction
public void postAdbRootAction ()
如果设备需要在 adb root 之后和设备恢复在线之前执行一些特定操作,请替换此方法。 默认实现不包含任何其他操作。此阶段无法保证 adb root 已启用。
抛出 | |
---|---|
DeviceNotAvailableException |
postAdbUnrootAction
public void postAdbUnrootAction ()
如果设备在 adb 取消 root 权限后,需要在重新上线之前执行一些特定操作,请替换此值。 默认实现不包含任何其他操作。我们无法保证此阶段一定会停用 adb root。
抛出 | |
---|---|
DeviceNotAvailableException |
postBootSetup
public void postBootSetup ()
抛出 | |
---|---|
DeviceNotAvailableException |
postInvocationTearDown
public void postInvocationTearDown (Throwable exception)
参数 | |
---|---|
exception |
Throwable |
preInvocationSetup
public void preInvocationSetup (IBuildInfo info, MultiMap<String, String> attributes)
参数 | |
---|---|
info |
IBuildInfo |
attributes |
MultiMap |
抛出 | |
---|---|
DeviceNotAvailableException |
|
TargetSetupError |
pullDir
public boolean pullDir (String deviceFilePath, File localDir)
参数 | |
---|---|
deviceFilePath |
String |
localDir |
File |
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
pullFile
public boolean pullFile (String remoteFilePath, File localFile)
参数 | |
---|---|
remoteFilePath |
String |
localFile |
File |
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
pullFile
public File pullFile (String remoteFilePath)
参数 | |
---|---|
remoteFilePath |
String |
返回 | |
---|---|
File |
抛出 | |
---|---|
DeviceNotAvailableException |
pullFileContents
public String pullFileContents (String remoteFilePath)
参数 | |
---|---|
remoteFilePath |
String |
返回 | |
---|---|
String |
抛出 | |
---|---|
DeviceNotAvailableException |
pullFileFromExternal
public File pullFileFromExternal (String remoteFilePath)
参数 | |
---|---|
remoteFilePath |
String |
返回 | |
---|---|
File |
抛出 | |
---|---|
DeviceNotAvailableException |
pushDir
public boolean pushDir (File localFileDir, String deviceFilePath,excludedDirectories)
参数 | |
---|---|
localFileDir |
File |
deviceFilePath |
String |
excludedDirectories |
|
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
pushDir
public boolean pushDir (File localFileDir, String deviceFilePath)
参数 | |
---|---|
localFileDir |
File |
deviceFilePath |
String |
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
pushFile
public boolean pushFile (File localFile, String remoteFilePath)
参数 | |
---|---|
localFile |
File |
remoteFilePath |
String |
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
pushString
public boolean pushString (String contents, String remoteFilePath)
参数 | |
---|---|
contents |
String |
remoteFilePath |
String |
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
重新启动
public void reboot (String reason)
参数 | |
---|---|
reason |
String |
抛出 | |
---|---|
DeviceNotAvailableException |
重新启动
public void reboot ()
抛出 | |
---|---|
DeviceNotAvailableException |
rebootIntoBootloader
public void rebootIntoBootloader ()
抛出 | |
---|---|
DeviceNotAvailableException |
rebootIntoFastbootd
public void rebootIntoFastbootd ()
抛出 | |
---|---|
DeviceNotAvailableException |
rebootIntoRecovery
public void rebootIntoRecovery ()
抛出 | |
---|---|
DeviceNotAvailableException |
rebootIntoSideload
public void rebootIntoSideload ()
抛出 | |
---|---|
DeviceNotAvailableException |
rebootIntoSideload
public void rebootIntoSideload (boolean autoReboot)
参数 | |
---|---|
autoReboot |
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
rebootUntilOnline
public void rebootUntilOnline ()
抛出 | |
---|---|
DeviceNotAvailableException |
rebootUntilOnline
public void rebootUntilOnline (String reason)
参数 | |
---|---|
reason |
String |
抛出 | |
---|---|
DeviceNotAvailableException |
rebootUserspace
public void rebootUserspace ()
抛出 | |
---|---|
DeviceNotAvailableException |
rebootUserspaceUntilOnline
public void rebootUserspaceUntilOnline ()
抛出 | |
---|---|
DeviceNotAvailableException |
recoverDevice
public void recoverDevice ()
尝试恢复设备通信。
抛出 | |
---|---|
DeviceNotAvailableException |
如果设备不再可用 |
remountSystemWritable
public void remountSystemWritable ()
抛出 | |
---|---|
DeviceNotAvailableException |
remountVendorWritable
public void remountVendorWritable ()
抛出 | |
---|---|
DeviceNotAvailableException |
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 |
resetContentProviderSetup
public void resetContentProviderSetup ()
重置内容提供方设置的标志,以便再次触发该设置。
runInstrumentationTests
public boolean runInstrumentationTests (IRemoteAndroidTestRunner runner, ITestLifeCycleReceiver... listeners)
参数 | |
---|---|
runner |
IRemoteAndroidTestRunner |
listeners |
ITestLifeCycleReceiver |
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
runInstrumentationTests
public boolean runInstrumentationTests (IRemoteAndroidTestRunner runner,listeners)
参数 | |
---|---|
runner |
IRemoteAndroidTestRunner |
listeners |
|
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
runInstrumentationTestsAsUser
public boolean runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId, ITestLifeCycleReceiver... listeners)
参数 | |
---|---|
runner |
IRemoteAndroidTestRunner |
userId |
int |
listeners |
ITestLifeCycleReceiver |
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
runInstrumentationTestsAsUser
public boolean runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId,listeners)
参数 | |
---|---|
runner |
IRemoteAndroidTestRunner |
userId |
int |
listeners |
|
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
setConfiguration
public void setConfiguration (IConfiguration configuration)
注入正在使用的 IConfiguration
。
参数 | |
---|---|
configuration |
IConfiguration |
setDate
public void setDate (Date date)
参数 | |
---|---|
date |
Date |
抛出 | |
---|---|
DeviceNotAvailableException |
setDeviceOwner
public boolean setDeviceOwner (String componentName, int userId)
参数 | |
---|---|
componentName |
String |
userId |
int |
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
setDeviceState
public void setDeviceState (TestDeviceState deviceState)
参数 | |
---|---|
deviceState |
TestDeviceState |
setEmulatorOutputStream
public void setEmulatorOutputStream (SizeLimitedOutputStream output)
对于模拟器,将 SizeLimitedOutputStream
设置为日志输出
参数 | |
---|---|
output |
SizeLimitedOutputStream :用于记录输出
|
setEmulatorProcess
public void setEmulatorProcess (Process p)
参数 | |
---|---|
p |
Process |
setFastbootEnabled
public void setFastbootEnabled (boolean fastbootEnabled)
参数 | |
---|---|
fastbootEnabled |
boolean |
setFastbootPath
public void setFastbootPath (String fastbootPath)
参数 | |
---|---|
fastbootPath |
String |
setIDevice
public void setIDevice (IDevice newDevice)
参数 | |
---|---|
newDevice |
IDevice |
setOptions
public void setOptions (TestDeviceOptions options)
参数 | |
---|---|
options |
TestDeviceOptions |
setProperty
public boolean setProperty (String propKey, String propValue)
参数 | |
---|---|
propKey |
String |
propValue |
String |
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
setRecovery
public void setRecovery (IDeviceRecovery recovery)
参数 | |
---|---|
recovery |
IDeviceRecovery |
setRecoveryMode
public void setRecoveryMode (ITestDevice.RecoveryMode mode)
参数 | |
---|---|
mode |
ITestDevice.RecoveryMode |
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 |
setUseFastbootErase
public void setUseFastbootErase (boolean useFastbootErase)
参数 | |
---|---|
useFastbootErase |
boolean |
startLogcat
public void startLogcat ()
startUser
public boolean startUser (int userId)
参数 | |
---|---|
userId |
int |
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
startUser
public boolean startUser (int userId, boolean waitFlag)
参数 | |
---|---|
userId |
int |
waitFlag |
boolean |
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
stopEmulatorOutput
public void stopEmulatorOutput ()
stopLogcat
public void stopLogcat ()
stopUser
public boolean stopUser (int userId)
参数 | |
---|---|
userId |
int |
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
stopUser
public boolean stopUser (int userId, boolean waitFlag, boolean forceFlag)
参数 | |
---|---|
userId |
int |
waitFlag |
boolean |
forceFlag |
boolean |
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
switchToAdbTcp
public String switchToAdbTcp ()
返回 | |
---|---|
String |
抛出 | |
---|---|
DeviceNotAvailableException |
switchToAdbUsb
public boolean switchToAdbUsb ()
返回 | |
---|---|
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 |
syncFiles
public boolean syncFiles (File localFileDir, String deviceFilePath)
参数 | |
---|---|
localFileDir |
File |
deviceFilePath |
String |
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
takeBugreport
public Bugreport takeBugreport ()
返回 | |
---|---|
Bugreport |
unencryptDevice
public boolean unencryptDevice ()
返回 | |
---|---|
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 |
unlockDevice
public boolean unlockDevice ()
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
waitForBootComplete
public boolean waitForBootComplete (long timeOut)
参数 | |
---|---|
timeOut |
long |
返回 | |
---|---|
boolean |
抛出 | |
---|---|
DeviceNotAvailableException |
waitForDeviceAvailable
public void waitForDeviceAvailable ()
抛出 | |
---|---|
DeviceNotAvailableException |
waitForDeviceAvailable
public void waitForDeviceAvailable (long waitTime)
参数 | |
---|---|
waitTime |
long |
抛出 | |
---|---|
DeviceNotAvailableException |
waitForDeviceInRecovery
public boolean waitForDeviceInRecovery (long waitTime)
参数 | |
---|---|
waitTime |
long |
返回 | |
---|---|
boolean |
waitForDeviceInSideload
public boolean waitForDeviceInSideload (long waitTime)
参数 | |
---|---|
waitTime |
long |
返回 | |
---|---|
boolean |
waitForDeviceNotAvailable
public boolean waitForDeviceNotAvailable (long waitTime)
参数 | |
---|---|
waitTime |
long |
返回 | |
---|---|
boolean |
waitForDeviceOnline
public void waitForDeviceOnline ()
抛出 | |
---|---|
DeviceNotAvailableException |
waitForDeviceOnline
public void waitForDeviceOnline (long waitTime)
参数 | |
---|---|
waitTime |
long |
抛出 | |
---|---|
DeviceNotAvailableException |
waitForDeviceShell
public boolean waitForDeviceShell (long waitTime)
参数 | |
---|---|
waitTime |
long |
返回 | |
---|---|
boolean |
受保护的方法
checkApiLevelAgainst
protected void checkApiLevelAgainst (String feature, int strictMinLevel)
参数 | |
---|---|
feature |
String |
strictMinLevel |
int |
createRebootDeviceAction
protected NativeDevice.RebootDeviceAction createRebootDeviceAction (NativeDevice.RebootMode rebootMode, String reason)
创建一个 RebootDeviceAction
,以便在执行重新启动操作时使用。
参数 | |
---|---|
rebootMode |
NativeDevice.RebootMode :此重新启动的模式。 |
reason |
String :针对此次重新启动。 |
返回 | |
---|---|
NativeDevice.RebootDeviceAction |
创建的 RebootDeviceAction 。
|
doAdbReboot
protected void doAdbReboot (NativeDevice.RebootMode rebootMode, String reason)
执行 adb reboot。
参数 | |
---|---|
rebootMode |
NativeDevice.RebootMode :此重新启动的模式。 |
reason |
String :针对此次重新启动。 |
抛出 | |
---|---|
DeviceNotAvailableException |
ensureRuntimePermissionSupported
protected void ensureRuntimePermissionSupported ()
在运行时权限不受支持时抛出异常的辅助方法
抛出 | |
---|---|
DeviceNotAvailableException |
getBugreportInternal
protected InputStreamSource getBugreportInternal ()
返回 | |
---|---|
InputStreamSource |
getBugreportzInternal
protected File getBugreportzInternal ()
用于将 bugreportz ZIP 文件作为 ERROR(/File)
获取的内部辅助方法。
返回 | |
---|---|
File |
internalGetProperty
protected String internalGetProperty (String propName, String fastbootVar, String description)
默认情况下,从 ddmlib 缓存中提取设备属性,并回退到 `adb shell getprop` 或 `fastboot getvar`,具体取决于设备是否处于 Fastboot 模式。
参数 | |
---|---|
propName |
String :`adb shell getprop` 返回的设备属性的名称 |
fastbootVar |
String :要查询的等效 fastboot 变量的名称。如果为 null ,则不会尝试进行 fastboot 查询 |
description |
String :变量的简单说明。第一个字母应采用大写形式。 |
返回 | |
---|---|
String |
一个字符串(可能为 null 或空),其中包含指定属性的值
|
抛出 | |
---|---|
DeviceNotAvailableException |
isNewer
protected boolean isNewer (File localFile, IFileEntry entry)
如果本地文件比远程文件新,则返回 true
。IFileEntry
以分钟为单位,如果时间相同,则文件将被视为较新。
参数 | |
---|---|
localFile |
File |
entry |
IFileEntry |
返回 | |
---|---|
boolean |
performDeviceAction
protected boolean performDeviceAction (String actionDescription, com.android.tradefed.device.NativeDevice.DeviceAction action, int retryAttempts)
在此设备上执行操作。尝试恢复设备,并在操作失败时可选择重试命令。
参数 | |
---|---|
actionDescription |
String :要执行的操作的简短说明。仅用于日志记录目的。 |
action |
com.android.tradefed.device.NativeDevice.DeviceAction :要执行的操作 |
retryAttempts |
int :如果操作失败但恢复成功,重试会尝试执行操作 |
返回 | |
---|---|
boolean |
如果操作成功执行,则为 true |
抛出 | |
---|---|
DeviceNotAvailableException |
如果恢复尝试失败或已尝试最大次数且未成功 |
postAdbReboot
protected void postAdbReboot ()
重新启动后可以执行的可能额外操作。
抛出 | |
---|---|
DeviceNotAvailableException |
prePostBootSetup
protected void prePostBootSetup ()
允许每种设备类型(AndroidNativeDevice、TestDevice)替换此方法以进行特定的启动后设置。
抛出 | |
---|---|
DeviceNotAvailableException |
setClock
protected void setClock (Clock clock)
设置要使用的 Clock 实例。
参数 | |
---|---|
clock |
Clock |
setLogStartDelay
protected void setLogStartDelay (int delay)
设置在开始为在线设备捕获 Logcat 数据之前等待的时间(以毫秒为单位)。
参数 | |
---|---|
delay |
int :延迟时间(毫秒)
|
waitForDeviceNotAvailable
protected void waitForDeviceNotAvailable (String operationDesc, long time)
参数 | |
---|---|
operationDesc |
String |
time |
long |