mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-07-25 09:45:19 +00:00
patches: wifi aware mesh refactor core (#549)
* Refactor WifiAware memory management and lifecycle handling * Fix Wi-Fi Aware reconnection by ensuring callback unregistration and session watchdog * fix(wifiaware): allow WifiAwareController to restart service if session drops * Enhance WiFi Aware logging with network request timeouts and detailed callback status * Ensure explicit release of WiFi Aware network callbacks on failure or disconnection --------- Co-authored-by: aidenvalue <>
This commit is contained in:
co-authored by
aidenvalue <>
parent
ee4b2610f9
commit
3a1589972b
@@ -43,9 +43,19 @@ class WifiAwareConnectionTracker(
|
||||
try { it.close() } catch (e: Exception) { Log.w(TAG, "Error closing server socket for $id: ${e.message}") }
|
||||
}
|
||||
|
||||
// 3. Unregister network callback
|
||||
// Ensure any pending/active network request is explicitly released
|
||||
releaseNetworkRequest(id)
|
||||
}
|
||||
|
||||
fun releaseNetworkRequest(id: String) {
|
||||
if (!networkCallbacks.containsKey(id)) return
|
||||
|
||||
// 3. Unregister network callback properly from ConnectivityManager
|
||||
networkCallbacks.remove(id)?.let {
|
||||
try { cm.unregisterNetworkCallback(it) } catch (e: Exception) { Log.w(TAG, "Error unregistering callback for $id: ${e.message}") }
|
||||
try {
|
||||
Log.d(TAG, "Unregistering network callback for $id")
|
||||
cm.unregisterNetworkCallback(it)
|
||||
} catch (e: Exception) { Log.w(TAG, "Error unregistering callback for $id: ${e.message}") }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user