Your Android phone and your Windows PC, working as one. Local-first, end-to-end encrypted, no account.
fix(android): entering the pairing code in the notification no longer freezes the app
Beef2891a78b9ad
diff --git a/android/app/src/main/kotlin/app/nectarlink/android/elevated/PairingNotification.kt b/android/app/src/main/kotlin/app/nectarlink/android/elevated/PairingNotification.ktindex a94b1e3..b29e91f 100644--- a/android/app/src/main/kotlin/app/nectarlink/android/elevated/PairingNotification.kt+++ b/android/app/src/main/kotlin/app/nectarlink/android/elevated/PairingNotification.kt@@ -14,9 +14,11 @@ import androidx.core.app.NotificationManagerCompatimport androidx.core.app.RemoteInputimport androidx.core.content.ContextCompatimport app.nectarlink.android.R+import java.util.concurrent.atomic.AtomicBooleanimport kotlinx.coroutines.CoroutineScopeimport kotlinx.coroutines.Dispatchersimport kotlinx.coroutines.SupervisorJob+import kotlinx.coroutines.delayimport kotlinx.coroutines.launch/**@@ -29,6 +31,8 @@ object PairingNotification {private const val CHANNEL = "elevated"private const val ID = 7private const val KEY_CODE = "code"+ /** How long the receiver waits for pairing before letting Android move on. */+ private const val RECEIVER_MS = 8_000Lprivate val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO)/** Asks for the code; false if notifications are off for the app. */@@ -71,6 +75,15 @@ object PairingNotification {}show(app, app.getString(R.string.elevated_pairing))val pending = goAsync()+ // Android stops a receiver after about ten seconds (an "isn't+ // responding" error), and finding the pairing dialog alone can take+ // that long: let it go in time; the pairing carries on.+ val released = AtomicBoolean(false)+ val release = { if (released.compareAndSet(false, true)) pending.finish() }+ scope.launch {+ delay(RECEIVER_MS)+ release()+ }scope.launch {try {if (Elevated.pair(code)) {@@ -84,7 +97,7 @@ object PairingNotification {show(app, app.getString(why))}} finally {- pending.finish()+ release()}}}