From ba8da027ae1117a111d2959eb247a96d38c4f5f0 Mon Sep 17 00:00:00 2001 From: "Jack Boswell (boswelja)" Date: Thu, 22 Apr 2021 12:50:45 +1200 Subject: [PATCH] Remove suspend modifier from getCapabilitiesFor --- .../watchconnection/core/PlatformConnectionHandler.kt | 2 +- .../boswelja/watchconnection/core/WatchConnectionClient.kt | 2 +- .../watchconnection/tizen/TizenConnectionHandler.kt | 6 ++++-- .../watchconnection/wearos/WearOSConnectionHandler.kt | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/core/src/main/kotlin/com/boswelja/watchconnection/core/PlatformConnectionHandler.kt b/core/src/main/kotlin/com/boswelja/watchconnection/core/PlatformConnectionHandler.kt index 9af432f7..a84a27df 100644 --- a/core/src/main/kotlin/com/boswelja/watchconnection/core/PlatformConnectionHandler.kt +++ b/core/src/main/kotlin/com/boswelja/watchconnection/core/PlatformConnectionHandler.kt @@ -28,7 +28,7 @@ interface PlatformConnectionHandler { * @param watchId See [Watch.platformId]. * @return A [Flow] of capability strings declared by the watch. */ - suspend fun getCapabilitiesFor(watchId: String): Flow + fun getCapabilitiesFor(watchId: String): Flow /** * Send a message to a watch with the given ID. Note that a successful response doesn't diff --git a/core/src/main/kotlin/com/boswelja/watchconnection/core/WatchConnectionClient.kt b/core/src/main/kotlin/com/boswelja/watchconnection/core/WatchConnectionClient.kt index 425c1c3e..ccf9fbdf 100644 --- a/core/src/main/kotlin/com/boswelja/watchconnection/core/WatchConnectionClient.kt +++ b/core/src/main/kotlin/com/boswelja/watchconnection/core/WatchConnectionClient.kt @@ -51,7 +51,7 @@ class WatchConnectionClient( * @param watch See [Watch]. * @return A [Flow] of capability strings declared by the watch. */ - suspend fun getCapabilitiesFor(watch: Watch): Flow? { + fun getCapabilitiesFor(watch: Watch): Flow? { return connectionHandlers[watch.platform]?.getCapabilitiesFor(watch.platformId) } diff --git a/tizen/src/main/kotlin/com/boswelja/watchconnection/tizen/TizenConnectionHandler.kt b/tizen/src/main/kotlin/com/boswelja/watchconnection/tizen/TizenConnectionHandler.kt index abd906db..5038d5f0 100644 --- a/tizen/src/main/kotlin/com/boswelja/watchconnection/tizen/TizenConnectionHandler.kt +++ b/tizen/src/main/kotlin/com/boswelja/watchconnection/tizen/TizenConnectionHandler.kt @@ -120,7 +120,7 @@ class TizenConnectionHandler internal constructor( override fun watchesWithApp(): Flow = allWatches() @ExperimentalCoroutinesApi - override suspend fun getCapabilitiesFor(watchId: String): Flow { + override fun getCapabilitiesFor(watchId: String): Flow { var flow = capabilityMap[watchId] if (flow == null) { // Flow doesn't already exist, create a new one @@ -132,7 +132,9 @@ class TizenConnectionHandler internal constructor( } // Request capability stream - sendMessage(watchId, CAPABILITY_MESSAGE) + coroutineScope.launch(Dispatchers.IO + capabilityJob) { + sendMessage(watchId, CAPABILITY_MESSAGE) + } return flow.mapNotNull { it } } diff --git a/wearos/src/main/kotlin/com/boswelja/watchconnection/wearos/WearOSConnectionHandler.kt b/wearos/src/main/kotlin/com/boswelja/watchconnection/wearos/WearOSConnectionHandler.kt index f5a91519..ccb750f7 100644 --- a/wearos/src/main/kotlin/com/boswelja/watchconnection/wearos/WearOSConnectionHandler.kt +++ b/wearos/src/main/kotlin/com/boswelja/watchconnection/wearos/WearOSConnectionHandler.kt @@ -66,7 +66,7 @@ class WearOSConnectionHandler internal constructor( } } - override suspend fun getCapabilitiesFor(watchId: String): Flow = flow { + override fun getCapabilitiesFor(watchId: String): Flow = flow { // Get all capabilities val capabilities = capabilityClient .getAllCapabilities(CapabilityClient.FILTER_REACHABLE).await()