DeviceMonitor

public final class DeviceMonitor
extends Object implements ClientTracker

java.lang.Object
   ↳ com.android.tradefed.device.server.DeviceMonitor


DeviceMonitor 用于监控连接到 adb 的设备。

在一个线程上,它运行 DeviceListMonitorTask。这会建立与 adb 主机的套接字连接,并发出 ERROR(/DeviceListMonitorTask.ADB_TRACK_DEVICES_COMMAND)。然后,它会监控该套接字,以了解设备连接和设备状态的所有变化。如果未启用 ::getClientSupport,则不会运行 DeviceClientMonitorTask,并且设备不会注册。

在另一个线程中,它运行 DeviceClientMonitorTask。这会为每个已注册的设备建立与 adb 主机的套接字连接,并发出 ERROR(/DeviceClientMonitorTask.ADB_TRACK_JDWP_COMMAND)。在此连接上,它会监控设备上的活跃客户端。注意:单个线程会监控来自所有设备的 JDWP 连接。与 adb 的不同套接字连接(每个设备一个)通过单个选择器进行多路复用。

摘要

嵌套类

class DeviceMonitor.DeviceListComparisonResult

 

公共构造函数

DeviceMonitor(AndroidDebugBridge server)

创建新的 DeviceMonitor 对象并将其与正在运行的 AndroidDebugBridge 对象相关联。

公共方法

int getConnectionAttemptCount()
IDevice[] getDevices()

返回设备。

int getRestartAttemptCount()
boolean hasInitialDeviceList()
boolean isMonitoring()

返回监控器当前是否已连接到调试桥服务器。

void start()

开始监控。

void stop()

停止监控。

void trackClientToDropAndReopen(ClientImpl client)

用于指示客户端已断开连接,但应尝试重新打开与客户端的连接的回调。

void trackDeviceToDropAndReopen(DeviceImpl device)

用于指示设备已断开连接的回调。

void trackDisconnectedClient(ClientImpl client)

客户端断开连接时的回调。

公共构造函数

DeviceMonitor

public DeviceMonitor (AndroidDebugBridge server)

创建新的 DeviceMonitor 对象并将其与正在运行的 AndroidDebugBridge 对象相关联。

参数
server AndroidDebugBridge:正在运行的 AndroidDebugBridge

公共方法

getConnectionAttemptCount

public int getConnectionAttemptCount ()

返回
int

getDevices

public IDevice[] getDevices ()

返回设备。

返回
IDevice[]

getRestartAttemptCount

public int getRestartAttemptCount ()

返回
int

hasInitialDeviceList

public boolean hasInitialDeviceList ()

返回
boolean

isMonitoring

public boolean isMonitoring ()

返回监控器当前是否已连接到调试桥服务器。

返回
boolean

start

public void start ()

开始监控。

停止

public void stop ()

停止监控。

trackClientToDropAndReopen

public void trackClientToDropAndReopen (ClientImpl client)

用于指示客户端已断开连接但应尝试重新打开与客户端的连接的回调。

参数
client ClientImpl:已丢弃。

trackDeviceToDropAndReopen

public void trackDeviceToDropAndReopen (DeviceImpl device)

回调,用于指示设备已断开连接。应尝试重新打开与设备的连接,并重新建立与在该设备上运行的任何客户端的连接。

参数
device DeviceImpl:已丢弃。

trackDisconnectedClient

public void trackDisconnectedClient (ClientImpl client)

客户端断开连接时的回调。此回调旨在通知持有客户端套接字注册的任何线程释放该注册。

参数
client ClientImpl:已降价