diff --git a/App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawDeviceInfoProbe.java b/App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawDeviceInfoProbe.java index 553a4311..2eaacad6 100644 --- a/App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawDeviceInfoProbe.java +++ b/App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawDeviceInfoProbe.java @@ -23,6 +23,7 @@ public class FaceclawDeviceInfoProbe implements FaceclawBleListener { private final Context context; private final String rightAddress; + private final String leftAddress; private final FaceclawBleManager bleManager; private final Handler mainHandler = new Handler(Looper.getMainLooper()); @@ -35,13 +36,21 @@ public class FaceclawDeviceInfoProbe implements FaceclawBleListener { private byte[] awaitPb = null; private CountDownLatch awaitLatch = null; + /** + * A sid-0x09 frame that carried firmware versions without matching the + * awaited magic — some firmware pushes the settings snapshot on a magic it + * picked itself instead of (or in addition to) acking the read. + */ + private volatile byte[] unsolicitedSettingsPb; + private volatile FaceclawDeviceInfoProbeListener listener; private volatile Thread worker; private volatile boolean cancelled = false; - public FaceclawDeviceInfoProbe(Context context, String rightAddress) { + public FaceclawDeviceInfoProbe(Context context, String rightAddress, String leftAddress) { this.context = context.getApplicationContext(); this.rightAddress = rightAddress == null ? "" : rightAddress; + this.leftAddress = leftAddress == null ? "" : leftAddress; this.bleManager = new FaceclawBleManager(this.context); this.bleManager.setListener(this); } @@ -83,44 +92,28 @@ public class FaceclawDeviceInfoProbe implements FaceclawBleListener { return; } - emitState("connecting", ""); - connectArm(rightAddress); + byte[] ack = probeArm(rightAddress, "right"); + // The right lens is the documented control endpoint, but a silent + // right lens has been observed on stock 2.2.9 even after a + // successful security auth — run the same probe against the left + // lens rather than giving up, and log which lens answered. + if (ack == null && !cancelled && !leftAddress.trim().isEmpty() + && !leftAddress.equalsIgnoreCase(rightAddress)) { + emitLog("right lens did not answer the settings query; probing the left lens"); + try { + ack = probeArm(leftAddress, "left"); + } catch (Exception e) { + emitLog("left-lens probe failed: " + (e.getMessage() == null ? e.toString() : e.getMessage())); + } + } if (cancelled) { emitError("Cancelled."); return; } - - // Firmware 2.2.9 answers no queries until the security-auth - // exchange completes over an encrypted link; on a phone with no - // existing bond this is also what triggers SMP pairing (and its - // OS prompt), so it must come before the prelude and query. Soft: - // this probe also runs against the custom firmware, whose response - // to the exchange is not yet hardware-verified, so an unconfirmed - // auth falls through to the query and only enriches its error. - emitState("authenticating", ""); - boolean authenticated = authenticate(rightAddress); - if (cancelled) { - emitError("Cancelled."); - return; - } - - emitState("querying", ""); - // Session prelude, then a settings/device-info read (both arms' - // versions and the CFW capability string ride back in one response). - if (writeAndAwaitAck(rightAddress, BleProtocol.PRELUDE_ACK_SID, BleProtocol.FLAG_REQUEST, - BleProtocol.PRELUDE_ACK_MAGIC, BleProtocol.PRELUDE_F5872_PAYLOAD, - ConnectionOptions.PRELUDE_TIMEOUT_MS) == null) { - throw new IllegalStateException("session prelude not acked"); - } - - int magic = allocMagic(); - byte[] ack = writeAndAwaitAck(rightAddress, BleProtocol.SID_UI_SETTING, BleProtocol.FLAG_REQUEST, - magic, BleProtocol.buildSettingsQuery(magic), QUERY_TIMEOUT_MS); if (ack == null) { - throw new IllegalStateException(authenticated - ? "no response to the device-info query" - : "no response to the device-info query — authentication with the glasses did not complete;" - + " if Android shows a Bluetooth pairing request, accept it and try again"); + throw new IllegalStateException( + "no response to the device-info query on either lens — check `adb logcat -s " + + TAG + "` for the frame trace"); } BleProtocol.FirmwareInfo info = BleProtocol.parseSettingsFirmwareInfo(ack); @@ -140,6 +133,64 @@ public class FaceclawDeviceInfoProbe implements FaceclawBleListener { } } + /** + * Connect + authenticate + prelude + settings read on one lens. Returns the + * settings ack protobuf, an unsolicited settings push that carried firmware + * versions, or null when the lens never answered the read. Throws on + * connect or prelude failure; the caller wraps the fallback lens's attempt + * so its failure cannot mask the primary lens's outcome. + */ + private byte[] probeArm(String address, String label) throws InterruptedException { + emitState("connecting", label); + connectArm(address); + if (cancelled) { + return null; + } + + // Firmware 2.2.9 answers no queries until the security-auth exchange + // completes over an encrypted link; on a phone with no existing bond + // this is also what triggers SMP pairing (and its OS prompt), so it + // must come before the prelude and query. Soft: this probe also runs + // against the custom firmware, whose response to the exchange is not + // yet hardware-verified, so an unconfirmed auth falls through. + emitState("authenticating", label); + boolean authenticated = authenticate(address); + if (cancelled) { + return null; + } + + emitState("querying", label); + // Session prelude, then a settings/device-info read (both arms' + // versions and the CFW capability string ride back in one response). + if (writeAndAwaitAck(address, BleProtocol.PRELUDE_ACK_SID, BleProtocol.FLAG_REQUEST, + BleProtocol.PRELUDE_ACK_MAGIC, BleProtocol.PRELUDE_F5872_PAYLOAD, + ConnectionOptions.PRELUDE_TIMEOUT_MS) == null) { + throw new IllegalStateException("session prelude not acked (" + label + " lens)" + + (authenticated ? "" : "; authentication did not complete —" + + " if Android shows a Bluetooth pairing request, accept it and try again")); + } + + // Two attempts: the first read straight after a fresh pairing has been + // seen to go unanswered while a later one succeeds. + for (int attempt = 0; attempt < 2 && !cancelled; attempt++) { + int magic = allocMagic(); + byte[] ack = writeAndAwaitAck(address, BleProtocol.SID_UI_SETTING, BleProtocol.FLAG_REQUEST, + magic, BleProtocol.buildSettingsQuery(magic), QUERY_TIMEOUT_MS); + if (ack != null) { + return ack; + } + // A push with the firmware versions on the device's own magic is + // as good as the ack we asked for. + byte[] pushed = unsolicitedSettingsPb; + if (pushed != null) { + emitLog("using unsolicited settings push instead of the read ack (" + label + " lens)"); + return pushed; + } + emitLog("settings query attempt " + (attempt + 1) + " unanswered (" + label + " lens)"); + } + return null; + } + private boolean authenticate(String address) throws InterruptedException { int magic = allocMagic(); byte[] ack = writeAndAwaitAck(address, BleProtocol.SID_SECURITY_AUTH, BleProtocol.FLAG_SECURITY_AUTH, @@ -176,10 +227,13 @@ public class FaceclawDeviceInfoProbe implements FaceclawBleListener { synchronized (lock) { seq = nextSeq++ & 0xff; } + emitLog(String.format("tx %s sid=0x%02x flag=0x%02x magic=%d seq=0x%02x len=%d", + address, sid, flag, magic, seq, payload.length)); List frames = BleProtocol.framePb(payload, sid, flag, seq); boolean written = bleManager.writeFrames( address, BleProtocol.WRITE_CHAR_UUID, frames, ConnectionOptions.WRITE_TYPE, ConnectionOptions.WRITE_TIMEOUT_MS); if (!written) { + emitLog("tx write FAILED sid=0x" + Integer.toHexString(sid)); synchronized (lock) { awaitLatch = null; } @@ -199,8 +253,22 @@ public class FaceclawDeviceInfoProbe implements FaceclawBleListener { } BleProtocol.ParsedFrame frame = BleProtocol.parseFrame(data); if (!frame.ok) { + emitLog("rx " + address + " unparseable frame len=" + data.length + + " head=" + FaceclawFirmwareUtil.bytesToHex(java.util.Arrays.copyOf(data, Math.min(16, data.length)))); return; } + // Log every control frame while diagnosing 2.2.9: sid/flag/type/magic + // plus a payload prefix is enough to reconstruct what the lens said. + emitLog(String.format("rx %s sid=0x%02x flag=0x%02x type=%d magic=%d frag=%d/%d len=%d pb=%s", + address, frame.sid, frame.flag, frame.msgType, frame.msgSeq, + data.length > 5 ? data[5] & 0xff : 0, data.length > 4 ? data[4] & 0xff : 0, frame.pb.length, + FaceclawFirmwareUtil.bytesToHex(java.util.Arrays.copyOf(frame.pb, Math.min(40, frame.pb.length))))); + if (frame.sid == BleProtocol.SID_UI_SETTING + && BleProtocol.parseSettingsFirmwareInfo(frame.pb) != null) { + // Any settings frame carrying firmware versions answers the probe's + // question, whether or not it matches the magic we asked with. + unsolicitedSettingsPb = frame.pb; + } if (frame.flag == BleProtocol.FLAG_NOTIFY || frame.flag == BleProtocol.FLAG_NOTIFY_ALT) { return; // async event, not an ack } diff --git a/App_Resources/Android/src/main/res/drawable-hdpi/background.png b/App_Resources/Android/src/main/res/drawable-hdpi/background.png deleted file mode 100644 index bbefbf42..00000000 Binary files a/App_Resources/Android/src/main/res/drawable-hdpi/background.png and /dev/null differ diff --git a/App_Resources/Android/src/main/res/drawable-hdpi/logo.png b/App_Resources/Android/src/main/res/drawable-hdpi/logo.png index e788deb3..9a212517 100644 Binary files a/App_Resources/Android/src/main/res/drawable-hdpi/logo.png and b/App_Resources/Android/src/main/res/drawable-hdpi/logo.png differ diff --git a/App_Resources/Android/src/main/res/drawable-ldpi/background.png b/App_Resources/Android/src/main/res/drawable-ldpi/background.png deleted file mode 100644 index f6a08eea..00000000 Binary files a/App_Resources/Android/src/main/res/drawable-ldpi/background.png and /dev/null differ diff --git a/App_Resources/Android/src/main/res/drawable-ldpi/logo.png b/App_Resources/Android/src/main/res/drawable-ldpi/logo.png index e4cac1ad..10758abe 100644 Binary files a/App_Resources/Android/src/main/res/drawable-ldpi/logo.png and b/App_Resources/Android/src/main/res/drawable-ldpi/logo.png differ diff --git a/App_Resources/Android/src/main/res/drawable-mdpi/background.png b/App_Resources/Android/src/main/res/drawable-mdpi/background.png deleted file mode 100644 index 0c90f0f7..00000000 Binary files a/App_Resources/Android/src/main/res/drawable-mdpi/background.png and /dev/null differ diff --git a/App_Resources/Android/src/main/res/drawable-mdpi/logo.png b/App_Resources/Android/src/main/res/drawable-mdpi/logo.png index ce3c3a4b..0f4c7204 100644 Binary files a/App_Resources/Android/src/main/res/drawable-mdpi/logo.png and b/App_Resources/Android/src/main/res/drawable-mdpi/logo.png differ diff --git a/App_Resources/Android/src/main/res/drawable-nodpi/splash_screen.xml b/App_Resources/Android/src/main/res/drawable-nodpi/splash_screen.xml index ada77f92..a0acfca1 100644 --- a/App_Resources/Android/src/main/res/drawable-nodpi/splash_screen.xml +++ b/App_Resources/Android/src/main/res/drawable-nodpi/splash_screen.xml @@ -1,8 +1,8 @@ - + - \ No newline at end of file + diff --git a/App_Resources/Android/src/main/res/drawable-xhdpi/background.png b/App_Resources/Android/src/main/res/drawable-xhdpi/background.png deleted file mode 100644 index 3541570c..00000000 Binary files a/App_Resources/Android/src/main/res/drawable-xhdpi/background.png and /dev/null differ diff --git a/App_Resources/Android/src/main/res/drawable-xhdpi/logo.png b/App_Resources/Android/src/main/res/drawable-xhdpi/logo.png index 88267df0..a44364f4 100644 Binary files a/App_Resources/Android/src/main/res/drawable-xhdpi/logo.png and b/App_Resources/Android/src/main/res/drawable-xhdpi/logo.png differ diff --git a/App_Resources/Android/src/main/res/drawable-xxhdpi/background.png b/App_Resources/Android/src/main/res/drawable-xxhdpi/background.png deleted file mode 100644 index abb0fc70..00000000 Binary files a/App_Resources/Android/src/main/res/drawable-xxhdpi/background.png and /dev/null differ diff --git a/App_Resources/Android/src/main/res/drawable-xxhdpi/logo.png b/App_Resources/Android/src/main/res/drawable-xxhdpi/logo.png index 55800c9a..32c4f53f 100644 Binary files a/App_Resources/Android/src/main/res/drawable-xxhdpi/logo.png and b/App_Resources/Android/src/main/res/drawable-xxhdpi/logo.png differ diff --git a/App_Resources/Android/src/main/res/drawable-xxxhdpi/background.png b/App_Resources/Android/src/main/res/drawable-xxxhdpi/background.png deleted file mode 100644 index 10897752..00000000 Binary files a/App_Resources/Android/src/main/res/drawable-xxxhdpi/background.png and /dev/null differ diff --git a/App_Resources/Android/src/main/res/drawable-xxxhdpi/logo.png b/App_Resources/Android/src/main/res/drawable-xxxhdpi/logo.png index 0703f90f..bdf0bb04 100644 Binary files a/App_Resources/Android/src/main/res/drawable-xxxhdpi/logo.png and b/App_Resources/Android/src/main/res/drawable-xxxhdpi/logo.png differ diff --git a/app/app.css b/app/app.css index fc0bdb32..365b6da7 100644 --- a/app/app.css +++ b/app/app.css @@ -29,6 +29,12 @@ Button.-primary { font-size: 18; } +/* Body/explanatory text in the onboarding flow; the theme default is too + * small to comfortably read paragraphs of legalese, especially on tablets. */ +.body-text { + font-size: 18; +} + /* * Stands in for the lens preview when showing it would be misleading (silent * mode, or a disconnect explained by a flat battery). Sized by the view model diff --git a/app/images/faceclaw-logo.png b/app/images/faceclaw-logo.png new file mode 100644 index 00000000..5356a4e8 Binary files /dev/null and b/app/images/faceclaw-logo.png differ diff --git a/app/native/device-info-probe.ts b/app/native/device-info-probe.ts index c5ac9ac3..dec0ab0f 100644 --- a/app/native/device-info-probe.ts +++ b/app/native/device-info-probe.ts @@ -25,11 +25,11 @@ export class DeviceInfoProbe { private resolveFn: ((info: DeviceInfo) => void) | null = null; private rejectFn: ((error: Error) => void) | null = null; - constructor(rightAddress: string) { + constructor(rightAddress: string, leftAddress = "") { const context = Utils.android.getApplicationContext(); if (!context) throw new Error("Android application context unavailable"); - this.probe = new com.faceclaw.app.FaceclawDeviceInfoProbe(context, rightAddress); + this.probe = new com.faceclaw.app.FaceclawDeviceInfoProbe(context, rightAddress, leftAddress); this.listenerProxy = new com.faceclaw.app.FaceclawDeviceInfoProbeListener({ onLog: (line: string) => this.emit(this.logListeners, String(line)), onState: (state: string, detail: string) => diff --git a/app/phone-ui/config-page.xml b/app/phone-ui/config-page.xml index 410fda3d..366c17b6 100644 --- a/app/phone-ui/config-page.xml +++ b/app/phone-ui/config-page.xml @@ -2,7 +2,7 @@ -