wireless: Disconnect works while the car hasn't answered yet

This commit is contained in:
Seb3thehacker committed 2026-10-13 16:00:40 -07:00
1 parent 10e8568aba
commit 4f1e6dcbfa
1 file changed
+6
@@ -115,6 +115,7 @@ object WirelessLink {
/** Closes the Bluetooth channel, the socket and the Wi-Fi request. Safe to call any time. */ /** Closes the Bluetooth channel, the socket and the Wi-Fi request. Safe to call any time. */
fun stop(context: Context) { fun stop(context: Context) {
tcpRun++ tcpRun++
val starting = worker != null && SessionStatus.state.value.phase == SessionStatus.Phase.CONNECTING
worker?.interrupt() worker?.interrupt()
worker = null worker = null
runCatching { listener?.close() } runCatching { listener?.close() }
@@ -127,6 +128,11 @@ object WirelessLink {
runCatching { context.getSystemService(ConnectivityManager::class.java).unregisterNetworkCallback(cb) } runCatching { context.getSystemService(ConnectivityManager::class.java).unregisterNetworkCallback(cb) }
} }
network = null network = null
// Stopped before the car's session began, so nothing else resets Home's card.
if (starting) {
log.i("wireless start-up stopped")
SessionStatus.disconnected()
}
} }
/** A stable id for this phone as this app sees it, standing in for the serial a real phone sends. */ /** A stable id for this phone as this app sees it, standing in for the serial a real phone sends. */