Enumerations

enum class State : uint8_t
Name Value Comments
kAwaitingUsbConnection 0

In kAwaitingUsbConnection, we have called function_.SetInterface(this), and
are waiting for the function driver to call SetConfigured(true). Calls to
SetConfigured(false) are ignored.

Once SetConfigured(true) has been called, we:
- Send USB "receive" requests to the endpoint,
- Tell any connected UsbAdbImpl clients that the device is online, and
- Move to kOnline.

If a fadb::Device client requests shutdown by calling StopAdb() or closing
a UsbAdbImpl connection, we call function_.Deconfigure(), and move
to kStoppingForReconnect. If Stop is called, we move to kStoppingForUnbind.

kOnline 1

In kOnline, the USB connection is live, and we respond to any
QueueTx/Receive requests from UsbAdbImpl clients.

If any of the following happen:
- A fadb::Device client calls StopAdb().
- A UsbAdbImpl client closes their channel.
- The USB function driver calls SetConfigured(false)
- Stop gets called.

... we call function_.Deconfigure() and move to kStoppingForReconnect or
kStoppingForUnbind. (We hold onto the responder for any calls to StopAdb()).

kStoppingForUnbind 2

In kStoppingForUnbind, we wait for all outstanding USB requests to be completed.
Once they have been, we:
- Return OK to any pending StopAdb() calls (e.g. if Stop() was called while
a reconnect was pending),
- Tell any connected UsbAdbImpl clients that the device is offline,
- Close all UsbAdbImpl connections.

At that point, since the stoppage was caused by a call to Stop (or
Stop called while shutting down), we respond that the driver has
shutdown successfully.

kStoppingForReconnect 3

In kStoppingForReconnect, we wait for all outstanding USB requests to be completed.
Once they have been, we:
- Return OK to any StopAdb() calls that triggered the stoppage,
- Tell any connected UsbAdbImpl clients that the device is offline,
- Close all UsbAdbImpl connections.

At that point, we restart the USB connection by calling
function_.Configure(), and move back to kAwaitingUsbConnection.

The driver's internal state machine. Begins in kAwaitingUsbConnection.

Defined at line 45 of file ../../src/developer/adb/drivers/usb-adb-function/adb-function.h

Records