DeviceMonitor
public
final
class
DeviceMonitor
extends Object
implements
ClientTracker
| 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). It then
monitors that socket for all changes about device connection and device state. If ::getClientSupport is not enabled the DeviceClientMonitorTask is not
run, and devices are not registered.
On another thread it runs the 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. |
void
|
trackClientToDropAndReopen(ClientImpl client)
Callback for indicating that a client was dropped but an attempt should be made to reopen the connection with the client. |
void
|
trackDeviceToDropAndReopen(DeviceImpl device)
Callback to indicate that a device was dropped. |
void
|
trackDisconnectedClient(ClientImpl client)
Callback for when a client is disconnected. |
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.
trackClientToDropAndReopen
public void trackClientToDropAndReopen (ClientImpl client)
Callback for indicating that a client was dropped but an attempt should be made to reopen the connection with the client.
| Parameters | |
|---|---|
client |
ClientImpl: that was dropped. |
trackDeviceToDropAndReopen
public void trackDeviceToDropAndReopen (DeviceImpl device)
Callback to indicate that a device was dropped. An attempt should be made to reopen the connection with the device and reestablish connection with any of the clients running on that device.
| Parameters | |
|---|---|
device |
DeviceImpl: that was dropped. |
trackDisconnectedClient
public void trackDisconnectedClient (ClientImpl client)
Callback for when a client is disconnected. This callback is meant to notify any threads that hold a registration to a clients socket to release it.
| Parameters | |
|---|---|
client |
ClientImpl: that was dropped |
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 2025-12-04 UTC.