SwitchingDiscoveryDao
A switch-aware DiscoveryDao that resolves the active database on every call instead of pinning the one that was current at injection time. This is what Koin hands to feature:discovery consumers (ViewModels and the scan engine), which hold their DAO for their whole lifetime:
Flow methods re-latch through DatabaseProvider.observeCurrentDb, so an open discovery screen follows a device/DB switch and recovers from a wedged active Room pool.
Suspend methods go through DatabaseProvider.withDb, so writes register with the cross-transport merge drain barrier (a mid-scan merge can't snapshot-then-retire the DB underneath an in-flight session write). A callback is never replayed after it starts, so higher layers must make any retry policy explicit where idempotency is known.
withDb can return null while no database is available. Collection reads use empty defaults, count reads return zero, and operations that require a created row retain non-null checks so callers cannot proceed with an invalid id.
Functions
Snapshot used by DatabaseMerger to append a transport's discovery sessions to the unified DB.
The most recent recoverable session for deviceAddress. This includes active/interrupted scans and terminal scans whose home-radio restoration is still pending, so callers must inspect completionStatus rather than assuming an unfinished scan.