StubDevice

public class StubDevice
extends Object implements IDevice

java.lang.Object
   ↳ com.android.tradefed.device.StubDevice


IDevice 的存根占位实现。

摘要

公共构造函数

StubDevice(String serial)
StubDevice(String serial, boolean isEmulator)

公共方法

boolean arePropertiesSet()

如果已缓存属性,则返回 true

void createForward(int localPort, String remoteSocketName, IDevice.DeviceUnixSocketNamespace namespace)

在本地 TCP 端口和远程 Unix 网域套接字之间创建端口转发。

void createForward(int localPort, int remotePort)

在本地端口和远程端口之间创建端口转发。

void createReverse(int remotePort, int localPort)

在远程端口和本地端口之间创建端口反向。

void executeShellCommand(String command, IShellOutputReceiver receiver, long maxTimeToOutputResponse, TimeUnit maxTimeUnits)

在设备上执行 shell 命令,并将结果发送到 receiver

void executeShellCommand(String command, IShellOutputReceiver receiver)

在设备上执行 shell 命令,并将结果发送到 receiver

这类似于调用 executeShellCommand(command, receiver, DdmPreferences.getTimeOut())

void executeShellCommand(String command, IShellOutputReceiver receiver, int maxTimeToOutputResponse)

此方法已弃用。 使用 executeShellCommand(String, com.android.ddmlib.IShellOutputReceiver, long, TimeUnit)

void executeShellCommand(String command, IShellOutputReceiver receiver, long maxTimeout, long maxTimeToOutputResponse, TimeUnit maxTimeUnits)

在设备上执行 shell 命令,并将结果发送到 receiver

getAbis()

返回此设备支持的 ABI。

String getAvdName()

返回模拟器正在运行的 AVD 的名称。

String getAvdPath()

返回文件系统中虚拟设备的绝对路径。

getBattery(long freshnessTime, TimeUnit timeUnit)

返回设备的电池电量,范围为 0 到 100%。

getBattery()

返回设备的电池电量,范围为 0 到 100%。

Integer getBatteryLevel(long freshnessMs)

此方法已弃用。 请改用 getBattery(long, TimeUnit)

Integer getBatteryLevel()

此方法已弃用。 请改用 getBattery()

Client getClient(String applicationName)

按应用名称返回 Client

String getClientName(int pid)

按 PID 返回客户端的名称,如果 PID 未知,则返回 null

Client[] getClients()

返回客户端数组。

int getDensity()

通过读取系统属性 PROP_DEVICE_DENSITY 的值,返回设备屏幕的密度桶。

FileListingService getFileListingService()

返回相应设备的 FileListingService

String getLanguage()

返回用户的语言。

String getMountPoint(String name)

返回装载点。

String getName()

返回此设备的(人性化)名称。

getProperties()

此方法已弃用。 请改用 getSystemProperty(String)

String getProperty(String name)

一种便捷方法,尝试通过 IShellEnabledDevice.getSystemProperty(String) 以非常短的等待时间检索属性,并吞下异常。

String getPropertyCacheOrSync(String name)

此方法已弃用。 请改用 getProperty(String)

int getPropertyCount()

此方法已弃用。 在 ddmlib 中已弃用,原因是“实现细节”。

String getPropertySync(String name)

此方法已弃用。 请改用 getProperty(String)

String getRegion()

返回用户的地区。

RawImage getScreenshot()

拍摄设备屏幕截图,并以 RawImage 形式返回。

RawImage getScreenshot(long timeout, TimeUnit unit)
String getSerialNumber()

返回设备的序列号。

IDevice.DeviceState getState()

返回设备的状态。

SyncService getSyncService()

返回一个 SyncService 对象,用于将文件推送到设备或从设备拉取文件。

ListenableFuture<String> getSystemProperty(String name)

针对系统属性执行潜在的异步查询。

boolean hasClients()

返回 IDevice 是否包含 Client

void installPackage(String packageFilePath, boolean reinstall, InstallReceiver receiver, long maxTimeout, long maxTimeToOutputResponse, TimeUnit maxTimeUnits, String... extraArgs)

在设备上安装 Android 应用。

void installPackage(String packageFilePath, boolean reinstall, InstallReceiver receiver, String... extraArgs)

在设备上安装 Android 应用。

void installPackage(String packageFilePath, boolean reinstall, String... extraArgs)

在设备上安装 Android 应用。

void installPackages( apkFilePaths, boolean reinstall, extraArgs, long timeOutInMs, TimeUnit timeunit)

安装由多个 APK 文件(一个主软件包和 0 到 n 个拆分软件包)组成的 Android 应用

void installRemotePackage(String remoteFilePath, boolean reinstall, InstallReceiver receiver, String... extraArgs)

安装已推送到设备上临时位置的应用软件包。

void installRemotePackage(String remoteFilePath, boolean reinstall, String... extraArgs)

安装已推送到设备上临时位置的应用软件包。

void installRemotePackage(String remoteFilePath, boolean reinstall, InstallReceiver receiver, long maxTimeout, long maxTimeToOutputResponse, TimeUnit maxTimeUnits, String... extraArgs)

安装已推送到设备上临时位置的应用软件包。

boolean isBootLoader()

返回设备是否处于引导加载程序模式。

boolean isEmulator()

如果设备是模拟器,则返回 true

boolean isOffline()

如果设备处于离线状态,则返回此值。

boolean isOnline()

如果设备已准备就绪,则返回 true。

boolean isRoot()

查询设备的当前 root 状态。

void pullFile(String remote, String local)

提取单个文件。

void pushFile(String local, String remote)

推送单个文件。

void reboot(String into)

重新启动设备。

void removeForward(int localPort)

移除本地端口与远程端口之间的端口转发。

void removeForward(int localPort, int remotePort)

void removeForward(int localPort, String remoteSocketName, IDevice.DeviceUnixSocketNamespace namespace)

void removeRemotePackage(String remoteFilePath)

从设备中移除文件。

void removeReverse(int remotePort)

移除远程端口与本地端口之间的端口反转。

boolean root()

要求 adb 守护程序在设备上成为 root 用户。

void setSerial(String serial)
void startScreenRecorder(String remoteFilePath, ScreenRecorderOptions options, IShellOutputReceiver receiver)

如果设备支持 IDevice.Feature.SCREEN_RECORD,则在设备上启动屏幕录制。

boolean supportsFeature(IDevice.HardwareFeature arg0)

返回相应设备是否支持给定的硬件功能。

boolean supportsFeature(IDevice.Feature feature)

返回相应设备是否支持给定的软件功能。

String syncPackageToDevice(String localFilePath)

将文件推送到设备

String uninstallApp(String applicationID, String... extraArgs)

从设备中卸载应用。

String uninstallPackage(String packageName)

从设备中卸载软件包。

公共构造函数

StubDevice

public StubDevice (String serial)

参数
serial String

StubDevice

public StubDevice (String serial, 
                boolean isEmulator)

参数
serial String

isEmulator boolean

公共方法

arePropertiesSet

public boolean arePropertiesSet ()

如果已缓存属性,则返回 true

返回
boolean

createForward

public void createForward (int localPort, 
                String remoteSocketName, 
                IDevice.DeviceUnixSocketNamespace namespace)

在本地 TCP 端口和远程 Unix 网域套接字之间创建端口转发。

参数
localPort int:要转发的本地端口

remoteSocketName String:设备上创建的 Unix 网域套接字的名称

namespace IDevice.DeviceUnixSocketNamespace:创建 Unix 网域套接字的命名空间

抛出
AdbCommandRejectedException
TimeoutException

createForward

public void createForward (int localPort, 
                int remotePort)

在本地端口和远程端口之间创建端口转发。

参数
localPort int:要转发的本地端口

remotePort int:远程端口。

抛出
AdbCommandRejectedException
TimeoutException

createReverse

public void createReverse (int remotePort, 
                int localPort)

在远程端口和本地端口之间创建端口反向。

参数
remotePort int:要反向的远程端口。

localPort int:本地端口

抛出
AdbCommandRejectedException
TimeoutException

executeShellCommand

public void executeShellCommand (String command, 
                IShellOutputReceiver receiver, 
                long maxTimeToOutputResponse, 
                TimeUnit maxTimeUnits)

在设备上执行 shell 命令,并将结果发送到 receiver

maxTimeToOutputResponse 用作预期设备输出命令时的最长等待时间。
在任何时候,如果 shell 命令在超过 maxTimeToOutputResponse 的时间内未输出任何内容,该方法将抛出 ShellCommandUnresponsiveException

对于日志输出等命令,应使用 maxTimeToOutputResponse 值为 0,这意味着该方法永远不会抛出异常,并且会阻塞,直到接收方的 IShellOutputReceiver.isCancelled() 返回 true

参数
command String:要执行的 shell 命令

receiver IShellOutputReceiver:将接收 shell 命令输出的 IShellOutputReceiver

maxTimeToOutputResponse long:允许命令在最长多长时间内不输出任何响应。值为 0 表示该方法将无限期等待(直到 receiver 取消执行)命令输出,并且永远不会抛出异常。

maxTimeUnits TimeUnit:非零 maxTimeToOutputResponse 值的单位。

抛出
AdbCommandRejectedException
ShellCommandUnresponsiveException
TimeoutException

executeShellCommand

public void executeShellCommand (String command, 
                IShellOutputReceiver receiver)

在设备上执行 shell 命令,并将结果发送到 receiver

这类似于调用 executeShellCommand(command, receiver, DdmPreferences.getTimeOut())

参数
command String:要执行的 shell 命令

receiver IShellOutputReceiver:将接收 shell 命令输出的 IShellOutputReceiver

抛出
AdbCommandRejectedException
ShellCommandUnresponsiveException
TimeoutException

executeShellCommand

public void executeShellCommand (String command, 
                IShellOutputReceiver receiver, 
                int maxTimeToOutputResponse)

此方法已弃用。
使用 executeShellCommand(String, com.android.ddmlib.IShellOutputReceiver, long, TimeUnit)

参数
command String

receiver IShellOutputReceiver

maxTimeToOutputResponse int

抛出
AdbCommandRejectedException
ShellCommandUnresponsiveException
TimeoutException

executeShellCommand

public void executeShellCommand (String command, 
                IShellOutputReceiver receiver, 
                long maxTimeout, 
                long maxTimeToOutputResponse, 
                TimeUnit maxTimeUnits)

在设备上执行 shell 命令,并将结果发送到 receiver

maxTimeToOutputResponse 用作预期设备输出命令时的最长等待时间。
在任何时候,如果 shell 命令在超过 maxTimeToOutputResponse 的时间内未输出任何内容,该方法将抛出 ShellCommandUnresponsiveException

对于日志输出等命令,应使用 maxTimeToOutputResponse 值为 0,这意味着该方法永远不会抛出异常,并且会阻塞,直到接收方的 IShellOutputReceiver.isCancelled() 返回 true

参数
command String:要执行的 shell 命令

receiver IShellOutputReceiver:将接收 shell 命令输出的 IShellOutputReceiver

maxTimeout long:命令返回的最长超时时间。值为 0 表示不会应用最大超时时间。

maxTimeToOutputResponse long:允许命令在最长多长时间内不输出任何响应。值为 0 表示该方法将无限期等待(直到 receiver 取消执行)命令输出,并且永远不会抛出异常。

maxTimeUnits TimeUnit:非零 maxTimeoutmaxTimeToOutputResponse 值的单位。

抛出
AdbCommandRejectedException
ShellCommandUnresponsiveException
TimeoutException

getAbis

public  getAbis ()

返回相应设备支持的 ABI。ABI 按首选顺序排序,第一个 ABI 是最首选的。

返回
ABI 列表。

getAvdName

public String getAvdName ()

返回模拟器正在运行的 AVD 的名称。

仅当 isEmulator() 返回 true 时,此值才有效。

如果模拟器未运行任何 AVD(例如,它正在从 Android 源代码树 build 运行),此方法将返回“<build>”。

注意:如果您想控制超时时间,建议使用 getAvdData()

返回
String AVD 的名称,如果没有,则为 null

getAvdPath

public String getAvdPath ()

返回文件系统中虚拟设备的绝对路径。路径取决于操作系统;在 Linux 上,路径将使用 / 作为名称分隔符,而在 Windows 上,路径将使用 \ 作为分隔符。

注意:如果您想控制超时时间,建议使用 getAvdData()

返回
String AVD 路径;如果这是实体设备,则为 null;模拟器控制台子命令失败;或者模拟器的版本低于 30.0.18

getBattery

public  getBattery (long freshnessTime, 
                TimeUnit timeUnit)

返回设备的电池电量,范围为 0 到 100%。

电池电量可能会被缓存。仅当自上次成功查询以来 freshnessTime 已过期时,才查询设备的电池电量。

参数
freshnessTime long:所需的电池电量新近度

timeUnit TimeUnit:freshnessTime 的 ERROR(/TimeUnit)

返回
可用于查询电池电量的 ERROR(/Future)。如果无法检索电池电量,则相应 Future 将返回 ERROR(/ExecutionException)

getBattery

public  getBattery ()

返回设备的电池电量,范围为 0 到 100%。

电池电量可能会被缓存。仅当自上次成功查询以来已过去 5 分钟时,才查询设备的电池电量。

返回
可用于查询电池电量的 ERROR(/Future)。如果无法检索电池电量,则相应 Future 将返回 ERROR(/ExecutionException)

getBatteryLevel

public Integer getBatteryLevel (long freshnessMs)

此方法已弃用。
请改用 getBattery(long, TimeUnit)

返回设备的电池电量,范围为 0 到 100%。

电池电量可能会被缓存。仅当自上次成功查询以来已过去 freshnessMs 毫秒时,才查询设备的电池电量。

返回
Integer 电池电量,如果无法检索到电池电量,则为 null

抛出
AdbCommandRejectedException
ShellCommandUnresponsiveException
TimeoutException

getBatteryLevel

public Integer getBatteryLevel ()

此方法已弃用。
请改用 getBattery()

返回设备的电池电量,范围为 0 到 100%。

电池电量可能会被缓存。仅当自上次成功查询以来已过去 5 分钟时,才查询设备的电池电量。

返回
Integer 电池电量,如果无法检索到电池电量,则为 null

抛出
AdbCommandRejectedException
ShellCommandUnresponsiveException
TimeoutException

getClient

public Client getClient (String applicationName)

按应用名称返回 Client

参数
applicationName String:应用的名称

返回
Client Client 对象;如果未找到匹配项,则返回 null

getClientName

public String getClientName (int pid)

按 PID 返回客户端的名称,如果 PID 未知,则返回 null

参数
pid int:客户端的 PID。

返回
String

getClients

public Client[] getClients ()

返回客户端数组。

返回
Client[]

getDensity

public int getDensity ()

通过读取系统属性 PROP_DEVICE_DENSITY 的值,返回设备屏幕的密度桶。

返回
int 密度,如果无法确定,则为 -1。

getFileListingService

public FileListingService getFileListingService ()

返回相应设备的 FileListingService

返回
FileListingService

getLanguage

public String getLanguage ()

返回用户的语言。

返回
String 用户的语言,如果未知,则为 null

getMountPoint

public String getMountPoint (String name)

返回装载点。

参数
name String:要返回的挂载点的名称

返回
String

getName

public String getName ()

返回相应设备的(人性化)名称。对于 AVD,通常是 AVD 名称;对于设备,则是制造商名称、型号名称和序列号的组合。

返回
String

getProperties

public  getProperties ()

此方法已弃用。
请改用 getSystemProperty(String)

返回缓存的设备属性。它包含“getprop”的整个输出

返回

getProperty

public String getProperty (String name)

一种便捷方法,尝试通过 IShellEnabledDevice.getSystemProperty(String) 检索属性,等待时间非常短,并会捕获异常。

注意:如果您想控制超时时间,建议使用 IShellEnabledDevice.getSystemProperty(String)

参数
name String:要返回的值的名称。

返回
String 该值或 null(如果属性值无法立即获取)

getPropertyCacheOrSync

public String getPropertyCacheOrSync (String name)

此方法已弃用。
请改用 getProperty(String)

getProperty(String)getPropertySync(String) 的组合,用于尝试从缓存中检索属性。如果未找到,将同步尝试直接查询设备,并在成功时重新填充缓存。

参数
name String:要返回的值的名称。

返回
String 值或 null(如果属性不存在)

抛出
AdbCommandRejectedException
ShellCommandUnresponsiveException
TimeoutException

getPropertyCount

public int getPropertyCount ()

此方法已弃用。
在 ddmlib 中已弃用,原因是“实现细节”。

返回相应设备的属性数量。

返回
int

getPropertySync

public String getPropertySync (String name)

此方法已弃用。
请改用 getProperty(String)

getProperty(String) 的一种变体,它会尝试直接从设备检索给定的属性,而不使用缓存。此方法应(仅)用于任何易失性属性。

参数
name String:要返回的值的名称。

返回
String 值或 null(如果属性不存在)

抛出
AdbCommandRejectedException
ShellCommandUnresponsiveException
TimeoutException

getRegion

public String getRegion ()

返回用户的地区。

返回
String 用户的地区,如果未知,则为 null

getScreenshot

public RawImage getScreenshot ()

拍摄设备屏幕截图,并以 RawImage 形式返回。

返回
RawImage 如果出现问题,则将屏幕截图标记为 RawImagenull

抛出
AdbCommandRejectedException
TimeoutException

getScreenshot

public RawImage getScreenshot (long timeout, 
                TimeUnit unit)

参数
timeout long

unit TimeUnit

返回
RawImage

抛出
AdbCommandRejectedException
TimeoutException

getSerialNumber

public String getSerialNumber ()

返回设备的序列号。

返回
String

getState

public IDevice.DeviceState getState ()

返回设备的状态。

返回
IDevice.DeviceState

getSyncService

public SyncService getSyncService ()

返回一个 SyncService 对象,用于将文件推送到设备或从设备拉取文件。

返回
SyncService null 如果无法创建 SyncService。如果 adb 因 IDevice 无效(或已断开连接)而拒绝打开连接,就会发生这种情况。

抛出
AdbCommandRejectedException
TimeoutException

getSystemProperty

public ListenableFuture<String> getSystemProperty (String name)

针对系统属性执行潜在的异步查询。

参数
name String:要返回的值的名称。

返回
ListenableFuture<String> ListenableFuture. ERROR(get/Future#get() get) 可能会返回 null。

hasClients

public boolean hasClients ()

返回 IDevice 是否包含 Client

返回
boolean

installPackage

public void installPackage (String packageFilePath, 
                boolean reinstall, 
                InstallReceiver receiver, 
                long maxTimeout, 
                long maxTimeToOutputResponse, 
                TimeUnit maxTimeUnits, 
                String... extraArgs)

在设备上安装 Android 应用。这是一个辅助方法,它将 syncPackageToDevice、installRemotePackage 和 removePackage 步骤结合在一起

参数
packageFilePath String:要安装的本地主机上文件的绝对文件系统路径

reinstall boolean:如果应重新安装应用,则设置为 true

receiver InstallReceiver:用于监控安装并获取最终状态的 InstallReceiver

maxTimeout long:命令返回的最长超时时间。值为 0 表示不会应用最大超时时间。

maxTimeToOutputResponse long:允许命令在最长多长时间内不输出任何响应。值为 0 表示该方法将无限期等待(直到 receiver 取消执行)命令输出,并且永远不会抛出异常。

maxTimeUnits TimeUnit:非零 maxTimeoutmaxTimeToOutputResponse 值的单位。

extraArgs String:要传递的可选额外实参。如需了解可用选项,请参阅“adb shell pm install --help”。

抛出
InstallException

installPackage

public void installPackage (String packageFilePath, 
                boolean reinstall, 
                InstallReceiver receiver, 
                String... extraArgs)

在设备上安装 Android 应用。这是一个辅助方法,它将 syncPackageToDevice、installRemotePackage 和 removePackage 步骤结合在一起

参数
packageFilePath String:要安装的本地主机上文件的绝对文件系统路径

reinstall boolean:如果应重新安装应用,则设置为 true

receiver InstallReceiver:用于监控安装并获取最终状态的 InstallReceiver

extraArgs String:要传递的可选额外实参。如需了解可用选项,请参阅“adb shell pm install --help”。

抛出
InstallException

installPackage

public void installPackage (String packageFilePath, 
                boolean reinstall, 
                String... extraArgs)

在设备上安装 Android 应用。这是一个辅助方法,它将 syncPackageToDevice、installRemotePackage 和 removePackage 步骤结合在一起

参数
packageFilePath String:要安装的本地主机上文件的绝对文件系统路径

reinstall boolean:如果应重新安装应用,则设置为 true

extraArgs String:要传递的可选额外实参。如需了解可用选项,请参阅“adb shell pm install --help”。

抛出
InstallException

installPackages

public void installPackages ( apkFilePaths, 
                boolean reinstall, 
                 extraArgs, 
                long timeOutInMs, 
                TimeUnit timeunit)

安装由多个 APK 文件(一个主软件包和 0 到 n 个拆分软件包)组成的 Android 应用

参数
apkFilePaths :要安装的 APK 列表(1 个主 APK + 0 到 n 个拆分 APK)

reinstall boolean:如果应重新安装应用,则设置为 true

extraArgs :要传递的可选额外实参。如需了解可用选项,请参阅“adb shell pm install --help”。

timeOutInMs long:安装超时

timeunit TimeUnit:与超时参数对应的 ERROR(/TimeUnit)

抛出
InstallException

installRemotePackage

public void installRemotePackage (String remoteFilePath, 
                boolean reinstall, 
                InstallReceiver receiver, 
                String... extraArgs)

安装已推送到设备上临时位置的应用软件包。

参数
remoteFilePath String:设备上软件包文件的绝对文件路径

reinstall boolean:如果应重新安装应用,则设置为 true

receiver InstallReceiver:用于监控安装并获取最终状态的 InstallReceiver

extraArgs String:要传递的可选额外实参。如需了解可用选项,请参阅“adb shell pm install --help”。

抛出
InstallException

installRemotePackage

public void installRemotePackage (String remoteFilePath, 
                boolean reinstall, 
                String... extraArgs)

安装已推送到设备上临时位置的应用软件包。

参数
remoteFilePath String:设备上软件包文件的绝对文件路径

reinstall boolean:如果应重新安装应用,则设置为 true

extraArgs String:要传递的可选额外实参。如需了解可用选项,请参阅“adb shell pm install --help”。

抛出
InstallException

installRemotePackage

public void installRemotePackage (String remoteFilePath, 
                boolean reinstall, 
                InstallReceiver receiver, 
                long maxTimeout, 
                long maxTimeToOutputResponse, 
                TimeUnit maxTimeUnits, 
                String... extraArgs)

安装已推送到设备上临时位置的应用软件包。

参数
remoteFilePath String:设备上软件包文件的绝对文件路径

reinstall boolean:如果应重新安装应用,则设置为 true

receiver InstallReceiver:用于监控安装并获取最终状态的 InstallReceiver

maxTimeout long:命令返回的最长超时时间。值为 0 表示不会应用最大超时时间。

maxTimeToOutputResponse long:允许命令在最长多长时间内不输出任何响应。值为 0 表示该方法将无限期等待(直到 receiver 取消执行)命令输出,并且永远不会抛出异常。

maxTimeUnits TimeUnit:非零 maxTimeoutmaxTimeToOutputResponse 值的单位。

extraArgs String:要传递的可选额外实参。如需了解可用选项,请参阅“adb shell pm install --help”。

抛出
InstallException

isBootLoader

public boolean isBootLoader ()

返回设备是否处于引导加载程序模式。

返回
boolean 如果 getState() 返回 DeviceState.BOOTLOADER,则为 true

isEmulator

public boolean isEmulator ()

如果设备是模拟器,则返回 true

返回
boolean

isOffline

public boolean isOffline ()

如果设备处于离线状态,则返回。

返回
boolean 如果 getState() 返回 DeviceState.OFFLINE,则为 true

isOnline

public boolean isOnline ()

如果设备已准备就绪,则返回。

返回
boolean 如果 getState() 返回 DeviceState.ONLINE,则为 true

isRoot

public boolean isRoot ()

查询设备的当前 root 状态。如需了解详情,请参阅“adb root”。

返回
boolean 如果 adb 守护程序以 root 身份运行,则为 true,否则为 false。

抛出
AdbCommandRejectedException
ShellCommandUnresponsiveException
TimeoutException

pullFile

public void pullFile (String remote, 
                String local)

提取单个文件。

参数
remote String:远程文件的完整路径

local String:本地目的地。

抛出
AdbCommandRejectedException
SyncException
TimeoutException

pushFile

public void pushFile (String local, 
                String remote)

推送单个文件。

参数
local String:本地文件路径。

remote String:远程文件路径

抛出
AdbCommandRejectedException
SyncException
TimeoutException

重新启动

public void reboot (String into)

重新启动设备。

参数
into String:要重启进入的引导加载程序名称,或 null 以仅重启设备。

抛出
AdbCommandRejectedException
TimeoutException

removeForward

public void removeForward (int localPort)

移除本地端口与远程端口之间的端口转发。

参数
localPort int:要转发的本地端口

抛出
AdbCommandRejectedException
TimeoutException

removeForward

public void removeForward (int localPort, 
                int remotePort)

参数
localPort int

remotePort int

抛出
AdbCommandRejectedException
TimeoutException

removeForward

public void removeForward (int localPort, 
                String remoteSocketName, 
                IDevice.DeviceUnixSocketNamespace namespace)

参数
localPort int

remoteSocketName String

namespace IDevice.DeviceUnixSocketNamespace

抛出
AdbCommandRejectedException
TimeoutException

removeRemotePackage

public void removeRemotePackage (String remoteFilePath)

从设备中移除文件。

参数
remoteFilePath String:要移除的文件的设备路径

抛出
InstallException

removeReverse

public void removeReverse (int remotePort)

移除远程端口与本地端口之间的端口反转。

参数
remotePort int:远程端口。

抛出
AdbCommandRejectedException
TimeoutException

root

public boolean root ()

请求 adb 守护程序在设备上成为 root 用户。此操作可能会静默失败,并且只能在开发者 build 上成功。如需了解详情,请参阅“adb root”。

返回
boolean 如果 adb 守护程序以 root 身份运行,则为 true,否则为 false。

抛出
AdbCommandRejectedException
ShellCommandUnresponsiveException
TimeoutException

setSerial

public void setSerial (String serial)

参数
serial String

startScreenRecorder

public void startScreenRecorder (String remoteFilePath, 
                ScreenRecorderOptions options, 
                IShellOutputReceiver receiver)

如果设备支持 IDevice.Feature.SCREEN_RECORD,则在设备上启动屏幕录制。

参数
remoteFilePath String

options ScreenRecorderOptions

receiver IShellOutputReceiver

抛出
AdbCommandRejectedException
ShellCommandUnresponsiveException
TimeoutException

supportsFeature

public boolean supportsFeature (IDevice.HardwareFeature arg0)

返回相应设备是否支持给定的硬件功能。

参数
arg0 IDevice.HardwareFeature

返回
boolean

supportsFeature

public boolean supportsFeature (IDevice.Feature feature)

返回相应设备是否支持给定的软件功能。

参数
feature IDevice.Feature

返回
boolean

syncPackageToDevice

public String syncPackageToDevice (String localFilePath)

将文件推送到设备

参数
localFilePath String:本地主机上文件的绝对路径

返回
String String 设备上文件的目标路径

抛出
AdbCommandRejectedException
SyncException
TimeoutException

uninstallApp

public String uninstallApp (String applicationID, 
                String... extraArgs)

从设备中卸载应用。

参数
applicationID String:要卸载的 Android 应用 ID

extraArgs String:要传递的可选额外实参。如需了解可用选项,请参阅“adb shell pm install --help”。

返回
String 一个包含错误代码的 String,如果成功,则为 null

抛出
InstallException

uninstallPackage

public String uninstallPackage (String packageName)

从设备中卸载软件包。

参数
packageName String:要卸载的 Android 应用 ID

返回
String 一个包含错误代码的 String,如果成功,则为 null

抛出
InstallException