INativeDevice
public interface INativeDevice
com.android.tradefed.device.INativeDevice |
为ddmlib IDevice
提供可靠且更高级别的API。
概要
常数 | |
---|---|
int | UNKNOWN_API_LEVEL 无法检测到API级别时的默认值 |
公开方法 | |
---|---|
abstract boolean | checkApiLevelAgainstNextRelease (int strictMinLevel) 在最低支持级别下,检查当前是否支持某个功能。 |
abstract void | clearLogcat () 删除任何累积的logcat数据。 |
abstract void | deleteFile (String deviceFilePath) 删除设备上文件或目录的辅助方法。 |
abstract boolean | disableAdbRoot () 关闭adb根目录。 |
abstract boolean | doesFileExist (String deviceFilePath) 确定设备上文件是否存在的辅助方法。 |
abstract boolean | enableAdbRoot () 打开adb根目录。 |
abstract boolean | encryptDevice (boolean inplace) 加密设备。 |
abstract String | executeAdbCommand (String... commandArgs) 将adb命令作为系统命令执行的Helper方法。 |
abstract CommandResult | executeFastbootCommand (String... commandArgs) 帮助程序方法,将fastboot命令作为系统命令执行,默认超时为2分钟。 |
abstract CommandResult | executeFastbootCommand (long timeout, String... commandArgs) 将fastboot命令作为系统命令执行的Helper方法。 |
abstract CommandResult | executeLongFastbootCommand (String... commandArgs) 将长时间运行的fastboot命令作为系统命令执行的Helper方法。 |
abstract String | executeShellCommand (String command) 执行adb shell命令并以 |
abstract void | executeShellCommand (String command, IShellOutputReceiver receiver, long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts) 执行adb shell命令,并使用更多参数来控制命令行为。 |
abstract void | executeShellCommand (String command, IShellOutputReceiver receiver, long maxTimeoutForCommand, long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts) 执行adb shell命令,并使用更多参数来控制命令行为。 |
abstract void | executeShellCommand (String command, IShellOutputReceiver receiver) 执行给定的adb shell命令,如果命令失败,则重试多次。 |
abstract CommandResult | executeShellV2Command (String command) 帮助程序方法,该方法执行adb shell命令,并以适当填充命令状态输出stdout和stderr的 |
abstract CommandResult | executeShellV2Command (String command, OutputStream pipeToOutput) Helper方法,该方法执行adb shell命令,并将结果作为 |
abstract CommandResult | executeShellV2Command (String command, File pipeAsInput) Helper方法,该方法执行adb shell命令,并将结果作为 |
abstract CommandResult | executeShellV2Command (String command, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts) 执行adb shell命令,并使用更多参数来控制命令行为。 |
abstract CommandResult | executeShellV2Command (String command, long maxTimeoutForCommand, TimeUnit timeUnit) 执行adb shell命令,并使用更多参数来控制命令行为。 |
abstract CommandResult | executeShellV2Command (String command, File pipeAsInput, OutputStream pipeToOutput, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts) 执行adb shell命令,并使用更多参数来控制命令行为。 |
abstract CommandResult | fastbootWipePartition (String partition) 擦除设备分区的辅助方法。 |
abstract int | getApiLevel () 获取设备API级别。 |
abstract String | getBasebandVersion () 获取此设备的基带(无线电)版本的便捷方法。 |
abstract Integer | getBattery () 返回设备的当前电池电量;如果电池电量不可用,则返回Null。 |
abstract String | getBootloaderVersion () 获取此设备的引导程序版本的便捷方法。 |
abstract InputStreamSource | getBugreport () 从设备检索错误报告。 |
abstract InputStreamSource | getBugreportz () 从设备检索错误报告。 |
abstract String | getBuildAlias () 检索设备当前正在运行的内部版本的别名。 |
abstract String | getBuildFlavor () 检索设备的构建味道。 |
abstract String | getBuildId () 检索设备当前正在运行的版本。 |
abstract String | getBuildSigningKeys () 返回用于签署设备映像的密钥类型 通常,Android设备可能会使用测试键(如AOSP中的签名)或释放键(由各个设备制造商控制)进行签名 |
abstract String[] | getChildren (String deviceFilePath) 替代使用 |
abstract String | getDeviceClass () 获取设备类。 |
abstract long | getDeviceDate () 返回设备的日期,以毫秒为单位。 |
abstract DeviceDescriptor | getDeviceDescriptor () 从设备信息返回 |
abstract TestDeviceState | getDeviceState () 获取设备的状态。 |
abstract long | getDeviceTimeOffset (Date date) 帮助程序获取设备与给定 |
abstract InputStreamSource | getEmulatorOutput () 获取模拟器stdout和stderr的流 |
abstract long | getExternalStoreFreeSpace () 确定设备外部存储上可用空间量的辅助方法。 |
abstract String | getFastbootProductType () 在快速启动模式下获取此设备产品类型的便捷方法。 |
abstract String | getFastbootProductVariant () 在快速启动模式下获取此设备产品类型的便捷方法。 |
abstract IFileEntry | getFileEntry (String path) 检索对设备上远程文件的引用。 |
abstract IDevice | getIDevice () 返回对关联的ddmlib |
abstract long | getLastExpectedRebootTimeMillis () 返回自 |
abstract InputStreamSource | getLogcat () 获取logcat数据的快照流。 |
abstract InputStreamSource | getLogcat (int maxBytes) 捕获捕获的logcat数据的最后 |
abstract InputStreamSource | getLogcatDump () 获取设备的当前logcat的转储。 |
abstract InputStreamSource | getLogcatSince (long date) 从提供的日期开始获取捕获的logcat数据的快照流。 |
abstract String | getMountPoint (String mountName) 返回安装点。 |
abstract ITestDevice.MountPointInfo | getMountPointInfo (String mountpoint) 返回与指定的安装点路径相对应的 |
abstract | getMountPointInfo () 返回设备上/ proc / mounts中信息的解析版本 |
abstract long | getPartitionFreeSpace (String partition) 确定设备分区上可用空间量的辅助方法。 |
abstract ProcessInfo | getProcessByName (String processName) Helper方法运行“ ps”命令并返回给定进程名称的USER,PID和NAME。 |
abstract String | getProcessPid (String process) 返回服务的pid;如果出现问题,则返回null。 |
abstract | getProcesses () Helper方法运行“ ps”命令并返回所有进程的USER,PID和NAME的列表。 |
abstract String | getProductType () 获取此设备产品类型的便捷方法。 |
abstract String | getProductVariant () 获取此设备产品变型的便捷方法。 |
abstract String | getProperty (String name) 从设备检索给定的属性值。 |
abstract ITestDevice.RecoveryMode | getRecoveryMode () 获取设备当前使用的恢复模式。 |
abstract String | getSerialNumber () 获取此设备序列号的便捷方法。 |
abstract | getTombstones () 从设备获取并返回逻辑删除列表。 |
abstract long | getTotalMemory () 返回总物理内存大小(以字节为单位),如果发生内部错误,则返回-1 |
abstract boolean | getUseFastbootErase () 获取是否使用fastboot擦除或fastboot格式擦除设备上的分区。 |
abstract boolean | isAdbRoot () |
abstract boolean | isAdbTcp () |
abstract boolean | isDeviceEncrypted () 返回设备是否已加密。 |
abstract boolean | isDirectory (String deviceFilePath) 如果设备上的路径是目录,则返回True,否则返回false。 |
abstract boolean | isEncryptionSupported () 返回设备是否支持加密。 |
abstract boolean | isExecutable (String fullPath) 如果设备上的文件路径是可执行文件,则返回True,否则返回false。 |
abstract boolean | isHeadless () 如果设备无头(无屏幕),则返回true,否则返回false。 |
abstract boolean | isRuntimePermissionSupported () 检查设备上的平台是否支持运行时权限授予 |
abstract boolean | logBugreport (String dataName, ITestLogger listener) 进行错误报告并将其记录到报告程序的助手方法。 |
abstract void | logOnDevice (String tag, Log.LogLevel level, String format, Object... args) 在设备的日志中记录一条消息。 |
abstract void | nonBlockingReboot () 发出命令以重新引导设备,并在命令完成后以及adb不再可见设备时返回。 |
abstract void | postBootSetup () 执行说明以配置设备以在每次引导后对其进行测试。 |
abstract void | postInvocationTearDown () 特定于设备的所需额外清理步骤将在调用完成后执行。 |
abstract void | preInvocationSetup ( IBuildInfo info) 设备特定的必需设置的额外步骤将在调用流程之前在设备上执行。 |
default void | preInvocationSetup ( IBuildInfo info, testResourceBuildInfos) preInvocationSetup ( IBuildInfo info, testResourceBuildInfos) 设备特定的必需设置的额外步骤将在调用流程之前在设备上执行。 |
abstract boolean | pullDir (String deviceFilePath, File localDir) 从设备递归提取目录内容。 |
abstract File | pullFile (String remoteFilePath) 从设备上检索文件,将其存储在本地临时 |
abstract boolean | pullFile (String remoteFilePath, File localFile) 从设备上检索文件。 |
abstract String | pullFileContents (String remoteFilePath) 从设备上检索文件,然后返回内容。 |
abstract File | pullFileFromExternal (String remoteFilePath) 一种方便的方法,用于从设备的外部存储中检索文件,将其存储在本地临时 |
abstract boolean | pushDir (File localDir, String deviceFilePath, excludedDirectories) pushDir (File localDir, String deviceFilePath, excludedDirectories) 将目录内容递归推送到设备,同时排除一些已过滤的目录。 |
abstract boolean | pushDir (File localDir, String deviceFilePath) 递归将目录内容推送到设备。 |
abstract boolean | pushFile (File localFile, String deviceFilePath) 将文件推送到设备 |
abstract boolean | pushString (String contents, String deviceFilePath) 将从字符串创建的文件推送到设备 |
abstract void | reboot () 将设备重新引导到adb模式。 |
abstract void | rebootIntoBootloader () 将设备重新引导到引导加载程序模式。 |
abstract void | rebootIntoRecovery () 将设备重新引导到adb恢复模式。 |
abstract void | rebootUntilOnline () 一个 |
abstract void | remountSystemWritable () 使设备上的系统分区可写。 |
abstract boolean | runInstrumentationTests (IRemoteAndroidTestRunner runner, ITestLifeCycleReceiver... listeners) 使用一个或多个作为参数传递的侦听器执行 |
abstract boolean | runInstrumentationTests (IRemoteAndroidTestRunner runner, listeners) runInstrumentationTests (IRemoteAndroidTestRunner runner, listeners) 运行检测测试,并提供设备恢复。 |
abstract boolean | runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId, ITestLifeCycleReceiver... listeners) 与 |
abstract boolean | runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId, listeners) runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId, listeners) 与 |
abstract void | setDate (Date date) 在设备上设置日期 注意:在设备上设置日期需要root |
abstract void | setOptions ( TestDeviceOptions options) 设置设备的 |
abstract boolean | setProperty (String propKey, String propValue) 在设备上设置给定的属性值。 |
abstract void | setRecovery ( IDeviceRecovery recovery) 设置要用于此设备的 |
abstract void | setRecoveryMode ( ITestDevice.RecoveryMode mode) 设置要用于设备的当前恢复模式。 |
abstract void | setUseFastbootErase (boolean useFastbootErase) 设置是使用fastboot擦除还是fastboot格式擦除设备上的分区。 |
abstract void | startLogcat () 开始在后台捕获设备的logcat输出。 |
abstract void | stopEmulatorOutput () 关闭并删除仿真器输出。 |
abstract void | stopLogcat () 停止捕获设备的logcat输出,并丢弃当前保存的logcat数据。 |
abstract String | switchToAdbTcp () 将设备切换到adb-over-tcp模式。 |
abstract boolean | switchToAdbUsb () 通过USB模式将设备切换到adb。 |
abstract boolean | syncFiles (File localFileDir, String deviceFilePath) 将本地文件目录的内容增量同步到设备。 |
abstract Bugreport | takeBugreport () 进行一个错误报告,并将其返回到 |
abstract boolean | unencryptDevice () 解密设备。 |
abstract boolean | unlockDevice () 如果设备处于加密状态,则解锁设备。 |
abstract boolean | waitForBootComplete (long timeOut) 阻塞,直到设置了设备的启动完成标志。 |
abstract void | waitForDeviceAvailable () 等待设备响应并可以进行测试。 |
abstract void | waitForDeviceAvailable (long waitTime) 等待设备响应并可以进行测试。 |
abstract boolean | waitForDeviceInRecovery (long waitTime) 阻止设备处于“ adb恢复”状态(请注意,这与 |
abstract boolean | waitForDeviceNotAvailable (long waitTime) 设备的块不可用,即adb丢失 |
abstract void | waitForDeviceOnline () 阻塞,直到通过adb看到设备为止。 |
abstract void | waitForDeviceOnline (long waitTime) 阻塞,直到通过adb看到设备为止。 |
abstract boolean | waitForDeviceShell (long waitTime) 等待设备响应基本的adb shell命令。 |
常数
UNKNOWN_API_LEVEL
public static final int UNKNOWN_API_LEVEL
无法检测到API级别时的默认值
常数值:-1(0xffffffff)
公开方法
checkApiLevelAgainstNextRelease
public abstract boolean checkApiLevelAgainstNextRelease (int strictMinLevel)
在最低支持级别下,检查当前是否支持某个功能。在提高API级别之前,此方法会考虑尚未发布的功能。
参量 | |
---|---|
strictMinLevel | int :支持该功能的严格的最小可能级别。 |
退货 | |
---|---|
boolean | 如果支持级别,则为True。否则为假。 |
投掷 | |
---|---|
DeviceNotAvailableException |
clearLogcat
public abstract void clearLogcat ()
删除任何累积的logcat数据。
当您要确保ITestDevice#getLogcat()
仅返回在特定时间点之后生成的日志数据时(例如在刷新新的设备版本后等),这很有用。删除文件
public abstract void deleteFile (String deviceFilePath)
删除设备上文件或目录的辅助方法。
参量 | |
---|---|
deviceFilePath | String :设备上文件的绝对路径。 |
投掷 | |
---|---|
DeviceNotAvailableException |
disableAdbRoot
public abstract boolean disableAdbRoot ()
关闭adb根目录。
禁用adb root可能会导致设备与adb断开连接。该方法将阻塞,直到设备可用。退货 | |
---|---|
boolean | 如果成功,则为true 。 |
投掷 | |
---|---|
DeviceNotAvailableException | 与设备的连接丢失并且无法恢复。 |
didFileExist
public abstract boolean doesFileExist (String deviceFilePath)
确定设备上文件是否存在的辅助方法。
参量 | |
---|---|
deviceFilePath | String :要检查的设备上文件的绝对路径 |
退货 | |
---|---|
boolean | 如果文件存在则为true ,否则为false 。 |
投掷 | |
---|---|
DeviceNotAvailableException | 与设备的连接丢失并且无法恢复。 |
enableAdbRoot
public abstract boolean enableAdbRoot ()
打开adb root。如果“ enable-root”设置为“ false”,将记录一条消息并返回而不启用root。
启用adb root可能会导致设备与adb断开连接。该方法将阻塞,直到设备可用。退货 | |
---|---|
boolean | 如果成功,则为true 。 |
投掷 | |
---|---|
DeviceNotAvailableException | 与设备的连接丢失并且无法恢复。 |
cryptoDevice
public abstract boolean encryptDevice (boolean inplace)
加密设备。
可以对设备进行加密或就地擦除。就地加密不会擦除设备上的任何数据,但通常比擦除要长几个数量级。如果该设备尚未加密,则此方法将重新启动设备,并在设备联机之前将其阻止。此外,重启后它不会解密设备。因此,当此方法返回时,设备可能未完全启动和/或未准备好进行测试。参量 | |
---|---|
inplace | boolean :如果加密过程应该就位并且不应擦除设备。 |
退货 | |
---|---|
boolean | 如果成功,则为true 。 |
投掷 | |
---|---|
DeviceNotAvailableException | 如果重启后设备不可用。 |
UnsupportedOperationException | 如果设备不支持加密。 |
executeAdbCommand
public abstract String executeAdbCommand (String... commandArgs)
将adb命令作为系统命令执行的Helper方法。
应尽可能使用executeShellCommand(String)
代替,因为该方法可提供更好的故障检测和性能。参量 | |
---|---|
commandArgs | String :adb命令和要运行的参数 |
退货 | |
---|---|
String | 命令的标准输出。如果命令执行失败,则返回null 。 |
投掷 | |
---|---|
DeviceNotAvailableException | 与设备的连接丢失并且无法恢复。 |
executeFastbootCommand
public abstract CommandResult executeFastbootCommand (String... commandArgs)
帮助程序方法,将fastboot命令作为系统命令执行,默认超时为2分钟。
预期在设备已经处于快速启动模式时使用。参量 | |
---|---|
commandArgs | String :fastboot命令和要运行的参数 |
退货 | |
---|---|
CommandResult | 包含命令输出的CommandResult |
投掷 | |
---|---|
DeviceNotAvailableException | 与设备的连接丢失并且无法恢复。 |
executeFastbootCommand
public abstract CommandResult executeFastbootCommand (long timeout, String... commandArgs)
将fastboot命令作为系统命令执行的Helper方法。
预计在设备已经处于快速启动模式时使用。参量 | |
---|---|
timeout | long :命令到期前的时间(以毫秒为单位) |
commandArgs | String :fastboot命令和要运行的参数 |
退货 | |
---|---|
CommandResult | 包含命令输出的CommandResult |
投掷 | |
---|---|
DeviceNotAvailableException | 与设备的连接丢失并且无法恢复。 |
executeLongFastbootCommand
public abstract CommandResult executeLongFastbootCommand (String... commandArgs)
将长时间运行的fastboot命令作为系统命令执行的Helper方法。
与executeFastbootCommand(String)
相同,除了使用更长的超时时间。参量 | |
---|---|
commandArgs | String :fastboot命令和要运行的参数 |
退货 | |
---|---|
CommandResult | 包含命令输出的CommandResult |
投掷 | |
---|---|
DeviceNotAvailableException | 与设备的连接丢失并且无法恢复。 |
executeShellCommand
public abstract String executeShellCommand (String command)
执行adb shell命令并以String
返回输出的Helper方法。
参量 | |
---|---|
command | String :要运行的adb shell命令 |
退货 | |
---|---|
String | 外壳输出 |
投掷 | |
---|---|
DeviceNotAvailableException | 与设备的连接丢失并且无法恢复。 |
executeShellCommand
public abstract void executeShellCommand (String command, IShellOutputReceiver receiver, long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts)
执行adb shell命令,并使用更多参数来控制命令行为。
参量 | |
---|---|
command | String :要运行的adb shell命令 |
receiver | IShellOutputReceiver :将Shell输出IShellOutputReceiver 到的IShellOutputReceiver 。 |
maxTimeToOutputShellResponse | long :允许命令不输出任何响应的最long ; timeUnit 指定的timeUnit |
timeUnit | TimeUnit : maxTimeToOutputShellResponse 单位 |
retryAttempts | int :如果命令由于异常而失败的最大重试次数。如果执行retryAttempts没有成功,将引发retryAttempts 。 |
投掷 | |
---|---|
DeviceNotAvailableException | 与设备的连接丢失并且无法恢复。 |
executeShellCommand
public abstract void executeShellCommand (String command, IShellOutputReceiver receiver, long maxTimeoutForCommand, long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts)
执行adb shell命令,并使用更多参数来控制命令行为。
参量 | |
---|---|
command | String :要运行的adb shell命令 |
receiver | IShellOutputReceiver :将Shell输出IShellOutputReceiver 到的IShellOutputReceiver 。 |
maxTimeoutForCommand | long :命令完成的最大超时; timeUnit 指定的timeUnit |
maxTimeToOutputShellResponse | long :允许命令不输出任何响应的最long ; timeUnit 指定的timeUnit |
timeUnit | TimeUnit : maxTimeToOutputShellResponse 单位 |
retryAttempts | int :如果命令由于异常而失败的最大重试次数。如果执行retryAttempts没有成功,将引发retryAttempts 。 |
投掷 | |
---|---|
DeviceNotAvailableException | 与设备的连接丢失并且无法恢复。 |
executeShellCommand
public abstract void executeShellCommand (String command, IShellOutputReceiver receiver)
执行给定的adb shell命令,如果命令失败,则重试多次。
一种带有默认值的executeShellCommand(String, com.android.ddmlib.IShellOutputReceiver, long, TimeUnit, int)
的简单形式。参量 | |
---|---|
command | String :要运行的adb shell命令 |
receiver | IShellOutputReceiver :将Shell输出IShellOutputReceiver 到的IShellOutputReceiver 。 |
投掷 | |
---|---|
DeviceNotAvailableException | 与设备的连接丢失并且无法恢复。 |
executeShellV2Command
public abstract CommandResult executeShellV2Command (String command)
帮助程序方法,该方法执行adb shell命令,并以适当填充命令状态输出stdout和stderr的CommandResult
返回结果。
参量 | |
---|---|
command | String :应运行的命令。 |
退货 | |
---|---|
CommandResult | CommandResult 的结果。 |
投掷 | |
---|---|
DeviceNotAvailableException | 与设备的连接丢失并且无法恢复。 |
executeShellV2Command
public abstract CommandResult executeShellV2Command (String command, OutputStream pipeToOutput)
Helper方法,该方法执行adb shell命令,并将结果作为CommandResult
返回,并正确填充命令状态输出stdout和stderr。
参量 | |
---|---|
command | String :应运行的命令。 |
pipeToOutput | OutputStream : ERROR(/OutputStream) 将在其中重定向标准输出。 |
退货 | |
---|---|
CommandResult | CommandResult 的结果。 |
投掷 | |
---|---|
DeviceNotAvailableException | 与设备的连接丢失并且无法恢复。 |
executeShellV2Command
public abstract CommandResult executeShellV2Command (String command, File pipeAsInput)
Helper方法,该方法执行adb shell命令,并将结果作为CommandResult
返回,并正确填充命令状态输出stdout和stderr。
参量 | |
---|---|
command | String :应运行的命令。 |
pipeAsInput | File :一个ERROR(/File) ,将通过管道将其作为命令的输入。 |
退货 | |
---|---|
CommandResult | CommandResult 的结果。 |
投掷 | |
---|---|
DeviceNotAvailableException | 与设备的连接丢失并且无法恢复。 |
executeShellV2Command
public abstract CommandResult executeShellV2Command (String command, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts)
执行adb shell命令,并使用更多参数来控制命令行为。
参量 | |
---|---|
command | String :要运行的adb shell命令 |
maxTimeoutForCommand | long :命令完成的最大超时; timeUnit 指定的timeUnit |
timeUnit | TimeUnit : maxTimeToOutputShellResponse 单位 |
retryAttempts | int :如果命令由于异常而失败的最大重试次数。如果执行retryAttempts没有成功,将引发retryAttempts 。 |
退货 | |
---|---|
CommandResult |
投掷 | |
---|---|
DeviceNotAvailableException | 与设备的连接丢失并且无法恢复。 |
executeShellV2Command
public abstract CommandResult executeShellV2Command (String command, long maxTimeoutForCommand, TimeUnit timeUnit)
执行adb shell命令,并使用更多参数来控制命令行为。
参量 | |
---|---|
command | String :要运行的adb shell命令 |
maxTimeoutForCommand | long :命令完成的最大超时; timeUnit 指定的timeUnit |
timeUnit | TimeUnit : maxTimeToOutputShellResponse 单位 |
退货 | |
---|---|
CommandResult |
投掷 | |
---|---|
DeviceNotAvailableException | 与设备的连接丢失并且无法恢复。 |
executeShellV2Command
public abstract CommandResult executeShellV2Command (String command, File pipeAsInput, OutputStream pipeToOutput, long maxTimeoutForCommand, TimeUnit timeUnit, int retryAttempts)
执行adb shell命令,并使用更多参数来控制命令行为。
参量 | |
---|---|
command | String :要运行的adb shell命令 |
pipeAsInput | File :一个ERROR(/File) ,将通过管道将其作为命令的输入。 |
pipeToOutput | OutputStream : ERROR(/OutputStream) 将在其中重定向标准输出。 |
maxTimeoutForCommand | long :命令完成的最大超时; timeUnit 指定的timeUnit |
timeUnit | TimeUnit : maxTimeToOutputShellResponse 单位 |
retryAttempts | int :如果命令由于异常而失败的最大重试次数。如果执行retryAttempts没有成功,将引发retryAttempts 。 |
退货 | |
---|---|
CommandResult |
投掷 | |
---|---|
DeviceNotAvailableException | 如果与设备的连接丢失并且无法恢复。 |
fastbootWipePartition
public abstract CommandResult fastbootWipePartition (String partition)
擦除设备分区的辅助方法。
如果getUseFastbootErase()
为true
,则将使用fastboot擦除来擦除分区。然后,设备必须在下次引导时创建文件系统。否则,将使用快速启动格式,该格式将在设备上创建新的文件系统。预期在设备已经处于快速启动模式时使用。参量 | |
---|---|
partition | String :要擦除的分区 |
退货 | |
---|---|
CommandResult | 包含命令输出的CommandResult |
投掷 | |
---|---|
DeviceNotAvailableException | 与设备的连接丢失并且无法恢复。 |
getApiLevel
public abstract int getApiLevel ()
获取设备API级别。默认为UNKNOWN_API_LEVEL
。
退货 | |
---|---|
int | 一个整数,指示设备的API级别 |
投掷 | |
---|---|
DeviceNotAvailableException |
getBasebandVersion
获取此设备的基带(无线电)版本的便捷方法。获取无线电版本是特定于设备的,因此它可能不会为所有设备返回正确的信息。此方法依靠gsm.version.baseband属性返回正确的版本信息。对于某些CDMA设备,这是不准确的,并且此处返回的版本可能与fastboot报告的版本不匹配,并且可能不会返回CDMA无线电的版本。 TL; DR如果gsm.version.baseband属性与fastboot getvar version-baseband
返回的版本相同,则此方法仅报告准确的版本。
退货 | |
---|---|
String | String 基带版本;如果无法确定,则为null (设备没有广播或无法读取版本字符串) |
投掷 | |
---|---|
DeviceNotAvailableException | 如果与设备的连接丢失并且无法恢复。 |
getBattery
public abstract Integer getBattery ()
返回设备的当前电池电量;如果电池电量不可用,则返回Null。
退货 | |
---|---|
Integer |
getBootloaderVersion
public abstract String getBootloaderVersion ()
获取此设备的引导程序版本的便捷方法。
将尝试从设备的当前状态检索引导加载程序版本。 (即,如果设备处于快速启动模式,它将尝试从快速启动中检索版本)退货 | |
---|---|
String | String 引导加载程序版本;如果找不到,则为null |
投掷 | |
---|---|
DeviceNotAvailableException | 如果与设备的连接丢失并且无法恢复。 |
getBugreport
public abstract InputStreamSource getBugreport ()
从设备检索错误报告。
可以确保在没有sdcard的设备上(或尚未安装sdcard的设备)继续执行此操作。退货 | |
---|---|
InputStreamSource | 一个InputStreamSource ,它将按需生成错误报告内容。如果失败, InputStreamSource 将产生一个空的ERROR(/InputStream) 。 |
getBugreportz
public abstract InputStreamSource getBugreportz ()
从设备检索错误报告。 Zip格式的bugreport包含主要的bugreport和其他对调试有用的日志文件。
仅支持“ adb版本”> 1.0.36退货 | |
---|---|
InputStreamSource | 包含bugreportz的zip文件的InputStreamSource ,如果失败,则返回null。 |
getBuildAlias
public abstract String getBuildAlias ()
检索设备当前正在运行的内部版本的别名。
构建别名通常比构建ID(通常是Nexus构建的数字)更具可读性。例如,最终的Android 4.2版本具有内部别名JDQ39和内部ID 573038
退货 | |
---|---|
String | 构建别名或如果无法检索则退回到构建ID |
投掷 | |
---|---|
DeviceNotAvailableException |
getBuildId
public abstract String getBuildId ()
检索设备当前正在运行的版本。
退货 | |
---|---|
String | 构建ID或IBuildInfo#UNKNOWN_BUILD_ID 如果无法检索) |
投掷 | |
---|---|
DeviceNotAvailableException |
getBuildSigningKeys
public abstract String getBuildSigningKeys ()
返回用于签署设备映像的密钥类型
通常,Android设备可能会使用测试键(如AOSP中的签名)或释放键(由各个设备制造商控制)进行签名
退货 | |
---|---|
String | 如果找到签名密钥,则为null。 |
投掷 | |
---|---|
DeviceNotAvailableException |
getChildren
public abstract String[] getChildren (String deviceFilePath)
替代使用IFileEntry
,由于权限的IFileEntry
,有时无法使用。
参量 | |
---|---|
deviceFilePath | String :是设备上进行搜索的路径 |
退货 | |
---|---|
String[] | 包含设备路径中所有文件的字符串数组。 |
投掷 | |
---|---|
DeviceNotAvailableException |
getDeviceDate
public abstract long getDeviceDate ()
返回设备的日期,以毫秒为单位。
退货 | |
---|---|
long | 以日期格式的设备日期。 |
投掷 | |
---|---|
DeviceNotAvailableException |
getDeviceDescriptor
public abstract DeviceDescriptor getDeviceDescriptor ()
从设备信息返回DeviceDescriptor
以获取有关它的信息,而无需传递实际的设备对象。
退货 | |
---|---|
DeviceDescriptor |
getDeviceTimeOffset
public abstract long getDeviceTimeOffset (Date date)
帮助程序获取设备与给定ERROR(/Date)
之间的时间差。在内部使用纪元时间。
参量 | |
---|---|
date | Date |
退货 | |
---|---|
long | 毫秒差 |
投掷 | |
---|---|
DeviceNotAvailableException |
getEmulatorOutput
public abstract InputStreamSource getEmulatorOutput ()
获取模拟器stdout和stderr的流
退货 | |
---|---|
InputStreamSource | 仿真器输出 |
getExternalStoreFreeSpace
public abstract long getExternalStoreFreeSpace ()
确定设备外部存储上可用空间量的辅助方法。
退货 | |
---|---|
long | 可用空间量(KB) |
投掷 | |
---|---|
DeviceNotAvailableException | 与设备的连接丢失并且无法恢复。 |
getFastbootProductType
public abstract String getFastbootProductType ()
在快速启动模式下获取此设备产品类型的便捷方法。
仅当设备应处于快速启动状态时,才应使用此方法。在这种情况下,它比通用的getProductType()
方法要安全一些,因为如果设备处于错误状态或没有响应,则ITestDevice会知道将设备恢复为快速启动。退货 | |
---|---|
String | String 产品类型名称;如果无法确定,则返回null |
投掷 | |
---|---|
DeviceNotAvailableException | 与设备的连接丢失并且无法恢复。 |
getFastbootProductVariant
public abstract String getFastbootProductVariant ()
在快速启动模式下获取此设备产品类型的便捷方法。
仅当设备应处于快速启动状态时,才应使用此方法。在这种情况下,它比通用的getProductType()
方法更安全一些,因为如果设备处于错误状态或没有响应,则ITestDevice会知道将设备恢复为快速启动。退货 | |
---|---|
String | String 产品类型名称;如果无法确定,则返回null |
投掷 | |
---|---|
DeviceNotAvailableException | 如果与设备的连接丢失并且无法恢复。 |
getFileEntry
public abstract IFileEntry getFileEntry (String path)
检索对设备上远程文件的引用。
参量 | |
---|---|
path | String :要检索的文件路径。可以是绝对路径或相对于'/'的路径。 (即同时支持“ / system”和“ system”语法) |
退货 | |
---|---|
IFileEntry | IFileEntry 如果找不到指定path下的文件,则IFileEntry null |
投掷 | |
---|---|
DeviceNotAvailableException |
getIDevice
public abstract IDevice getIDevice ()
返回对关联的ddmlib IDevice
的引用。
IDevice
。因此,调用者不应保留对IDevice
的引用,因为该引用可能会过时。退货 | |
---|---|
IDevice | IDevice |
getLastExpectedRebootTimeMillis
public abstract long getLastExpectedRebootTimeMillis ()
返回自System.currentTimeMillis()
返回EPOCH以来,Tradefed API上一次触发重新引导的时间(以毫秒为单位System.currentTimeMillis()
。
退货 | |
---|---|
long |
getLogcat
public abstract InputStreamSource getLogcat ()
获取logcat数据的快照流。
在两种模式下工作:
TestDeviceOptions#getMaxLogcatDataSize()
字节。退货 | |
---|---|
InputStreamSource |
getLogcat
public abstract InputStreamSource getLogcat (int maxBytes)
捕获捕获的logcat数据的最后maxBytes
个快照流。
当您希望捕获捕获的logcat数据的频繁快照而又不会导致获取整个getLogcat()
快照可能造成较大的磁盘空间损失时,该功能getLogcat()
。
参量 | |
---|---|
maxBytes | int :要返回的最大数据量。应该是可以舒适地容纳在内存中的量 |
退货 | |
---|---|
InputStreamSource |
getLogcatDump
public abstract InputStreamSource getLogcatDump ()
获取设备的当前logcat的转储。与getLogcat()
不同,此方法将始终返回logcat的静态转储。
缺点是如果设备不可达,则不会返回任何内容。
退货 | |
---|---|
InputStreamSource | logcat数据的InputStreamSource 。如果无法捕获logcat数据,则返回空流。 |
getLogcatSince
public abstract InputStreamSource getLogcatSince (long date)
从提供的日期开始获取捕获的logcat数据的快照流。设备上的时间应使用getDeviceDate()
。
参量 | |
---|---|
date | long :以毫秒为单位,以自从何时开始快照直至出现的时代格式开始。 (可以使用'date +%s'获得) |
退货 | |
---|---|
InputStreamSource |
getMountPoint
public abstract String getMountPoint (String mountName)
返回安装点。
如果IDevice
的缓存信息不可用,则直接查询设备。待办事项:将此行为移至IDevice#getMountPoint(String)
参量 | |
---|---|
mountName | String :安装点的名称 |
退货 | |
---|---|
String | 挂载点或null |
getMountPointInfo
public abstract ITestDevice.MountPointInfo getMountPointInfo (String mountpoint)
返回与指定的安装点路径相对应的MountPointInfo
如果该路径未安装任何东西,否则返回null
否则该路径不会出现在/ proc / mounts中作为安装点。
参量 | |
---|---|
mountpoint | String |
退货 | |
---|---|
ITestDevice.MountPointInfo | MountPointInfo ERROR(/List) ,其中包含“ / proc / mounts”中的信息 |
投掷 | |
---|---|
DeviceNotAvailableException |
也可以看看:
getMountPointInfo
public abstractgetMountPointInfo ()
返回设备上/ proc / mounts中信息的解析版本
退货 | |
---|---|
MountPointInfo ERROR(/List) ,其中包含“ / proc / mounts”中的信息 |
投掷 | |
---|---|
DeviceNotAvailableException |
getPartitionFreeSpace
public abstract long getPartitionFreeSpace (String partition)
确定设备分区上可用空间量的辅助方法。
参量 | |
---|---|
partition | String |
退货 | |
---|---|
long | 可用空间量(KB) |
投掷 | |
---|---|
DeviceNotAvailableException | 如果与设备的连接丢失并且无法恢复。 |
getProcessByName
public abstract ProcessInfo getProcessByName (String processName)
Helper方法运行“ ps”命令并返回给定进程名称的USER,PID和NAME。
参量 | |
---|---|
processName | String |
退货 | |
---|---|
ProcessInfo | 给定processName的ProcessInfo |
投掷 | |
---|---|
DeviceNotAvailableException |
getProcessPid
public abstract String getProcessPid (String process)
返回服务的pid;如果出现问题,则返回null。
参量 | |
---|---|
process | String |
退货 | |
---|---|
String |
投掷 | |
---|---|
DeviceNotAvailableException |
getProcesses
public abstractgetProcesses ()
Helper方法运行“ ps”命令并返回所有进程的USER,PID和NAME的列表。
退货 | |
---|---|
ProcessInfo对象列表 |
投掷 | |
---|---|
DeviceNotAvailableException |
getProductType
public abstract String getProductType ()
获取此设备产品类型的便捷方法。
如果设备处于adb或fastboot模式,则此方法将起作用。退货 | |
---|---|
String | String 产品类型名称。不会为空 |
投掷 | |
---|---|
DeviceNotAvailableException | 如果与设备的连接丢失并且无法恢复,或者无法确定产品类型 |
getProductVariant
public abstract String getProductVariant ()
获取此设备产品变型的便捷方法。
如果设备处于adb或fastboot模式,则此方法将起作用。退货 | |
---|---|
String | String 产品变体名称;如果无法确定,则为null |
投掷 | |
---|---|
DeviceNotAvailableException | 与设备的连接丢失并且无法恢复。 |
getProperty
public abstract String getProperty (String name)
从设备检索给定的属性值。
参量 | |
---|---|
name | String :属性名称 |
退货 | |
---|---|
String | 属性值;如果不存在,则返回null |
投掷 | |
---|---|
DeviceNotAvailableException |
getRecoveryMode
public abstract ITestDevice.RecoveryMode getRecoveryMode ()
获取设备当前使用的恢复模式。
退货 | |
---|---|
ITestDevice.RecoveryMode | 设备当前使用的恢复模式。 |
getTombstones
public abstractgetTombstones ()
从设备获取并返回逻辑删除列表。需要root。
这种方法是尽力而为的,因此,如果出于任何原因未能将一个逻辑删除,则该逻辑删除将从列表中丢失。只有DeviceNotAvailableException
会提前终止该方法。
退货 | |
---|---|
逻辑删除文件列表,如果没有逻辑删除则为空。 |
投掷 | |
---|---|
DeviceNotAvailableException |
也可以看看:
getTotalMemory
public abstract long getTotalMemory ()
返回总物理内存大小(以字节为单位),如果发生内部错误,则返回-1
退货 | |
---|---|
long |
getUseFastbootErase
public abstract boolean getUseFastbootErase ()
获取是使用fastboot擦除还是fastboot格式擦除设备上的分区。
退货 | |
---|---|
boolean | 如果将使用fastboot擦除,则为true 如果将使用fastboot格式,则为false 。 |
isAdbRoot
public abstract boolean isAdbRoot ()
退货 | |
---|---|
boolean | 如果设备当前具有adb根,则为true ,否则为false 。 |
投掷 | |
---|---|
DeviceNotAvailableException | 与设备的连接丢失并且无法恢复。 |
isAdbTcp
public abstract boolean isAdbTcp ()
退货 | |
---|---|
boolean | 如果设备连接到adb-over-tcp,则为true ,否则为false 。 |
isDeviceEncrypted
public abstract boolean isDeviceEncrypted ()
返回设备是否已加密。
退货 | |
---|---|
boolean | 如果设备已加密,则为true 。 |
投掷 | |
---|---|
DeviceNotAvailableException | 如果与设备的连接丢失并且无法恢复。 |
isDirectory
public abstract boolean isDirectory (String deviceFilePath)
如果设备上的路径是目录,则返回True,否则返回false。
参量 | |
---|---|
deviceFilePath | String |
退货 | |
---|---|
boolean |
投掷 | |
---|---|
DeviceNotAvailableException |
isEncryptionSupported
public abstract boolean isEncryptionSupported ()
返回设备是否支持加密。
退货 | |
---|---|
boolean | 如果设备支持加密,则为true 。 |
投掷 | |
---|---|
DeviceNotAvailableException |
isExecutable
public abstract boolean isExecutable (String fullPath)
如果设备上的文件路径是可执行文件,则返回True,否则返回false。
参量 | |
---|---|
fullPath | String |
退货 | |
---|---|
boolean |
投掷 | |
---|---|
DeviceNotAvailableException |
无头
public abstract boolean isHeadless ()
如果设备无头(无屏幕),则返回true,否则返回false。
退货 | |
---|---|
boolean |
投掷 | |
---|---|
DeviceNotAvailableException |
isRuntimePermissionSupported
public abstract boolean isRuntimePermissionSupported ()
检查设备上的平台是否支持运行时权限授予
退货 | |
---|---|
boolean | 如果支持运行时权限,则为true,否则为false。 |
投掷 | |
---|---|
DeviceNotAvailableException |
logBugreport
public abstract boolean logBugreport (String dataName, ITestLogger listener)
进行错误报告并将其记录到报告程序的助手方法。
参量 | |
---|---|
dataName | String :将用来报告错误报告的名称。 |
listener | ITestLogger :用于记录ITestLogger 的ITestLogger 。 |
退货 | |
---|---|
boolean | 如果记录成功,则为True,否则为false。 |
logOnDevice
public abstract void logOnDevice (String tag, Log.LogLevel level, String format, Object... args)
在设备的日志中记录一条消息。 This is a safe call that will not throw even if the logging fails.
Parameters | |
---|---|
tag | String : The tag under which we log our message in the logcat. |
level | Log.LogLevel : The debug level of the message in the logcat. |
format | String : The message format. |
args | Object : the args to be replaced via String.format(). |
nonBlockingReboot
public abstract void nonBlockingReboot ()
Issues a command to reboot device and returns on command complete and when device is no longer visible to adb.
Throws | |
---|---|
DeviceNotAvailableException |
postBootSetup
public abstract void postBootSetup ()
Perform instructions to configure device for testing that after every boot.
Should be called after device is fully booted/available In normal circumstances this method doesn't need to be called explicitly, as implementations should perform these steps automatically when performing a reboot. Where it may need to be called is when device reboots due to other events (eg when a fastboot update command has completed)Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
postInvocationTearDown
public abstract void postInvocationTearDown ()
Extra steps for device specific required clean up that will be executed after the invocation is done.
preInvocationSetup
public abstract void preInvocationSetup (IBuildInfo info)
Extra steps for device specific required setup that will be executed on the device prior to the invocation flow.
Parameters | |
---|---|
info | IBuildInfo |
Throws | |
---|---|
DeviceNotAvailableException | |
TargetSetupError |
preInvocationSetup
public void preInvocationSetup (IBuildInfo info,testResourceBuildInfos)
Extra steps for device specific required setup that will be executed on the device prior to the invocation flow.
Parameters | |
---|---|
info | IBuildInfo |
testResourceBuildInfos |
Throws | |
---|---|
DeviceNotAvailableException | |
TargetSetupError |
pullDir
public abstract boolean pullDir (String deviceFilePath, File localDir)
Recursively pull directory contents from device.
Parameters | |
---|---|
deviceFilePath | String : the absolute file path of the remote source |
localDir | File : the local directory to pull files into |
Returns | |
---|---|
boolean | true if file was pulled successfully. false otherwise. |
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
pullFile
public abstract File pullFile (String remoteFilePath)
Retrieves a file off device, stores it in a local temporary ERROR(/File)
, and returns that File
.
Parameters | |
---|---|
remoteFilePath | String : the absolute path to file on device. |
Returns | |
---|---|
File | A ERROR(/File) containing the contents of the device file, or null if the copy failed for any reason (including problems with the host filesystem) |
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
pullFile
public abstract boolean pullFile (String remoteFilePath, File localFile)
Retrieves a file off device.
Parameters | |
---|---|
remoteFilePath | String : the absolute path to file on device. |
localFile | File : the local file to store contents in. If non-empty, contents will be replaced. |
Returns | |
---|---|
boolean | true if file was retrieved successfully. false otherwise. |
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
pullFileContents
public abstract String pullFileContents (String remoteFilePath)
Retrieves a file off device, and returns the contents.
Parameters | |
---|---|
remoteFilePath | String : the absolute path to file on device. |
Returns | |
---|---|
String | AString containing the contents of the device file, or null if the copy failed for any reason (including problems with the host filesystem) |
Throws | |
---|---|
DeviceNotAvailableException |
pullFileFromExternal
public abstract File pullFileFromExternal (String remoteFilePath)
A convenience method to retrieve a file from the device's external storage, stores it in a local temporary ERROR(/File)
, and return a reference to that File
.
Parameters | |
---|---|
remoteFilePath | String : the path to file on device, relative to the device's external storage mountpoint |
Returns | |
---|---|
File | A ERROR(/File) containing the contents of the device file, or null if the copy failed for any reason (including problems with the host filesystem) |
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
pushDir
public abstract boolean pushDir (File localDir, String deviceFilePath,excludedDirectories)
Recursively push directory contents to device while excluding some directories that are filtered.
Parameters | |
---|---|
localDir | File : the local directory to push |
deviceFilePath | String : the absolute file path of the remote destination |
excludedDirectories |
Returns | |
---|---|
boolean | true if file was pushed successfully. false otherwise. |
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
pushDir
public abstract boolean pushDir (File localDir, String deviceFilePath)
Recursively push directory contents to device.
Parameters | |
---|---|
localDir | File : the local directory to push |
deviceFilePath | String : the absolute file path of the remote destination |
Returns | |
---|---|
boolean | true if file was pushed successfully. false otherwise. |
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
pushFile
public abstract boolean pushFile (File localFile, String deviceFilePath)
Push a file to device
Parameters | |
---|---|
localFile | File : the local file to push |
deviceFilePath | String : the remote destination absolute file path |
Returns | |
---|---|
boolean | true if file was pushed successfully. false otherwise. |
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
pushString
public abstract boolean pushString (String contents, String deviceFilePath)
Push file created from a string to device
Parameters | |
---|---|
contents | String : the contents of the file to push |
deviceFilePath | String : the remote destination absolute file path |
Returns | |
---|---|
boolean | true if string was pushed successfully. false otherwise. |
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
reboot
public abstract void reboot ()
Reboots the device into adb mode.
Blocks until device becomes available.Throws | |
---|---|
DeviceNotAvailableException | if device is not available after reboot |
rebootIntoBootloader
public abstract void rebootIntoBootloader ()
Reboots the device into bootloader mode.
Blocks until device is in bootloader mode.Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
rebootIntoRecovery
public abstract void rebootIntoRecovery ()
Reboots the device into adb recovery mode.
Blocks until device enters recoveryThrows | |
---|---|
DeviceNotAvailableException | if device is not available after reboot |
rebootUntilOnline
public abstract void rebootUntilOnline ()
An alternate to reboot()
that only blocks until device is online ie visible to adb.
Throws | |
---|---|
DeviceNotAvailableException | if device is not available after reboot |
remountSystemWritable
public abstract void remountSystemWritable ()
Make the system partition on the device writable. May reboot the device.
Throws | |
---|---|
DeviceNotAvailableException |
runInstrumentationTests
public abstract boolean runInstrumentationTests (IRemoteAndroidTestRunner runner, ITestLifeCycleReceiver... listeners)
Convenience method for performing ERROR(/#runInstrumentationTests(com.android.ddmlib.testrunner.IRemoteAndroidTestRunner,Collection))
with one or more listeners passed as parameters.
Parameters | |
---|---|
runner | IRemoteAndroidTestRunner : the IRemoteAndroidTestRunner which runs the tests |
listeners | ITestLifeCycleReceiver : the test result listener(s) |
Returns | |
---|---|
boolean | true if test command completed. false if it failed to complete, but recovery succeeded |
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. ie test command failed to complete and recovery failed. |
runInstrumentationTests
public abstract boolean runInstrumentationTests (IRemoteAndroidTestRunner runner,listeners)
Runs instrumentation tests, and provides device recovery.
If connection with device is lost before test run completes, and recovery succeeds, all listeners will be informed of testRunFailed and "false" will be returned. The test command will not be rerun. It is left to callers to retry if necessary.
If connection with device is lost before test run completes, and recovery fails, all listeners will be informed of testRunFailed and DeviceNotAvailableException will be thrown.
Parameters | |
---|---|
runner | IRemoteAndroidTestRunner : the IRemoteAndroidTestRunner which runs the tests |
listeners |
Returns | |
---|---|
boolean | true if test command completed. false if it failed to complete due to device communication exception, but recovery succeeded |
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. ie test command failed to complete and recovery failed. |
runInstrumentationTestsAsUser
public abstract boolean runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId, ITestLifeCycleReceiver... listeners)
Same as ITestDevice#runInstrumentationTests(IRemoteAndroidTestRunner, ITestLifeCycleReceiver...)
but runs the test for a given user.
Parameters | |
---|---|
runner | IRemoteAndroidTestRunner |
userId | int |
listeners | ITestLifeCycleReceiver |
Returns | |
---|---|
boolean |
Throws | |
---|---|
DeviceNotAvailableException |
runInstrumentationTestsAsUser
public abstract boolean runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId,listeners)
Same as ERROR(ITestDevice#runInstrumentationTests(IRemoteAndroidTestRunner, Collection)/com.android.tradefed.device.ITestDevice#runInstrumentationTests(com.android.ddmlib.testrunner.IRemoteAndroidTestRunner,Collection) ITestDevice#runInstrumentationTests(IRemoteAndroidTestRunner, Collection))
but runs the test for the given user.
Parameters | |
---|---|
runner | IRemoteAndroidTestRunner |
userId | int |
listeners |
Returns | |
---|---|
boolean |
Throws | |
---|---|
DeviceNotAvailableException |
setDate
public abstract void setDate (Date date)
Sets the date on device
Note: setting date on device requires root
Parameters | |
---|---|
date | Date : specify a particular date; will use host date if null |
Throws | |
---|---|
DeviceNotAvailableException |
setOptions
public abstract void setOptions (TestDeviceOptions options)
Set the TestDeviceOptions
for the device
Parameters | |
---|---|
options | TestDeviceOptions |
setProperty
public abstract boolean setProperty (String propKey, String propValue)
Sets the given property value on the device. Requires adb root is true.
Parameters | |
---|---|
propKey | String : The key targeted to be set. |
propValue | String : The property value to be set. |
Returns | |
---|---|
boolean | returns True if the setprop command was successful, False otherwise. |
Throws | |
---|---|
DeviceNotAvailableException |
setRecovery
public abstract void setRecovery (IDeviceRecovery recovery)
Set the IDeviceRecovery
to use for this device. Should be set when device is first allocated.
Parameters | |
---|---|
recovery | IDeviceRecovery : the IDeviceRecovery |
setRecoveryMode
public abstract void setRecoveryMode (ITestDevice.RecoveryMode mode)
Set the current recovery mode to use for the device.
Used to control what recovery method to use when a device communication problem is encountered. Its recommended to only use this method sparingly when needed (for example, when framework is down, etcParameters | |
---|---|
mode | ITestDevice.RecoveryMode : whether 'recover till online only' mode should be on or not. |
setUseFastbootErase
public abstract void setUseFastbootErase (boolean useFastbootErase)
Set whether to use fastboot erase or fastboot format to wipe a partition on the device.
Parameters | |
---|---|
useFastbootErase | boolean : true if fastboot erase should be used or false if fastboot format should be used. |
See also:
startLogcat
public abstract void startLogcat ()
Start capturing logcat output from device in the background.
Will have no effect if logcat output is already being captured. Data can be later retrieved via getLogcat. When the device is no longer in use,stopLogcat()
must be called. startLogcat()
and stopLogcat()
do not normally need to be called when within a TF invocation context, as the TF framework will start and stop logcat.stopEmulatorOutput
public abstract void stopEmulatorOutput ()
Close and delete the emulator output.
stopLogcat
public abstract void stopLogcat ()
Stop capturing logcat output from device, and discard currently saved logcat data.
Will have no effect if logcat output is not being captured.switchToAdbTcp
public abstract String switchToAdbTcp ()
Switch device to adb-over-tcp mode.
Returns | |
---|---|
String | the tcp serial number or null if device could not be switched |
Throws | |
---|---|
DeviceNotAvailableException |
switchToAdbUsb
public abstract boolean switchToAdbUsb ()
Switch device to adb over usb mode.
Returns | |
---|---|
boolean | true if switch was successful, false otherwise. |
Throws | |
---|---|
DeviceNotAvailableException |
syncFiles
public abstract boolean syncFiles (File localFileDir, String deviceFilePath)
Incrementally syncs the contents of a local file directory to device.
Decides which files to push by comparing timestamps of local files with their remote equivalents. Only 'newer' or non-existent files will be pushed to device. Thus overhead should be relatively small if file set on device is already up to date. Hidden files (with names starting with ".") will be ignored. Example usage: syncFiles("/tmp/files", "/sdcard") will created a /sdcard/files directory if it doesn't already exist, and recursively push the /tmp/files contents to /sdcard/files.Parameters | |
---|---|
localFileDir | File : the local file directory containing files to recursively push. |
deviceFilePath | String : the remote destination absolute file path root. All directories in thos file path must be readable. ie pushing to /data/local/tmp when adb is not root will fail |
Returns | |
---|---|
boolean | true if files were synced successfully. false otherwise. |
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
takeBugreport
public abstract Bugreport takeBugreport ()
Take a bugreport and returns it inside a Bugreport
object to handle it. Return null in case of issue.
Bugreport#close()
.Returns | |
---|---|
Bugreport |
unencryptDevice
public abstract boolean unencryptDevice ()
Unencrypts the device.
Unencrypting the device may cause device to be wiped and may reboot device. This method will block until device is available and ready for testing. Requires fastboot inorder to wipe the userdata partition.Returns | |
---|---|
boolean | true if successful. |
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
UnsupportedOperationException | if encryption is not supported on the device. |
unlockDevice
public abstract boolean unlockDevice ()
Unlocks the device if the device is in an encrypted state.
This method may restart the framework but will not callpostBootSetup()
. Therefore, the device might not be fully ready to be tested when this method returns.Returns | |
---|---|
boolean | true if successful or if the device is unencrypted. |
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
UnsupportedOperationException | if encryption is not supported on the device. |
waitForBootComplete
public abstract boolean waitForBootComplete (long timeOut)
Blocks until the device's boot complete flag is set.
Parameters | |
---|---|
timeOut | long : time in msecs to wait for the flag to be set |
Returns | |
---|---|
boolean | true if device's boot complete flag is set within the timeout |
Throws | |
---|---|
DeviceNotAvailableException |
waitForDeviceAvailable
public abstract void waitForDeviceAvailable ()
Waits for the device to be responsive and available for testing. Uses default timeout.
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
waitForDeviceAvailable
public abstract void waitForDeviceAvailable (long waitTime)
Waits for the device to be responsive and available for testing.
Parameters | |
---|---|
waitTime | long : the time in ms to wait |
Throws | |
---|---|
DeviceNotAvailableException | if device is still unresponsive after waitTime expires. |
waitForDeviceInRecovery
public abstract boolean waitForDeviceInRecovery (long waitTime)
Blocks for the device to be in the 'adb recovery' state (note this is distinct from IDeviceRecovery
).
Parameters | |
---|---|
waitTime | long : the time in ms to wait |
Returns | |
---|---|
boolean | true if device boots into recovery before time expires. false otherwise |
waitForDeviceNotAvailable
public abstract boolean waitForDeviceNotAvailable (long waitTime)
Blocks for the device to be not available ie missing from adb
Parameters | |
---|---|
waitTime | long : the time in ms to wait |
Returns | |
---|---|
boolean | true if device becomes not available before time expires. false otherwise |
waitForDeviceOnline
public abstract void waitForDeviceOnline ()
Blocks until device is visible via adb. Uses default timeout
Note the device may not necessarily be responsive to commands on completion. UsewaitForDeviceAvailable()
instead.Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
waitForDeviceOnline
public abstract void waitForDeviceOnline (long waitTime)
Blocks until device is visible via adb.
Note the device may not necessarily be responsive to commands on completion. UsewaitForDeviceAvailable()
instead.Parameters | |
---|---|
waitTime | long : the time in ms to wait |
Throws | |
---|---|
DeviceNotAvailableException | if connection with device is lost and cannot be recovered. |
waitForDeviceShell
public abstract boolean waitForDeviceShell (long waitTime)
Waits for device to be responsive to a basic adb shell command.
Parameters | |
---|---|
waitTime | long : the time in ms to wait |
Returns | |
---|---|
boolean | true if device becomes responsive before waitTime elapses. |