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_.SetInterface(nullptr), and move
to kStoppingUsb. Likewise if PrepareStop is called.

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)
- PrepareStop get called.

... we call function_.SetInterface(nullptr) and move to kStoppingUsb. (We
hold onto the responder for any calls to StopAdb()).

kStoppingUsb 2

In kStoppingUsb, 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 (or
happened while in kStoppingUsb).
- Tell any connected UsbAdbImpl clients that the device is
offline,
- Close all UsbAdbImpl connections.

At that point, if the stoppage was caused by a call to PrepareStop (or
PrepareStop we called while shutting down), we respond that the driver has
shutdown successfully. Otherwise, we restart the USB connection by calling
function_.SetInterface(this), and move back to kAwaitingUsbConnection.

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

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

Records