创新设备

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 deviceSoftRestarted ( ProcessInfo prevSystemServerProcess)

通过将当前 system_server 与之前的 system_server ProcessInfo进行比较来检查设备是否软重启的辅助方法。

abstract boolean deviceSoftRestartedSince (long utcEpochTime, TimeUnit timeUnit)

检查设备是否从设备纪元以来的 UTC 时间及其ERROR(/TimeUnit)软重启的辅助方法。

abstract boolean disableAdbRoot ()

关闭 adb root。

abstract boolean doesFileExist (String deviceFilePath)

确定设备上的文件是否存在的辅助方法。

abstract boolean enableAdbRoot ()

打开 adb root。

abstract String executeAdbCommand (long timeout, String... commandArgs)

将 adb 命令作为具有指定超时的系统命令执行的辅助方法。

abstract String executeAdbCommand (String... commandArgs)

将 adb 命令作为系统命令执行的辅助方法。

abstract String executeAdbCommand (long timeout, envMap, String... commandArgs) executeAdbCommand (long timeout, envMap, String... commandArgs)

将 adb 命令作为具有指定超时的系统命令执行的辅助方法。

abstract CommandResult executeFastbootCommand (long timeout, String... commandArgs)

将 fastboot 命令作为系统命令执行的辅助方法。

abstract CommandResult executeFastbootCommand (String... commandArgs)

将 fastboot 命令作为系统命令执行的辅助方法,默认超时为 2 分钟。

abstract CommandResult executeLongFastbootCommand (String... commandArgs)

将长时间运行的 fastboot 命令作为系统命令执行的辅助方法。

abstract CommandResult executeLongFastbootCommand ( envVarMap, String... commandArgs) executeLongFastbootCommand ( envVarMap, String... commandArgs)

将长时间运行的 fastboot 命令作为具有系统环境变量的系统命令执行的辅助方法。

abstract String executeShellCommand (String command)

执行 adb shell 命令并将输出作为ERROR(/String)返回的帮助程序方法。

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 命令并将结果作为CommandResult返回的辅助方法,其中正确填充了命令状态输出、stdout 和 stderr。

abstract CommandResult executeShellV2Command (String command, OutputStream pipeToOutput)

执行 adb shell 命令并将结果作为CommandResult返回的帮助程序方法,其中正确填充了命令状态输出和 stderr。

abstract CommandResult executeShellV2Command (String command, File pipeAsInput)

执行 adb shell 命令并将结果作为CommandResult返回的帮助程序方法,其中正确填充了命令状态输出、stdout 和 stderr。

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 executeShellV2Command (String command, File pipeAsInput, OutputStream pipeToOutput, OutputStream pipeToError, 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 boolean getBooleanProperty (String name, boolean defaultValue)

返回给定属性的布尔值。

abstract getBootHistory ()

Helper 方法收集带有启动时间和启动原因的启动历史映射。

abstract getBootHistorySince (long utcEpochTime, TimeUnit timeUnit)

Helper 方法从设备的纪元以来的给定时间和指定的时间单位收集启动历史映射,其中包含启动时间和启动原因。

abstract String getBootloaderVersion ()

获取此设备的引导加载程序版本的便捷方法。

abstract String getBuildAlias ()

检索设备当前运行的构建的别名。

abstract String getBuildFlavor ()

检索设备的构建风格。

abstract String getBuildId ()

检索设备当前正在运行的版本。

abstract String getBuildSigningKeys ()

返回用于签署设备映像的密钥类型

通常,Android 设备可能使用测试密钥(如 AOSP)或发布密钥(由各个设备制造商控制)进行签名

abstract DeviceDescriptor getCachedDeviceDescriptor ()

如果分配了设备,则返回缓存的DeviceDescriptor ,否则返回当前的DeviceDescriptor

abstract DeviceDescriptor getCachedDeviceDescriptor (boolean shortDescriptor)

如果分配了设备,则返回缓存的DeviceDescriptor ,否则返回当前的DeviceDescriptor

abstract String[] getChildren (String deviceFilePath)

使用IFileEntry的替代方法有时会因为权限问题而无法工作。

abstract AbstractConnection getConnection ()

返回与设备关联的连接。

abstract String getDeviceClass ()

获取设备类。

abstract long getDeviceDate ()

从纪元开始以毫秒为单位返回设备的日期。

abstract DeviceDescriptor getDeviceDescriptor ()

从设备信息中返回一个DeviceDescriptor以获取有关它的信息,而不传递实际的设备对象。

abstract DeviceDescriptor getDeviceDescriptor (boolean shortDescriptor)

从设备信息中返回一个DeviceDescriptor以获取有关它的信息,而不传递实际的设备对象。

abstract TestDeviceState getDeviceState ()

获取设备的状态。

abstract long getDeviceTimeOffset (Date date)

帮助获取设备与给定ERROR(/Date)之间的时差。

abstract InputStreamSource getEmulatorOutput ()

获取模拟器stdout和stderr的流

abstract long getExternalStoreFreeSpace ()

确定设备外部存储可用空间量的辅助方法。

abstract String getFastbootProductType ()

在 fastboot 模式下获取此设备的产品类型的便捷方法。

abstract String getFastbootProductVariant ()

在 fastboot 模式下获取此设备的产品类型的便捷方法。

abstract String getFastbootSerialNumber ()

返回快速启动模式序列号。

abstract String getFastbootVariable (String variableName)

从设备中检索给定的 fastboot 变量值。

abstract IFileEntry getFileEntry (String path)

检索对设备上远程文件的引用。

abstract IDevice getIDevice ()

返回对关联的 ddmlib IDevice引用。

abstract long getIntProperty (String name, long defaultValue)

从设备返回给定属性的整数值。

abstract long getLastExpectedRebootTimeMillis ()

返回自ERROR(/System#currentTimeMillis())返回的 EPOCH 以来 Tradefed API 上次触发重启的毫秒数。

abstract int getLaunchApiLevel ()

获取设备首次启动的 API 级别。

abstract InputStreamSource getLogcat ()

获取 logcat 数据的快照流。

abstract InputStreamSource getLogcat (int maxBytes)

获取捕获的 logcat 数据的最后maxBytes的快照流。

abstract InputStreamSource getLogcatDump ()

获取设备当前 logcat 的转储。

abstract InputStreamSource getLogcatSince (long date)

从提供的日期开始获取捕获的 logcat 数据的快照流。

abstract String getMountPoint (String mountName)

返回挂载点。

abstract ITestDevice.MountPointInfo getMountPointInfo (String mountpoint)

返回对应于指定挂载点路径的MountPointInfo ,如果该路径没有挂载任何内容或不作为挂载点出现在 /proc/mounts 中,则返回null

abstract getMountPointInfo ()

返回设备上 /proc/mounts 中信息的解析版本

abstract long getPartitionFreeSpace (String partition)

确定设备分区上可用空间量的辅助方法。

abstract ProcessInfo getProcessByName (String processName)

Helper 方法运行“pidof”和“stat”命令并返回具有给定进程的 PID 和进程启动时间的ProcessInfo对象。

abstract String getProcessPid (String process)

如果出现问题,则返回服务的 pid 或 null。

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 erase 或 fastboot format 擦除设备上的分区。

abstract boolean isAdbRoot ()
abstract boolean isAdbTcp ()
abstract boolean isAppEnumerationSupported ()

检查设备上的平台是否支持应用枚举

abstract boolean isBypassLowTargetSdkBlockSupported ()

检查设备上的平台是否支持在应用安装时绕过低目标 sdk 块

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 isStateBootloaderOrFastbootd ()

如果设备处于TestDeviceState#FASTBOOTTestDeviceState.FASTBOOTD中,则返回 true。

abstract boolean logAnrs ( ITestLogger logger)

从设备收集和记录 ANR。

abstract void logOnDevice (String tag, Log.LogLevel level, String format, Object... args)

在设备的 logcat 中记录一条消息。

abstract void nonBlockingReboot ()

发出命令以重新启动设备并在命令完成时返回,当设备不再对 adb 可见时。

abstract void postBootSetup ()

执行说明以配置设备以在每次启动后进行测试。

default void postInvocationTearDown ()

此方法已弃用。请改用postInvocationTearDown(Throwable)

abstract void postInvocationTearDown (Throwable invocationException)

特定于设备的额外步骤需要清理,将在调用完成后执行。

default void preInvocationSetup ( IBuildInfo info, MultiMap <String, String> attributes)

设备特定所需设置的额外步骤将在调用流程之前在设备上执行。

abstract boolean pullDir (String deviceFilePath, File localDir)

递归地从设备中提取目录内容。

abstract File pullFile (String remoteFilePath, int userId)

从设备中检索文件,将其存储在本地临时ERROR(/File)中,然后返回该File

abstract File pullFile (String remoteFilePath)

从设备中检索文件,将其存储在本地临时ERROR(/File)中,然后返回该File

abstract boolean pullFile (String remoteFilePath, File localFile)

从设备中检索文件。

abstract boolean pullFile (String remoteFilePath, File localFile, int userId)

从设备中检索文件。

abstract String pullFileContents (String remoteFilePath)

从设备中检索文件,并返回内容。

abstract File pullFileFromExternal (String remoteFilePath)

从设备的外部存储中检索文件的便捷方法,将其存储在本地临时ERROR(/File)中,并返回对该File的引用。

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, boolean evaluateContentProviderNeeded)

pushFile(File, String)的变体,可以选择考虑评估对内容提供者的需求。

abstract boolean pushFile (File localFile, String deviceFilePath)

将文件推送到设备。

abstract boolean pushString (String contents, String deviceFilePath)

将从字符串创建的文件推送到设备

abstract void reboot ()

将设备重新启动到 adb 模式。

abstract void reboot (String reason)

将设备重新启动到 adb 模式,并给出在重新启动后保持不变的reason

abstract void rebootIntoBootloader ()

将设备重新启动到引导加载程序模式。

abstract void rebootIntoFastbootd ()

将设备重新启动到 fastbootd 模式。

abstract void rebootIntoRecovery ()

将设备重新启动到 adb 恢复模式。

abstract void rebootIntoSideload (boolean autoReboot)

将设备重新启动到 adb sideload 模式(请注意,这是 recovery 下的一种特殊模式)

阻塞直到设备进入侧载模式

abstract void rebootIntoSideload ()

将设备重新启动到 adb sideload 模式(请注意,这是 recovery 下的一种特殊模式)

阻塞直到设备进入侧载模式

abstract void rebootUntilOnline ()

reboot()的替代方法,它只会阻塞直到设备在线,即对 adb 可见。

abstract void rebootUntilOnline (String reason)

reboot()的替代方法,它只会阻塞直到设备在线,即对 adb 可见。

abstract void rebootUserspace ()

仅重启设备的用户空间部分。

abstract void rebootUserspaceUntilOnline ()

rebootUserspace() ()} 的替代方法,它只会阻塞直到设备在线,即对 adb 可见。

abstract void remountSystemWritable ()

使设备上的系统分区可写。

abstract void remountVendorWritable ()

使设备上的供应商分区可写。

abstract boolean runInstrumentationTests (IRemoteAndroidTestRunner runner, ITestLifeCycleReceiver... listeners)

使用作为参数传递的一个或多个侦听器执行ERROR(/#runInstrumentationTests(com.android.ddmlib.testrunner.IRemoteAndroidTestRunner,Collection))的便捷方法。

abstract boolean runInstrumentationTests (IRemoteAndroidTestRunner runner, listeners) runInstrumentationTests (IRemoteAndroidTestRunner runner, listeners)

运行仪器测试,并提供设备恢复。

abstract boolean runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId, listeners) runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId, listeners)

ERROR(ITestDevice#runInstrumentationTests(IRemoteAndroidTestRunner, Collection)/com.android.tradefed.device.ITestDevice#runInstrumentationTests(com.android.ddmlib.testrunner.IRemoteAndroidTestRunner,Collection) ITestDevice#runInstrumentationTests(IRemoteAndroidTestRunner, Collection))但运行测试对于给定的用户。

abstract boolean runInstrumentationTestsAsUser (IRemoteAndroidTestRunner runner, int userId, ITestLifeCycleReceiver... listeners)

ITestDevice#runInstrumentationTests(IRemoteAndroidTestRunner, ITestLifeCycleReceiver...)相同,但为给定用户运行测试。

abstract void setDate (Date date)

在设备上设置日期

注意:在设备上设置日期需要 root

abstract void setOptions ( TestDeviceOptions options)

为设备设置TestDeviceOptions

abstract boolean setProperty (String propKey, String propValue)

在设备上设置给定的属性值。

abstract void setRecovery ( IDeviceRecovery recovery)

设置要用于此设备的IDeviceRecovery

abstract void setRecoveryMode ( ITestDevice.RecoveryMode mode)

设置当前用于设备的恢复模式。

abstract void setUseFastbootErase (boolean useFastbootErase)

设置是否使用 fastboot erase 或 fastboot format 擦除设备上的分区。

abstract void startLogcat ()

开始在后台捕获设备的 logcat 输出。

abstract void stopEmulatorOutput ()

关闭并删除模拟器输出。

abstract void stopLogcat ()

停止从设备捕获 logcat 输出,并丢弃当前保存的 logcat 数据。

abstract String switchToAdbTcp ()

将设备切换到 adb-over-tcp 模式。

abstract boolean switchToAdbUsb ()

将设备切换到 adb over usb 模式。

abstract boolean syncFiles (File localFileDir, String deviceFilePath)

将本地文件目录的内容增量同步到设备。

abstract boolean unlockDevice ()

如果设备处于加密状态,则解锁设备。

abstract boolean waitForBootComplete (long timeOut)

阻塞,直到设置设备的启动完成标志。

abstract boolean waitForDeviceAvailable ()

等待设备响应并可用于测试。

abstract boolean waitForDeviceAvailable (long waitTime)

等待设备响应并可用于测试。

abstract boolean waitForDeviceAvailableInRecoverPath (long waitTime)

等待设备响应并可用,而不考虑恢复路径。

abstract void waitForDeviceBootloader ()

阻塞直到设备通过快速启动可见。

abstract boolean waitForDeviceInRecovery (long waitTime)

设备处于“adb recovery”状态的块(注意这与IDeviceRecovery不同)。

abstract boolean waitForDeviceInSideload (long waitTime)

设备处于“adb sideload”状态的块

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)

公共方法

检查 ApiLevelAgainstNextRelease

public abstract boolean checkApiLevelAgainstNextRelease (int strictMinLevel)

在给定最低支持级别的情况下,检查当前是否支持某个功能。在提升 API 级别之前,此方法考虑了尚未发布的功能。

参数
strictMinLevel int :支持该功能的严格最小可能级别。

退货
boolean如果支持该级别,则为真。否则为假。

投掷
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

清除日志猫

public abstract void clearLogcat ()

删除任何累积的 logcat 数据。

这对于您想要确保ITestDevice#getLogcat()仅返回在特定点之后生成的日志数据(例如在刷新新设备构建之后等)的情况很有用。

删除文件

public abstract void deleteFile (String deviceFilePath)

用于删除设备上的文件或目录的辅助方法。

参数
deviceFilePath String : 文件在设备上的绝对路径。

投掷
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

设备软重启

public abstract boolean deviceSoftRestarted (ProcessInfo prevSystemServerProcess)

通过将当前 system_server 与之前的 system_server ProcessInfo进行比较来检查设备是否软重启的辅助方法。使用getProcessByName(String)获取ProcessInfo

参数
prevSystemServerProcess ProcessInfo :之前的system_server进程ProcessInfo

退货
boolean如果设备软重启则为true

投掷
如果设备有异常启动原因
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

deviceSoftRestartedSince

public abstract boolean deviceSoftRestartedSince (long utcEpochTime, 
                TimeUnit timeUnit)

检查设备是否从设备纪元以来的 UTC 时间及其ERROR(/TimeUnit)软重启的辅助方法。软重启是指 system_server 在设备硬重启之外重启(例如:请求重启)。可以通过方法getDeviceDate()获取以毫秒为单位的当前设备 utcEpochTime。

参数
utcEpochTime long :自纪元以来以秒为单位的设备时间。

timeUnit TimeUnit :给定 utcEpochTime 的时间单位TimeUnit

退货
boolean如果设备软重启则为true

投掷
如果设备有异常启动原因
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

禁用 AdbRoot

public abstract boolean disableAdbRoot ()

关闭 adb root。

禁用 adb root 可能会导致设备与 adb 断开连接。此方法将阻塞,直到设备可用。

退货
boolean如果成功则为true

投掷
DeviceNotAvailableException如果与设备的连接丢失且无法恢复。

文件是否存在

public abstract boolean doesFileExist (String deviceFilePath)

确定设备上的文件是否存在的辅助方法。

参数
deviceFilePath String : 要检查的设备上文件的绝对路径

退货
boolean如果文件存在true ,否则为false

投掷
DeviceNotAvailableException如果与设备的连接丢失且无法恢复。

启用 AdbRoot

public abstract boolean enableAdbRoot ()

打开 adb root。如果“enable-root”设置为“false”,将记录一条消息并在不启用 root 的情况下返回。

启用 adb root 可能会导致设备与 adb 断开连接。此方法将阻塞,直到设备可用。

退货
boolean如果成功则为true

投掷
DeviceNotAvailableException如果与设备的连接丢失且无法恢复。

执行 Adb 命令

public abstract String executeAdbCommand (long timeout, 
                String... commandArgs)

将 adb 命令作为具有指定超时的系统命令执行的辅助方法。

executeShellCommand(String)应尽可能改用,因为该方法可提供更好的故障检测和性能。

参数
timeout long :设备被认为无响应之前的时间(以毫秒为单位),0L 表示没有超时

commandArgs String :要运行的 adb 命令和参数

退货
String来自命令的标准输出。如果命令执行失败则为null

投掷
DeviceNotAvailableException如果与设备的连接丢失且无法恢复。

执行 Adb 命令

public abstract String executeAdbCommand (String... commandArgs)

将 adb 命令作为系统命令执行的辅助方法。

executeShellCommand(String)应尽可能改用,因为该方法可提供更好的故障检测和性能。

参数
commandArgs String :要运行的 adb 命令和参数

退货
String来自命令的标准输出。如果命令执行失败则为null

投掷
DeviceNotAvailableException如果与设备的连接丢失且无法恢复。

执行 Adb 命令

public abstract String executeAdbCommand (long timeout, 
                 envMap, 
                String... commandArgs)

将 adb 命令作为具有指定超时的系统命令执行的辅助方法。

executeShellCommand(String)应尽可能改用,因为该方法可提供更好的故障检测和性能。

参数
timeout long :设备被认为无响应之前的时间(以毫秒为单位),0L 表示没有超时

envMap :为命令设置的环境

commandArgs String :要运行的 adb 命令和参数

退货
String来自命令的标准输出。如果命令执行失败则为null

投掷
DeviceNotAvailableException如果与设备的连接丢失且无法恢复。

执行Fastboot命令

public abstract CommandResult executeFastbootCommand (long timeout, 
                String... commandArgs)

将 fastboot 命令作为系统命令执行的辅助方法。

预计在设备已经处于快速启动模式时使用。

参数
timeout long :命令过期前的时间(以毫秒为单位)

commandArgs String :要运行的 fastboot 命令和参数

退货
CommandResult包含命令输出的 CommandResult

投掷
DeviceNotAvailableException如果与设备的连接丢失且无法恢复。

执行Fastboot命令

public abstract CommandResult executeFastbootCommand (String... commandArgs)

将 fastboot 命令作为系统命令执行的辅助方法,默认超时为 2 分钟。

预计在设备已经处于快速启动模式时使用。

参数
commandArgs String :要运行的 fastboot 命令和参数

退货
CommandResult包含命令输出的 CommandResult

投掷
DeviceNotAvailableException如果与设备的连接丢失且无法恢复。

executeLongFastbootCommand

public abstract CommandResult executeLongFastbootCommand (String... commandArgs)

将长时间运行的 fastboot 命令作为系统命令执行的辅助方法。

executeFastbootCommand(String)相同,只是使用了更长的超时时间。

参数
commandArgs String :要运行的 fastboot 命令和参数

退货
CommandResult包含命令输出的 CommandResult

投掷
DeviceNotAvailableException如果与设备的连接丢失且无法恢复。

executeLongFastbootCommand

public abstract CommandResult executeLongFastbootCommand ( envVarMap, 
                String... commandArgs)

将长时间运行的 fastboot 命令作为具有系统环境变量的系统命令执行的辅助方法。

executeFastbootCommand(String)相同,只是使用了更长的超时时间。

参数
envVarMap : fastboot命令运行的系统环境变量

commandArgs String :要运行的 fastboot 命令和参数

退货
CommandResult包含命令输出的 CommandResult

投掷
DeviceNotAvailableException如果与设备的连接丢失且无法恢复。

执行Shell命令

public abstract String executeShellCommand (String command)

执行 adb shell 命令并将输出作为ERROR(/String)返回的帮助程序方法。

参数
command String :要运行的 adb shell 命令

退货
String外壳输出

投掷
DeviceNotAvailableException如果与设备的连接丢失且无法恢复。

执行Shell命令

public abstract void executeShellCommand (String command, 
                IShellOutputReceiver receiver, 
                long maxTimeToOutputShellResponse, 
                TimeUnit timeUnit, 
                int retryAttempts)

执行 adb shell 命令,使用更多参数来控制命令行为。

参数
command String :要运行的 adb shell 命令

receiver IShellOutputReceiver :将 shell 输出定向到的IShellOutputReceiver

maxTimeToOutputShellResponse long :允许命令不输出任何响应的最长时间; timeUnit中指定的单位

timeUnit TimeUnit : maxTimeToOutputShellResponse的单位

retryAttempts int :如果由于异常而失败,重试命令的最大次数。如果retryAttempts执行失败,将抛出 DeviceNotResponsiveException。

投掷
DeviceNotAvailableException如果与设备的连接丢失且无法恢复。

执行Shell命令

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

maxTimeoutForCommand long :命令完成的最大超时时间; timeUnit中指定的单位

maxTimeToOutputShellResponse long :允许命令不输出任何响应的最长时间; timeUnit中指定的单位

timeUnit TimeUnit : maxTimeToOutputShellResponse的单位

retryAttempts int :如果由于异常而失败,重试命令的最大次数。如果retryAttempts执行失败,将抛出 DeviceNotResponsiveException。

投掷
DeviceNotAvailableException如果与设备的连接丢失且无法恢复。

执行Shell命令

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

投掷
DeviceNotAvailableException如果与设备的连接丢失且无法恢复。

执行ShellV2命令

public abstract CommandResult executeShellV2Command (String command)

执行 adb shell 命令并将结果作为CommandResult返回的辅助方法,其中正确填充了命令状态输出、stdout 和 stderr。

参数
command String :应该运行的命令。

退货
CommandResult CommandResult中的结果。

投掷
DeviceNotAvailableException如果与设备的连接丢失且无法恢复。

执行ShellV2命令

public abstract CommandResult executeShellV2Command (String command, 
                OutputStream pipeToOutput)

执行 adb shell 命令并将结果作为CommandResult返回的帮助程序方法,其中正确填充了命令状态输出和 stderr。 stdout 被定向到指定的流。

参数
command String :应该运行的命令。

pipeToOutput OutputStream : ERROR(/OutputStream) std 输出将被重定向的位置,或者为 null。

退货
CommandResult CommandResult中的结果。

投掷
DeviceNotAvailableException如果与设备的连接丢失且无法恢复。

执行ShellV2命令

public abstract CommandResult executeShellV2Command (String command, 
                File pipeAsInput)

执行 adb shell 命令并将结果作为CommandResult返回的帮助程序方法,其中正确填充了命令状态输出、stdout 和 stderr。

参数
command String :应该运行的命令。

pipeAsInput File :一个ERROR(/File) ,将作为命令的输入通过管道传输,或者为 null。

退货
CommandResult CommandResult中的结果。

投掷
DeviceNotAvailableException如果与设备的连接丢失且无法恢复。

执行ShellV2命令

public abstract CommandResult executeShellV2Command (String command, 
                long maxTimeoutForCommand, 
                TimeUnit timeUnit, 
                int retryAttempts)

执行 adb shell 命令,使用更多参数来控制命令行为。

参数
command String :要运行的 adb shell 命令

maxTimeoutForCommand long :命令完成的最大超时时间; timeUnit中指定的单位

timeUnit TimeUnit : maxTimeToOutputShellResponse的单位

retryAttempts int :如果由于异常而失败,重试命令的最大次数。如果retryAttempts执行失败,将抛出 DeviceNotResponsiveException。

退货
CommandResult

投掷
DeviceNotAvailableException如果与设备的连接丢失且无法恢复。

执行ShellV2命令

public abstract CommandResult executeShellV2Command (String command, 
                long maxTimeoutForCommand, 
                TimeUnit timeUnit)

执行 adb shell 命令,使用更多参数来控制命令行为。

参数
command String :要运行的 adb shell 命令

maxTimeoutForCommand long :命令完成的最大超时时间; timeUnit中指定的单位

timeUnit TimeUnit : maxTimeToOutputShellResponse的单位

退货
CommandResult

投掷
DeviceNotAvailableException如果与设备的连接丢失且无法恢复。

执行ShellV2命令

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) ,将作为命令的输入通过管道传输,或者为 null。

pipeToOutput OutputStream : ERROR(/OutputStream) std 输出将被重定向的位置,或者为 null。

maxTimeoutForCommand long :命令完成的最大超时时间; timeUnit中指定的单位

timeUnit TimeUnit : maxTimeToOutputShellResponse的单位

retryAttempts int :如果由于异常而失败,重试命令的最大次数。如果retryAttempts执行失败,将抛出 DeviceNotResponsiveException。

退货
CommandResult

投掷
DeviceNotAvailableException如果与设备的连接丢失且无法恢复。

执行ShellV2命令

public abstract CommandResult executeShellV2Command (String command, 
                File pipeAsInput, 
                OutputStream pipeToOutput, 
                OutputStream pipeToError, 
                long maxTimeoutForCommand, 
                TimeUnit timeUnit, 
                int retryAttempts)

执行 adb shell 命令,使用更多参数来控制命令行为。

参数
command String :要运行的 adb shell 命令

pipeAsInput File :一个ERROR(/File) ,将作为命令的输入通过管道传输,或者为 null。

pipeToOutput OutputStream : ERROR(/OutputStream) std 输出将被重定向的位置,或者为 null。

pipeToError OutputStream : ERROR(/OutputStream)标准错误将被重定向,或者为空。

maxTimeoutForCommand long :命令完成的最大超时时间; timeUnit中指定的单位

timeUnit TimeUnit : maxTimeToOutputShellResponse的单位

retryAttempts int :如果由于异常而失败,重试命令的最大次数。如果retryAttempts执行失败,将抛出 DeviceNotResponsiveException。

退货
CommandResult

投掷
DeviceNotAvailableException如果与设备的连接丢失且无法恢复。

fastboot擦除分区

public abstract CommandResult fastbootWipePartition (String partition)

擦除设备分区的辅助方法。

如果getUseFastbootErase()true ,则将使用 fastboot erase 擦除分区。然后设备必须在下次启动时创建一个文件系统。否则,将使用 fastboot 格式,这将在设备上创建一个新的文件系统。

预计在设备已经处于快速启动模式时使用。

参数
partition String :要擦除的分区

退货
CommandResult包含命令输出的 CommandResult

投掷
DeviceNotAvailableException如果与设备的连接丢失且无法恢复。

获取API级别

public abstract int getApiLevel ()

获取设备 API 级别。默认为UNKNOWN_API_LEVEL

退货
int一个整数,指示设备的 API 级别

投掷
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

获取基带版本

public abstract String getBasebandVersion ()

获取此设备的基带(无线电)版本的便捷方法。获取无线电版本是特定于设备的,因此它可能不会为所有设备返回正确的信息。此方法依赖 gsm.version.baseband 属性返回正确的版本信息。这对于某些 CDMA 设备不准确,此处返回的版本可能与 fastboot 报告的版本不匹配,并且可能不会返回 CDMA 无线电的版本。 TL;DR 此方法仅在 gsm.version.baseband 属性与fastboot getvar version-baseband返回的版本相同时报告准确的版本。

退货
String ERROR(/String)基带版本,如果无法确定则为null (设备没有无线电或无法读取版本字符串)

投掷
DeviceNotAvailableException如果与设备的连接丢失且无法恢复。

获取电池

public abstract Integer getBattery ()

返回设备的当前电池电量,如果电池电量不可用,则返回 Null。

退货
Integer

获取布尔属性

public abstract boolean getBooleanProperty (String name, 
                boolean defaultValue)

返回给定属性的布尔值。

参数
name String : 属性名称

defaultValue boolean :属性为空或不存在时返回的默认值。

退货
boolean如果属性值为"1""y""yes""on""true" ,则为true ;如果属性值为"0""n""no""off" ,则为false"false" ,否则为defaultValue

投掷
DeviceNotAvailableException

获取启动历史

public abstract  getBootHistory ()

Helper 方法收集带有启动时间和启动原因的启动历史映射。

退货
启动时间映射(UTC 时间,自纪元以来的秒数)和启动原因

投掷
DeviceNotAvailableException

getBootHistorySince

public abstract  getBootHistorySince (long utcEpochTime, 
                TimeUnit timeUnit)

Helper 方法从设备的纪元以来的给定时间和指定的时间单位收集启动历史映射,其中包含启动时间和启动原因。可以通过方法getDeviceDate()获取以毫秒为单位的当前设备 utcEpochTime。

参数
utcEpochTime long :自纪元以来的设备时间。

timeUnit TimeUnit :时间单位TimeUnit

退货
启动时间映射(UTC 时间,自纪元以来的秒数)和启动原因

投掷
DeviceNotAvailableException

获取引导程序版本

public abstract String getBootloaderVersion ()

获取此设备的引导加载程序版本的便捷方法。

将尝试从设备的当前状态检索引导加载程序版本。 (即如果设备处于快速启动模式,它将尝试从快速启动中检索版本)

退货
String ERROR(/String)引导加载程序版本,如果找不到则为null

投掷
DeviceNotAvailableException如果与设备的连接丢失且无法恢复。

getBuildAlias

public abstract String getBuildAlias ()

检索设备当前运行的构建的别名。

构建别名通常是比构建 ID 更易读的字符串(通常是 Nexus 构建的数字)。例如,最终的 Android 4.2 版本具有构建别名 JDQ39 和构建 ID 573038

退货
String构建别名,如果无法检索则回退到构建 ID

投掷
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

获取BuildFlavor

public abstract String getBuildFlavor ()

检索设备的构建风格。

退货
String构建风格,如果无法检索则为 null

投掷
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

获取BuildId

public abstract String getBuildId ()

检索设备当前正在运行的版本。

退货
String构建 ID 或IBuildInfo#UNKNOWN_BUILD_ID (如果无法检索)

投掷
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

getBuildSigningKeys

public abstract String getBuildSigningKeys ()

返回用于签署设备映像的密钥类型

通常,Android 设备可能使用测试密钥(如 AOSP)或发布密钥(由各个设备制造商控制)进行签名

退货
String如果找到签名密钥,否则为 null。

投掷
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

获取缓存设备描述符

public abstract DeviceDescriptor getCachedDeviceDescriptor ()

如果分配了设备,则返回缓存的DeviceDescriptor ,否则返回当前的DeviceDescriptor

退货
DeviceDescriptor

获取缓存设备描述符

public abstract DeviceDescriptor getCachedDeviceDescriptor (boolean shortDescriptor)

如果分配了设备,则返回缓存的DeviceDescriptor ,否则返回当前的DeviceDescriptor

参数
shortDescriptor boolean :是否将描述符限制为最低限度的信息

退货
DeviceDescriptor

得到孩子

public abstract String[] getChildren (String deviceFilePath)

使用IFileEntry的替代方法有时会因为权限问题而无法工作。

参数
deviceFilePath String :是设备上进行搜索的路径

退货
String[]包含设备路径中所有文件的字符串数组。

投掷
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

获取连接

public abstract AbstractConnection getConnection ()

返回与设备关联的连接。

退货
AbstractConnection

获取设备类

public abstract String getDeviceClass ()

获取设备类。

退货
String ERROR(/String)设备类。

获取设备日期

public abstract long getDeviceDate ()

从纪元开始以毫秒为单位返回设备的日期。

退货
long纪元格式的设备日期。

投掷
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

获取设备描述符

public abstract DeviceDescriptor getDeviceDescriptor ()

从设备信息中返回一个DeviceDescriptor以获取有关它的信息,而不传递实际的设备对象。

退货
DeviceDescriptor

获取设备描述符

public abstract DeviceDescriptor getDeviceDescriptor (boolean shortDescriptor)

从设备信息中返回一个DeviceDescriptor以获取有关它的信息,而不传递实际的设备对象。

参数
shortDescriptor boolean :是否将描述符限制为最低限度的信息

退货
DeviceDescriptor

获取设备状态

public abstract TestDeviceState getDeviceState ()

获取设备的状态。

退货
TestDeviceState

获取设备时间偏移量

public abstract long getDeviceTimeOffset (Date date)

帮助获取设备与给定ERROR(/Date)之间的时差。在内部使用大纪元时间。

参数
date Date

退货
long以毫秒为单位的差异

投掷
DeviceNotAvailableException

获取模拟器输出

public abstract InputStreamSource getEmulatorOutput ()

获取模拟器stdout和stderr的流

退货
InputStreamSource模拟器输出

getExternalStoreFreeSpace

public abstract long getExternalStoreFreeSpace ()

确定设备外部存储可用空间量的辅助方法。

退货
long以 KB 为单位的可用空间量

投掷
DeviceNotAvailableException如果与设备的连接丢失且无法恢复。

getFastbootProductType

public abstract String getFastbootProductType ()

在 fastboot 模式下获取此设备的产品类型的便捷方法。

仅当设备应处于快速启动时才应使用此方法。在这种情况下,它比通用的getProductType()方法更安全一些,因为如果设备处于不正确的状态或没有响应,ITestDevice 将知道将设备恢复到快速启动。

退货
String ERROR(/String)产品类型名称,如果无法确定则为null

投掷
DeviceNotAvailableException如果与设备的连接丢失且无法恢复。

getFastbootProductVariant

public abstract String getFastbootProductVariant ()

在 fastboot 模式下获取此设备的产品类型的便捷方法。

仅当设备应处于快速启动时才应使用此方法。在这种情况下,它比通用的getProductType()方法更安全一些,因为如果设备处于不正确的状态或没有响应,ITestDevice 将知道将设备恢复到快速启动。

退货
String ERROR(/String)产品类型名称,如果无法确定则为null

投掷
DeviceNotAvailableException如果与设备的连接丢失且无法恢复。

getFastbootSerialNumber

public abstract String getFastbootSerialNumber ()

返回快速启动模式序列号。

退货
String

getFastboot变量

public abstract String getFastbootVariable (String variableName)

从设备中检索给定的 fastboot 变量值。

参数
variableName String : 变量名

退货
String属性值,如果不存在则为null

投掷
不支持的操作异常
DeviceNotAvailableException

获取文件入口

public abstract IFileEntry getFileEntry (String path)

检索对设备上远程文件的引用。

参数
path String :要检索的文件路径。可以是绝对路径或相对于“/”的路径。 (即支持“/system”和“system”语法)

退货
IFileEntry如果找不到给定path的文件,则IFileEntrynull

投掷
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

获取设备

public abstract IDevice getIDevice ()

返回对关联的 ddmlib IDevice引用。

每次设备与 adb 断开连接并重新连接时,DDMS 可能会分配一个新的IDevice 。因此,调用者不应保留对IDevice引用,因为该引用可能会过时。

退货
IDevice IDevice

getInt属性

public abstract long getIntProperty (String name, 
                long defaultValue)

从设备返回给定属性的整数值。

参数
name String : 属性名称

defaultValue long :属性为空或不存在时返回的默认值。

退货
long属性值或defaultValue (如果属性为空、不存在或没有整数值)。

投掷
DeviceNotAvailableException

getLastExpectedRebootTimeMillis

public abstract long getLastExpectedRebootTimeMillis ()

Returns the last time Tradefed APIs triggered a reboot in milliseconds since EPOCH as returned by ERROR(/System#currentTimeMillis()) .

退货
long

getLaunchApiLevel

public abstract int getLaunchApiLevel ()

Get the device's first launched API Level. Defaults to UNKNOWN_API_LEVEL .

退货
int an integer indicating the first launched API Level of device

投掷
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

getLogcat

public abstract InputStreamSource getLogcat ()

Grabs a snapshot stream of the logcat data.

Works in two modes:

  • If the logcat is currently being captured in the background, will return up to TestDeviceOptions.getMaxLogcatDataSize() bytes of the current contents of the background logcat capture
  • Otherwise, will return a static dump of the logcat data if device is currently responding

    退货
    InputStreamSource

  • getLogcat

    public abstract InputStreamSource getLogcat (int maxBytes)

    Grabs a snapshot stream of the last maxBytes of captured logcat data.

    Useful for cases when you want to capture frequent snapshots of the captured logcat data without incurring the potentially big disk space penalty of getting the entire getLogcat() snapshot.

    参数
    maxBytes int : the maximum amount of data to return. Should be an amount that can comfortably fit in memory

    退货
    InputStreamSource

    getLogcatDump

    public abstract InputStreamSource getLogcatDump ()

    Get a dump of the current logcat for device. Unlike getLogcat() , this method will always return a static dump of the logcat.

    Has the disadvantage that nothing will be returned if device is not reachable.

    退货
    InputStreamSource a InputStreamSource of the logcat data. An empty stream is returned if fail to capture logcat data.

    getLogcatSince

    public abstract InputStreamSource getLogcatSince (long date)

    Grabs a snapshot stream of captured logcat data starting the date provided. The time on the device should be used getDeviceDate() .

    参数
    date long : in millisecond since epoch format of when to start the snapshot until present. (can be be obtained using 'date +%s')

    退货
    InputStreamSource

    getMountPoint

    public abstract String getMountPoint (String mountName)

    Returns a mount point.

    Queries the device directly if the cached info in IDevice is not available.

    TODO: move this behavior to IDevice#getMountPoint(String)

    参数
    mountName String : the name of the mount point

    退货
    String the mount point or null

    getMountPointInfo

    public abstract ITestDevice.MountPointInfo getMountPointInfo (String mountpoint)

    Returns a MountPointInfo corresponding to the specified mountpoint path, or null if that path has nothing mounted or otherwise does not appear in /proc/mounts as a mountpoint.

    参数
    mountpoint String

    退货
    ITestDevice.MountPointInfo A ERROR(/List) of MountPointInfo containing the information in "/proc/mounts"

    投掷
    DeviceNotAvailableException

    getMountPointInfo

    public abstract  getMountPointInfo ()

    Returns a parsed version of the information in /proc/mounts on the device

    退货
    A ERROR(/List) of MountPointInfo containing the information in "/proc/mounts"

    投掷
    DeviceNotAvailableException

    getPartitionFreeSpace

    public abstract long getPartitionFreeSpace (String partition)

    Helper method to determine amount of free space on device partition.

    参数
    partition String

    退货
    long the amount of free space in KB

    投掷
    DeviceNotAvailableException if connection with device is lost and cannot be recovered.

    getProcessByName

    public abstract ProcessInfo getProcessByName (String processName)

    Helper method runs the "pidof" and "stat" command and returns ProcessInfo object with PID and process start time of the given process.

    参数
    processName String : the proces name String.

    退货
    ProcessInfo ProcessInfo of given processName

    投掷
    DeviceNotAvailableException

    getProcessPid

    public abstract String getProcessPid (String process)

    Returns the pid of the service or null if something went wrong.

    参数
    process String : The proces name String.

    退货
    String

    投掷
    DeviceNotAvailableException

    getProductType

    public abstract String getProductType ()

    Convenience method to get the product type of this device.

    This method will work if device is in either adb or fastboot mode.

    退货
    String the ERROR(/String) product type name. Will not be null

    投掷
    DeviceNotAvailableException if connection with device is lost and cannot be recovered, or if product type can not be determined

    getProductVariant

    public abstract String getProductVariant ()

    Convenience method to get the product variant of this device.

    This method will work if device is in either adb or fastboot mode.

    退货
    String the ERROR(/String) product variant name or null if it cannot be determined

    投掷
    DeviceNotAvailableException if connection with device is lost and cannot be recovered.

    getProperty

    public abstract String getProperty (String name)

    Retrieve the given property value from the device.

    参数
    name String : the property name

    退货
    String the property value or null if it does not exist

    投掷
    com.android.tradefed.device.DeviceNotAvailableException
    DeviceNotAvailableException

    getRecoveryMode

    public abstract ITestDevice.RecoveryMode getRecoveryMode ()

    Get the current recovery mode used for the device.

    退货
    ITestDevice.RecoveryMode the current recovery mode used for the device.

    getSerialNumber

    public abstract String getSerialNumber ()

    Convenience method to get serial number of this device.

    退货
    String the ERROR(/String) serial number

    getTombstones

    public abstract  getTombstones ()

    Fetch and return the list of tombstones from the devices. Requires root.

    method is best-effort so if one tombstone fails to be pulled for any reason it will be missing from the list. Only a DeviceNotAvailableException will terminate the method early.

    退货
    A list of tombstone files, empty if no tombstone.

    投掷
    DeviceNotAvailableException

    getTotalMemory

    public abstract long getTotalMemory ()

    Returns total physical memory size in bytes or -1 in case of internal error

    退货
    long

    getUseFastbootErase

    public abstract boolean getUseFastbootErase ()

    Get whether to use fastboot erase or fastboot format to wipe a partition on the device.

    退货
    boolean true if fastboot erase will be used or false if fastboot format will be used.

    isAdbRoot

    public abstract boolean isAdbRoot ()

    退货
    boolean true if device currently has adb root, false otherwise.

    投掷
    DeviceNotAvailableException if connection with device is lost and cannot be recovered.

    isAdbTcp

    public abstract boolean isAdbTcp ()

    退货
    boolean true if device is connected to adb-over-tcp, false otherwise.

    isAppEnumerationSupported

    public abstract boolean isAppEnumerationSupported ()

    Check whether platform on device supports app enumeration

    退货
    boolean True if app enumeration is supported, false otherwise

    投掷
    com.android.tradefed.device.DeviceNotAvailableException
    DeviceNotAvailableException

    isBypassLowTargetSdkBlockSupported

    public abstract boolean isBypassLowTargetSdkBlockSupported ()

    Check whether platform on device supports bypassing low target sdk block on app installs

    退货
    boolean True if bypass low target sdk block is supported, false otherwise

    投掷
    com.android.tradefed.device.DeviceNotAvailableException
    DeviceNotAvailableException

    isDeviceEncrypted

    public abstract boolean isDeviceEncrypted ()

    Returns if the device is encrypted.

    退货
    boolean true if the device is encrypted.

    投掷
    DeviceNotAvailableException if connection with device is lost and cannot be recovered.

    isDirectory

    public abstract boolean isDirectory (String deviceFilePath)

    Return True if the path on the device is a directory, false otherwise.

    参数
    deviceFilePath String

    退货
    boolean

    投掷
    com.android.tradefed.device.DeviceNotAvailableException
    DeviceNotAvailableException

    isEncryptionSupported

    public abstract boolean isEncryptionSupported ()

    Returns if encryption is supported on the device.

    退货
    boolean true if the device supports encryption.

    投掷
    com.android.tradefed.device.DeviceNotAvailableException
    DeviceNotAvailableException

    isExecutable

    public abstract boolean isExecutable (String fullPath)

    Returns True if the file path on the device is an executable file, false otherwise.

    参数
    fullPath String

    退货
    boolean

    投掷
    com.android.tradefed.device.DeviceNotAvailableException
    DeviceNotAvailableException

    isHeadless

    public abstract boolean isHeadless ()

    Return true if the device is headless (no screen), false otherwise.

    退货
    boolean

    投掷
    DeviceNotAvailableException

    isRuntimePermissionSupported

    public abstract boolean isRuntimePermissionSupported ()

    Check whether platform on device supports runtime permission granting

    退货
    boolean True if runtime permission are supported, false otherwise.

    投掷
    com.android.tradefed.device.DeviceNotAvailableException
    DeviceNotAvailableException

    isStateBootloaderOrFastbootd

    public abstract boolean isStateBootloaderOrFastbootd ()

    Returns true if device is in TestDeviceState#FASTBOOT or TestDeviceState.FASTBOOTD .

    退货
    boolean

    logAnrs

    public abstract boolean logAnrs (ITestLogger logger)

    Collects and log ANRs from the device.

    参数
    logger ITestLogger : an ITestLogger to log the ANRs.

    退货
    boolean True if the logging was successful, false otherwise.

    投掷
    DeviceNotAvailableException

    logOnDevice

    public abstract void logOnDevice (String tag, 
                    Log.LogLevel level, 
                    String format, 
                    Object... args)

    Log a message in the logcat of the device. This is a safe call that will not throw even if the logging fails.

    参数
    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.

    投掷
    com.android.tradefed.device.DeviceNotAvailableException
    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)

    投掷
    DeviceNotAvailableException if connection with device is lost and cannot be recovered.

    postInvocationTearDown

    public void postInvocationTearDown ()

    This method is deprecated.
    Use postInvocationTearDown(Throwable) instead.

    Extra steps for device specific required clean up that will be executed after the invocation is done.

    postInvocationTearDown

    public abstract void postInvocationTearDown (Throwable invocationException)

    Extra steps for device specific required clean up that will be executed after the invocation is done.

    参数
    invocationException Throwable : if any, the final exception raised by the invocation failure.

    preInvocationSetup

    public void preInvocationSetup (IBuildInfo info, 
                    MultiMap<String, String> attributes)

    Extra steps for device specific required setup that will be executed on the device prior to the invocation flow.

    参数
    info IBuildInfo : The IBuildInfo of the device.

    attributes MultiMap : The attributes stored in the invocation context

    投掷
    com.android.tradefed.targetprep.TargetSetupError
    com.android.tradefed.device.DeviceNotAvailableException
    DeviceNotAvailableException
    TargetSetupError

    pullDir

    public abstract boolean pullDir (String deviceFilePath, 
                    File localDir)

    Recursively pull directory contents from device.

    参数
    deviceFilePath String : the absolute file path of the remote source

    localDir File : the local directory to pull files into

    退货
    boolean true if file was pulled successfully. false otherwise.

    投掷
    DeviceNotAvailableException if connection with device is lost and cannot be recovered.

    pullFile

    public abstract File pullFile (String remoteFilePath, 
                    int userId)

    Retrieves a file off device, stores it in a local temporary ERROR(/File) , and returns that File .

    参数
    remoteFilePath String : the absolute path to file on device.

    userId int : The user id to pull from

    退货
    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)

    投掷
    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 .

    参数
    remoteFilePath String : the absolute path to file on device.

    退货
    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)

    投掷
    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.

    参数
    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.

    退货
    boolean true if file was retrieved successfully. false otherwise.

    投掷
    DeviceNotAvailableException if connection with device is lost and cannot be recovered.

    pullFile

    public abstract boolean pullFile (String remoteFilePath, 
                    File localFile, 
                    int userId)

    Retrieves a file off device.

    参数
    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.

    userId int : The user id to pull from

    退货
    boolean true if file was retrieved successfully. false otherwise.

    投掷
    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.

    参数
    remoteFilePath String : the absolute path to file on device.

    退货
    String A ERROR(/String) containing the contents of the device file, or null if the copy failed for any reason (including problems with the host filesystem)

    投掷
    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 .

    参数
    remoteFilePath String : the path to file on device, relative to the device's external storage mountpoint

    退货
    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)

    投掷
    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.

    参数
    localDir File : the local directory to push

    deviceFilePath String : the absolute file path of the remote destination

    excludedDirectories : Set of excluded directories names that shouldn't be pushed.

    退货
    boolean true if file was pushed successfully. false otherwise.

    投掷
    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.

    参数
    localDir File : the local directory to push

    deviceFilePath String : the absolute file path of the remote destination

    退货
    boolean true if file was pushed successfully. false otherwise.

    投掷
    DeviceNotAvailableException if connection with device is lost and cannot be recovered.

    pushFile

    public abstract boolean pushFile (File localFile, 
                    String deviceFilePath, 
                    boolean evaluateContentProviderNeeded)

    Variant of pushFile(File, String) which can optionally consider evaluating the need for the content provider.

    参数
    localFile File : the local file to push

    deviceFilePath String : the remote destination absolute file path

    evaluateContentProviderNeeded boolean : whether to check if we need the content provider

    退货
    boolean true if file was pushed successfully. false otherwise.

    投掷
    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. By default using a content provider.

    参数
    localFile File : the local file to push

    deviceFilePath String : the remote destination absolute file path

    退货
    boolean true if file was pushed successfully. false otherwise.

    投掷
    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

    参数
    contents String : the contents of the file to push

    deviceFilePath String : the remote destination absolute file path

    退货
    boolean true if string was pushed successfully. false otherwise.

    投掷
    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.

    投掷
    DeviceNotAvailableException if device is not available after reboot

    reboot

    public abstract void reboot (String reason)

    Reboots the device into adb mode with given reason to be persisted across reboot.

    Blocks until device becomes available.

    Last reboot reason can be obtained by querying sys.boot.reason propety.

    参数
    reason String : a reason for this reboot, or null if no reason is specified.

    投掷
    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.

    投掷
    DeviceNotAvailableException if connection with device is lost and cannot be recovered.

    rebootIntoFastbootd

    public abstract void rebootIntoFastbootd ()

    Reboots the device into fastbootd mode.

    Blocks until device is in fastbootd mode.

    投掷
    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 recovery

    投掷
    DeviceNotAvailableException if device is not available after reboot

    rebootIntoSideload

    public abstract void rebootIntoSideload (boolean autoReboot)

    Reboots the device into adb sideload mode (note that this is a special mode under recovery)

    Blocks until device enters sideload mode

    参数
    autoReboot boolean : whether to automatically reboot the device after sideload

    投掷
    DeviceNotAvailableException if device is not in sideload after reboot

    rebootIntoSideload

    public abstract void rebootIntoSideload ()

    Reboots the device into adb sideload mode (note that this is a special mode under recovery)

    Blocks until device enters sideload mode

    投掷
    DeviceNotAvailableException if device is not in sideload after reboot

    rebootUntilOnline

    public abstract void rebootUntilOnline ()

    An alternate to reboot() that only blocks until device is online ie visible to adb.

    投掷
    DeviceNotAvailableException if device is not available after reboot

    rebootUntilOnline

    public abstract void rebootUntilOnline (String reason)

    An alternate to reboot() that only blocks until device is online ie visible to adb.

    参数
    reason String : a reason for this reboot, or null if no reason is specified.

    投掷
    DeviceNotAvailableException if device is not available after reboot

    See also:

    rebootUserspace

    public abstract void rebootUserspace ()

    Reboots only userspace part of device.

    Blocks until device becomes available.

    WARNING. Userspace reboot is currently under active development, use it on your own risk.

    投掷
    DeviceNotAvailableException if device is not available after reboot

    rebootUserspaceUntilOnline

    public abstract void rebootUserspaceUntilOnline ()

    An alternate to rebootUserspace() ()} that only blocks until device is online ie visible to adb.

    投掷
    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.

    投掷
    com.android.tradefed.device.DeviceNotAvailableException
    DeviceNotAvailableException

    remountVendorWritable

    public abstract void remountVendorWritable ()

    Make the vendor partition on the device writable. May reboot the device.

    投掷
    com.android.tradefed.device.DeviceNotAvailableException
    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.

    参数
    runner IRemoteAndroidTestRunner : the IRemoteAndroidTestRunner which runs the tests

    listeners ITestLifeCycleReceiver : the test result listener(s)

    退货
    boolean true if test command completed. false if it failed to complete, but recovery succeeded

    投掷
    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.

    参数
    runner IRemoteAndroidTestRunner : the IRemoteAndroidTestRunner which runs the tests

    listeners : the test result listeners

    退货
    boolean true if test command completed. false if it failed to complete due to device communication exception, but recovery succeeded

    投掷
    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, 
                     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.

    参数
    runner IRemoteAndroidTestRunner

    userId int

    listeners

    退货
    boolean

    投掷
    DeviceNotAvailableException

    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.

    参数
    runner IRemoteAndroidTestRunner

    userId int

    listeners ITestLifeCycleReceiver

    退货
    boolean

    投掷
    DeviceNotAvailableException

    setDate

    public abstract void setDate (Date date)

    Sets the date on device

    Note: setting date on device requires root

    参数
    date Date : specify a particular date; will use host date if null

    投掷
    com.android.tradefed.device.DeviceNotAvailableException
    DeviceNotAvailableException

    setOptions

    public abstract void setOptions (TestDeviceOptions options)

    Set the TestDeviceOptions for the device

    参数
    options TestDeviceOptions

    setProperty

    public abstract boolean setProperty (String propKey, 
                    String propValue)

    Sets the given property value on the device. Requires adb root is true.

    参数
    propKey String : The key targeted to be set.

    propValue String : The property value to be set.

    退货
    boolean returns True if the setprop command was successful, False otherwise.

    投掷
    com.android.tradefed.device.DeviceNotAvailableException
    DeviceNotAvailableException

    setRecovery

    public abstract void setRecovery (IDeviceRecovery recovery)

    Set the IDeviceRecovery to use for this device. Should be set when device is first allocated.

    参数
    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, etc

    参数
    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.

    参数
    useFastbootErase boolean : true if fastboot erase should be used or false if fastboot format should be used.

    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.

    退货
    String the tcp serial number or null if device could not be switched

    投掷
    com.android.tradefed.device.DeviceNotAvailableException
    DeviceNotAvailableException

    switchToAdbUsb

    public abstract boolean switchToAdbUsb ()

    Switch device to adb over usb mode.

    退货
    boolean true if switch was successful, false otherwise.

    投掷
    com.android.tradefed.device.DeviceNotAvailableException
    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.

    参数
    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

    退货
    boolean true if files were synced successfully. false otherwise.

    投掷
    DeviceNotAvailableException if connection with device is lost and cannot be recovered.

    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 call postBootSetup() . Therefore, the device might not be fully ready to be tested when this method returns.

    退货
    boolean true if successful or if the device is unencrypted.

    投掷
    DeviceNotAvailableException if connection with device is lost and cannot be recovered.
    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.

    参数
    timeOut long : time in msecs to wait for the flag to be set

    退货
    boolean true if device's boot complete flag is set within the timeout

    投掷
    com.android.tradefed.device.DeviceNotAvailableException
    DeviceNotAvailableException

    waitForDeviceAvailable

    public abstract boolean waitForDeviceAvailable ()

    Waits for the device to be responsive and available for testing. Uses default timeout.

    退货
    boolean True if device is available, False if recovery is disabled and unavailable.

    投掷
    DeviceNotAvailableException if connection with device is lost and cannot be recovered.

    waitForDeviceAvailable

    public abstract boolean waitForDeviceAvailable (long waitTime)

    Waits for the device to be responsive and available for testing.

    参数
    waitTime long : the time in ms to wait

    退货
    boolean True if device is available, False if recovery is disabled and unavailable.

    投掷
    DeviceNotAvailableException if device is still unresponsive after waitTime expires.

    waitForDeviceAvailableInRecoverPath

    public abstract boolean waitForDeviceAvailableInRecoverPath (long waitTime)

    Waits for the device to be responsive and available without considering recovery path.

    参数
    waitTime long

    退货
    boolean True if device is available, False if unavailable.

    投掷
    DeviceNotAvailableException if connection with device is lost and cannot be recovered.

    waitForDeviceBootloader

    public abstract void waitForDeviceBootloader ()

    Blocks until device is visible via fastboot. Use default timeout.

    投掷
    DeviceNotAvailableException if connection with device is lost and cannot be recovered.

    waitForDeviceInRecovery

    public abstract boolean waitForDeviceInRecovery (long waitTime)

    Blocks for the device to be in the 'adb recovery' state (note this is distinct from IDeviceRecovery ).

    参数
    waitTime long : the time in ms to wait

    退货
    boolean true if device boots into recovery before time expires. false otherwise

    waitForDeviceInSideload

    public abstract boolean waitForDeviceInSideload (long waitTime)

    Blocks for the device to be in the 'adb sideload' state

    参数
    waitTime long : the time in ms to wait

    退货
    boolean true if device boots into sideload before time expires. false otherwise

    waitForDeviceNotAvailable

    public abstract boolean waitForDeviceNotAvailable (long waitTime)

    Blocks for the device to be not available ie missing from adb

    参数
    waitTime long : the time in ms to wait

    退货
    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. Use waitForDeviceAvailable() instead.

    投掷
    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. Use waitForDeviceAvailable() instead.

    参数
    waitTime long : the time in ms to wait

    投掷
    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.

    参数
    waitTime long : the time in ms to wait

    退货
    boolean true if device becomes responsive before waitTime elapses.