forked from Blendman974/faceclaw
Detect custom firmware during onboarding; add uninstall option
This commit is contained in:
1 parent
cb78841a9d
commit
ea80d05607
20 files changed
+917
-46
No files matched your search
@@ -1,8 +1,13 @@
|
||||
import { EventData, Page } from "@nativescript/core";
|
||||
import { NavigatedData, Page } from "@nativescript/core";
|
||||
|
||||
import { ConfigViewModel } from "./config-view-model";
|
||||
|
||||
export function navigatingTo(args: EventData): void {
|
||||
export function navigatingTo(args: NavigatedData): void {
|
||||
const page = args.object as Page;
|
||||
page.bindingContext = new ConfigViewModel();
|
||||
// Preserve the model across back-navigation (returning from the unpair page)
|
||||
// so the onboarding "Continue" flow isn't lost.
|
||||
if (!page.bindingContext) {
|
||||
const context = (args.context as { onboarding?: boolean } | undefined) ?? undefined;
|
||||
page.bindingContext = new ConfigViewModel({ onboarding: context?.onboarding ?? false });
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@
|
||||
<Label row="5" text="{{ status }}" class="m-t-16" textWrap="true" />
|
||||
|
||||
<GridLayout row="6" columns="*,*" class="m-t-16">
|
||||
<Button col="0" text="Save" tap="{{ onSaveTap }}" class="-primary" />
|
||||
<Button col="0" text="{{ saveLabel }}" tap="{{ onSaveTap }}" class="-primary" />
|
||||
<Button col="1" text="Back" tap="{{ onBackTap }}" />
|
||||
</GridLayout>
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ type TextChangeArgs = { value?: string; object?: { text?: string } };
|
||||
|
||||
export class ConfigViewModel extends Observable {
|
||||
private readonly discovery = new DeviceDiscoveryBridge();
|
||||
private readonly onboarding: boolean;
|
||||
private _rightAddress = "";
|
||||
private _leftAddress = "";
|
||||
private _ringAddress = "";
|
||||
@@ -15,13 +16,20 @@ export class ConfigViewModel extends Observable {
|
||||
private _discoveryLog = "";
|
||||
private _discovering = false;
|
||||
|
||||
constructor() {
|
||||
constructor(options?: { onboarding?: boolean }) {
|
||||
super();
|
||||
this.onboarding = options?.onboarding ?? false;
|
||||
const stored = loadDeviceAddresses();
|
||||
this.rightAddress = stored.right;
|
||||
this.leftAddress = stored.left;
|
||||
this.ringAddress = stored.ring;
|
||||
this.status = "Edit addresses manually, or load them from paired devices or a scan.";
|
||||
this.status = this.onboarding
|
||||
? "Load the addresses from the glasses you paired with the official Even app, or scan / enter them, then Continue."
|
||||
: "Edit addresses manually, or load them from paired devices or a scan.";
|
||||
}
|
||||
|
||||
get saveLabel(): string {
|
||||
return this.onboarding ? "Continue" : "Save";
|
||||
}
|
||||
|
||||
get rightAddress(): string {
|
||||
@@ -111,6 +119,15 @@ export class ConfigViewModel extends Observable {
|
||||
}
|
||||
|
||||
onBackTap(): void {
|
||||
if (this.onboarding) {
|
||||
const frame = Frame.topmost();
|
||||
if (frame?.canGoBack()) {
|
||||
frame.goBack();
|
||||
return;
|
||||
}
|
||||
frame?.navigate({ moduleName: "phone-ui/onboarding-page", clearHistory: true });
|
||||
return;
|
||||
}
|
||||
Frame.topmost()?.navigate({
|
||||
moduleName: "phone-ui/main-page",
|
||||
clearHistory: true,
|
||||
@@ -118,28 +135,39 @@ export class ConfigViewModel extends Observable {
|
||||
}
|
||||
|
||||
onSaveTap(): void {
|
||||
if (!this.saveAddresses()) {
|
||||
return;
|
||||
}
|
||||
if (this.onboarding) {
|
||||
// Continue the onboarding chain: unpair the official app next.
|
||||
Frame.topmost()?.navigate({ moduleName: "phone-ui/onboarding-unpair-page" });
|
||||
}
|
||||
}
|
||||
|
||||
private saveAddresses(): boolean {
|
||||
const right = normalizeMacAddress(this.rightAddress);
|
||||
const left = normalizeMacAddress(this.leftAddress);
|
||||
const ring = normalizeMacAddress(this.ringAddress);
|
||||
|
||||
if (!isValidMacAddress(right)) {
|
||||
this.status = "Right arm MAC address is invalid.";
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
if (!isValidMacAddress(left)) {
|
||||
this.status = "Left arm MAC address is invalid.";
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
if (!isValidMacAddress(ring, true)) {
|
||||
this.status = "Ring MAC address is invalid.";
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
saveDeviceAddresses({ right, left, ring });
|
||||
this.rightAddress = right;
|
||||
this.leftAddress = left;
|
||||
this.ringAddress = ring;
|
||||
this.status = "Saved device addresses.";
|
||||
this.status = this.onboarding ? "Saved. Continuing..." : "Saved device addresses.";
|
||||
return true;
|
||||
}
|
||||
|
||||
private async populateFromDiscovery(
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<ActionBar title="Faceclaw">
|
||||
<ActionItem text="{{ buttonLabel }}" tap="{{ onTap }}" isEnabled="{{ canRun }}" android.position="popup" />
|
||||
<ActionItem text="Configure devices" tap="{{ onConfigureTap }}" isEnabled="{{ canRun }}" android.position="popup" />
|
||||
<ActionItem text="Uninstall custom firmware" tap="{{ onUninstallFirmwareTap }}" isEnabled="{{ canRun }}" android.position="popup" />
|
||||
<ActionItem text="{{ showLogMenuLabel }}" tap="{{ onToggleLogTap }}" android.position="popup" />
|
||||
</ActionBar>
|
||||
|
||||
@@ -16,7 +17,10 @@
|
||||
<Label text="{{ evenAppConflictMessage }}" textWrap="true" />
|
||||
<Button text="Open Even app settings" tap="{{ onOpenEvenAppSettingsTap }}" class="-primary" />
|
||||
</StackLayout>
|
||||
<Label text="{{ firmwareWarningMessage }}" textWrap="true" visibility="{{ firmwareWarningVisibility }}" />
|
||||
<StackLayout visibility="{{ firmwareWarningVisibility }}">
|
||||
<Label text="{{ firmwareWarningMessage }}" textWrap="true" />
|
||||
<Button text="Install custom firmware" tap="{{ onInstallFirmwareTap }}" class="-primary" />
|
||||
</StackLayout>
|
||||
<StackLayout visibility="{{ batteryOptimizationWarningVisibility }}">
|
||||
<Label text="Android will slow Faceclaw to a crawl when the phone screen is off unless it is exempt from battery optimization." textWrap="true" />
|
||||
<Button text="Allow unrestricted background usage" tap="{{ onAllowBackgroundUsageTap }}" class="-primary" />
|
||||
|
||||
@@ -332,6 +332,29 @@ export class MainViewModel extends Observable {
|
||||
Frame.topmost()?.navigate("phone-ui/config-page");
|
||||
}
|
||||
|
||||
async onInstallFirmwareTap(): Promise<void> {
|
||||
await this.openFlashPage("install");
|
||||
}
|
||||
|
||||
async onUninstallFirmwareTap(): Promise<void> {
|
||||
await this.openFlashPage("uninstall");
|
||||
}
|
||||
|
||||
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") {
|
||||
try {
|
||||
await dashboardController.disconnect();
|
||||
} catch {
|
||||
// proceed anyway; the flash page surfaces any connection trouble
|
||||
}
|
||||
}
|
||||
Frame.topmost()?.navigate({
|
||||
moduleName: "phone-ui/onboarding-flash-page",
|
||||
context: { mode, fromOnboarding: false },
|
||||
});
|
||||
}
|
||||
|
||||
onToggleLogTap(): void {
|
||||
this.showLog = !this.showLog;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import { EventData, Page } from "@nativescript/core";
|
||||
|
||||
import { OnboardingFirmwareCheckViewModel } from "./onboarding-firmware-check-view-model";
|
||||
|
||||
export function navigatingTo(args: EventData): void {
|
||||
const page = args.object as Page;
|
||||
if (!page.bindingContext) {
|
||||
page.bindingContext = new OnboardingFirmwareCheckViewModel();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" actionBarHidden="true">
|
||||
<GridLayout rows="*,auto" class="p-20">
|
||||
<ScrollView row="0">
|
||||
<StackLayout>
|
||||
<Label text="{{ headline }}" class="h1 text-center m-t-24" textWrap="true" />
|
||||
<ActivityIndicator busy="{{ busy }}" visibility="{{ busyVisibility }}" class="m-t-16" />
|
||||
<Label text="{{ status }}" class="m-t-16 text-center" textWrap="true" />
|
||||
</StackLayout>
|
||||
</ScrollView>
|
||||
|
||||
<GridLayout row="1" columns="*,*" class="m-t-20">
|
||||
<Button col="0" text="{{ secondaryLabel }}" tap="{{ onSecondaryTap }}" visibility="{{ secondaryVisibility }}" />
|
||||
<Button col="1" text="{{ primaryLabel }}" tap="{{ onPrimaryTap }}" visibility="{{ primaryVisibility }}" class="-primary" />
|
||||
</GridLayout>
|
||||
</GridLayout>
|
||||
</Page>
|
||||
@@ -0,0 +1,254 @@
|
||||
import { Frame, Observable } from "@nativescript/core";
|
||||
|
||||
import { ensureBlePermissions } from "../g2/android-permissions";
|
||||
import { isValidMacAddress, loadDeviceAddresses } from "../g2/device-addresses";
|
||||
import { classifyOnboardingFirmware, FLASHABLE_STOCK_VERSION_TEXT } from "../g2/firmware-compat";
|
||||
import { DeviceInfoProbe, DeviceInfoState } from "../native/device-info-probe";
|
||||
import { setOnboardingCompleted, setPreviewOnlyMode } from "./onboarding-state";
|
||||
|
||||
type CheckPhase = "checking" | "custom" | "flashable" | "newer" | "error";
|
||||
|
||||
export class OnboardingFirmwareCheckViewModel extends Observable {
|
||||
private _phase: CheckPhase = "checking";
|
||||
private _headline = "Checking Firmware";
|
||||
private _status = "";
|
||||
private _busy = true;
|
||||
|
||||
private probeInstance: DeviceInfoProbe | null = null;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
void this.check();
|
||||
}
|
||||
|
||||
// --- observable properties -------------------------------------------------
|
||||
|
||||
get headline(): string {
|
||||
return this._headline;
|
||||
}
|
||||
|
||||
set headline(value: string) {
|
||||
if (this._headline !== value) {
|
||||
this._headline = value;
|
||||
this.notifyPropertyChange("headline", value);
|
||||
}
|
||||
}
|
||||
|
||||
get status(): string {
|
||||
return this._status;
|
||||
}
|
||||
|
||||
set status(value: string) {
|
||||
if (this._status !== value) {
|
||||
this._status = value;
|
||||
this.notifyPropertyChange("status", value);
|
||||
}
|
||||
}
|
||||
|
||||
get busy(): boolean {
|
||||
return this._busy;
|
||||
}
|
||||
|
||||
set busy(value: boolean) {
|
||||
if (this._busy !== value) {
|
||||
this._busy = value;
|
||||
this.notifyPropertyChange("busy", value);
|
||||
this.notifyPropertyChange("busyVisibility", this.busyVisibility);
|
||||
}
|
||||
}
|
||||
|
||||
get busyVisibility(): "visible" | "collapse" {
|
||||
return this._busy ? "visible" : "collapse";
|
||||
}
|
||||
|
||||
get primaryLabel(): string {
|
||||
switch (this._phase) {
|
||||
case "custom":
|
||||
return "Finish";
|
||||
case "flashable":
|
||||
return "Install Firmware";
|
||||
case "newer":
|
||||
return "Proceed Anyway";
|
||||
case "error":
|
||||
return "Retry";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
get secondaryLabel(): string {
|
||||
return "Back";
|
||||
}
|
||||
|
||||
get primaryVisibility(): "visible" | "collapse" {
|
||||
return this.primaryLabel ? "visible" : "collapse";
|
||||
}
|
||||
|
||||
get secondaryVisibility(): "visible" | "collapse" {
|
||||
// Once the custom firmware is confirmed present, Finish is the only action.
|
||||
return this._phase === "custom" ? "collapse" : "visible";
|
||||
}
|
||||
|
||||
// --- button handlers -------------------------------------------------------
|
||||
|
||||
onPrimaryTap(): void {
|
||||
switch (this._phase) {
|
||||
case "custom":
|
||||
this.finish();
|
||||
return;
|
||||
case "flashable":
|
||||
case "newer":
|
||||
this.goToFlashing();
|
||||
return;
|
||||
case "error":
|
||||
void this.check();
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
onSecondaryTap(): void {
|
||||
this.disposeProbe();
|
||||
const frame = Frame.topmost();
|
||||
if (frame?.canGoBack()) {
|
||||
frame.goBack();
|
||||
return;
|
||||
}
|
||||
frame?.navigate({ moduleName: "phone-ui/onboarding-unpair-page", clearHistory: true });
|
||||
}
|
||||
|
||||
// --- probe flow ------------------------------------------------------------
|
||||
|
||||
private async check(): Promise<void> {
|
||||
if (!global.isAndroid) {
|
||||
this.toError("Firmware checking is only available on Android.");
|
||||
return;
|
||||
}
|
||||
this.setPhase("checking");
|
||||
this.headline = "Checking Firmware";
|
||||
this.busy = true;
|
||||
this.status = "Connecting to your glasses to read their firmware version...";
|
||||
|
||||
try {
|
||||
await ensureBlePermissions();
|
||||
const stored = loadDeviceAddresses();
|
||||
if (!isValidMacAddress(stored.right)) {
|
||||
this.toError("No glasses address is configured. Go back and set the device addresses.");
|
||||
return;
|
||||
}
|
||||
|
||||
this.disposeProbe();
|
||||
const probe = new DeviceInfoProbe(stored.right);
|
||||
this.probeInstance = probe;
|
||||
probe.onStateChange((state) => this.reportProbeState(state));
|
||||
|
||||
const info = await probe.run();
|
||||
this.probeInstance = null;
|
||||
|
||||
const { kind, version } = classifyOnboardingFirmware(info);
|
||||
this.applyClassification(kind, version, info.capabilities.trim());
|
||||
} catch (error) {
|
||||
this.probeInstance = null;
|
||||
this.toError(this.formatError(error));
|
||||
}
|
||||
}
|
||||
|
||||
private reportProbeState(state: DeviceInfoState): void {
|
||||
if (state === "connecting") {
|
||||
this.status = "Connecting to your glasses...";
|
||||
} else if (state === "querying") {
|
||||
this.status = "Reading the firmware version...";
|
||||
}
|
||||
}
|
||||
|
||||
private applyClassification(kind: string, version: string, capabilities: string): void {
|
||||
this.busy = false;
|
||||
switch (kind) {
|
||||
case "custom":
|
||||
this.setPhase("custom");
|
||||
this.headline = "Custom Firmware Detected";
|
||||
this.status =
|
||||
`Your glasses already run Faceclaw's custom firmware${version ? ` (version ${version})` : ""}` +
|
||||
`${capabilities ? `, extensions: ${capabilities}` : ""}. No flashing needed — you're all set.`;
|
||||
break;
|
||||
case "flashable":
|
||||
this.setPhase("flashable");
|
||||
this.headline = "Ready to Install";
|
||||
this.status =
|
||||
`Your glasses run stock firmware ${version}. This is compatible — tap Install Firmware to flash ` +
|
||||
"Faceclaw's custom firmware.";
|
||||
break;
|
||||
case "newer":
|
||||
this.setPhase("newer");
|
||||
this.headline = "Unrecognized Firmware";
|
||||
this.status =
|
||||
`Your glasses run stock firmware ${version}, which is newer than the ${FLASHABLE_STOCK_VERSION_TEXT} ` +
|
||||
"release Faceclaw's custom image is built from. Flashing may not work correctly and carries extra risk. " +
|
||||
"You can proceed anyway, or go back.";
|
||||
break;
|
||||
default:
|
||||
// "unknown" — connected but no version. Treat as a probe failure (hard block).
|
||||
this.toError(
|
||||
"Connected, but couldn't read a firmware version. Make sure the glasses are on and the Even app is " +
|
||||
"disconnected, then retry.",
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// --- terminal actions ------------------------------------------------------
|
||||
|
||||
private goToFlashing(): void {
|
||||
this.disposeProbe();
|
||||
Frame.topmost()?.navigate({
|
||||
moduleName: "phone-ui/onboarding-flash-page",
|
||||
context: { mode: "install", fromOnboarding: true },
|
||||
});
|
||||
}
|
||||
|
||||
private finish(): void {
|
||||
setPreviewOnlyMode(false);
|
||||
setOnboardingCompleted(true);
|
||||
this.disposeProbe();
|
||||
Frame.topmost()?.navigate({
|
||||
moduleName: "phone-ui/main-page",
|
||||
clearHistory: true,
|
||||
});
|
||||
}
|
||||
|
||||
private toError(message: string): void {
|
||||
this.disposeProbe();
|
||||
this.busy = false;
|
||||
this.status = message;
|
||||
this.setPhase("error");
|
||||
this.headline = "Couldn't Check Firmware";
|
||||
}
|
||||
|
||||
private setPhase(phase: CheckPhase): void {
|
||||
if (this._phase !== phase) {
|
||||
this._phase = phase;
|
||||
this.notifyPropertyChange("phase", phase);
|
||||
}
|
||||
this.notifyPropertyChange("primaryLabel", this.primaryLabel);
|
||||
this.notifyPropertyChange("secondaryLabel", this.secondaryLabel);
|
||||
this.notifyPropertyChange("primaryVisibility", this.primaryVisibility);
|
||||
this.notifyPropertyChange("secondaryVisibility", this.secondaryVisibility);
|
||||
}
|
||||
|
||||
private disposeProbe(): void {
|
||||
if (this.probeInstance) {
|
||||
try {
|
||||
this.probeInstance.close();
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
this.probeInstance = null;
|
||||
}
|
||||
}
|
||||
|
||||
private formatError(error: unknown): string {
|
||||
const raw = (error as Error)?.message ?? String(error);
|
||||
return raw.replace(/[\x00-\x1f]+/g, " ").replace(/\s+/g, " ").trim();
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,14 @@
|
||||
import { EventData, Page } from "@nativescript/core";
|
||||
import { NavigatedData, Page } from "@nativescript/core";
|
||||
|
||||
import { OnboardingFlashViewModel } from "./onboarding-flash-view-model";
|
||||
import { FlashMode, OnboardingFlashViewModel } from "./onboarding-flash-view-model";
|
||||
|
||||
export function navigatingTo(args: EventData): void {
|
||||
export function navigatingTo(args: NavigatedData): void {
|
||||
const page = args.object as Page;
|
||||
if (!page.bindingContext) {
|
||||
page.bindingContext = new OnboardingFlashViewModel();
|
||||
const context = (args.context as { mode?: FlashMode; fromOnboarding?: boolean } | undefined) ?? undefined;
|
||||
page.bindingContext = new OnboardingFlashViewModel({
|
||||
mode: context?.mode ?? "install",
|
||||
fromOnboarding: context?.fromOnboarding ?? true,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
} from "../g2/device-addresses";
|
||||
import {
|
||||
buildCustomFirmware,
|
||||
buildStockFirmware,
|
||||
FirmwareBuildError,
|
||||
FirmwareProgress,
|
||||
} from "../g2/firmware-builder";
|
||||
@@ -18,11 +19,12 @@ import { setOnboardingCompleted, setPreviewOnlyMode } from "./onboarding-state";
|
||||
|
||||
type FlashPhase = "intro" | "prompt" | "building" | "ready" | "flashing" | "flashed" | "error";
|
||||
|
||||
// Kept short to fit the glasses' ~50-column text grid.
|
||||
const GLASSES_WARNING =
|
||||
"Flashing custom firmware may void your warranty and can brick the glasses. Continue?";
|
||||
export type FlashMode = "install" | "uninstall";
|
||||
|
||||
export class OnboardingFlashViewModel extends Observable {
|
||||
private readonly mode: FlashMode;
|
||||
private readonly fromOnboarding: boolean;
|
||||
|
||||
private _phase: FlashPhase = "intro";
|
||||
private _headline = "Flash Custom Firmware";
|
||||
private _status = "";
|
||||
@@ -40,6 +42,30 @@ export class OnboardingFlashViewModel extends Observable {
|
||||
private flasherUnsubscribers: Array<() => void> = [];
|
||||
private retryAction: () => void = () => this.beginPrompt();
|
||||
|
||||
constructor(options?: { mode?: FlashMode; fromOnboarding?: boolean }) {
|
||||
super();
|
||||
this.mode = options?.mode ?? "install";
|
||||
this.fromOnboarding = options?.fromOnboarding ?? true;
|
||||
this._headline = this.mode === "uninstall" ? "Uninstall Custom Firmware" : "Flash Custom Firmware";
|
||||
this._status =
|
||||
this.mode === "uninstall"
|
||||
? "This connects to your glasses, asks for confirmation on the lens, then downloads and reflashes the " +
|
||||
"official firmware — removing Faceclaw's custom features."
|
||||
: "This connects to your glasses, asks for confirmation on the lens, then downloads, verifies, and flashes " +
|
||||
"Faceclaw's custom firmware.";
|
||||
}
|
||||
|
||||
// Kept short to fit the glasses' ~50-column text grid.
|
||||
private get glassesWarning(): string {
|
||||
return this.mode === "uninstall"
|
||||
? "Reinstalling the official firmware removes Faceclaw's custom features. Continue?"
|
||||
: "Flashing custom firmware will void your warranty and carries some risk of bricking the glasses. Continue?";
|
||||
}
|
||||
|
||||
private get noun(): string {
|
||||
return this.mode === "uninstall" ? "official firmware" : "custom firmware";
|
||||
}
|
||||
|
||||
// --- observable properties -------------------------------------------------
|
||||
|
||||
get phase(): FlashPhase {
|
||||
@@ -221,7 +247,7 @@ export class OnboardingFlashViewModel extends Observable {
|
||||
|
||||
private startCommunicator(addresses: { right: string; left: string }): void {
|
||||
this.disposePrompt();
|
||||
const prompt = new FlashPromptCommunicator(addresses, GLASSES_WARNING);
|
||||
const prompt = new FlashPromptCommunicator(addresses, this.glassesWarning);
|
||||
this.prompt = prompt;
|
||||
|
||||
this.promptUnsubscribers.push(
|
||||
@@ -297,13 +323,14 @@ export class OnboardingFlashViewModel extends Observable {
|
||||
this.status = "Confirmed. Downloading the stock firmware...";
|
||||
|
||||
try {
|
||||
const result = await buildCustomFirmware((progress) => this.reportBuildProgress(progress));
|
||||
const build = this.mode === "uninstall" ? buildStockFirmware : buildCustomFirmware;
|
||||
const result = await build((progress) => this.reportBuildProgress(progress));
|
||||
this.firmwarePath = result.path;
|
||||
this.busy = false;
|
||||
this.setPhase("ready");
|
||||
this.headline = "Firmware Ready";
|
||||
this.status =
|
||||
`Custom firmware prepared and verified (${result.bytes.toLocaleString()} bytes).\n\n` +
|
||||
`The ${this.noun} is prepared and verified (${result.bytes.toLocaleString()} bytes).\n\n` +
|
||||
"Tap Flash Now to write it to your glasses. Keep both lenses powered on and nearby — " +
|
||||
"each lens takes a few minutes, and the glasses will reboot when each lens finishes. " +
|
||||
"Do not close the app during flashing.";
|
||||
@@ -404,7 +431,11 @@ export class OnboardingFlashViewModel extends Observable {
|
||||
this.progress = 100;
|
||||
this.setPhase("flashed");
|
||||
this.headline = "All Done";
|
||||
this.status = detail || "Firmware installed. Your glasses are rebooting into Faceclaw's custom firmware.";
|
||||
this.status =
|
||||
detail ||
|
||||
(this.mode === "uninstall"
|
||||
? "Official firmware reinstalled. Your glasses are rebooting into the stock firmware."
|
||||
: "Firmware installed. Your glasses are rebooting into Faceclaw's custom firmware.");
|
||||
return;
|
||||
}
|
||||
this.toError(detail || "Flashing failed.", () => this.startFlashing());
|
||||
@@ -429,8 +460,12 @@ export class OnboardingFlashViewModel extends Observable {
|
||||
}
|
||||
|
||||
private finish(): void {
|
||||
setPreviewOnlyMode(false);
|
||||
setOnboardingCompleted(true);
|
||||
if (this.mode === "install") {
|
||||
// Reaching the app via a successful install completes onboarding and
|
||||
// clears preview-only. (Idempotent when already past onboarding.)
|
||||
setPreviewOnlyMode(false);
|
||||
setOnboardingCompleted(true);
|
||||
}
|
||||
this.disposePrompt();
|
||||
this.disposeFlasher();
|
||||
Frame.topmost()?.navigate({
|
||||
@@ -443,11 +478,14 @@ export class OnboardingFlashViewModel extends Observable {
|
||||
this.disposePrompt();
|
||||
this.disposeFlasher();
|
||||
const frame = Frame.topmost();
|
||||
if (frame?.canGoBack()) {
|
||||
if (this.fromOnboarding && frame?.canGoBack()) {
|
||||
frame.goBack();
|
||||
} else {
|
||||
frame?.navigate({ moduleName: "phone-ui/onboarding-page", clearHistory: true });
|
||||
return;
|
||||
}
|
||||
frame?.navigate({
|
||||
moduleName: this.fromOnboarding ? "phone-ui/onboarding-page" : "phone-ui/main-page",
|
||||
clearHistory: true,
|
||||
});
|
||||
}
|
||||
|
||||
private toError(message: string, retry: () => void): void {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import { EventData, Page } from "@nativescript/core";
|
||||
|
||||
import { OnboardingUnpairViewModel } from "./onboarding-unpair-view-model";
|
||||
|
||||
export function navigatingTo(args: EventData): void {
|
||||
const page = args.object as Page;
|
||||
if (!page.bindingContext) {
|
||||
page.bindingContext = new OnboardingUnpairViewModel();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" actionBarHidden="true">
|
||||
<GridLayout rows="*,auto" class="p-20">
|
||||
<ScrollView row="0">
|
||||
<StackLayout>
|
||||
<Label text="Disconnect the Even App" class="h1 text-center m-t-24" textWrap="true" />
|
||||
<Label
|
||||
text="Faceclaw and the official Even Realities app can't both be connected to the glasses at once. Before continuing, open the Even app, go to Home, select your glasses, open the Connection submenu, and press Disconnect (or turn off the Even app's Bluetooth)."
|
||||
class="m-t-24" textWrap="true" />
|
||||
<Button text="Open Even App Settings" tap="{{ onOpenEvenAppSettingsTap }}" class="-primary m-t-24" />
|
||||
</StackLayout>
|
||||
</ScrollView>
|
||||
|
||||
<GridLayout row="1" columns="*,*" class="m-t-20">
|
||||
<Button col="0" text="Back" tap="{{ onBackTap }}" />
|
||||
<Button col="1" text="Continue" tap="{{ onContinueTap }}" class="-primary" />
|
||||
</GridLayout>
|
||||
</GridLayout>
|
||||
</Page>
|
||||
@@ -0,0 +1,26 @@
|
||||
import { Frame, Observable } from "@nativescript/core";
|
||||
|
||||
import { openEvenAppSettings } from "../native/even-app-conflict";
|
||||
|
||||
export class OnboardingUnpairViewModel extends Observable {
|
||||
onOpenEvenAppSettingsTap(): void {
|
||||
openEvenAppSettings();
|
||||
}
|
||||
|
||||
onContinueTap(): void {
|
||||
Frame.topmost()?.navigate({ moduleName: "phone-ui/onboarding-firmware-check-page" });
|
||||
}
|
||||
|
||||
onBackTap(): void {
|
||||
const frame = Frame.topmost();
|
||||
if (frame?.canGoBack()) {
|
||||
frame.goBack();
|
||||
return;
|
||||
}
|
||||
frame?.navigate({
|
||||
moduleName: "phone-ui/config-page",
|
||||
context: { onboarding: true },
|
||||
clearHistory: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -67,10 +67,11 @@ export class OnboardingViewModel extends Observable {
|
||||
this.setStep(3);
|
||||
return;
|
||||
}
|
||||
// Step 3 primary: proceed to the flashing flow (connect + on-glasses
|
||||
// confirmation + firmware download/patch/verify).
|
||||
// Step 3 primary: begin the flashing setup — configure device addresses,
|
||||
// then unpair the official app, then check firmware and flash.
|
||||
Frame.topmost()?.navigate({
|
||||
moduleName: "phone-ui/onboarding-flash-page",
|
||||
moduleName: "phone-ui/config-page",
|
||||
context: { onboarding: true },
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user