From d08a21881025b8e4ba886c511ec28bb326e6d9e2 Mon Sep 17 00:00:00 2001 From: MasterControl Date: Mon, 16 Nov 2026 18:25:54 +0000 Subject: [PATCH] Revert "fix(ble): connect G2 arms with autoConnect=true" This reverts commit a9df3de59b625b433bb44559f6be2058b040c277. --- .../com/faceclaw/app/FaceclawBleManager.kt | 21 ++++++++++--------- .../g2protocol/session/GlassesSessionCore.kt | 15 ++++++------- .../app/g2protocol/session/SessionPorts.kt | 3 +-- 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawBleManager.kt b/App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawBleManager.kt index 16b842a5..3782e821 100644 --- a/App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawBleManager.kt +++ b/App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawBleManager.kt @@ -231,16 +231,17 @@ class FaceclawBleManager(context: Context) { fun connect(address: String?, timeoutMs: Int): Boolean = connect(address, timeoutMs, false) /** - * autoConnect=true is used for the ring and both glasses arms. The ring specifically - * needs it (Even's own vendor app connects the ring with Android's autoConnect flag - * set, confirmed via its own BLE debug log, "connect() - device: ..., - * auto: true"). A live test showed a ring-only direct connection dying almost - * exactly 5 seconds in, repeatedly, with nothing else competing for it, and the - * glasses arms showed the same "less patiently supervised" direct-connect drop. - * Direct connect (false) is faster to establish but Android supervises it less - * patiently. autoConnect=true can take much longer to actually complete (Android - * manages it as a background reconnect, not an immediate attempt), so it needs its - * own longer timeout. Like [connect], waits on an attempt already pending. + * EXPERIMENTAL (2026-09-11): the ring specifically needs autoConnect=true. + * Even's own vendor app connects the ring with Android's autoConnect flag + * set (confirmed via its own BLE debug log, "connect() - device: ..., + * auto: true"), while every other faceclaw connection (both glasses arms) + * uses autoConnect=false. Direct connect (false) is faster to establish + * but Android supervises it less patiently; a live test showed the + * ring-only direct connection dying almost exactly 5 seconds in, + * repeatedly, with nothing else competing for it. autoConnect=true can + * take much longer to actually complete (Android manages it as a + * background reconnect, not an immediate attempt), so this needs its own + * longer timeout. Like [connect], waits on an attempt already pending. */ fun connect(address: String?, timeoutMs: Int, autoConnect: Boolean): Boolean { val key = requireAddress(address) diff --git a/native/kotlin/shared/src/commonMain/kotlin/com/faceclaw/app/g2protocol/session/GlassesSessionCore.kt b/native/kotlin/shared/src/commonMain/kotlin/com/faceclaw/app/g2protocol/session/GlassesSessionCore.kt index 646a6d7e..00a5ff47 100644 --- a/native/kotlin/shared/src/commonMain/kotlin/com/faceclaw/app/g2protocol/session/GlassesSessionCore.kt +++ b/native/kotlin/shared/src/commonMain/kotlin/com/faceclaw/app/g2protocol/session/GlassesSessionCore.kt @@ -2339,12 +2339,9 @@ class GlassesSessionCore( try { // Dial both arms at once, so the left arm's attempt is already pending (and // can land) while the right arm is being set up; they share one window. - // autoConnect=true for both arms: a direct connection is supervised less - // patiently by Android's stack and was observed dropping the link shortly - // after it came up (the same failure that made the ring require autoConnect). val deadlineMs = now() + ConnectionOptions.ARM_CONNECT_WINDOW_MS - link.beginConnect(rightAddress, true) - link.beginConnect(leftAddress, true) + link.beginConnect(rightAddress, false) + link.beginConnect(leftAddress, false) connectArm(rightAddress, true, deadlineMs) connectArm(leftAddress, true, deadlineMs) if (!sleepDuringConnectSettling(800)) { @@ -2453,7 +2450,7 @@ class GlassesSessionCore( internal fun connectArm(address: String, enableRenderNotify: Boolean, deadlineMs: Long) { val timeoutMs = maxOf(deadlineMs - now(), ConnectionOptions.CONNECT_TIMEOUT_MS.toLong()) - if (!link.connect(address, timeoutMs.toInt(), true)) { + if (!link.connect(address, timeoutMs.toInt())) { throw ArmUnreachableException(if (address.equals(leftAddress, ignoreCase = true)) "left" else "right", address) } // requestConnectionPriority has no callback in this Android compile target, so there is @@ -2541,9 +2538,9 @@ class GlassesSessionCore( logLine("connecting direct ring $ringAddress") // autoConnect=true (see SessionLink.connect's 3-arg overload) - // matches what Even's own app does for this device specifically. - // Direct connect (false) was measured dying ~5s into an - // otherwise-idle ring connection, repeatedly, with nothing else - // competing for it. + // Direct connect (false, the default used for the glasses) was + // measured dying ~5s into an otherwise-idle ring connection, + // repeatedly, with nothing else competing for it. if (!link.connect(ringAddress, ConnectionOptions.RING_CONNECT_TIMEOUT_MS, true)) { throw IllegalStateException("connect failed: $ringAddress") } diff --git a/native/kotlin/shared/src/commonMain/kotlin/com/faceclaw/app/g2protocol/session/SessionPorts.kt b/native/kotlin/shared/src/commonMain/kotlin/com/faceclaw/app/g2protocol/session/SessionPorts.kt index 3c658c67..aaa076b6 100644 --- a/native/kotlin/shared/src/commonMain/kotlin/com/faceclaw/app/g2protocol/session/SessionPorts.kt +++ b/native/kotlin/shared/src/commonMain/kotlin/com/faceclaw/app/g2protocol/session/SessionPorts.kt @@ -18,8 +18,7 @@ interface SessionLink { /** * [connect] with the platform's background-reconnect mode (Android's autoConnect) when - * [autoConnect] is set. The R1 ring and the G2 glasses arms both need it; platforms - * without the distinction ignore it. + * [autoConnect] is set. The R1 ring needs it; platforms without the distinction ignore it. */ fun connect(address: String, timeoutMs: Int, autoConnect: Boolean): Boolean = connect(address, timeoutMs)