Switch from capability strings to numeric versioning for firmwares

This commit is contained in:
James Babcock committed 2026-09-11 00:22:36 -07:00
1 parent a57b3b2cbc
commit b0cf1e4f67
19 files changed
+293 -236

No files matched your search

@@ -77,7 +77,6 @@ public class FaceclawBleCommunicator implements FaceclawBleListener, Runnable {
new java.util.concurrent.CopyOnWriteArrayList<>();
private final java.util.List<FaceclawMicStatusListener> micStatusListeners =
new java.util.concurrent.CopyOnWriteArrayList<>();
private volatile String lastFirmwareCapabilities = "";
private volatile Thread workerThread;
private volatile boolean running;
private volatile boolean userDisconnectRequested;
@@ -130,7 +129,14 @@ public class FaceclawBleCommunicator implements FaceclawBleListener, Runnable {
private int faceclawFramebufferControlGeneration;
private int faceclawFramebufferControlSentCount;
private int faceclawWakePendingNonce = -1;
private boolean cfwCleanupSupported;
/**
* The last firmware-info read said the glasses run Faceclaw's custom
* firmware. Gates the private modes (cleanup, texture cache, ...) so stock
* or third-party firmware never sees them; the TS side checks the actual
* revision and disconnects on a mismatch, so no per-feature gating is
* needed here.
*/
private boolean customFirmwareDetected;
private boolean cfwCleanupDelivered;
private int lastCfwCleanupAckMagic;
@@ -260,9 +266,6 @@ public class FaceclawBleCommunicator implements FaceclawBleListener, Runnable {
// firmware frees the cache with the fb lease, and after any resync the
// cheap safe assumption is an empty cache (glyphs re-upload lazily).
private final TextureCacheState textureCache = new TextureCacheState();
private boolean textureCacheSupported;
private boolean textureImagesSupported;
private boolean fwTextSupported;
private final ArrayDeque<OutboundMessage> pendingMessages = new ArrayDeque<>();
private final ArrayDeque<OutboundMessage> inFlightMessages = new ArrayDeque<>();
@@ -819,11 +822,6 @@ public class FaceclawBleCommunicator implements FaceclawBleListener, Runnable {
}
}
/** The CFW capability token string from the last firmware-info read ("" before one arrives). */
public String getFirmwareCapabilities() {
return lastFirmwareCapabilities;
}
public void addAmbientLightListener(FaceclawAmbientLightListener listener) {
if (listener != null) {
ambientLightListeners.add(listener);
@@ -1327,7 +1325,7 @@ public class FaceclawBleCommunicator implements FaceclawBleListener, Runnable {
if (cfwCleanupDelivered) {
return true;
}
if (!cfwCleanupSupported || !running || !sessionReady
if (!customFirmwareDetected || !running || !sessionReady
|| shutdownRequested || !fixedLayoutCreated) {
logLine("skip CFW cleanup; mode 11 unavailable or image path not ready");
return false;
@@ -1960,7 +1958,7 @@ public class FaceclawBleCommunicator implements FaceclawBleListener, Runnable {
logLine("session ready");
synchronized (lock) {
// Query settings promptly on the first session so firmware
// version/capabilities (and battery) arrive without waiting for
// version/extension (and battery) arrive without waiting for
// the input-quiet battery poll. The settings response doubles as
// the firmware-compatibility check surfaced during onboarding.
if (!firmwareInfoQueried) {
@@ -2849,7 +2847,7 @@ public class FaceclawBleCommunicator implements FaceclawBleListener, Runnable {
// ink out of the baked deltas. Uploads (mode 12) ride ahead of the
// image message on the ordered transport. Falls through to the plain
// paths whenever the planner has nothing to draw.
if (textureCacheSupported && connectionOptions.TEXTURE_CACHE_FRAMES
if (customFirmwareDetected && connectionOptions.TEXTURE_CACHE_FRAMES
&& draws != null && draws.length > 0 && packed.length > 0) {
byte[] deltaBase = (connectionOptions.INCREMENTAL_FRAMES && lastEnqueuedPacked.length > 0
&& lastEnqueuedWidth == width && lastEnqueuedHeight == height)
@@ -2858,8 +2856,7 @@ public class FaceclawBleCommunicator implements FaceclawBleListener, Runnable {
TexturePlanner.Result tex = TexturePlanner.plan(
deltaBase, packed, width, height, draws, textureCache,
nextImageFrameId,
connectionOptions.MULTI_RECT_FRAMES, ConnectionOptions.MULTI_RECT_MAX_RECTS,
textureImagesSupported, fwTextSupported);
connectionOptions.MULTI_RECT_FRAMES, ConnectionOptions.MULTI_RECT_MAX_RECTS);
if (tex != null) {
nextImageFrameId = tex.nextFid;
for (byte[] upload : tex.uploads) {
@@ -3078,12 +3075,7 @@ public class FaceclawBleCommunicator implements FaceclawBleListener, Runnable {
}
BleProtocol.FirmwareInfo firmwareInfo = BleProtocol.parseSettingsFirmwareInfo(message.ackPayload);
if (firmwareInfo != null) {
lastFirmwareCapabilities = firmwareInfo.capabilities == null ? "" : firmwareInfo.capabilities;
cfwCleanupSupported = hasCapability(firmwareInfo.capabilities, "cleanup11");
textureCacheSupported = hasCapability(firmwareInfo.capabilities, "texcache12")
&& hasCapability(firmwareInfo.capabilities, "texstr14");
textureImagesSupported = hasCapability(firmwareInfo.capabilities, "teximg13");
fwTextSupported = hasCapability(firmwareInfo.capabilities, "font15");
customFirmwareDetected = firmwareInfo.isFaceclawFirmware();
emitFirmwareInfo(firmwareInfo);
}
};
@@ -3685,14 +3677,6 @@ public class FaceclawBleCommunicator implements FaceclawBleListener, Runnable {
// the very cause of the session teardown that got us here.
}
private static boolean hasCapability(String capabilities, String token) {
if (capabilities == null || token == null || token.isEmpty()) return false;
for (String capability : capabilities.trim().split("\\s+")) {
if (token.equals(capability)) return true;
}
return false;
}
private void emitRingEvent(String kind, String containerName, int eventType, int eventSource, int systemExitReasonCode, int frameId) {
final FaceclawBleCommunicatorListener current = listener;
if (current == null) {
@@ -3839,7 +3823,7 @@ public class FaceclawBleCommunicator implements FaceclawBleListener, Runnable {
}
mainHandler.post(() -> {
try {
current.onFirmwareInfo(info.leftVersion, info.rightVersion, info.capabilities);
current.onFirmwareInfo(info.leftVersion, info.rightVersion, info.extension);
} catch (Throwable t) {
Log.w(TAG, "listener onFirmwareInfo failed", t);
}
@@ -11,5 +11,5 @@ public interface FaceclawBleCommunicatorListener {
void onEvenAppConflict(String message);
void onFrameMetrics(int paintMs, int transmitMs, int tileCount);
void onFrameFinished(int frameId, String outcome);
void onFirmwareInfo(String leftVersion, String rightVersion, String capabilities);
void onFirmwareInfo(String leftVersion, String rightVersion, String extension);
}
@@ -12,8 +12,8 @@ import java.util.concurrent.TimeUnit;
/**
* Connects to the glasses (stock-firmware compatible), reads the device-info /
* settings response, and reports the firmware versions plus the CFW capability
* string (empty on stock firmware). Used by onboarding to decide whether to
* settings response, and reports the firmware versions plus the firmware-
* extension string (empty on stock firmware). Used by onboarding to decide whether to
* flash. Reuses FaceclawBleManager + BleProtocol; owns its own connection and
* runs on a single worker thread. Shows nothing on the lens.
*/
@@ -119,9 +119,9 @@ public class FaceclawDeviceInfoProbe implements FaceclawBleListener {
BleProtocol.FirmwareInfo info = BleProtocol.parseSettingsFirmwareInfo(ack);
String left = info == null ? "" : info.leftVersion;
String right = info == null ? "" : info.rightVersion;
String caps = info == null ? "" : info.capabilities;
emitLog("device-info: L=" + left + " R=" + right + " caps=[" + caps + "]");
emitResult(left, right, caps);
String extension = info == null ? "" : info.extension;
emitLog("device-info: L=" + left + " R=" + right + " ext=[" + extension + "]");
emitResult(left, right, extension);
} catch (Exception e) {
String message = cancelled ? "Cancelled." : (e.getMessage() == null ? e.toString() : e.getMessage());
emitError(message);
@@ -161,7 +161,7 @@ public class FaceclawDeviceInfoProbe implements FaceclawBleListener {
emitState("querying", label);
// Session prelude, then a settings/device-info read (both arms'
// versions and the CFW capability string ride back in one response).
// versions and the firmware-extension 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) {
@@ -329,11 +329,11 @@ public class FaceclawDeviceInfoProbe implements FaceclawBleListener {
});
}
private void emitResult(String left, String right, String caps) {
private void emitResult(String left, String right, String extension) {
mainHandler.post(() -> {
FaceclawDeviceInfoProbeListener current = listener;
if (current != null) {
current.onResult(left, right, caps);
current.onResult(left, right, extension);
}
});
}
@@ -7,8 +7,8 @@ public interface FaceclawDeviceInfoProbeListener {
/** Lifecycle: connecting, querying. */
void onState(String state, String detail);
/** Terminal success: firmware versions and the CFW capability string (may be empty). */
void onResult(String leftVersion, String rightVersion, String capabilities);
/** Terminal success: firmware versions and the firmware-extension string (empty on stock). */
void onResult(String leftVersion, String rightVersion, String extension);
/** Terminal failure (couldn't connect or read the version). */
void onError(String message);
@@ -50,16 +50,15 @@ public class BleProtocol {
public static final int FACECLAW_WAKE_CONTROL_FIELD = 101;
public static final int FACECLAW_WAKE_EVENT_FIELD = 102;
/**
* CFW mic_control (EVENCFW/16, caps tokens micctl/micmc/micraw): host
* writes an ['M','C',ver,op,...] record as settings field 103; each temple
* CFW mic_control: host writes an ['M','C',ver,op,...] record as settings
* field 103; each temple
* reports a 21-byte ['M','C',ver,...] status as field 104, both appended
* to settings read responses and as standalone commandId=3 pushes.
*/
public static final int FACECLAW_MIC_CONTROL_FIELD = 103;
public static final int FACECLAW_MIC_STATUS_FIELD = 104;
/**
* CFW als_sensor (EVENCFW/18, caps token als16): ambient-light reports on
* settings-channel field 105, 24-byte ['A','L',ver,reason,...] records from
* CFW als_sensor: ambient-light reports on settings-channel field 105, 24-byte ['A','L',ver,reason,...] records from
* the master temple (decoded in app/native/ambient-light.ts).
*/
public static final int FACECLAW_ALS_REPORT_FIELD = 105;
@@ -475,7 +474,7 @@ public class BleProtocol {
return body;
}
/** Field 106: RB/version 1/flags/percentage, from CFW ringbat17. */
/** Field 106: RB/version 1/flags/percentage, from the CFW ring-battery cache. */
public static RingBatterySnapshot parseRingBattery(byte[] pb) {
if (pb == null) return null;
byte[] body = readFieldBytes(stripTrailingCrc(pb), 106);
@@ -585,11 +584,14 @@ public class BleProtocol {
}
/**
* Firmware versions and the CFW capability advertisement from a settings
* Firmware versions and the firmware-extension string from a settings
* READ ack. Versions are fields 5/6 of the deviceReceiveRequestFromApp
* submessage (field 4); the custom firmware additionally appends top-level
* field 100, a string like "EVENCFW/6 img576 img640 ... directfb fbguard", which
* stock firmware never sends. Returns null when the ack carries none of it.
* submessage (field 4); Faceclaw's custom firmware additionally appends
* top-level field 100 with its revision ("Faceclaw/<n>"; older builds sent
* "EVENCFW/<ver> <tokens>"), which stock firmware never sends. Returns null
* when the ack carries none of it. Compatibility is judged on the TS side
* (app/g2/firmware-compat.ts); Java only needs to know whether the firmware
* is ours at all.
*/
public static FirmwareInfo parseSettingsFirmwareInfo(byte[] pb) {
byte[] root = stripTrailingCrc(pb);
@@ -599,11 +601,11 @@ public class BleProtocol {
}
String leftVersion = readStringFieldValue(request, 5);
String rightVersion = readStringFieldValue(request, 6);
String capabilities = readStringFieldValue(root, 100);
if (leftVersion.isEmpty() && rightVersion.isEmpty() && capabilities.isEmpty()) {
String extension = readStringFieldValue(root, 100);
if (leftVersion.isEmpty() && rightVersion.isEmpty() && extension.isEmpty()) {
return null;
}
return new FirmwareInfo(leftVersion, rightVersion, capabilities);
return new FirmwareInfo(leftVersion, rightVersion, extension);
}
public static byte[] wrapEvenHub(int cmd, int magic, int innerFieldNumber, byte[] inner) {
@@ -1120,14 +1122,28 @@ public class BleProtocol {
}
public static final class FirmwareInfo {
/** Prefix of the firmware-extension string on Faceclaw's custom firmware. */
public static final String FACECLAW_EXTENSION_PREFIX = "Faceclaw/";
final String leftVersion;
final String rightVersion;
final String capabilities;
/** Raw field-100 string ("" on stock firmware). */
final String extension;
FirmwareInfo(String leftVersion, String rightVersion, String capabilities) {
FirmwareInfo(String leftVersion, String rightVersion, String extension) {
this.leftVersion = leftVersion;
this.rightVersion = rightVersion;
this.capabilities = capabilities;
this.extension = extension == null ? "" : extension;
}
/**
* True when the glasses run Faceclaw's custom firmware (any revision).
* Whether the revision is the one this app needs is decided on the TS
* side, which disconnects on a mismatch; this only guards the private
* modes against stock or third-party firmware in the meantime.
*/
public boolean isFaceclawFirmware() {
return extension.trim().startsWith(FACECLAW_EXTENSION_PREFIX);
}
}
}
@@ -118,15 +118,14 @@ public final class TexturePlanner {
/**
* Plan a cached-draw update. previous is the delta base (the frame the
* shadow currently holds), or null/mismatched for a full-frame keyframe.
* allowImages requires the teximg13 capability; allowFwText requires
* font15. Returns null when the plain paths should run instead (no
* replayable draws, or identical frames).
* Returns null when the plain paths should run instead (no replayable
* draws, or identical frames).
*/
public static Result plan(
byte[] previous, byte[] next, int width, int height,
SurfaceCompositor.ScreenDraw[] draws,
TextureCacheState cache, int fidStart,
boolean allowMultiRect, int maxRects, boolean allowImages, boolean allowFwText) {
boolean allowMultiRect, int maxRects) {
if (next == null || draws == null || draws.length == 0 || width <= 0 || height <= 0) {
return null;
}
@@ -171,14 +170,12 @@ public final class TexturePlanner {
List<FwPunch> fwPunches = new ArrayList<>();
int fwGlyphCount = 0;
int fwBaked = 0;
if (allowFwText) {
for (SurfaceCompositor.ScreenDraw draw : draws) {
if (draw.kind != SurfaceCompositor.ScreenDraw.KIND_FWTEXT) continue;
fwBaked += planFwRun(draw, rects, next, stride, width, height, fwSubs, fwPunches);
}
fwGlyphCount = fwPunches.size();
bakedCandidates += fwBaked;
for (SurfaceCompositor.ScreenDraw draw : draws) {
if (draw.kind != SurfaceCompositor.ScreenDraw.KIND_FWTEXT) continue;
fwBaked += planFwRun(draw, rects, next, stride, width, height, fwSubs, fwPunches);
}
fwGlyphCount = fwPunches.size();
bakedCandidates += fwBaked;
for (SurfaceCompositor.ScreenDraw draw : draws) {
if (draw.kind == SurfaceCompositor.ScreenDraw.KIND_GLYPH) {
GlyphAtlas.Glyph atlas = GlyphAtlas.get(draw.fontId, draw.encoding);
@@ -204,7 +201,6 @@ public final class TexturePlanner {
}
selected.add(new Selected(draw, atlas, null, gx, top));
} else {
if (!allowImages) continue; // firmware lacks teximg13: stays baked
ImageAtlas.Entry atlas = ImageAtlas.get(draw.imageId);
if (atlas == null) continue;
if (!intersectsAny(rects, draw.x, draw.y, atlas.width, atlas.height)) {
+1 -2
View File
@@ -113,8 +113,7 @@ export class LightSensorDemoLayer implements Layer {
if (!report) {
const message = this.enabled ? "Waiting for a report…" : "Paused (page not visible).";
image.drawText(small, 22, 44, message, 190);
image.drawText(small, 22, 66, "Needs custom firmware with the als16", 120);
image.drawText(small, 22, 82, "extension (EVENCFW/18 or newer).", 120);
image.drawText(small, 22, 66, "Needs Faceclaw's custom firmware.", 120);
image.drawText(small, 20, height - 16, `${GESTURE_DOUBLE_CLICK} back`, 110);
return image;
}
+7 -19
View File
@@ -20,8 +20,9 @@ declare const com: any;
* Host-side controller for the CFW mic_control array: sends the same config
* to both temples (each temple is its own endpoint and its own 2-mic array),
* tracks per-temple field-104 status, and keeps the 90 s streaming lease
* renewed while capture is armed. Degrades cleanly on firmware without the
* feature: micControlSupported() is false and apply() refuses to arm.
* renewed while capture is armed. The feature is part of the required
* firmware revision, so the only gate is the developer setting:
* micControlSupported() is false and apply() refuses to arm when it is off.
*/
const CONFIG_SETTING_KEY = "microphones.array-config";
@@ -38,26 +39,13 @@ function activeCommunicator(): any {
}
}
/** True when the connected glasses advertise the CFW mic_control feature. */
export function micControlAdvertised(): boolean {
const communicator = activeCommunicator();
if (!communicator) return false;
try {
const caps = String(communicator.getFirmwareCapabilities() ?? "");
return caps.trim().split(/\s+/).includes("micctl");
} catch {
return false;
}
}
/**
* True when the connected glasses advertise the CFW mic_control feature AND
* the "Use microphone control" developer setting is on. With the setting off
* (the default), Faceclaw behaves exactly as it would on firmware without the
* micctl caps token.
* True when the "Use microphone control" developer setting is on. With the
* setting off, Faceclaw behaves exactly as it would on firmware without the
* mic-control channel (one mixed stream).
*/
export function micControlSupported(): boolean {
return useMicControlSetting.get() && micControlAdvertised();
return useMicControlSetting.get();
}
export function loadMicConfig(): MicConfig {
+2 -3
View File
@@ -1,7 +1,6 @@
/**
* Wire codec for the CFW mic_control feature (g2flash `microphone-configurations`
* branch, EVENCFW/16, caps tokens micctl/micmc/micraw). Mirrors the contract
* header in g2flash patches/mic_control.c:
* Wire codec for the CFW mic_control feature. Mirrors the contract header in
* g2flash patches/mic_control.c:
*
* field 103 (write) ['M','C', ver, op, <9 config bytes for CONFIGURE>]
* field 104 (read) 21-byte ['M','C', ver, active, src, chanMask, codec,
+3 -5
View File
@@ -23,7 +23,7 @@ import { isAsrModelReady, startAsrModelDownload, asrModelState } from "../../nat
import { CaptionsLayer } from "./captions-layer";
import { LevelsLayer } from "./levels-layer";
import { RadarLayer } from "./radar-layer";
import { loadMicConfig, micArrayController, micControlAdvertised, micControlSupported, saveMicConfig } from "./mic-control";
import { loadMicConfig, micArrayController, micControlSupported, saveMicConfig } from "./mic-control";
import { isMicModelReady, micModelState, startMicModelDownload } from "./mic-models";
import { micChannelLabel, type MicChannelKey, type MicConfig } from "./mic-protocol";
import { micSession } from "./mic-session";
@@ -166,7 +166,7 @@ function micSetupMenu(): MenuLayer {
{
label: "Array status",
description:
"Per-temple mic-control status. Requires the mic-control custom firmware (caps token micctl) and the Use microphone control developer setting.",
"Per-temple mic-control status. Requires the Use microphone control developer setting.",
onSelect: (ctx) => {
micArrayController.query();
const { left, right } = micArrayController.getStatuses();
@@ -186,9 +186,7 @@ function micSetupMenu(): MenuLayer {
"Array status",
micControlSupported()
? `${describe("Left", left)}\n${describe("Right", right)}\n${consistency}`
: micControlAdvertised()
? "Mic-control is available but disabled. Turn on Settings > Developer > Use microphone control to control the four mics individually."
: "The connected firmware does not advertise mic-control. Flash the microphone-configurations CFW build to control the four mics individually; on stock firmware the glasses stream one mixed channel with a firmware-computed direction of arrival.",
: "Mic-control is disabled. Turn on Settings > Developer > Use microphone control to control the four mics individually; while it is off the glasses stream one mixed channel with a firmware-computed direction of arrival.",
),
);
},
+15 -26
View File
@@ -16,7 +16,7 @@ import { ALL_NOTIFICATIONS, onAndroidNotificationPosted, readActiveNotifications
import { shouldShowNotificationOnGlasses } from "../native/notification-sources";
import { openEvenAppSettings, readEvenAppNotificationState } from "../native/even-app-conflict";
import { grayImageToPreviewSource } from "../native/gray-image-preview";
import { firmwareIncompatibilityMessage } from "./firmware-compat";
import { firmwareIncompatibilityMessage, hasCompatibleFirmware } from "./firmware-compat";
import { hasExtractedEvenHubFonts } from "./firmware-builder";
import { resumeAutoReconnect, suppressAutoReconnect } from "./reconnect-policy";
import { WearRemote, type WearRemoteInputKind } from "./wear-remote";
@@ -253,9 +253,9 @@ class DashboardController {
private evenHubSuspendTimer: ReturnType<typeof setTimeout> | null = null;
private evenHubSessionSuspended = false;
private evenHubResumePromise: Promise<boolean> | null = null;
private faceclawWakeLeaseSupported = false;
/** Faceclaw's firmware at the required revision reported in; its extensions can be used. */
private customFirmwareConfirmed = false;
private faceclawWakeLeaseState: boolean | null = null;
private wearNotifySupported = false;
private glassesWorn: boolean | null = null;
private phoneLocked = false;
private glassesLocked = false;
@@ -631,7 +631,7 @@ class DashboardController {
const communicator = this.communicator;
if (
!lockScreenEnabledSetting.get() ||
!this.wearNotifySupported ||
!this.customFirmwareConfirmed ||
this.phase !== "connected" ||
!communicator
) {
@@ -736,7 +736,7 @@ class DashboardController {
// foreground app when Faceclaw handles the glasses wakeword. Without the
// latter, Even AI displaces EvenHub before our first wake frame can ACK.
return (
this.faceclawWakeLeaseSupported &&
this.customFirmwareConfirmed &&
(suspendEvenHubWhenScreenOffSetting.get() || wakeWordActionSetting.get() !== "off")
);
}
@@ -816,7 +816,7 @@ class DashboardController {
}
void (async () => {
if (this.faceclawWakeLeaseSupported) {
if (this.customFirmwareConfirmed) {
// Refresh immediately before teardown so the first suspended wake
// cannot race an old lease's expiry.
const leaseReady = await this.syncFaceclawWakeLease(communicator, true);
@@ -1291,9 +1291,8 @@ class DashboardController {
);
let communicator: FaceclawCommunicatorBridge | null = null;
this.faceclawWakeLeaseSupported = false;
this.customFirmwareConfirmed = false;
this.faceclawWakeLeaseState = null;
this.wearNotifySupported = false;
this.lockSurfaceConfigured = false;
this.evenHubResumePromise = null;
this.connectRunning = true;
@@ -1441,26 +1440,18 @@ class DashboardController {
this.offFirmwareInfo = communicator.onFirmwareInfo((info) => {
this.appendLog(
`firmware: L=${info.leftVersion || "?"} R=${info.rightVersion || "?"}` +
(info.capabilities ? ` caps="${info.capabilities}"` : " (no CFW capability string)"),
(info.extension ? ` ext="${info.extension}"` : " (no firmware extension string)"),
);
const warning = firmwareIncompatibilityMessage(info) ?? "";
const wakeLeaseSupported = info.capabilities
.trim()
.split(/\s+/)
.includes("wakelease");
const wearNotifySupported = info.capabilities
.trim()
.split(/\s+/)
.includes("wearnotify");
if (wakeLeaseSupported !== this.faceclawWakeLeaseSupported) {
this.faceclawWakeLeaseSupported = wakeLeaseSupported;
// The firmware contract is all-or-nothing: a compatible revision has
// every extension (wake lease, wear notifications, ...) we use.
const customFirmwareConfirmed = !warning && hasCompatibleFirmware(info);
if (customFirmwareConfirmed !== this.customFirmwareConfirmed) {
this.customFirmwareConfirmed = customFirmwareConfirmed;
this.faceclawWakeLeaseState = null;
void this.syncFaceclawWakeLease().catch((error) => {
this.appendLog(`wake takeover lease sync failed: ${this.formatError(error)}`);
});
}
if (wearNotifySupported !== this.wearNotifySupported) {
this.wearNotifySupported = wearNotifySupported;
this.ensureWearStateTracking();
}
if (warning !== this.firmwareWarningMessage) {
@@ -1558,8 +1549,7 @@ class DashboardController {
}
this.communicator = null;
this.lockSurfaceConfigured = false;
this.wearNotifySupported = false;
this.faceclawWakeLeaseSupported = false;
this.customFirmwareConfirmed = false;
this.faceclawWakeLeaseState = null;
this.evenHubResumePromise = null;
this.clearDashboardTimer();
@@ -1751,9 +1741,8 @@ class DashboardController {
await communicator?.close().catch(() => {});
} finally {
stopForegroundNotification();
this.faceclawWakeLeaseSupported = false;
this.customFirmwareConfirmed = false;
this.faceclawWakeLeaseState = null;
this.wearNotifySupported = false;
this.setPhase("disconnected");
this.setStatus("Disconnected.");
this.appendLog("Disconnected from the glasses.");
+135 -71
View File
@@ -1,14 +1,35 @@
/**
* Compatibility check for the glasses firmware. Faceclaw requires the custom
* firmware: version >= 2.2.4.34 with the required direct-framebuffer and wear
* notification tokens in the CFW capability string. Stock firmware sends no
* capability string at all.
* Compatibility check for the glasses firmware. Faceclaw requires its own
* custom firmware at a specific revision.
*
* The firmware identifies itself through one extra string in the sid-0x09
* settings READ response (protobuf field 100, the "firmware extension" slot):
*
* "Faceclaw/<n>" -- Faceclaw's custom firmware, revision <n>. The revision
* goes up whenever the firmware contract changes and is
* not kept in sync with Faceclaw app versions.
* "EVENCFW/..." -- older Faceclaw firmware, from before revisions existed
* (it advertised feature tokens instead). Always outdated.
* (empty) -- stock firmware; it never sends the field.
* anything else -- custom firmware from a different source.
*
* Because an exact revision is required, nothing else in the app gates on the
* extension string: once the firmware is compatible, every feature it provides
* is assumed present.
*/
import { type FirmwareInfo } from "../native/faceclaw-communicator";
export type FirmwareInfo = {
leftVersion: string;
rightVersion: string;
/** Raw contents of the firmware-extension slot ("" on stock firmware). */
extension: string;
};
const MIN_FIRMWARE_VERSION = [2, 2, 4, 34];
const REQUIRED_FIRMWARE_EXTENSIONS = ["img640", "fbguard", "wearnotify"] as const;
/** The Faceclaw firmware revision this build of the app needs. */
export const REQUIRED_FACECLAW_FIRMWARE_VERSION = 1;
const FACECLAW_PREFIX = "Faceclaw/";
const LEGACY_PREFIX = "EVENCFW";
// The stock firmware release Faceclaw's custom image is built from. Stock at or
// below this can be flashed with our patched image; a newer stock version is
@@ -18,6 +39,42 @@ export const BASE_STOCK_VERSION_TEXT = BASE_STOCK_VERSION.join(".");
export const VALIDATED_STOCK_VERSION = [2, 2, 10, 10];
export const VALIDATED_STOCK_VERSION_TEXT = VALIDATED_STOCK_VERSION.join(".");
export type FirmwareExtension =
/** Nothing in the slot: stock firmware. */
| { kind: "none" }
/** Faceclaw's firmware at the given revision. */
| { kind: "faceclaw"; version: number }
/** Pre-revision Faceclaw firmware ("EVENCFW/<ver> <tokens>"). */
| { kind: "legacy-faceclaw"; text: string }
/** Custom firmware from some other project. */
| { kind: "other"; text: string };
export function parseFirmwareExtension(extension: string): FirmwareExtension {
const text = extension.trim();
if (!text) return { kind: "none" };
if (text.startsWith(FACECLAW_PREFIX)) {
const version = parseInt(text.slice(FACECLAW_PREFIX.length), 10);
if (Number.isFinite(version) && version >= 0) return { kind: "faceclaw", version };
return { kind: "other", text };
}
if (text.startsWith(LEGACY_PREFIX)) return { kind: "legacy-faceclaw", text };
return { kind: "other", text };
}
/** Short user-facing description of what the extension slot reported. */
export function describeFirmwareExtension(extension: FirmwareExtension): string {
switch (extension.kind) {
case "faceclaw":
return `Faceclaw firmware revision ${extension.version}`;
case "legacy-faceclaw":
return `an older Faceclaw firmware (reported "${extension.text}")`;
case "other":
return `custom firmware from a different source (reported "${extension.text}")`;
default:
return "stock firmware";
}
}
function parseDottedVersion(version: string): number[] {
return version
.trim()
@@ -38,66 +95,53 @@ function compareVersions(a: number[], b: number[]): number {
return 0;
}
/**
* True when the glasses run Faceclaw's firmware at the required revision or
* newer. (A newer revision is accepted: revisions only add to the contract.)
*/
export function hasCompatibleFirmware(info: FirmwareInfo): boolean {
const extension = parseFirmwareExtension(info.extension);
return extension.kind === "faceclaw" && extension.version >= REQUIRED_FACECLAW_FIRMWARE_VERSION;
}
/**
* Human-readable explanation of why this firmware cannot run Faceclaw, or
* null if it is compatible. Returns null when no version was reported at all
* null if it is compatible. Returns null when nothing was reported at all
* (no data is not evidence of incompatibility).
*/
export function firmwareIncompatibilityMessage(info: FirmwareInfo): string | null {
const reportedVersions = [info.leftVersion, info.rightVersion].filter((v) => v.trim().length > 0);
if (reportedVersions.length === 0) return null;
const extension = parseFirmwareExtension(info.extension);
if (reportedVersions.length === 0 && extension.kind === "none") return null;
const minVersionText = MIN_FIRMWARE_VERSION.join(".");
const versionsText = `L=${info.leftVersion || "unknown"} R=${info.rightVersion || "unknown"}`;
const required = `Faceclaw firmware revision ${REQUIRED_FACECLAW_FIRMWARE_VERSION}`;
if (reportedVersions.some((v) => compareVersions(parseDottedVersion(v), MIN_FIRMWARE_VERSION) < 0)) {
return (
`The glasses report firmware ${versionsText}, but Faceclaw requires the modified firmware, ` +
`version ${minVersionText} or newer. Displaying images will not work until the glasses firmware is updated.`
);
switch (extension.kind) {
case "faceclaw":
if (extension.version >= REQUIRED_FACECLAW_FIRMWARE_VERSION) return null;
return (
`The glasses run Faceclaw firmware revision ${extension.version} (base ${versionsText}), ` +
`but this version of Faceclaw requires revision ${REQUIRED_FACECLAW_FIRMWARE_VERSION}. ` +
"Install the updated custom firmware to continue."
);
case "legacy-faceclaw":
return (
`The glasses run an older version of Faceclaw's custom firmware (reported "${extension.text}", ` +
`base ${versionsText}). This version of Faceclaw requires ${required}. ` +
"Install the updated custom firmware to continue."
);
case "other":
return (
`The glasses run custom firmware from a different source (reported "${extension.text}", ` +
`base ${versionsText}). Faceclaw requires ${required}; installing it will replace the current firmware.`
);
default:
return (
`The glasses report stock firmware ${versionsText}. Faceclaw requires ${required}. ` +
"Displaying images will not work until the custom firmware is installed."
);
}
const tokens = info.capabilities.trim().split(/\s+/);
const missingExtensions = REQUIRED_FIRMWARE_EXTENSIONS.filter(
(extension) => !tokens.includes(extension),
);
if (missingExtensions.length) {
return (
`The glasses firmware (${versionsText}) does not advertise the required ` +
`${missingExtensions.map((extension) => `"${extension}"`).join(" and ")} extension` +
`${missingExtensions.length === 1 ? "" : "s"}` +
`${info.capabilities.trim() ? ` (reported: ${info.capabilities.trim()})` : ", which suggests stock firmware"}. ` +
`Faceclaw requires the modified firmware with the guarded 640x480 direct-framebuffer path and wear notifications.`
);
}
return null;
}
/** True when the glasses advertise every custom-firmware extension Faceclaw needs. */
export function hasCustomFirmware(info: FirmwareInfo): boolean {
const tokens = info.capabilities.trim().split(/\s+/);
return REQUIRED_FIRMWARE_EXTENSIONS.every((extension) => tokens.includes(extension));
}
/**
* True when the firmware advertises the optional mic-control extension: the
* private field-103/104 channel for per-temple multi-microphone capture that
* the Microphones app's 4-mic array mode and beamforming need. Absent on the
* stock single-mono-stream path, which still works (firmware-computed
* direction of arrival, one mixed channel).
*/
export function hasMicControl(info: FirmwareInfo): boolean {
return info.capabilities.trim().split(/\s+/).includes("micctl");
}
/**
* True when the firmware advertises the optional ambient-light extension:
* image-handler mode 16 (query / passive polling of the OPT3001 light sensor)
* with field-105 reports, used to drive a phone-side brightness policy.
*/
export function hasAmbientLightSensor(info: FirmwareInfo): boolean {
return info.capabilities.trim().split(/\s+/).includes("als16");
}
/** The higher of the two arms' reported versions, or "" if none reported. */
@@ -111,36 +155,56 @@ export function reportedFirmwareVersion(info: FirmwareInfo): string {
/**
* How the pre-flash firmware check should treat the connected glasses:
* - "custom": Faceclaw's firmware is already installed — nothing to flash.
* - "custom": Faceclaw's firmware at the required revision (or newer) is
* already installed — nothing to flash.
* - "older-faceclaw": Faceclaw's firmware at an older revision (including
* the pre-revision "EVENCFW" builds) — flash to update it.
* - "other-custom": custom firmware from a different source — flash to
* replace it.
* - "flashable-stock": stock firmware at or below the version we build from.
* - "newer-stock-validated": stock firmware newer than the version we build
* from, on which the downgrade has been tested successfully
* - "newer-stock-unvalidated": stock firmware newer than we recognize — flash only on override.
* - "unknown": no version could be read (treated as a probe/connection failure).
*/
export type OnboardingFirmwareKind = "custom" | "flashable-stock" | "newer-stock-validated" | "newer-stock-unvalidated" | "unknown";
export type OnboardingFirmwareKind =
| "custom"
| "older-faceclaw"
| "other-custom"
| "flashable-stock"
| "newer-stock-validated"
| "newer-stock-unvalidated"
| "unknown";
export function classifyOnboardingFirmware(info: FirmwareInfo): {
kind: OnboardingFirmwareKind;
version: string;
extension: FirmwareExtension;
} {
if (hasCustomFirmware(info)) {
return { kind: "custom", version: reportedFirmwareVersion(info) };
}
const extension = parseFirmwareExtension(info.extension);
const version = reportedFirmwareVersion(info);
switch (extension.kind) {
case "faceclaw":
return {
kind: extension.version >= REQUIRED_FACECLAW_FIRMWARE_VERSION ? "custom" : "older-faceclaw",
version,
extension,
};
case "legacy-faceclaw":
return { kind: "older-faceclaw", version, extension };
case "other":
return { kind: "other-custom", version, extension };
default:
break;
}
if (!version) {
return { kind: "unknown", version: "" };
return { kind: "unknown", version: "", extension };
}
if (compareVersions(parseDottedVersion(version), BASE_STOCK_VERSION) <= 0) {
return { kind: "flashable-stock", version };
return { kind: "flashable-stock", version, extension };
} else if (compareVersions(parseDottedVersion(version), VALIDATED_STOCK_VERSION) <= 0) {
return { kind: "newer-stock-validated", version };
return { kind: "newer-stock-validated", version, extension };
} else {
return { kind: "newer-stock-unvalidated", version };
return { kind: "newer-stock-unvalidated", version, extension };
}
}
/** Cached R1 battery reports in settings field 106 and query mode 17. */
export function hasRingBattery(info: FirmwareInfo): boolean {
return info.capabilities.trim().split(/\s+/).includes("ringbat17");
}
+11 -11
View File
@@ -19,7 +19,7 @@ export type FirmwarePatchSet = {
export const CFW_PATCH_SET: FirmwarePatchSet = {
"base": "g2_2.2.9.22.bin",
"baseSha256": "a03fbea9f68a9de6bc271daabb9f3a41c59053d1086622c76a4e990f829cc561",
"outputSha256": "c471d8bc63d61528dd7fc12154b17f6657d79a88aa0034e2b9f89eed38f3cea6",
"outputSha256": "d65a2930519e82a5ff72e7c6c852a25f2ed7651133fa95ccba5fbecdf76ef950",
"patches": [
{
"offset": 1363762,
@@ -108,19 +108,19 @@ export const CFW_PATCH_SET: FirmwarePatchSet = {
{
"offset": 831036,
"old": "1df057fc",
"new": "80f33df9",
"new": "80f333f9",
"desc": "bl gesture_press (Faceclaw lease gates event 9 vs stock UI event 8)"
},
{
"offset": 831042,
"old": "24f023f9",
"new": "80f3def9",
"new": "80f3d4f9",
"desc": "bl gesture_short_long (Faceclaw lease gates event 11 vs stock Menu path)"
},
{
"offset": 831800,
"old": "1df0d9fa",
"new": "7ff3c3ff",
"new": "7ff3b9ff",
"desc": "bl gesture_release (source-qualified event 10 vs stock UI event 0x4a)"
},
{
@@ -168,43 +168,43 @@ export const CFW_PATCH_SET: FirmwarePatchSet = {
{
"offset": 4476518,
"old": "",
"new": "02fb01f000e000bfb0b54ff2ac44c2f229040146206846f23f52c5f28802b2eb500f40f258304cf2e9124cf67e25c2f20000c0f24802caf2101518bf25609047002804bf691c2160b0bd00bf0846ffe7014640f258304cf20732c2f20000c0f24802104770b500284ed001684ef66a62ccf2ff02914218bf70bd90f8081190f8095146f6756c8d42c0f2510c2ad205eb8501014491f80d2191f80e4191f80ae191f80b3191f80c1142ea0424012c4ff0010298bf14466e1c054680f80961b9b164294eea032028bf6421012888bf024644f62060824228bf02460cf5e2731046984706e0002180f80811bde870406047e047d5f8040138b142f64d42c0f244022146bde87040104770bd00bf2de9f04f9db04ff2a84ac2f2290adaf800b058466ff39600b0f1005f40f07d81dbf800004ef66a67ccf2ff07b84240f074819bf82802002800f05d81dbf82442002c00f0588140f6b400c2f20000d0f8008004a802f0d4ffb8f1000f00f02382032045f24075cff68070a4f1600108f160026ff0bf03c0f2020500bf0e6ed41826664e6ec03366668e6eab42a666ce6ee6660e6f26674e6f66678e6fa667ce6fe667d1f88060c4f88060d1f88460c4f88460d1f88860c4f88860d1f88c60c4f88c60d1f89060c4f89060d1f89460c4f89460d1f89860c4f89860d1f89c60c4f89c60d1f8a060c4f8a060d1f8a460c4f8a460d1f8a860c4f8a860d1f8ac60c4f8ac60d1f8b060c4f8b060d1f8b460c4f8b460d1f8b860c4f8b860d1f8bc60c4f8bc6051f8c06fc4f8c0604e68c4f8c4608e68c4f8c860ce68c4f8cc600e69c4f8d0604e69c4f8d4608e69c4f8d860ce69c4f8dc600e6ac4f8e0604e6ac4f8e4608e6ac4f8e860ce6ac4f8ec600e6bc4f8f0604e6bc4f8f4608e6bc4f8f860ce6bc4f8fc600e6cc4f800614e6cc4f804618e6cc4f80861ce6cc4f80c610e6dc4f810614e6dc4f814618e6dc4f81861ce6dc4f81c617ff462afdaf800603040b0f1005f40f0b2803068b84240f0ae8096f8ce00002840f07a8196f8dc10002000298df8140000f0f28105a90a5c002a00f0c5810a185378002b00f083819378002b00f08181d378002b00f07f811379002b00f07d815379002b00f07b819379002b00f07981d379002b00f07781137a002b00f07581537a002b00f07381937a002b00f07181d37a002b00f06f81137b002b00f06d81537b002b00f06b81937b002b00f06981d37b002b00f06781137c002b00f06581537c002b00f06381937c002b00f06181d37c002b00f05f81137d002b00f05d81537d002b00f05b81937d002b00f05981d37d002b00f05781137e002b00f05581537e002b00f05381937e002b00f05181d37e002b00f04f81137f002b00f04d81537f002b00f04b81937f002b00f04981d27f002a00f04781203060287ff47baf66e19bf82a0270b1dbf82c0240b146f68051c2f207010968401a002800f3f48000208bf82a0240f6d100c0f247001db0bde8f04f00474ff4497005f0e5f8002800f0c7804ff6dc41cff6ff71002200bf4318433183f8242383f8252383f8262383f8272383f8282383f8292383f82a2383f82b2383f82c2383f82d2383f82e2383f82f2383f8302383f8312383f8322383f8332383f8342383f8352383f8362383f8372383f8382383f8392383f83a2383f83b2383f83c2383f83d2383f83e2383f83f2383f8402383f8412383f8422383f8432383f8442383f8452383f8462383f8472383f8482383f8492383f84a2383f84b2383f84c2383f84d2383f84e2383f84f2383f8502383f8512383f8522383f8532383f8542383f8552383f8562383f8572383f8582383f8592383f85a2383f85b2383f85c2383f85d2383f85e2383f85f2383f8602383f8612383f8622383f8632383f8642383f8652383f866237ff476af012180f8ce104ff0ff310760a0f8e010a0f8e210a0f8e410a0f8e610a0f8e810a0f8ea10a0f8ec10a0f8ee10a0f8f010a0f8f210a0f8f410a0f8f610a0f8f810a0f8fa10a0f8fc10a0f8fe1010e000208bf82802cbf824028bf82a0201208bf8290240f6d100c0f24700804715e00020caf8000000208bf82802cbf824024ff416304cf60361069005a8c0f24701cdf81480884701208bf82a0204a802f0b4fecbf8d4001db0bde8f08f01303ae0023038e0033036e0043034e0053032e0063030e007302ee008302ce009302ae00a3028e00b3026e00c3024e00d3022e00e3020e00f301ee010301ce011301ae0123018e0133016e0143014e0153012e0163010e017300ee018300ce019300ae01a3008e01b3006e01c3004e01d3002e01e3000e01f305f2821d84ff052020a541dd0014445225e284a7018d04f225d288a7014d052225c28ca7010d044225b280a710cd045225a284a7108d0522259288a7104d020225828ca7142f0168500208df87300012096f8dd10002900f0c280002105aa535c002b00f0a08057187b78002b5ed0bb78002b5dd0fb78002b5cd03b79002b5bd07b79002b5ad0bb79002b59d0fb79002b58d03b7a002b57d07b7a002b56d0bb7a002b55d0fb7a002b54d03b7b002b53d07b7b002b52d0bb7b002b51d0fb7b002b50d03b7c002b4fd07b7c002b4ed0bb7c002b4dd0fb7c002b4cd03b7d002b4bd07b7d002b4ad0bb7d002b49d0fb7d002b48d03b7e002b47d07b7e002b46d0bb7e002b45d0fb7e002b44d03b7f002b43d07b7f002b42d0bb7f002b41d0fb7f002b40d0203160297ff49aaf54e001313ae0023138e0033136e0043134e0053132e0063130e007312ee008312ce009312ae00a3128e00b3126e00c3124e00d3122e00e3120e00f311ee010311ce011311ae0123118e0133116e0143114e0153112e0163110e017310ee018310ce019310ae01a3108e01b3106e01c3104e01d3102e01e3100e01f315f2915d84ff05303535411d00a444b235e2953700cd049235d29937008d050235c29d37004d020235b29137140f0c28200218df87310013096f8de10002900f0be80002105aa535c002b00f0a08057187b78002b5ed0bb78002b5dd0fb78002b5cd03b79002b5bd07b79002b5ad0bb79002b59d0fb79002b58d03b7a002b57d07b7a002b56d0bb7a002b55d0fb7a002b54d03b7b002b53d07b7b002b52d0bb7b002b51d0fb7b002b50d03b7c002b4fd07b7c002b4ed0bb7c002b4dd0fb7c002b4cd03b7d002b4bd07b7d002b4ad0bb7d002b49d0fb7d002b48d03b7e002b47d07b7e002b46d0bb7e002b45d0fb7e002b44d03b7f002b43d07b7f002b42d0bb7f002b41d0fb7f002b40d0203160297ff49aaf50e001313ae0023138e0033136e0043134e0053132e0063130e007312ee008312ce009312ae00a3128e00b3126e00c3124e00d3122e00e3120e00f311ee010311ce011311ae0123118e0133116e0143114e0153112e0163110e017310ee018310ce019310ae01a3108e01b3106e01c3104e01d3102e01e3100e01f315Line truncated
"new": "02fb01f000e000bfb0b54ff2ac44c2f229040146206846f23f52c5f28802b2eb500f40f258304cf2e9124cf67e25c2f20000c0f24802caf2101518bf25609047002804bf691c2160b0bd00bf0846ffe7014640f258304cf20732c2f20000c0f24802104770b500284ed001684ef66a62ccf2ff02914218bf70bd90f8081190f8095146f6756c8d42c0f2510c2ad205eb8501014491f80d2191f80e4191f80ae191f80b3191f80c1142ea0424012c4ff0010298bf14466e1c054680f80961b9b164294eea032028bf6421012888bf024644f62060824228bf02460cf5e2731046984706e0002180f80811bde870406047e047d5f8040138b142f64d42c0f244022146bde87040104770bd00bf2de9f04f9db04ff2a84ac2f2290adaf800b058466ff39600b0f1005f40f07d81dbf800004ef66a67ccf2ff07b84240f074819bf82802002800f05d81dbf82442002c00f0588140f6b400c2f20000d0f8008004a802f0d4ffb8f1000f00f02382032045f24075cff68070a4f1600108f160026ff0bf03c0f2020500bf0e6ed41826664e6ec03366668e6eab42a666ce6ee6660e6f26674e6f66678e6fa667ce6fe667d1f88060c4f88060d1f88460c4f88460d1f88860c4f88860d1f88c60c4f88c60d1f89060c4f89060d1f89460c4f89460d1f89860c4f89860d1f89c60c4f89c60d1f8a060c4f8a060d1f8a460c4f8a460d1f8a860c4f8a860d1f8ac60c4f8ac60d1f8b060c4f8b060d1f8b460c4f8b460d1f8b860c4f8b860d1f8bc60c4f8bc6051f8c06fc4f8c0604e68c4f8c4608e68c4f8c860ce68c4f8cc600e69c4f8d0604e69c4f8d4608e69c4f8d860ce69c4f8dc600e6ac4f8e0604e6ac4f8e4608e6ac4f8e860ce6ac4f8ec600e6bc4f8f0604e6bc4f8f4608e6bc4f8f860ce6bc4f8fc600e6cc4f800614e6cc4f804618e6cc4f80861ce6cc4f80c610e6dc4f810614e6dc4f814618e6dc4f81861ce6dc4f81c617ff462afdaf800603040b0f1005f40f0b2803068b84240f0ae8096f8ce00002840f07a8196f8dc10002000298df8140000f0f28105a90a5c002a00f0c5810a185378002b00f083819378002b00f08181d378002b00f07f811379002b00f07d815379002b00f07b819379002b00f07981d379002b00f07781137a002b00f07581537a002b00f07381937a002b00f07181d37a002b00f06f81137b002b00f06d81537b002b00f06b81937b002b00f06981d37b002b00f06781137c002b00f06581537c002b00f06381937c002b00f06181d37c002b00f05f81137d002b00f05d81537d002b00f05b81937d002b00f05981d37d002b00f05781137e002b00f05581537e002b00f05381937e002b00f05181d37e002b00f04f81137f002b00f04d81537f002b00f04b81937f002b00f04981d27f002a00f04781203060287ff47baf66e19bf82a0270b1dbf82c0240b146f68051c2f207010968401a002800f3f48000208bf82a0240f6d100c0f247001db0bde8f04f00474ff4497005f0dbf8002800f0c7804ff6dc41cff6ff71002200bf4318433183f8242383f8252383f8262383f8272383f8282383f8292383f82a2383f82b2383f82c2383f82d2383f82e2383f82f2383f8302383f8312383f8322383f8332383f8342383f8352383f8362383f8372383f8382383f8392383f83a2383f83b2383f83c2383f83d2383f83e2383f83f2383f8402383f8412383f8422383f8432383f8442383f8452383f8462383f8472383f8482383f8492383f84a2383f84b2383f84c2383f84d2383f84e2383f84f2383f8502383f8512383f8522383f8532383f8542383f8552383f8562383f8572383f8582383f8592383f85a2383f85b2383f85c2383f85d2383f85e2383f85f2383f8602383f8612383f8622383f8632383f8642383f8652383f866237ff476af012180f8ce104ff0ff310760a0f8e010a0f8e210a0f8e410a0f8e610a0f8e810a0f8ea10a0f8ec10a0f8ee10a0f8f010a0f8f210a0f8f410a0f8f610a0f8f810a0f8fa10a0f8fc10a0f8fe1010e000208bf82802cbf824028bf82a0201208bf8290240f6d100c0f24700804715e00020caf8000000208bf82802cbf824024ff416304cf60361069005a8c0f24701cdf81480884701208bf82a0204a802f0b4fecbf8d4001db0bde8f08f01303ae0023038e0033036e0043034e0053032e0063030e007302ee008302ce009302ae00a3028e00b3026e00c3024e00d3022e00e3020e00f301ee010301ce011301ae0123018e0133016e0143014e0153012e0163010e017300ee018300ce019300ae01a3008e01b3006e01c3004e01d3002e01e3000e01f305f2821d84ff052020a541dd0014445225e284a7018d04f225d288a7014d052225c28ca7010d044225b280a710cd045225a284a7108d0522259288a7104d020225828ca7142f0168500208df87300012096f8dd10002900f0c280002105aa535c002b00f0a08057187b78002b5ed0bb78002b5dd0fb78002b5cd03b79002b5bd07b79002b5ad0bb79002b59d0fb79002b58d03b7a002b57d07b7a002b56d0bb7a002b55d0fb7a002b54d03b7b002b53d07b7b002b52d0bb7b002b51d0fb7b002b50d03b7c002b4fd07b7c002b4ed0bb7c002b4dd0fb7c002b4cd03b7d002b4bd07b7d002b4ad0bb7d002b49d0fb7d002b48d03b7e002b47d07b7e002b46d0bb7e002b45d0fb7e002b44d03b7f002b43d07b7f002b42d0bb7f002b41d0fb7f002b40d0203160297ff49aaf54e001313ae0023138e0033136e0043134e0053132e0063130e007312ee008312ce009312ae00a3128e00b3126e00c3124e00d3122e00e3120e00f311ee010311ce011311ae0123118e0133116e0143114e0153112e0163110e017310ee018310ce019310ae01a3108e01b3106e01c3104e01d3102e01e3100e01f315f2915d84ff05303535411d00a444b235e2953700cd049235d29937008d050235c29d37004d020235b29137140f0c28200218df87310013096f8de10002900f0be80002105aa535c002b00f0a08057187b78002b5ed0bb78002b5dd0fb78002b5cd03b79002b5bd07b79002b5ad0bb79002b59d0fb79002b58d03b7a002b57d07b7a002b56d0bb7a002b55d0fb7a002b54d03b7b002b53d07b7b002b52d0bb7b002b51d0fb7b002b50d03b7c002b4fd07b7c002b4ed0bb7c002b4dd0fb7c002b4cd03b7d002b4bd07b7d002b4ad0bb7d002b49d0fb7d002b48d03b7e002b47d07b7e002b46d0bb7e002b45d0fb7e002b44d03b7f002b43d07b7f002b42d0bb7f002b41d0fb7f002b40d0203160297ff49aaf50e001313ae0023138e0033136e0043134e0053132e0063130e007312ee008312ce009312ae00a3128e00b3126e00c3124e00d3122e00e3120e00f311ee010311ce011311ae0123118e0133116e0143114e0153112e0163110e017310ee018310ce019310ae01a3108e01b3106e01c3104e01d3102e01e3100e01f315Line truncated
"desc": "append injected blobs to main-app payload"
},
{
"offset": 779114,
"old": "846a3800",
"new": "86113900",
"new": "e8103900",
"desc": "main-app subheader payload size (ps)"
},
{
"offset": 152,
"old": "046b3800",
"new": "06123900",
"new": "68113900",
"desc": "main-app TOC entry size (ps + 128)"
},
{
"offset": 779234,
"old": "846a3804",
"new": "86113904",
"new": "e8103904",
"desc": "main-app preamble length (low 24 bits)"
},
{
"offset": 779238,
"old": "85c355a2",
"new": "a15746f8",
"new": "642d8359",
"desc": "[5] ota/s200_firmware_ota.bin preamble crc32"
},
{
"offset": 156,
"old": "ed292ee4",
"new": "3a0c8944",
"new": "2ecbc5ac",
"desc": "[5] ota/s200_firmware_ota.bin component crc32c (TOC)"
},
{
"offset": 779118,
"old": "ed292ee4",
"new": "3a0c8944",
"new": "2ecbc5ac",
"desc": "[5] ota/s200_firmware_ota.bin component crc32c (subheader)"
}
]
+1 -1
View File
@@ -1,6 +1,6 @@
/**
* Ambient light sensor access through the custom firmware (CFW image-handler
* mode 16, capability token "als16"; see g2flash/patches/als_sensor.c).
* mode 16; see g2flash/patches/als_sensor.c).
*
* The stock firmware only reads its OPT3001 light sensor while auto-brightness
* is on, and then steps the panel brightness itself (visible flicker). The CFW
+6 -8
View File
@@ -1,19 +1,17 @@
import { Utils } from "@nativescript/core";
import { type FirmwareInfo } from "../g2/firmware-compat";
declare const com: any;
export type DeviceInfo = {
leftVersion: string;
rightVersion: string;
capabilities: string;
};
export type DeviceInfo = FirmwareInfo;
export type DeviceInfoState = "connecting" | "authenticating" | "querying";
/**
* TS wrapper around the native FaceclawDeviceInfoProbe — a one-shot,
* stock-compatible connect + firmware/device-info read. `run()` resolves with
* the firmware versions and CFW capability string, or rejects on failure.
* the firmware versions and the firmware-extension string, or rejects on failure.
*/
export class DeviceInfoProbe {
private readonly probe: any;
@@ -34,11 +32,11 @@ export class DeviceInfoProbe {
onLog: (line: string) => this.emit(this.logListeners, String(line)),
onState: (state: string, detail: string) =>
this.emit(this.stateListeners, String(state) as DeviceInfoState, String(detail ?? "")),
onResult: (leftVersion: string, rightVersion: string, capabilities: string) =>
onResult: (leftVersion: string, rightVersion: string, extension: string) =>
this.settle(null, {
leftVersion: String(leftVersion),
rightVersion: String(rightVersion),
capabilities: String(capabilities),
extension: String(extension),
}),
onError: (message: string) => this.settle(new Error(String(message)), null),
});
+6 -8
View File
@@ -32,11 +32,9 @@ export type FrameMetrics = {
tileCount: number;
};
export type FirmwareInfo = {
leftVersion: string;
rightVersion: string;
capabilities: string;
};
import { type FirmwareInfo } from "../g2/firmware-compat";
export type { FirmwareInfo };
/**
* Compositor surface configuration. Position/size are in screen pixels;
@@ -230,11 +228,11 @@ export class FaceclawCommunicatorBridge {
onFrameFinished: (frameId: number, outcome: string) => {
this.recordFrameFinished(Number(frameId), String(outcome));
},
onFirmwareInfo: (leftVersion: string, rightVersion: string, capabilities: string) => {
const info = {
onFirmwareInfo: (leftVersion: string, rightVersion: string, extension: string) => {
const info: FirmwareInfo = {
leftVersion: String(leftVersion),
rightVersion: String(rightVersion),
capabilities: String(capabilities),
extension: String(extension),
};
this.emitAsync(this.firmwareInfoListeners, info);
},
@@ -7,7 +7,14 @@ import {
hasExtractedEvenHubFonts,
type FirmwareProgress,
} from "../g2/firmware-builder";
import { BASE_STOCK_VERSION_TEXT, classifyOnboardingFirmware, type OnboardingFirmwareKind } from "../g2/firmware-compat";
import {
BASE_STOCK_VERSION_TEXT,
REQUIRED_FACECLAW_FIRMWARE_VERSION,
classifyOnboardingFirmware,
describeFirmwareExtension,
type FirmwareExtension,
type OnboardingFirmwareKind,
} from "../g2/firmware-compat";
import { DeviceInfoProbe, DeviceInfoState } from "../native/device-info-probe";
import { setOnboardingCompleted, setPreviewOnlyMode } from "./onboarding-state";
import { formatErrorMessage } from "../util/format-error";
@@ -145,7 +152,7 @@ export class OnboardingFirmwareCheckViewModel extends Observable {
if (this._phase !== "error") return;
// Same path as a real "custom" classification, so the phone-side G2 fonts
// still get extracted when they're missing.
this.applyClassification("custom", "", "");
this.applyClassification("custom", "", { kind: "none" });
}
// --- probe flow ------------------------------------------------------------
@@ -176,8 +183,8 @@ export class OnboardingFirmwareCheckViewModel extends Observable {
const info = await probe.run();
this.probeInstance = null;
const { kind, version } = classifyOnboardingFirmware(info);
this.applyClassification(kind, version, info.capabilities.trim());
const { kind, version, extension } = classifyOnboardingFirmware(info);
this.applyClassification(kind, version, extension);
} catch (error) {
this.probeInstance = null;
this.toError(this.formatError(error));
@@ -195,10 +202,11 @@ export class OnboardingFirmwareCheckViewModel extends Observable {
}
}
private applyClassification(kind: OnboardingFirmwareKind, version: string, capabilities: string): void {
private applyClassification(kind: OnboardingFirmwareKind, version: string, extension: FirmwareExtension): void {
this.busy = false;
// `kind` is classifyOnboardingFirmware's OnboardingFirmwareKind ("custom" |
// "flashable-stock" | "newer-stock-unvalidated" | "newer-stock-validated" | "unknown") -- NOT CheckPhase's shorter
// "older-faceclaw" | "other-custom" | "flashable-stock" | "newer-stock-unvalidated" |
// "newer-stock-validated" | "unknown") -- NOT CheckPhase's shorter
// "flashable"/"newer-validated"/"newer" (used below via setPhase for _phase/primaryLabel/etc).
// The two types share two of four names, so a typo'd case label here type-checks
// fine as long as `kind` stays plain `string`, but silently falls through to
@@ -208,10 +216,26 @@ export class OnboardingFirmwareCheckViewModel extends Observable {
switch (kind) {
case "custom":
if (!hasExtractedEvenHubFonts()) {
void this.extractFontsForCustomFirmware(version, capabilities);
void this.extractFontsForCustomFirmware(version, extension);
break;
}
this.showCustomReady(version, capabilities, false);
this.showCustomReady(version, extension, false);
break;
case "older-faceclaw":
this.setPhase("flashable");
this.headline = "Firmware Update Available";
this.status =
`Your glasses run ${describeFirmwareExtension(extension)}${version ? `, based on stock ${version}` : ""}. ` +
`This version of Faceclaw needs revision ${REQUIRED_FACECLAW_FIRMWARE_VERSION}. ` +
"Tap Install Firmware to update it.";
break;
case "other-custom":
this.setPhase("flashable");
this.headline = "Other Custom Firmware";
this.status =
`Your glasses run ${describeFirmwareExtension(extension)}${version ? `, based on stock ${version}` : ""}. ` +
`Faceclaw needs its own custom firmware (revision ${REQUIRED_FACECLAW_FIRMWARE_VERSION}). ` +
"Tap Install Firmware to replace the current firmware with it.";
break;
case "flashable-stock":
this.setPhase("flashable");
@@ -249,7 +273,7 @@ export class OnboardingFirmwareCheckViewModel extends Observable {
}
}
private async extractFontsForCustomFirmware(version: string, capabilities: string): Promise<void> {
private async extractFontsForCustomFirmware(version: string, extension: FirmwareExtension): Promise<void> {
this.setPhase("fonts");
this.headline = "Preparing G2 Fonts";
this.busy = true;
@@ -258,7 +282,7 @@ export class OnboardingFirmwareCheckViewModel extends Observable {
"Downloading the official firmware to extract them; your glasses will not be reflashed.";
try {
await downloadAndExtractEvenHubFonts((progress) => this.reportFontProgress(progress));
this.showCustomReady(version, capabilities, true);
this.showCustomReady(version, extension, true);
} catch (error) {
this.toError(
`Custom firmware is installed, but the G2 fonts could not be prepared: ${this.formatError(error)}`,
@@ -283,13 +307,16 @@ export class OnboardingFirmwareCheckViewModel extends Observable {
}
}
private showCustomReady(version: string, capabilities: string, extractedFonts: boolean): void {
private showCustomReady(version: string, extension: FirmwareExtension, extractedFonts: boolean): void {
this.busy = false;
this.setPhase("custom");
this.headline = extractedFonts ? "Fonts Ready" : "Custom Firmware Detected";
const details = [
extension.kind === "faceclaw" ? `revision ${extension.version}` : "",
version ? `based on stock ${version}` : "",
].filter(Boolean);
this.status =
`Your glasses already run Faceclaw's custom firmware${version ? ` (version ${version})` : ""}` +
`${capabilities ? `, extensions: ${capabilities}` : ""}. ` +
`Your glasses already run Faceclaw's custom firmware${details.length ? ` (${details.join(", ")})` : ""}. ` +
(extractedFonts
? "The phone-side G2 fonts were extracted successfully. No flashing was needed — you're all set."
: "The phone-side G2 fonts are present. No flashing needed — you're all set.");
+1 -1
View File
@@ -493,7 +493,7 @@ export const useMicControlSetting = new ConfigSettingBoolean({
storageKey: "developer.useMicControl",
defaultValue: true,
description:
"Use the custom firmware's per-temple mic-control channel (caps token micctl) for the Microphones app's array capture. When off, behave as if the firmware doesn't have the feature and use the standard single mixed stream.",
"Use the custom firmware's per-temple mic-control channel for the Microphones app's array capture. When off, use the standard single mixed stream.",
});
export const showBleBandwidthSetting = new ConfigSettingBoolean({
+1
View File
@@ -11,6 +11,7 @@
"outDir": "../.test-build"
},
"include": [
"../app/g2/firmware-compat.ts",
"../app/g2/glasses-hardware-identity.ts",
"../app/g2/ble-proximity.ts",
"../app/g2/even-advertisement.ts",