forked from Blendman974/faceclaw
G1 support: Flashing within the Android app
This commit is contained in:
1 parent
345ba36c33
commit
38c52ebc31
37 files changed
+2819
-32
No files matched your search
@@ -0,0 +1,345 @@
|
||||
import { Frame, Observable } from "@nativescript/core";
|
||||
|
||||
import { G1ArmScanner } from "../g1/arm-scanner";
|
||||
import { G1V0_IMAGE } from "../g1/firmware/g1v0-image";
|
||||
import { buildG1Firmware, type BuiltG1Firmware, type G1BuildProgress } from "../g1/firmware-builder";
|
||||
import { saveG1Arm, saveG1Pair } from "../g1/addresses";
|
||||
import { G1_CASE_INSTRUCTIONS, G1_INSTALL_NOTICE, G1_SIDES, g1FlashPercent, type G1FlashResult, type G1Side } from "../g1/flash-plan";
|
||||
import { loadDeviceAddresses, loadPairedGlassesIdentity } from "../g2/device-addresses";
|
||||
import { downloadAndExtractEvenHubFonts, hasExtractedEvenHubFonts } from "../g2/firmware-builder";
|
||||
import { type GlassesPairCandidate } from "../g2/pairing-candidates";
|
||||
import { resumeAutoReconnect, suppressAutoReconnect } from "../g2/reconnect-policy";
|
||||
import { ensureBlePermissions } from "../native/ble-permissions";
|
||||
import { G1Flasher, type G1FlasherOptions } from "../native/g1-flasher";
|
||||
import { formatErrorMessage } from "../util/format-error";
|
||||
import { finishOnboardingNavigation } from "./onboarding-navigation";
|
||||
import { setOnboardingCompleted, setPreviewOnlyMode } from "./onboarding-state";
|
||||
|
||||
type Phase = "intro" | "preparing" | "flashing" | "flashed" | "error" | "unavailable";
|
||||
|
||||
const LOCATE_MS = 45_000;
|
||||
/** An arm takes about 20 s to copy the image, and a hung boot resets itself within two minutes. */
|
||||
const RETURN_MS = 240_000;
|
||||
const CONNECT_MS = 60_000;
|
||||
/** A new arm pairs only once it knows it's in the case, which a full case can take a while to tell it. */
|
||||
const FIRST_PAIRING_MS = 120_000;
|
||||
|
||||
/**
|
||||
* The install page on a G1, in place of OnboardingFlashViewModel. The two arms are separate devices that each take the
|
||||
* image over MCUmgr (G1ArmFlashFlow), left first. There is nothing on the lens to confirm with before g1v0 is on the arm,
|
||||
* so the confirmation is on the phone: the page before, or this one's intro.
|
||||
*
|
||||
* Every run starts by listening for what each arm runs now, so a retry picks up wherever the last one stopped. An arm's
|
||||
* new address is saved as soon as it's known.
|
||||
*/
|
||||
export class G1FlashViewModel extends Observable {
|
||||
private phase: Phase = "intro";
|
||||
private readonly fromOnboarding: boolean;
|
||||
private readonly scanner = new G1ArmScanner();
|
||||
private image: BuiltG1Firmware | null = null;
|
||||
private flasher: G1Flasher | null = null;
|
||||
private generation = 0;
|
||||
private disposed = false;
|
||||
private unpairedArm = false;
|
||||
|
||||
headline = "Install Faceclaw's Firmware";
|
||||
status = "";
|
||||
log = "";
|
||||
busy = false;
|
||||
progress = 0;
|
||||
|
||||
constructor(options?: { mode?: "install" | "uninstall"; fromOnboarding?: boolean; autoStart?: boolean }) {
|
||||
super();
|
||||
this.fromOnboarding = options?.fromOnboarding ?? true;
|
||||
if (options?.mode === "uninstall") {
|
||||
// Restoring Even's firmware has never been run on a real arm, and an arm whose network core is older than the
|
||||
// image may not come back, so the phone doesn't offer it yet.
|
||||
this.phase = "unavailable";
|
||||
this.headline = "Back to Even's Firmware";
|
||||
this.status = "Faceclaw can't restore Even's firmware on a G1 yet. It takes a computer: see \"Restore Even's firmware\" in " +
|
||||
"the ScouterKit firmware's README.";
|
||||
return;
|
||||
}
|
||||
suppressAutoReconnect();
|
||||
this.status = `${G1_CASE_INSTRUCTIONS}\n\n${G1_INSTALL_NOTICE}`;
|
||||
if (options?.autoStart) void this.run();
|
||||
}
|
||||
|
||||
// --- what the page binds --------------------------------------------------
|
||||
|
||||
get logVisibility(): "visible" | "collapse" {
|
||||
return this.log ? "visible" : "collapse";
|
||||
}
|
||||
|
||||
get busyVisibility(): "visible" | "collapse" {
|
||||
return this.busy ? "visible" : "collapse";
|
||||
}
|
||||
|
||||
get progressVisibility(): "visible" | "collapse" {
|
||||
return this.phase === "flashing" ? "visible" : "collapse";
|
||||
}
|
||||
|
||||
get primaryLabel(): string {
|
||||
switch (this.phase) {
|
||||
case "intro":
|
||||
return "Install";
|
||||
case "flashed":
|
||||
return "Finish";
|
||||
case "error":
|
||||
return "Retry";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
get primaryVisibility(): "visible" | "collapse" {
|
||||
return this.primaryLabel ? "visible" : "collapse";
|
||||
}
|
||||
|
||||
get secondaryLabel(): string {
|
||||
return "Back";
|
||||
}
|
||||
|
||||
get secondaryVisibility(): "visible" | "collapse" {
|
||||
// No way out mid-install, or after one.
|
||||
return this.phase === "preparing" || this.phase === "flashing" || this.phase === "flashed" ? "collapse" : "visible";
|
||||
}
|
||||
|
||||
onPrimaryTap(): void {
|
||||
if (this.phase === "intro" || this.phase === "error") void this.run();
|
||||
else if (this.phase === "flashed") this.finish();
|
||||
}
|
||||
|
||||
onSecondaryTap(): void {
|
||||
if (this.phase === "intro" || this.phase === "error" || this.phase === "unavailable") this.leave();
|
||||
}
|
||||
|
||||
// --- the install ----------------------------------------------------------
|
||||
|
||||
private async run(): Promise<void> {
|
||||
const generation = ++this.generation;
|
||||
const live = () => !this.disposed && generation === this.generation;
|
||||
this.setPhase("preparing");
|
||||
this.setBusy(true);
|
||||
this.setText("Preparing Firmware", "Getting the firmware ready...");
|
||||
try {
|
||||
await ensureBlePermissions();
|
||||
if (!live()) return;
|
||||
if (!this.image) {
|
||||
this.image = await buildG1Firmware((progress) => {
|
||||
if (live()) this.setStatus(describeBuild(progress));
|
||||
});
|
||||
this.appendLog(`firmware ${this.image.version} prepared and verified (${this.image.bytes.toLocaleString()} bytes)`);
|
||||
}
|
||||
await this.prepareFonts(live);
|
||||
if (!live()) return;
|
||||
|
||||
this.setPhase("flashing");
|
||||
this.setText("Installing Firmware", "Listening for your glasses...");
|
||||
const identity = loadPairedGlassesIdentity();
|
||||
const stored = loadDeviceAddresses();
|
||||
const pair = await this.scanner.waitForPair({ serial: identity?.serial, left: stored.left, right: stored.right }, LOCATE_MS);
|
||||
if (!live()) return;
|
||||
if (!pair) {
|
||||
throw new Error("Couldn't hear both arms of your glasses. Make sure they're in the case with the lid open, and that no other app " +
|
||||
"or phone is connected to them, then retry.");
|
||||
}
|
||||
saveG1Pair(pair);
|
||||
|
||||
this.unpairedArm = false;
|
||||
for (const side of G1_SIDES) {
|
||||
await this.installArm(side, pair, live);
|
||||
if (!live()) return;
|
||||
}
|
||||
this.finished();
|
||||
} catch (error) {
|
||||
if (live()) this.failed(formatErrorMessage(error));
|
||||
}
|
||||
}
|
||||
|
||||
private async installArm(side: G1Side, pair: GlassesPairCandidate, live: () => boolean): Promise<void> {
|
||||
const arm = pair[side]!;
|
||||
const fromStock = arm.g1Firmware === "stock";
|
||||
this.setProgress(g1FlashPercent(side, 0, 1));
|
||||
this.setStatus(`Connecting to the ${side} arm...`);
|
||||
const installed = await this.flash({
|
||||
address: arm.address,
|
||||
side,
|
||||
firmwarePath: this.image!.path,
|
||||
mode: fromStock ? "stock" : "update",
|
||||
connectWindowMs: CONNECT_MS,
|
||||
}, (state) => {
|
||||
if (state === "pairing") this.setStatus(`Pairing with the ${side} arm. If your phone asks, accept it.`);
|
||||
else if (state === "checking") this.setStatus(`Checking the ${side} arm...`);
|
||||
else if (state === "flashing") this.setStatus(`Sending the firmware to the ${side} arm. Nothing has changed yet.`);
|
||||
else if (state === "committing") this.setStatus(`Installing on the ${side} arm. Keep the glasses in the case.`);
|
||||
}, (sent, total) => this.setProgress(g1FlashPercent(side, sent, total)));
|
||||
if (!live()) return;
|
||||
this.setProgress(g1FlashPercent(side, 1, 1));
|
||||
if (!installed.flashed) {
|
||||
this.appendLog(`${side} arm already runs ${installed.version}`);
|
||||
return;
|
||||
}
|
||||
|
||||
this.setStatus(`The ${side} arm is restarting into the new firmware. This takes about 20 seconds; keep it in the case.`);
|
||||
const identity = loadPairedGlassesIdentity();
|
||||
const back = await this.scanner.waitForG1v0Arm(side, identity?.serial ?? pair.serial, RETURN_MS);
|
||||
if (!live()) return;
|
||||
if (!back) {
|
||||
throw new Error(`The ${side} arm hasn't come back yet. Leave the glasses in the plugged-in case for a few minutes, with the lid ` +
|
||||
"open: an interrupted install finishes by itself. Then retry.");
|
||||
}
|
||||
saveG1Arm(side, back);
|
||||
if (back.g1Firmware === "g1v0-safe") {
|
||||
throw new Error(`The ${side} arm came back in safe mode: the new firmware restarted repeatedly. Retry to install it again.`);
|
||||
}
|
||||
|
||||
this.setStatus(`Pairing with the ${side} arm. If your phone asks, accept it.`);
|
||||
let running: G1FlashResult;
|
||||
try {
|
||||
running = await this.flash({
|
||||
address: back.address,
|
||||
side,
|
||||
firmwarePath: "",
|
||||
mode: "probe",
|
||||
connectWindowMs: fromStock ? FIRST_PAIRING_MS : RETURN_MS,
|
||||
});
|
||||
} catch (error) {
|
||||
if (!fromStock || !live()) throw error;
|
||||
// Installed, as its advertising shows; it just won't pair yet. The next connection pairs it.
|
||||
this.appendLog(`${side} arm not paired yet: ${formatErrorMessage(error)}`);
|
||||
this.unpairedArm = true;
|
||||
return;
|
||||
}
|
||||
if (!live()) return;
|
||||
if (running.version !== installed.version) {
|
||||
throw new Error(`The ${side} arm runs ${running.version}, not ${installed.version}: it didn't take the new firmware. Retry to try again.`);
|
||||
}
|
||||
this.appendLog(`${side} arm runs ${running.version}`);
|
||||
}
|
||||
|
||||
private async flash(
|
||||
options: G1FlasherOptions,
|
||||
onState?: (state: string) => void,
|
||||
onProgress?: (sent: number, total: number) => void,
|
||||
) {
|
||||
const flasher = new G1Flasher(options);
|
||||
this.flasher = flasher;
|
||||
flasher.onLog((line) => this.appendLog(line));
|
||||
if (onState) flasher.onState(onState);
|
||||
if (onProgress) flasher.onProgress(onProgress);
|
||||
try {
|
||||
return await flasher.run();
|
||||
} finally {
|
||||
if (this.flasher === flasher) this.flasher = null;
|
||||
flasher.close();
|
||||
}
|
||||
}
|
||||
|
||||
/** A G2's install gets these from the same download; Faceclaw's fonts are a phone-side matter, so a failure here is no reason to stop. */
|
||||
private async prepareFonts(live: () => boolean): Promise<void> {
|
||||
if (hasExtractedEvenHubFonts()) return;
|
||||
if (live()) this.setStatus("Preparing fonts...");
|
||||
try {
|
||||
await downloadAndExtractEvenHubFonts();
|
||||
} catch (error) {
|
||||
this.appendLog(`fonts not prepared: ${formatErrorMessage(error)}`);
|
||||
}
|
||||
}
|
||||
|
||||
private finished(): void {
|
||||
// The glasses are ready for the main page to connect to.
|
||||
resumeAutoReconnect();
|
||||
this.setBusy(false);
|
||||
this.setProgress(100);
|
||||
this.setPhase("flashed");
|
||||
this.setText("All Done", `Both arms run Faceclaw's firmware ${G1V0_IMAGE.version}.` + (this.unpairedArm
|
||||
? " Keep the glasses in the case with the lid open until Faceclaw has connected: they only pair in the case."
|
||||
: ""));
|
||||
}
|
||||
|
||||
private failed(message: string): void {
|
||||
this.setBusy(false);
|
||||
this.setPhase("error");
|
||||
this.setText("Something Went Wrong", message);
|
||||
}
|
||||
|
||||
private finish(): void {
|
||||
setPreviewOnlyMode(false);
|
||||
setOnboardingCompleted(true);
|
||||
this.teardown();
|
||||
finishOnboardingNavigation();
|
||||
}
|
||||
|
||||
private leave(): void {
|
||||
this.teardown();
|
||||
const frame = Frame.topmost();
|
||||
if (this.fromOnboarding && frame?.canGoBack()) {
|
||||
frame.goBack();
|
||||
return;
|
||||
}
|
||||
if (!this.fromOnboarding) {
|
||||
finishOnboardingNavigation();
|
||||
return;
|
||||
}
|
||||
frame?.navigate({ moduleName: "phone-ui/onboarding-page", clearHistory: true });
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this.disposed = true;
|
||||
this.teardown();
|
||||
}
|
||||
|
||||
private teardown(): void {
|
||||
++this.generation;
|
||||
this.scanner.stop();
|
||||
this.flasher?.close();
|
||||
this.flasher = null;
|
||||
}
|
||||
|
||||
// --- page state -----------------------------------------------------------
|
||||
|
||||
private setText(headline: string, status: string): void {
|
||||
this.set("headline", headline);
|
||||
this.set("status", status);
|
||||
}
|
||||
|
||||
private setStatus(status: string): void {
|
||||
this.set("status", status);
|
||||
}
|
||||
|
||||
private setBusy(busy: boolean): void {
|
||||
this.set("busy", busy);
|
||||
this.notifyPropertyChange("busyVisibility", this.busyVisibility);
|
||||
}
|
||||
|
||||
private setProgress(percent: number): void {
|
||||
this.set("progress", Math.max(0, Math.min(100, Math.round(percent))));
|
||||
}
|
||||
|
||||
private setPhase(phase: Phase): void {
|
||||
this.phase = phase;
|
||||
for (const property of ["primaryLabel", "primaryVisibility", "secondaryVisibility", "progressVisibility"] as const) {
|
||||
this.notifyPropertyChange(property, this[property]);
|
||||
}
|
||||
}
|
||||
|
||||
private appendLog(line: string): void {
|
||||
const stamp = new Date().toISOString().slice(11, 19);
|
||||
this.set("log", this.log ? `${this.log}\n[${stamp}] ${line}` : `[${stamp}] ${line}`);
|
||||
this.notifyPropertyChange("logVisibility", this.logVisibility);
|
||||
}
|
||||
}
|
||||
|
||||
function describeBuild(progress: G1BuildProgress): string {
|
||||
switch (progress) {
|
||||
case "downloading":
|
||||
return "Downloading the parts it needs from Even's firmware server...";
|
||||
case "verifying":
|
||||
return "Verifying the download...";
|
||||
case "assembling":
|
||||
return "Assembling the firmware...";
|
||||
default:
|
||||
return "Saving the firmware...";
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@
|
||||
<ActionItem text="Conversations" tap="{{ onConversationsTap }}" android.position="popup" />
|
||||
<ActionItem text="Take screenshot" tap="{{ onTakeScreenshotTap }}" android.position="popup" />
|
||||
<ActionItem text="Record screen" tap="{{ onRecordScreenTap }}" android.position="popup" />
|
||||
<ActionItem text="Check firmware" tap="{{ onCheckFirmwareTap }}" isEnabled="{{ canRun }}" visibility="{{ glassesMenuItemsVisibility }}" android.position="popup" />
|
||||
<ActionItem text="Uninstall custom firmware" tap="{{ onUninstallFirmwareTap }}" isEnabled="{{ canRun }}" visibility="{{ glassesMenuItemsVisibility }}" android.position="popup" />
|
||||
</ActionBar>
|
||||
|
||||
|
||||
@@ -662,6 +662,14 @@ export class MainViewModel extends RemoteControlsViewModel {
|
||||
* auto-reconnect suppression right away.
|
||||
*/
|
||||
async onPrepareFontsTap(): Promise<void> {
|
||||
await this.openFirmwareCheck();
|
||||
}
|
||||
|
||||
async onCheckFirmwareTap(): Promise<void> {
|
||||
await this.openFirmwareCheck();
|
||||
}
|
||||
|
||||
private async openFirmwareCheck(): Promise<void> {
|
||||
this.setWarningsModalVisible(false);
|
||||
if (this.phase === "connected" || this.phase === "charging" || this.phase === "connecting") {
|
||||
try {
|
||||
@@ -909,8 +917,9 @@ export class MainViewModel extends RemoteControlsViewModel {
|
||||
}
|
||||
|
||||
private async openFlashPage(mode: "install" | "uninstall"): Promise<void> {
|
||||
// The flasher needs the glasses to itself, so drop the main connection first.
|
||||
if (this.phase === "connected" || this.phase === "charging") {
|
||||
// The flasher needs the glasses to itself, so drop the main connection first. That includes a session
|
||||
// still retrying: an install brings arms back at the addresses it is dialling.
|
||||
if (this.phase === "connected" || this.phase === "charging" || this.phase === "connecting") {
|
||||
try {
|
||||
await dashboardController.disconnect();
|
||||
} catch {
|
||||
|
||||
@@ -18,11 +18,21 @@ import {
|
||||
type OnboardingFirmwareKind,
|
||||
} from "../g2/firmware-compat";
|
||||
import { DeviceInfoProbe, DeviceInfoState } from "../native/device-info-probe";
|
||||
import { G1Flasher } from "../native/g1-flasher";
|
||||
import { saveG1Pair } from "../g1/addresses";
|
||||
import { G1ArmScanner } from "../g1/arm-scanner";
|
||||
import { G1V0_IMAGE } from "../g1/firmware/g1v0-image";
|
||||
import { G1_CASE_INSTRUCTIONS, G1_INSTALL_NOTICE, g1FirmwareState, type G1FlashResult, type G1Side } from "../g1/flash-plan";
|
||||
import { loadPairedGlassesIdentity } from "../g2/device-addresses";
|
||||
import { glassesTypeSetting } from "../ui/dashboard-settings";
|
||||
import { setOnboardingCompleted, setPreviewOnlyMode } from "./onboarding-state";
|
||||
import { formatErrorMessage } from "../util/format-error";
|
||||
|
||||
type CheckPhase = "checking" | "fonts" | "custom" | "flashable" | "newer-validated" | "newer" | "error";
|
||||
|
||||
const G1_LOCATE_MS = 30_000;
|
||||
const G1_CHECK_CONNECT_MS = 45_000;
|
||||
|
||||
export class OnboardingFirmwareCheckViewModel extends Observable {
|
||||
private _phase: CheckPhase = "checking";
|
||||
private _headline = "Checking Firmware";
|
||||
@@ -31,7 +41,7 @@ export class OnboardingFirmwareCheckViewModel extends Observable {
|
||||
|
||||
private generation = 0;
|
||||
|
||||
private probeInstance: DeviceInfoProbe | null = null;
|
||||
private probeInstance: { close(): void } | null = null;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
@@ -175,6 +185,10 @@ export class OnboardingFirmwareCheckViewModel extends Observable {
|
||||
try {
|
||||
await ensureBlePermissions();
|
||||
if (generation !== this.generation) return;
|
||||
if (glassesTypeSetting.get() === "g1") {
|
||||
await this.checkG1(generation);
|
||||
return;
|
||||
}
|
||||
const stored = loadDeviceAddresses();
|
||||
if (!isValidMacAddress(stored.right)) {
|
||||
this.toError("No glasses address is configured. Go back and set the device addresses.");
|
||||
@@ -194,11 +208,72 @@ export class OnboardingFirmwareCheckViewModel extends Observable {
|
||||
this.applyClassification(kind, version, extension);
|
||||
} catch (error) {
|
||||
if (generation !== this.generation) return;
|
||||
this.probeInstance = null;
|
||||
this.toError(this.formatError(error));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* What each arm's name says first, as that needs no connection: Even's firmware can't be asked in the same way, and an
|
||||
* arm that is about to be replaced shouldn't have to pair. Only arms on g1v0 are asked which version they run.
|
||||
*/
|
||||
private async checkG1(generation: number): Promise<void> {
|
||||
this.status = "Listening for your glasses...";
|
||||
const scanner = new G1ArmScanner();
|
||||
this.probeInstance = { close: () => scanner.stop() };
|
||||
const stored = loadDeviceAddresses();
|
||||
const pair = await scanner.waitForPair({ serial: loadPairedGlassesIdentity()?.serial, left: stored.left, right: stored.right }, G1_LOCATE_MS);
|
||||
if (generation !== this.generation) return;
|
||||
this.probeInstance = null;
|
||||
if (!pair) {
|
||||
this.toError(`Couldn't hear both arms of your glasses. ${G1_CASE_INSTRUCTIONS} Make sure no other app or phone is connected to them, then retry.`);
|
||||
return;
|
||||
}
|
||||
saveG1Pair(pair);
|
||||
const named = [pair.left!.g1Firmware, pair.right!.g1Firmware];
|
||||
if (named.includes("stock")) {
|
||||
this.showG1Install({ firmware: "stock" });
|
||||
return;
|
||||
}
|
||||
if (named.includes("g1v0-safe")) {
|
||||
this.showG1Install({ safeMode: true });
|
||||
return;
|
||||
}
|
||||
const arms: G1FlashResult[] = [];
|
||||
for (const side of ["left", "right"] as G1Side[]) {
|
||||
const flasher = new G1Flasher({ address: pair[side]!.address, side, firmwarePath: "", mode: "probe", connectWindowMs: G1_CHECK_CONNECT_MS });
|
||||
this.probeInstance = flasher;
|
||||
flasher.onState((state) => {
|
||||
if (generation !== this.generation) return;
|
||||
if (state === "pairing") {
|
||||
this.status = `Pairing with the ${side} arm. If your phone asks, accept it. A G1 pairs only in its case, with the lid open.`;
|
||||
} else {
|
||||
this.status = `Checking the ${side} arm...`;
|
||||
}
|
||||
});
|
||||
arms.push(await flasher.run());
|
||||
if (generation !== this.generation) return;
|
||||
this.disposeProbe();
|
||||
}
|
||||
const state = g1FirmwareState(arms, G1V0_IMAGE.version);
|
||||
if (state === "current") this.applyClassification("custom", arms[0]!.version ?? "", { kind: "none" });
|
||||
else this.showG1Install(state === "stock" ? { firmware: "stock" } : state === "safe-mode" ? { safeMode: true } : arms.find((arm) => arm.version) ?? {});
|
||||
}
|
||||
|
||||
private showG1Install(found: G1FlashResult): void {
|
||||
this.busy = false;
|
||||
this.setPhase("flashable");
|
||||
if (found.firmware === "stock") {
|
||||
this.headline = "Ready to Install";
|
||||
this.status = `Your glasses run Even's firmware.\n\n${G1_CASE_INSTRUCTIONS}\n\n${G1_INSTALL_NOTICE}`;
|
||||
} else if (found.safeMode) {
|
||||
this.headline = "Firmware Needs Reinstalling";
|
||||
this.status = `An arm of your glasses is in safe mode: its firmware restarted repeatedly. Installing it again usually fixes this.\n\n${G1_CASE_INSTRUCTIONS}`;
|
||||
} else {
|
||||
this.headline = "Firmware Update Available";
|
||||
this.status = `Your glasses run Faceclaw's firmware ${found.version ?? ""}, and this version of Faceclaw comes with ${G1V0_IMAGE.version}.\n\n${G1_CASE_INSTRUCTIONS}`;
|
||||
}
|
||||
}
|
||||
|
||||
private reportProbeState(state: DeviceInfoState, detail: string): void {
|
||||
// The probe brings up the right lens, then the left, and pairs with each
|
||||
// in turn (they are separate Bluetooth devices with separate bonds).
|
||||
@@ -326,7 +401,7 @@ export class OnboardingFirmwareCheckViewModel extends Observable {
|
||||
this.busy = false;
|
||||
this.setPhase("custom");
|
||||
this.headline = extractedFonts ? "Fonts Ready" : "Custom Firmware Detected";
|
||||
const details = [
|
||||
const details = glassesTypeSetting.get() === "g1" ? [version].filter(Boolean) : [
|
||||
extension.kind === "faceclaw" ? `revision ${extension.version}` : "",
|
||||
version ? `based on stock ${version}` : "",
|
||||
].filter(Boolean);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { NavigatedData, Page } from "@nativescript/core";
|
||||
|
||||
import { glassesTypeSetting } from "../ui/dashboard-settings";
|
||||
import { G1FlashViewModel } from "./g1-flash-view-model";
|
||||
import { FlashMode, OnboardingFlashViewModel } from "./onboarding-flash-view-model";
|
||||
|
||||
export function navigatingTo(args: NavigatedData): void {
|
||||
@@ -7,16 +9,17 @@ export function navigatingTo(args: NavigatedData): void {
|
||||
if (!page.bindingContext) {
|
||||
const context =
|
||||
(args.context as { mode?: FlashMode; fromOnboarding?: boolean; autoStart?: boolean } | undefined) ?? undefined;
|
||||
page.bindingContext = new OnboardingFlashViewModel({
|
||||
const options = {
|
||||
mode: context?.mode ?? "install",
|
||||
fromOnboarding: context?.fromOnboarding ?? true,
|
||||
autoStart: context?.autoStart ?? false,
|
||||
});
|
||||
};
|
||||
page.bindingContext = glassesTypeSetting.get() === "g1" ? new G1FlashViewModel(options) : new OnboardingFlashViewModel(options);
|
||||
}
|
||||
}
|
||||
|
||||
export function navigatingFrom(args: NavigatedData): void {
|
||||
const page = args.object as Page;
|
||||
(page.bindingContext as OnboardingFlashViewModel | undefined)?.dispose();
|
||||
(page.bindingContext as OnboardingFlashViewModel | G1FlashViewModel | undefined)?.dispose();
|
||||
page.bindingContext = null;
|
||||
}
|
||||
@@ -30,7 +30,7 @@ const STEP_CONTENT: Record<OnboardingStep, StepContent> = {
|
||||
2: {
|
||||
headline: "Before You Continue",
|
||||
tagline: "",
|
||||
body: "This software provides a custom user interface and functionality for the Even Realities G2 smart glasses. It is not created or supported by Even Realities. If this software somehow breaks your headset, this is not Even's fault and is not covered by the hardware's warranty. If this software doesn't break you headset, using this software may void the hardware's warranty anyways, at the sole discretion of Even Realities. This software is beta; don't rely on it for anything critically important." +
|
||||
body: "This software provides a custom user interface and functionality for the Even Realities G2 and G1 smart glasses. It is not created or supported by Even Realities. If this software somehow breaks your headset, this is not Even's fault and is not covered by the hardware's warranty. If this software doesn't break you headset, using this software may void the hardware's warranty anyways, at the sole discretion of Even Realities. This software is beta; don't rely on it for anything critically important." +
|
||||
(global.isIOS ? "\n\niOS / TestFlight privacy\n\n" + IOS_PRIVACY_NOTICE : ""),
|
||||
primaryLabel: "Agree",
|
||||
secondaryLabel: "Back",
|
||||
@@ -40,7 +40,7 @@ const STEP_CONTENT: Record<OnboardingStep, StepContent> = {
|
||||
3: {
|
||||
headline: "Custom Firmware Required",
|
||||
tagline: "",
|
||||
body: "Faceclaw only runs on Even Realities G2 glasses that have Faceclaw's custom firmware installed. You have two choices:\n\n• Preview Only — explore Faceclaw's interface on your phone's screen without pairing any glasses. Nothing is written to a headset.\n\n• Flash Firmware — install the custom firmware on your glasses now, then use Faceclaw for real.\n\nFlashing replaces the official firmware. You can uninstall and return to the official firmware later, by reconnecting the official Even Realities app. Installing custom firmware is not covered by warranty.",
|
||||
body: "Faceclaw only runs on Even Realities G2 or G1 glasses that have Faceclaw's custom firmware installed. You have two choices:\n\n• Preview Only — explore Faceclaw's interface on your phone's screen without pairing any glasses. Nothing is written to a headset.\n\n• Flash Firmware — install the custom firmware on your glasses now, then use Faceclaw for real.\n\nFlashing replaces the official firmware. On a G2 you can uninstall and return to the official firmware later, by reconnecting the official Even Realities app; on a G1 that takes a computer. Installing custom firmware is not covered by warranty.",
|
||||
primaryLabel: "Flash Firmware",
|
||||
secondaryLabel: "Preview Only",
|
||||
splash: false,
|
||||
|
||||
@@ -358,8 +358,7 @@ export class PairingViewModel extends Observable {
|
||||
ring: ringAddress,
|
||||
};
|
||||
saveDeviceAddresses(addresses);
|
||||
const g1 = !!pair?.g1Firmware;
|
||||
if (pair) glassesTypeSetting.set(g1 ? "g1" : "g2");
|
||||
if (pair) glassesTypeSetting.set(pair.g1Firmware ? "g1" : "g2");
|
||||
if (pair) {
|
||||
savePairedGlassesIdentity({
|
||||
serial: pair.serial ?? "",
|
||||
@@ -386,12 +385,6 @@ export class PairingViewModel extends Observable {
|
||||
this.dispose();
|
||||
if (this.onboarding) {
|
||||
setPreviewOnlyMode(false);
|
||||
if (g1) {
|
||||
// The G2 firmware check and flash pages don't apply: a G1's firmware is installed from a
|
||||
// computer, and the session reports incompatible firmware if it lacks the display path.
|
||||
finishOnboardingNavigation();
|
||||
return;
|
||||
}
|
||||
// Continue the onboarding chain: check the glasses' firmware next.
|
||||
Frame.topmost()?.navigate({ moduleName: "phone-ui/onboarding-firmware-check-page" });
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user