forked from Blendman974/faceclaw
We're going to extend the Faceclaw app onboarding process to include checking for and installing the custom firmware (currently handled externally with the scripts in ../g2flash). We'll add script scripts/resetOnboarding.sh that uses adb to reset the app on the attached phone to default/pre-onboarding state for testing. The onboarding process will explain that it's only compatible with custom firmware, with options to either skip and try out the app using only the phone-screen preview (instead of pairing with glasses), or proceed with flashing. If the user proceeds with flashing, we first connect to the glasses (with the existing mechanism), and display an on-glasses confirmation prompt. Because this prompt needs compatibility with stock firmware, it will use a different subset of the BLE protocol than the main app does (in particular, no image containers), so we'll have a separate bluetooth communication class rather than extending FaceclawBleCommunicator. We'll send an init message to start a Hub app, initialize a layout with a text container and a list, populate the text container with a message saying that flashing will void warranty and the list with No and Yes, set up a keepalive/heartbeat message timer, and wait for a menu selection. (Refer to ../g2-kit-unofficial/ble/docs and ../g2-kit-unofficial/ble/gen for protocol details). If the prompt is approved, we go to the flashing screen. On the flashing screen, we first download the official firmware, apply patches to it, and check that it has the expected result hash. See ../g2flash/build_cfw.sh and ../g2flash/apply_patches.py for details. Let's implement everything prior to the update itself now, ie, the on-device confirmation prompt, and downloading, patching and verifying the modded firmware. scripts/resetOnboarding.sh is meant to reset a pref so that Faceclaw reruns its first-run onboarding on next launch, but fails with "No onboarding keys were set. App is already in pre-onboarding state." (And onboarding doesn't trigger on next launch) Thanks. I tested the on-glasses prompt on real hardware and it worked as expected. Next up, let's port the flashing procedure itself. One detail of the flashing procedure worth noting: the two lenses get updated separately, and at the end of updating either lens, both lenses get rebooted, creating a brief period when neither is reachable, so the timeout to look for the second lens should not be too short.
157 lines
5.2 KiB
TypeScript
157 lines
5.2 KiB
TypeScript
import { Frame, Observable } from "@nativescript/core";
|
|
|
|
import { setOnboardingCompleted, setPreviewOnlyMode } from "./onboarding-state";
|
|
|
|
type OnboardingStep = 1 | 2 | 3;
|
|
|
|
type StepContent = {
|
|
headline: string;
|
|
tagline: string;
|
|
body: string;
|
|
primaryLabel: string;
|
|
secondaryLabel: string;
|
|
showLogo: boolean;
|
|
showTagline: boolean;
|
|
showSecondary: boolean;
|
|
};
|
|
|
|
const STEP_CONTENT: Record<OnboardingStep, StepContent> = {
|
|
1: {
|
|
headline: "Faceclaw",
|
|
tagline: "Perching on the faces of giants",
|
|
body: "",
|
|
primaryLabel: "Next",
|
|
secondaryLabel: "",
|
|
showLogo: true,
|
|
showTagline: true,
|
|
showSecondary: false,
|
|
},
|
|
2: {
|
|
headline: "Before You Continue",
|
|
tagline: "",
|
|
body:
|
|
"This unofficial 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 my headset, this is not Even's fault and is not covered by the hardware's warranty. If this software doesn't break my headset, using this software may void the hardware's warranty anyways, at the sole discretion of Even Realities. This software is a development prototype and may not be relied on for anything important. This software may be broken at any time by software or firmware updates created by Even, and this will not be Even's fault.",
|
|
primaryLabel: "Agree",
|
|
secondaryLabel: "Back",
|
|
showLogo: false,
|
|
showTagline: false,
|
|
showSecondary: true,
|
|
},
|
|
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. This connects to your glasses, asks for confirmation on the lens, then downloads and prepares the firmware.\n\nFlashing replaces the official firmware. It may void your warranty and, like any firmware update, carries a risk of bricking the device. You can only be connected to one app at a time, so disconnect the official Even app before flashing (open it, go to Home, select your glasses, open Connection, and press Disconnect).",
|
|
primaryLabel: "Flash Firmware",
|
|
secondaryLabel: "Preview Only",
|
|
showLogo: false,
|
|
showTagline: false,
|
|
showSecondary: true,
|
|
},
|
|
};
|
|
|
|
export class OnboardingViewModel extends Observable {
|
|
private _step: OnboardingStep = 1;
|
|
|
|
constructor() {
|
|
super();
|
|
this.publish();
|
|
}
|
|
|
|
onPrimaryTap(): void {
|
|
if (this._step === 1) {
|
|
this.setStep(2);
|
|
return;
|
|
}
|
|
if (this._step === 2) {
|
|
this.setStep(3);
|
|
return;
|
|
}
|
|
// Step 3 primary: proceed to the flashing flow (connect + on-glasses
|
|
// confirmation + firmware download/patch/verify).
|
|
Frame.topmost()?.navigate({
|
|
moduleName: "phone-ui/onboarding-flash-page",
|
|
});
|
|
}
|
|
|
|
onSecondaryTap(): void {
|
|
if (this._step === 2) {
|
|
this.setStep(1);
|
|
return;
|
|
}
|
|
if (this._step === 3) {
|
|
// Step 3 secondary: skip flashing, use the on-phone preview only.
|
|
setPreviewOnlyMode(true);
|
|
setOnboardingCompleted(true);
|
|
Frame.topmost()?.navigate({
|
|
moduleName: "phone-ui/main-page",
|
|
clearHistory: true,
|
|
});
|
|
}
|
|
}
|
|
|
|
get headline(): string {
|
|
return STEP_CONTENT[this._step].headline;
|
|
}
|
|
|
|
get tagline(): string {
|
|
return STEP_CONTENT[this._step].tagline;
|
|
}
|
|
|
|
get body(): string {
|
|
return STEP_CONTENT[this._step].body;
|
|
}
|
|
|
|
get primaryLabel(): string {
|
|
return STEP_CONTENT[this._step].primaryLabel;
|
|
}
|
|
|
|
get secondaryLabel(): string {
|
|
return STEP_CONTENT[this._step].secondaryLabel;
|
|
}
|
|
|
|
get showLogo(): boolean {
|
|
return STEP_CONTENT[this._step].showLogo;
|
|
}
|
|
|
|
get showTagline(): boolean {
|
|
return STEP_CONTENT[this._step].showTagline;
|
|
}
|
|
|
|
get showSecondary(): boolean {
|
|
return STEP_CONTENT[this._step].showSecondary;
|
|
}
|
|
|
|
get logoVisibility(): "visible" | "collapse" {
|
|
return this.showLogo ? "visible" : "collapse";
|
|
}
|
|
|
|
get taglineVisibility(): "visible" | "collapse" {
|
|
return this.showTagline ? "visible" : "collapse";
|
|
}
|
|
|
|
get secondaryVisibility(): "visible" | "collapse" {
|
|
return this.showSecondary ? "visible" : "collapse";
|
|
}
|
|
|
|
private setStep(step: OnboardingStep): void {
|
|
if (this._step === step) return;
|
|
this._step = step;
|
|
this.publish();
|
|
}
|
|
|
|
private publish(): void {
|
|
this.notifyPropertyChange("headline", this.headline);
|
|
this.notifyPropertyChange("tagline", this.tagline);
|
|
this.notifyPropertyChange("body", this.body);
|
|
this.notifyPropertyChange("primaryLabel", this.primaryLabel);
|
|
this.notifyPropertyChange("secondaryLabel", this.secondaryLabel);
|
|
this.notifyPropertyChange("showLogo", this.showLogo);
|
|
this.notifyPropertyChange("showTagline", this.showTagline);
|
|
this.notifyPropertyChange("showSecondary", this.showSecondary);
|
|
this.notifyPropertyChange("logoVisibility", this.logoVisibility);
|
|
this.notifyPropertyChange("taglineVisibility", this.taglineVisibility);
|
|
this.notifyPropertyChange("secondaryVisibility", this.secondaryVisibility);
|
|
}
|
|
}
|