From b74868bfb3bb5ed2205c80b0eaf489363658b711 Mon Sep 17 00:00:00 2001 From: James Babcock Date: Tue, 25 Aug 2026 21:14:50 -0700 Subject: [PATCH] Flasher only uses right lens for confirmation, rather than confusedly trying to check via each lens separately --- .../app/FaceclawFlashPromptCommunicator.java | 51 ++++--------------- app/native/flash-prompt-communicator.ts | 8 +-- app/phone-ui/onboarding-flash-view-model.ts | 2 +- 3 files changed, 17 insertions(+), 44 deletions(-) diff --git a/App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawFlashPromptCommunicator.java b/App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawFlashPromptCommunicator.java index 6aba3b3d..e7bce6ca 100644 --- a/App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawFlashPromptCommunicator.java +++ b/App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawFlashPromptCommunicator.java @@ -26,6 +26,10 @@ import java.util.concurrent.TimeUnit; * protobuf helpers (BleProtocol), but owns its own GATT connection and runs its * whole lifecycle on a single worker thread. It expects the main app to be * disconnected while it runs (onboarding, before flashing). + * + * Only the right arm is used: the lenses relay messages to each other, so + * anything sent to the right arm reaches both, and acks/events only ever come + * from the right arm anyway. */ public class FaceclawFlashPromptCommunicator implements FaceclawBleListener { private static final String TAG = "FaceclawFlashPrompt"; @@ -43,7 +47,6 @@ public class FaceclawFlashPromptCommunicator implements FaceclawBleListener { private final Context context; private final String rightAddress; - private final String leftAddress; private final String warningText; private final FaceclawBleManager bleManager; private final Handler mainHandler = new Handler(Looper.getMainLooper()); @@ -58,7 +61,6 @@ public class FaceclawFlashPromptCommunicator implements FaceclawBleListener { private volatile boolean cancelled = false; private volatile boolean finished = false; private volatile boolean rightConnected = false; - private volatile boolean leftConnected = false; private volatile boolean rightLost = false; private volatile Boolean approved = null; private volatile ScheduledExecutorService heartbeatExecutor; @@ -66,10 +68,9 @@ public class FaceclawFlashPromptCommunicator implements FaceclawBleListener { private int nextMagic = 100; private int nextSeq = 0x40; - public FaceclawFlashPromptCommunicator(Context context, String rightAddress, String leftAddress, String warningText) { + public FaceclawFlashPromptCommunicator(Context context, String rightAddress, String warningText) { this.context = context.getApplicationContext(); this.rightAddress = rightAddress == null ? "" : rightAddress; - this.leftAddress = leftAddress == null ? "" : leftAddress; this.warningText = warningText == null ? "" : warningText; this.bleManager = new FaceclawBleManager(this.context); this.bleManager.setListener(this); @@ -116,18 +117,8 @@ public class FaceclawFlashPromptCommunicator implements FaceclawBleListener { } emitState("connecting", ""); - connectArm(rightAddress, "right"); + connectArm(rightAddress); rightConnected = true; - - boolean haveLeft = !leftAddress.trim().isEmpty() && !leftAddress.equalsIgnoreCase(rightAddress); - if (haveLeft) { - try { - connectArm(leftAddress, "left"); - leftConnected = true; - } catch (Exception e) { - emitLog("left arm connect failed (continuing on right only): " + e.getMessage()); - } - } if (cancelled) { teardown(); return; @@ -135,14 +126,6 @@ public class FaceclawFlashPromptCommunicator implements FaceclawBleListener { emitState("connected", ""); bringUpArm(rightAddress); - if (leftConnected) { - try { - bringUpArm(leftAddress); - } catch (Exception e) { - emitLog("left arm prompt failed (continuing on right only): " + e.getMessage()); - leftConnected = false; - } - } startHeartbeat(); emitState("prompting", ""); @@ -158,7 +141,7 @@ public class FaceclawFlashPromptCommunicator implements FaceclawBleListener { if (approved != null) { boolean result = Boolean.TRUE.equals(approved); try { - sendShutdownBoth(); + sendShutdown(); } catch (Exception ignored) { } emitResult(result); @@ -182,7 +165,7 @@ public class FaceclawFlashPromptCommunicator implements FaceclawBleListener { } } - private void connectArm(String address, String labelForLog) { + private void connectArm(String address) { if (!bleManager.connect(address, ConnectionOptions.CONNECT_TIMEOUT_MS)) { throw new IllegalStateException("connect failed: " + address); } @@ -194,7 +177,7 @@ public class FaceclawFlashPromptCommunicator implements FaceclawBleListener { if (!bleManager.enableNotifications(address, BleProtocol.NOTIFY_CHAR_UUID, true, ConnectionOptions.DESCRIPTOR_TIMEOUT_MS)) { throw new IllegalStateException("enableNotifications failed: " + address); } - emitLog("connected " + labelForLog + " arm"); + emitLog("connected right arm"); } private void bringUpArm(String address) throws InterruptedException { @@ -301,9 +284,6 @@ public class FaceclawFlashPromptCommunicator implements FaceclawBleListener { if (rightConnected) { writeFrame(rightAddress, BleProtocol.SID_EVENHUB, BleProtocol.FLAG_REQUEST, heartbeat); } - if (leftConnected) { - writeFrame(leftAddress, BleProtocol.SID_EVENHUB, BleProtocol.FLAG_REQUEST, heartbeat); - } } catch (Exception e) { Log.w(TAG, "heartbeat failed: " + e.getMessage()); } @@ -317,14 +297,11 @@ public class FaceclawFlashPromptCommunicator implements FaceclawBleListener { } } - private void sendShutdownBoth() { + private void sendShutdown() { byte[] shutdown = BleProtocol.buildShutdown(allocMagic(), 0); if (rightConnected) { writeFrame(rightAddress, BleProtocol.SID_EVENHUB, BleProtocol.FLAG_REQUEST, shutdown); } - if (leftConnected) { - writeFrame(leftAddress, BleProtocol.SID_EVENHUB, BleProtocol.FLAG_REQUEST, shutdown); - } } private void teardown() { @@ -335,7 +312,6 @@ public class FaceclawFlashPromptCommunicator implements FaceclawBleListener { } catch (Exception ignored) { } rightConnected = false; - leftConnected = false; } @Override @@ -355,10 +331,7 @@ public class FaceclawFlashPromptCommunicator implements FaceclawBleListener { return; } if (frame.flag == BleProtocol.FLAG_NOTIFY || frame.flag == BleProtocol.FLAG_NOTIFY_ALT) { - // Async events (taps/selections) only ever come from the right arm. - if (address.equalsIgnoreCase(rightAddress)) { - handleEvent(frame); - } + handleEvent(frame); return; } if (frame.msgSeq >= 0) { @@ -407,8 +380,6 @@ public class FaceclawFlashPromptCommunicator implements FaceclawBleListener { selectionLatch.countDown(); } } - } else if (address.equalsIgnoreCase(leftAddress)) { - leftConnected = false; } } diff --git a/app/native/flash-prompt-communicator.ts b/app/native/flash-prompt-communicator.ts index 19f08c47..a31cb420 100644 --- a/app/native/flash-prompt-communicator.ts +++ b/app/native/flash-prompt-communicator.ts @@ -17,6 +17,9 @@ export type FlashPromptState = * stock-firmware-compatible BLE path that shows the pre-flash confirmation on * the glasses and reports the user's Yes/No choice. Separate from * FaceclawCommunicatorBridge on purpose (different, minimal protocol subset). + * + * Talks to the right arm only: the lenses relay messages between themselves, + * and acks/events always come from the right arm. */ export class FlashPromptCommunicator { private readonly communicator: any; @@ -25,14 +28,13 @@ export class FlashPromptCommunicator { private readonly stateListeners = new Set<(state: FlashPromptState, detail: string) => void>(); private readonly resultListeners = new Set<(approved: boolean) => void>(); - constructor(addresses: { right: string; left: string }, warningText: string) { + constructor(rightAddress: string, warningText: string) { const context = Utils.android.getApplicationContext(); if (!context) throw new Error("Android application context unavailable"); this.communicator = new com.faceclaw.app.FaceclawFlashPromptCommunicator( context, - addresses.right, - addresses.left, + rightAddress, warningText, ); this.listenerProxy = new com.faceclaw.app.FaceclawFlashPromptListener({ diff --git a/app/phone-ui/onboarding-flash-view-model.ts b/app/phone-ui/onboarding-flash-view-model.ts index 0a4e368f..7d29bdf1 100644 --- a/app/phone-ui/onboarding-flash-view-model.ts +++ b/app/phone-ui/onboarding-flash-view-model.ts @@ -253,7 +253,7 @@ export class OnboardingFlashViewModel extends Observable { private startCommunicator(addresses: { right: string; left: string }): void { this.disposePrompt(); - const prompt = new FlashPromptCommunicator(addresses, this.glassesWarning); + const prompt = new FlashPromptCommunicator(addresses.right, this.glassesWarning); this.prompt = prompt; this.promptUnsubscribers.push(