DeviceMonitor
public
final
class
DeviceMonitor
extends Object
| java.lang.Object | |
| ↳ | com.android.tradefed.device.server.DeviceMonitor |
The DeviceMonitor monitors devices attached to adb.
On one thread, it runs the DeviceListMonitorTask. This establishes a socket connection
to the adb host, and issues a ERROR(DeviceListMonitorTask.ADB_TRACK_DEVICES_COMMAND/com.android.tradefed.device.server.DeviceListMonitorTask#ADB_TRACK_DEVICES_COMMAND DeviceListMonitorTask.ADB_TRACK_DEVICES_COMMAND). It then
monitors that socket for all changes about device connection and device state. If ERROR(/AndroidDebugBridge::getClientSupport) is not enabled the ERROR(/DeviceClientMonitorTask) is not
run, and devices are not registered.
On another thread it runs the ERROR(/DeviceClientMonitorTask). This establishes a socket
connection to the adb host per registered device and issues a ERROR(/DeviceClientMonitorTask.ADB_TRACK_JDWP_COMMAND). On this connection, it monitors active clients
on the device. Note: a single thread monitors jdwp connections from all devices. The different
socket connections to adb (one per device) are multiplexed over a single selector.
Summary
Nested classes | |
|---|---|
class |
DeviceMonitor.DeviceListComparisonResult
|
Public constructors | |
|---|---|
DeviceMonitor(AndroidDebugBridge server)
Creates a new |
|
Public methods | |
|---|---|
int
|
getConnectionAttemptCount()
|
IDevice[]
|
getDevices()
Returns the devices. |
int
|
getRestartAttemptCount()
|
boolean
|
hasInitialDeviceList()
|
boolean
|
isMonitoring()
Returns whether the monitor is currently connected to the debug bridge server. |
void
|
start()
Starts the monitoring. |
void
|
stop()
Stops the monitoring. |
Public constructors
DeviceMonitor
public DeviceMonitor (AndroidDebugBridge server)
Creates a new DeviceMonitor object and links it to the running AndroidDebugBridge object.
| Parameters | |
|---|---|
server |
AndroidDebugBridge: the running AndroidDebugBridge. |
Public methods
getConnectionAttemptCount
public int getConnectionAttemptCount ()
| Returns | |
|---|---|
int |
|
getRestartAttemptCount
public int getRestartAttemptCount ()
| Returns | |
|---|---|
int |
|
hasInitialDeviceList
public boolean hasInitialDeviceList ()
| Returns | |
|---|---|
boolean |
|
isMonitoring
public boolean isMonitoring ()
Returns whether the monitor is currently connected to the debug bridge server.
| Returns | |
|---|---|
boolean |
|
start
public void start ()
Starts the monitoring.
stop
public void stop ()
Stops the monitoring.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2026-06-22 UTC.