Skip to content

Commit 18e27cb

Browse files
committed
Unregister capabilities callback before disconnection.
1 parent f0079f1 commit 18e27cb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

profile/src/main/java/no/nordicsemi/android/toolbox/profile/repository/channelSounding/ChannelSoundingManager.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,14 @@ class ChannelSoundingManager @Inject constructor(
215215
rangingSession = null
216216
_rangingData.value = null
217217
// unregister the callback
218-
218+
rangingManager?.unregisterCapabilitiesCallback(rangingCapabilityCallback)
219+
// Invoke the onClosed callback after a short delay to ensure the session is closed
219220
onClosed?.let {
220221
_rangingData.value = RangingSessionAction.OnStart
221222
// Wait for a moment to ensure the session is properly closed before invoking the callback
222223
// Launch a coroutine to delay and call onClosed
223224
CoroutineScope(Dispatchers.IO).launch {
224-
delay(500)
225+
delay(1000)
225226
it()
226227
}
227228

0 commit comments

Comments
 (0)