Unregister capabilities callback before disconnection.

This commit is contained in:
hiar
2025-09-29 14:11:06 +02:00
committed by Himali Aryal
parent f0079f1fbb
commit 18e27cb3dd

View File

@@ -215,13 +215,14 @@ class ChannelSoundingManager @Inject constructor(
rangingSession = null
_rangingData.value = null
// unregister the callback
rangingManager?.unregisterCapabilitiesCallback(rangingCapabilityCallback)
// Invoke the onClosed callback after a short delay to ensure the session is closed
onClosed?.let {
_rangingData.value = RangingSessionAction.OnStart
// Wait for a moment to ensure the session is properly closed before invoking the callback
// Launch a coroutine to delay and call onClosed
CoroutineScope(Dispatchers.IO).launch {
delay(500)
delay(1000)
it()
}