Skip to content

Your Android phone and your Windows PC, working as one. Local-first, end-to-end encrypted, no account.

fix(android): one PC can't stop the microphone another PC is using

Bee94c173004b1a
diff --git a/android/app/src/main/kotlin/app/nectarlink/android/core/PhonePlatform.kt b/android/app/src/main/kotlin/app/nectarlink/android/core/PhonePlatform.kt
index 1e18725..d6b6c91 100644
--- a/android/app/src/main/kotlin/app/nectarlink/android/core/PhonePlatform.kt
+++ b/android/app/src/main/kotlin/app/nectarlink/android/core/PhonePlatform.kt
@@ -217,7 +217,7 @@ internal class PhonePlatform(
override fun micStopRequested(pcId: String) {
onMicStop(pcId)
- app.nectarlink.android.mic.MicService.stop(context)
+ app.nectarlink.android.mic.MicService.stop(context, pcId)
}
override fun webcamStopRequested(pcId: String) {
diff --git a/android/app/src/main/kotlin/app/nectarlink/android/mic/MicService.kt b/android/app/src/main/kotlin/app/nectarlink/android/mic/MicService.kt
index fe2bdb3..6e6ca48 100644
--- a/android/app/src/main/kotlin/app/nectarlink/android/mic/MicService.kt
+++ b/android/app/src/main/kotlin/app/nectarlink/android/mic/MicService.kt
@@ -215,9 +215,9 @@ class MicService : Service() {
/** The per-device toggle that lets a PC ask for the microphone (docs/protocol/mic.md). */
const val TOGGLE_NAME = "mic"
- /** The PC stopped listening. */
- fun stop(context: Context) {
- if (_streaming.value == null) return
+ /** [pcId] stopped listening; another PC's stream carries on. */
+ fun stop(context: Context, pcId: String) {
+ if (_streaming.value != pcId) return
context.startService(Intent(context, MicService::class.java).setAction(ACTION_STOP))
}