UsbRepository

class UsbRepository(application: Application, dispatchers: CoroutineDispatchers, processLifecycle: Lifecycle, usbBroadcastReceiverLazy: Lazy<UsbBroadcastReceiver>, usbManagerLazy: Lazy<UsbManager?>, usbSerialProberLazy: Lazy<UsbSerialProber>)(source)

Repository responsible for maintaining and updating the state of USB connectivity.

Constructors

Link copied to clipboard
constructor(application: Application, dispatchers: CoroutineDispatchers, processLifecycle: Lifecycle, usbBroadcastReceiverLazy: Lazy<UsbBroadcastReceiver>, usbManagerLazy: Lazy<UsbManager?>, usbSerialProberLazy: Lazy<UsbSerialProber>)

Properties

Link copied to clipboard

False when the device cannot act as a USB host, so no USB serial transport can ever work (e.g. Android XR).

Link copied to clipboard
val serialDevices: StateFlow<Map<String, UsbSerialDriver>>

Functions

Link copied to clipboard

True when the app already holds USB permission for device, so a request round-trip can be skipped.

Link copied to clipboard
suspend fun pokeDtr(driver: UsbSerialDriver, holdMillis: Long): Boolean

Opens driver's port, asserts DTR/RTS for holdMillis, and closes it again.

Link copied to clipboard
Link copied to clipboard
fun requestPermission(device: UsbDevice): Flow<Boolean>