fix(ble): connect G2 arms with autoConnect=true

Direct connect (autoConnect=false) is supervised less patiently by Android's
BLE stack; the ring already requires autoConnect=true for this reason, and the
glasses arms showed the same short-lived direct-connect drops. Switch both
arms' beginConnect and connect to autoConnect=true.
This commit is contained in:
MasterControl committed 2026-11-14 20:05:15 +00:00
1 parent 3eb9b09e3d
commit a9df3de59b
3 files changed
+21 -18

No files matched your search

@@ -2339,9 +2339,12 @@ 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, false)
link.beginConnect(leftAddress, false)
link.beginConnect(rightAddress, true)
link.beginConnect(leftAddress, true)
connectArm(rightAddress, true, deadlineMs)
connectArm(leftAddress, true, deadlineMs)
if (!sleepDuringConnectSettling(800)) {
@@ -2450,7 +2453,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())) {
if (!link.connect(address, timeoutMs.toInt(), true)) {
throw ArmUnreachableException(if (address.equals(leftAddress, ignoreCase = true)) "left" else "right", address)
}
// requestConnectionPriority has no callback in this Android compile target, so there is
@@ -2538,9 +2541,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, the default used for the glasses) was
// measured dying ~5s into an otherwise-idle ring connection,
// repeatedly, with nothing else competing for it.
// Direct connect (false) 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")
}
@@ -18,7 +18,8 @@ interface SessionLink {
/**
* [connect] with the platform's background-reconnect mode (Android's autoConnect) when
* [autoConnect] is set. The R1 ring needs it; platforms without the distinction ignore it.
* [autoConnect] is set. The R1 ring and the G2 glasses arms both need it; platforms
* without the distinction ignore it.
*/
fun connect(address: String, timeoutMs: Int, autoConnect: Boolean): Boolean = connect(address, timeoutMs)