From e49c5641c5bf998a19af2d2578fd8162b500cf26 Mon Sep 17 00:00:00 2001 From: MasterControl Date: Mon, 16 Nov 2026 18:25:54 +0000 Subject: [PATCH 1/4] Revert "fix(ble): drop CONNECTION_PRIORITY_HIGH for G2 arms" This reverts commit 4b4ab1b02c7579ab12d6ccc5a5e3d4f0da9b9c4d. --- .../app/g2protocol/session/GlassesSessionCore.kt | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) 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 c5726288..1de741b7 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 @@ -2464,13 +2464,11 @@ class GlassesSessionCore( throw ArmUnreachableException(if (address.equals(leftAddress, ignoreCase = true)) "left" else "right", address) } } - // Deliberately NOT requesting CONNECTION_PRIORITY_HIGH for the arms (mirrors the - // ring in connectRing). HIGH negotiates a ~5 s supervision timeout (interval=12 / - // timeout=500, 5000 ms) which makes the link die on any >5 s BLE gap and can strand - // an arm in a half-open "connected" state where it stops advertising and is only - // recoverable by a 5-tap reset. BALANCED's longer supervision timeout survives those - // gaps. The firmware's own fast-profile request (ble_link.c) still negotiates speed - // when a transfer needs it. + // requestConnectionPriority has no callback in this Android compile target, so there is + // no reliable completion point to keep it in the global GATT operation pipeline. But it's + // important enough for performance that we call it anyways. + link.requestHighPriority(address) + link.requestMtu(address, ConnectionOptions.DESIRED_MTU, ConnectionOptions.CONNECT_TIMEOUT_MS) if (!link.discoverServices(address, ConnectionOptions.SERVICES_TIMEOUT_MS)) { From c1ca1acf3b6e9a0d4b6988b3ca82d516f1e3aaa0 Mon Sep 17 00:00:00 2001 From: MasterControl Date: Mon, 16 Nov 2026 18:25:54 +0000 Subject: [PATCH 2/4] Revert "fix(ble): fall back to direct connect when autoConnect can't reach an arm" This reverts commit 52ead474e26538d121a1921691c43e56f8f61e97. --- .../com/faceclaw/app/g2protocol/ConnectionOptions.kt | 6 ------ .../app/g2protocol/session/GlassesSessionCore.kt | 10 +--------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/native/kotlin/shared/src/commonMain/kotlin/com/faceclaw/app/g2protocol/ConnectionOptions.kt b/native/kotlin/shared/src/commonMain/kotlin/com/faceclaw/app/g2protocol/ConnectionOptions.kt index 53baca95..2ab2911d 100644 --- a/native/kotlin/shared/src/commonMain/kotlin/com/faceclaw/app/g2protocol/ConnectionOptions.kt +++ b/native/kotlin/shared/src/commonMain/kotlin/com/faceclaw/app/g2protocol/ConnectionOptions.kt @@ -12,12 +12,6 @@ class ConnectionOptions { // giving up. Both are dialed at once, so a slow or missing arm gets the whole // window (it stays under Android's own ~30 s direct-connect timeout). const val ARM_CONNECT_WINDOW_MS = 20_000 - // When autoConnect (background reconnect) fails to reach an arm, a direct connect - // is retried: its aggressive scan can catch an arm that advertises only briefly, - // and the cached bond can sometimes recover a half-open link that stopped - // advertising after a dropped link. This is the direct retry's own window, - // independent of ARM_CONNECT_WINDOW_MS (already spent on the autoConnect attempt). - const val DIRECT_CONNECT_FALLBACK_TIMEOUT_MS = 15_000 const val SERVICES_TIMEOUT_MS = 5_000 const val DESCRIPTOR_TIMEOUT_MS = 5_000 const val RING_DESIRED_MTU = 247 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 1de741b7..646a6d7e 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 @@ -2454,15 +2454,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)) { - // autoConnect only connects on a fresh advertisement; an arm stuck in a - // half-open state (it stopped advertising after a dropped link) never - // produces one. Retry direct: the aggressive scan plus the cached bond - // can recover it. Still unreachable after that is a real failure. - logLine("autoConnect timed out for " + address + "; retrying direct connect") - ConnectionCounters.increment("g2.connect-fallback-direct") - if (!link.connect(address, ConnectionOptions.DIRECT_CONNECT_FALLBACK_TIMEOUT_MS, false)) { - throw ArmUnreachableException(if (address.equals(leftAddress, ignoreCase = true)) "left" else "right", address) - } + throw ArmUnreachableException(if (address.equals(leftAddress, ignoreCase = true)) "left" else "right", address) } // requestConnectionPriority has no callback in this Android compile target, so there is // no reliable completion point to keep it in the global GATT operation pipeline. But it's From d08a21881025b8e4ba886c511ec28bb326e6d9e2 Mon Sep 17 00:00:00 2001 From: MasterControl Date: Mon, 16 Nov 2026 18:25:54 +0000 Subject: [PATCH 3/4] 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) From 386a10775d06c0bb920080319c36f0ec3adeb540 Mon Sep 17 00:00:00 2001 From: MasterControl Date: Mon, 16 Nov 2026 18:32:34 +0000 Subject: [PATCH 4/4] Revert "fix: show silent-mode feedback and promptly detect exit" This reverts commit 02dba881317d8d2768f0593ffe8b5c2893cf814d. --- app/g2/dashboard-controller.ts | 50 +------------- app/phone-ui/main-page.xml | 3 - app/phone-ui/main-view-model.ts | 13 ---- docs/validation-silent-mode.md | 13 ---- .../app/g2protocol/ConnectionOptions.kt | 2 - .../g2protocol/session/GlassesSessionSend.kt | 5 +- .../faceclaw/app/GlassesSessionCoreTest.kt | 18 ----- tests/silent-mode-feedback.test.cjs | 67 ------------------- 8 files changed, 5 insertions(+), 166 deletions(-) delete mode 100644 docs/validation-silent-mode.md delete mode 100644 tests/silent-mode-feedback.test.cjs diff --git a/app/g2/dashboard-controller.ts b/app/g2/dashboard-controller.ts index 934be105..6e441fdf 100644 --- a/app/g2/dashboard-controller.ts +++ b/app/g2/dashboard-controller.ts @@ -120,7 +120,6 @@ export type DashboardSnapshot = { * glasses, and this says which harmless thing is actually going on. */ displayPreviewMessage: string; - silentModeFeedback: string; activeTextSettingId: string | null; activeTextEditorTitle: string; activeTextSettingTitle: string; @@ -296,9 +295,6 @@ class DashboardController { /** The screen area displayPreview shows (Preview scaling), or null for the whole panel. */ private displayPreviewCrop: ScreenRect | null = null; private silentMode = false; - private silentModeFeedback = ""; - private silentModeFeedbackGeneration = 0; - private silentModeFeedbackTimer: ReturnType | null = null; // Brightness value last pushed to the glasses; see pushBrightness. private lastPushedBrightness: string | null = null; private lastPushedHeadUp: string | null = null; @@ -1221,7 +1217,6 @@ class DashboardController { status: this.status, displayPreview: this.displayPreview, displayPreviewMessage: this.displayPreviewMessage(), - silentModeFeedback: this.silentModeFeedback, activeTextSettingId: primaryTextSetting?.id ?? null, activeTextEditorTitle: this.activeTextEditorTitle, activeTextSettingTitle: primaryTextSetting?.editorTitle ?? "", @@ -1260,43 +1255,6 @@ class DashboardController { * charging and silent mode both make the display unavailable while BLE stays * up, and a battery that just ran out simply stops answering. */ - private handleSilentMode(silent: boolean): void { - if (this.silentMode === silent) return; - this.silentMode = silent; - const generation = ++this.silentModeFeedbackGeneration; - if (this.silentModeFeedbackTimer !== null) clearTimeout(this.silentModeFeedbackTimer); - this.silentModeFeedbackTimer = null; - this.silentModeFeedback = silent - ? "Silent mode enabled — hold both touchpads to exit" - : "Silent mode disabled"; - if (!silent) { - void this.showSilentModeExit(generation).catch(error => { - this.appendLog(`silent-mode exit feedback failed: ${this.formatError(error)}`); - }); - this.silentModeFeedbackTimer = setTimeout(() => { - this.silentModeFeedbackTimer = null; - this.silentModeFeedback = ""; - this.emit(); - }, 5000); - } - this.emit(); - } - - private async showSilentModeExit(generation: number): Promise { - if (this.phase !== "connected" || this.silentMode || this.glassesLocked) return; - // The firmware powered the lenses down, and Faceclaw may have gone to - // sleep/suspended EvenHub meanwhile. Reusing the ordinary wake barrier is - // essential: rendering an alert into the retained surface alone is invisible. - this.cancelEvenHubSuspendTimer(); - shell.wake("sidebar"); - const ready = await this.ensureEvenHubSessionActive(); - if (!ready || generation !== this.silentModeFeedbackGeneration || this.silentMode || - this.phase !== "connected" || this.glassesLocked) return; - shell.showAlert("Silent mode disabled"); - shell.foregroundWindow()?.requestRender(); - this.requestShellRender(); - } - private displayPreviewMessage(): string { if (this.phase === "charging") { return chargingPreviewMessage(this.glassesDisplayState()); @@ -1731,7 +1689,9 @@ class DashboardController { }); }); this.offSilentMode = communicator.onSilentMode((silent) => { - this.handleSilentMode(silent); + if (this.silentMode === silent) return; + this.silentMode = silent; + this.emit(); }); this.offWearState = communicator.onWearState((wearing) => { this.handleWearState(wearing); @@ -3129,10 +3089,6 @@ class DashboardController { // Kept across "connecting": silent mode blocks app launches, so it can // itself cause the reconnect churn, and Java re-reports it either way. this.silentMode = false; - this.silentModeFeedbackGeneration++; - if (this.silentModeFeedbackTimer !== null) clearTimeout(this.silentModeFeedbackTimer); - this.silentModeFeedbackTimer = null; - this.silentModeFeedback = ""; } this.emit(); } diff --git a/app/phone-ui/main-page.xml b/app/phone-ui/main-page.xml index 10833a6a..29c12f08 100644 --- a/app/phone-ui/main-page.xml +++ b/app/phone-ui/main-page.xml @@ -74,9 +74,6 @@ class="ble-bandwidth-indicator" horizontalAlignment="center" verticalAlignment="bottom" /> -