From 55e39b65ecf7563076616a58d780fc38df201263 Mon Sep 17 00:00:00 2001 From: Maciej Korzeniewski Date: Thu, 5 Dec 2024 09:13:52 +0200 Subject: [PATCH] Fix doFirstTimeUse on Android so that it completes when all underlying operations are completed --- .../java/com/polar/sdk/impl/BDBleApiImpl.kt | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/sources/Android/android-communications/library/src/sdk/java/com/polar/sdk/impl/BDBleApiImpl.kt b/sources/Android/android-communications/library/src/sdk/java/com/polar/sdk/impl/BDBleApiImpl.kt index 579b63b2..2faf5b76 100644 --- a/sources/Android/android-communications/library/src/sdk/java/com/polar/sdk/impl/BDBleApiImpl.kt +++ b/sources/Android/android-communications/library/src/sdk/java/com/polar/sdk/impl/BDBleApiImpl.kt @@ -1520,8 +1520,10 @@ class BDBleApiImpl private constructor(context: Context, features: Set + return Completable.defer { try { + BleLogger.d(TAG, "doFirstTimeUse(identifier: $identifier): started") + val session = sessionPsFtpClientReady(identifier) val client = session.fetchClient(BlePsFtpUtils.RFC77_PFTP_SERVICE) as BlePsFtpClient? ?: throw PolarServiceNotAvailable() @@ -1537,7 +1539,7 @@ class BDBleApiImpl private constructor(context: Context, features: Set emitter.onError(error) } - ) + .doOnError { error -> + BleLogger.e(TAG, "doFirstTimeUse(identifier: $identifier): error $error") + } } catch (error: Throwable) { - BleLogger.e(TAG, "doConfig() error: $error") - emitter.onError(error) + BleLogger.e(TAG, "doFirstTimeUse(identifier: $identifier): error $error") + return@defer Completable.error(error) } } }