From 18e27cb3dd6c8151d23aa5e8c5acc3480d074a8e Mon Sep 17 00:00:00 2001 From: hiar Date: Mon, 29 Sep 2025 14:11:06 +0200 Subject: [PATCH] Unregister capabilities callback before disconnection. --- .../repository/channelSounding/ChannelSoundingManager.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/profile/src/main/java/no/nordicsemi/android/toolbox/profile/repository/channelSounding/ChannelSoundingManager.kt b/profile/src/main/java/no/nordicsemi/android/toolbox/profile/repository/channelSounding/ChannelSoundingManager.kt index 9e7f2efd..23b24012 100644 --- a/profile/src/main/java/no/nordicsemi/android/toolbox/profile/repository/channelSounding/ChannelSoundingManager.kt +++ b/profile/src/main/java/no/nordicsemi/android/toolbox/profile/repository/channelSounding/ChannelSoundingManager.kt @@ -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() }