mirror of
https://git.undefined-dev.fr/Blendman974/faceclaw.git
synced 2026-11-19 21:03:09 +00:00
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
@@ -0,0 +1,242 @@
|
||||
package com.faceclaw.app;
|
||||
|
||||
import android.bluetooth.BluetoothGatt;
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
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
|
||||
* flash. Reuses FaceclawBleManager + BleProtocol; owns its own connection and
|
||||
* runs on a single worker thread. Shows nothing on the lens.
|
||||
*/
|
||||
public class FaceclawDeviceInfoProbe implements FaceclawBleListener {
|
||||
private static final String TAG = "FaceclawDeviceInfo";
|
||||
private static final int QUERY_TIMEOUT_MS = 4_000;
|
||||
|
||||
private final Context context;
|
||||
private final String rightAddress;
|
||||
private final FaceclawBleManager bleManager;
|
||||
private final Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
|
||||
private final Object lock = new Object();
|
||||
private int nextSeq = 0x40;
|
||||
private int nextMagic = 100;
|
||||
|
||||
private int awaitSid = -1;
|
||||
private int awaitMagic = -1;
|
||||
private byte[] awaitPb = null;
|
||||
private CountDownLatch awaitLatch = null;
|
||||
|
||||
private volatile FaceclawDeviceInfoProbeListener listener;
|
||||
private volatile Thread worker;
|
||||
private volatile boolean cancelled = false;
|
||||
|
||||
public FaceclawDeviceInfoProbe(Context context, String rightAddress) {
|
||||
this.context = context.getApplicationContext();
|
||||
this.rightAddress = rightAddress == null ? "" : rightAddress;
|
||||
this.bleManager = new FaceclawBleManager(this.context);
|
||||
this.bleManager.setListener(this);
|
||||
}
|
||||
|
||||
public void setListener(FaceclawDeviceInfoProbeListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
synchronized (lock) {
|
||||
if (worker != null) {
|
||||
return;
|
||||
}
|
||||
worker = new Thread(this::run, "faceclaw-device-info");
|
||||
worker.start();
|
||||
}
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
cancelled = true;
|
||||
Thread w = worker;
|
||||
if (w != null) {
|
||||
w.interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
public void close() {
|
||||
cancel();
|
||||
try {
|
||||
bleManager.close();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
private void run() {
|
||||
try {
|
||||
if (rightAddress.trim().isEmpty()) {
|
||||
emitError("No right-arm address configured.");
|
||||
return;
|
||||
}
|
||||
|
||||
emitState("connecting", "");
|
||||
connectArm(rightAddress);
|
||||
if (cancelled) {
|
||||
emitError("Cancelled.");
|
||||
return;
|
||||
}
|
||||
|
||||
emitState("querying", "");
|
||||
// Session prelude, then a settings/device-info read (both arms'
|
||||
// versions and the CFW capability string ride back in one response).
|
||||
if (writeAndAwaitAck(rightAddress, BleProtocol.PRELUDE_ACK_SID, BleProtocol.FLAG_REQUEST,
|
||||
BleProtocol.PRELUDE_ACK_MAGIC, BleProtocol.PRELUDE_F5872_PAYLOAD,
|
||||
ConnectionOptions.PRELUDE_TIMEOUT_MS) == null) {
|
||||
throw new IllegalStateException("session prelude not acked");
|
||||
}
|
||||
|
||||
int magic = allocMagic();
|
||||
byte[] ack = writeAndAwaitAck(rightAddress, BleProtocol.SID_UI_SETTING, BleProtocol.FLAG_REQUEST,
|
||||
magic, BleProtocol.buildSettingsQuery(magic), QUERY_TIMEOUT_MS);
|
||||
if (ack == null) {
|
||||
throw new IllegalStateException("no response to the device-info query");
|
||||
}
|
||||
|
||||
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);
|
||||
} catch (Exception e) {
|
||||
String message = cancelled ? "Cancelled." : (e.getMessage() == null ? e.toString() : e.getMessage());
|
||||
emitError(message);
|
||||
} finally {
|
||||
try {
|
||||
bleManager.close();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void connectArm(String address) {
|
||||
if (!bleManager.connect(address, ConnectionOptions.CONNECT_TIMEOUT_MS)) {
|
||||
throw new IllegalStateException("connect failed");
|
||||
}
|
||||
bleManager.requestConnectionPriority(address, BluetoothGatt.CONNECTION_PRIORITY_HIGH);
|
||||
bleManager.requestMtu(address, ConnectionOptions.DESIRED_MTU, ConnectionOptions.CONNECT_TIMEOUT_MS);
|
||||
if (!bleManager.discoverServices(address, ConnectionOptions.SERVICES_TIMEOUT_MS)) {
|
||||
throw new IllegalStateException("service discovery failed");
|
||||
}
|
||||
if (!bleManager.enableNotifications(address, BleProtocol.NOTIFY_CHAR_UUID, true, ConnectionOptions.DESCRIPTOR_TIMEOUT_MS)) {
|
||||
throw new IllegalStateException("could not subscribe to notifications");
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] writeAndAwaitAck(String address, int sid, int flag, int magic, byte[] payload, int timeoutMs)
|
||||
throws InterruptedException {
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
synchronized (lock) {
|
||||
awaitSid = sid;
|
||||
awaitMagic = magic;
|
||||
awaitPb = null;
|
||||
awaitLatch = latch;
|
||||
}
|
||||
int seq;
|
||||
synchronized (lock) {
|
||||
seq = nextSeq++ & 0xff;
|
||||
}
|
||||
List<byte[]> frames = BleProtocol.framePb(payload, sid, flag, seq);
|
||||
boolean written = bleManager.writeFrames(
|
||||
address, BleProtocol.WRITE_CHAR_UUID, frames, ConnectionOptions.WRITE_TYPE, ConnectionOptions.WRITE_TIMEOUT_MS);
|
||||
if (!written) {
|
||||
synchronized (lock) {
|
||||
awaitLatch = null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
boolean acked = latch.await(timeoutMs, TimeUnit.MILLISECONDS);
|
||||
synchronized (lock) {
|
||||
awaitLatch = null;
|
||||
return acked ? awaitPb : null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNotification(String address, String characteristicUuid, byte[] data) {
|
||||
if (!BleProtocol.NOTIFY_CHAR_UUID.equalsIgnoreCase(characteristicUuid)) {
|
||||
return;
|
||||
}
|
||||
BleProtocol.ParsedFrame frame = BleProtocol.parseFrame(data);
|
||||
if (!frame.ok) {
|
||||
return;
|
||||
}
|
||||
if (frame.flag == BleProtocol.FLAG_NOTIFY || frame.flag == BleProtocol.FLAG_NOTIFY_ALT) {
|
||||
return; // async event, not an ack
|
||||
}
|
||||
synchronized (lock) {
|
||||
if (awaitLatch != null && frame.sid == awaitSid && frame.msgSeq == awaitMagic) {
|
||||
awaitPb = frame.pb;
|
||||
awaitLatch.countDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectionStateChange(String address, boolean connected) {
|
||||
if (!connected) {
|
||||
Log.i(TAG, "disconnected: " + address);
|
||||
}
|
||||
}
|
||||
|
||||
private int allocMagic() {
|
||||
synchronized (lock) {
|
||||
int magic = nextMagic;
|
||||
nextMagic = nextMagic >= 255 ? 100 : nextMagic + 1;
|
||||
return magic;
|
||||
}
|
||||
}
|
||||
|
||||
private void emitLog(String line) {
|
||||
Log.i(TAG, line);
|
||||
mainHandler.post(() -> {
|
||||
FaceclawDeviceInfoProbeListener current = listener;
|
||||
if (current != null) {
|
||||
current.onLog(line);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void emitState(String state, String detail) {
|
||||
final String safeDetail = detail == null ? "" : detail;
|
||||
mainHandler.post(() -> {
|
||||
FaceclawDeviceInfoProbeListener current = listener;
|
||||
if (current != null) {
|
||||
current.onState(state, safeDetail);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void emitResult(String left, String right, String caps) {
|
||||
mainHandler.post(() -> {
|
||||
FaceclawDeviceInfoProbeListener current = listener;
|
||||
if (current != null) {
|
||||
current.onResult(left, right, caps);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void emitError(String message) {
|
||||
final String safeMessage = message == null ? "" : message;
|
||||
mainHandler.post(() -> {
|
||||
FaceclawDeviceInfoProbeListener current = listener;
|
||||
if (current != null) {
|
||||
current.onError(safeMessage);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package com.faceclaw.app;
|
||||
|
||||
/** Callbacks from FaceclawDeviceInfoProbe to the TypeScript layer. */
|
||||
public interface FaceclawDeviceInfoProbeListener {
|
||||
void onLog(String line);
|
||||
|
||||
/** 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 failure (couldn't connect or read the version). */
|
||||
void onError(String message);
|
||||
}
|
||||
@@ -4,10 +4,10 @@ This is an unofficial user interface for the Even Realities G2 smart glasses.
|
||||
It is entirely unofficial, and comes with no support or warranty from Even
|
||||
Realities or from anyone.
|
||||
|
||||
To use it, you uninstall or unpair the official Even Realities app, then
|
||||
install the custom firmware from from https://github.com/jimrandomh/g2flash,
|
||||
then install this app on the same phone. Faceclaw is not compatible with the
|
||||
stock firmware due to limitations in how the stock firmware handles images.
|
||||
This app runs on Android, and requires installing custom firmware on the
|
||||
glasses. The Android app itself can install and uninstall the custom firmware;
|
||||
it downloads the stock firmware from Even and applies patches generated from
|
||||
https://github.com/jimrandomh/g2flash.
|
||||
|
||||
THIS IS AN UNFINISHED DEVELOPMENT PROTOTYPE; IF YOU DON'T HAVE ANY PROGRAMMING
|
||||
EXPERIENCE, OR YOU AREN'T COMFORTABLE EDITING, COMPILING, AND SIDELOADING AN
|
||||
|
||||
+44
-12
@@ -16,7 +16,8 @@ import { CFW_PATCH_SET, FirmwarePatchOp } from "./firmware/cfw-patches";
|
||||
declare const com: any;
|
||||
|
||||
const FIRMWARE_URL = "https://cdn.evenreal.co/firmware/a6966d807634cc97aec641a0dcca358b.bin";
|
||||
const OUTPUT_FILENAME = "g2_2.2.4.34_cfw.bin";
|
||||
const CFW_OUTPUT_FILENAME = "g2_2.2.4.34_cfw.bin";
|
||||
const STOCK_OUTPUT_FILENAME = "g2_2.2.4.34.bin";
|
||||
|
||||
export type FirmwareProgress =
|
||||
| { phase: "downloading" }
|
||||
@@ -50,16 +51,7 @@ export async function buildCustomFirmware(
|
||||
}
|
||||
};
|
||||
|
||||
report({ phase: "downloading" });
|
||||
const base = await downloadFirmware();
|
||||
|
||||
report({ phase: "verifying-base" });
|
||||
const baseSha = sha256Hex(base);
|
||||
if (baseSha !== CFW_PATCH_SET.baseSha256) {
|
||||
throw new FirmwareBuildError(
|
||||
`Downloaded stock firmware failed verification.\nexpected ${CFW_PATCH_SET.baseSha256}\ngot ${baseSha}`,
|
||||
);
|
||||
}
|
||||
const base = await downloadAndVerifyBase(report);
|
||||
|
||||
const patched = applyPatches(new Uint8Array(base), CFW_PATCH_SET.patches, (applied, total) =>
|
||||
report({ phase: "patching", applied, total }),
|
||||
@@ -75,13 +67,53 @@ export async function buildCustomFirmware(
|
||||
}
|
||||
|
||||
report({ phase: "writing" });
|
||||
const path = `${knownFolders.documents().path}/${OUTPUT_FILENAME}`;
|
||||
const path = `${knownFolders.documents().path}/${CFW_OUTPUT_FILENAME}`;
|
||||
writeFile(path, outBuffer);
|
||||
|
||||
report({ phase: "done", path, bytes: patched.length });
|
||||
return { path, bytes: patched.length, sha256: outSha };
|
||||
}
|
||||
|
||||
/**
|
||||
* Download and verify the unmodified stock firmware (no patches applied) and
|
||||
* persist it. Used to un-install the custom firmware by reflashing the original
|
||||
* image the CFW was built from.
|
||||
*/
|
||||
export async function buildStockFirmware(
|
||||
onProgress?: (progress: FirmwareProgress) => void,
|
||||
): Promise<BuiltFirmware> {
|
||||
const report = (progress: FirmwareProgress) => {
|
||||
try {
|
||||
onProgress?.(progress);
|
||||
} catch {
|
||||
// progress reporting must never break the build
|
||||
}
|
||||
};
|
||||
|
||||
const base = await downloadAndVerifyBase(report);
|
||||
|
||||
report({ phase: "writing" });
|
||||
const path = `${knownFolders.documents().path}/${STOCK_OUTPUT_FILENAME}`;
|
||||
writeFile(path, base);
|
||||
|
||||
report({ phase: "done", path, bytes: base.byteLength });
|
||||
return { path, bytes: base.byteLength, sha256: CFW_PATCH_SET.baseSha256 };
|
||||
}
|
||||
|
||||
async function downloadAndVerifyBase(report: (progress: FirmwareProgress) => void): Promise<ArrayBuffer> {
|
||||
report({ phase: "downloading" });
|
||||
const base = await downloadFirmware();
|
||||
|
||||
report({ phase: "verifying-base" });
|
||||
const baseSha = sha256Hex(base);
|
||||
if (baseSha !== CFW_PATCH_SET.baseSha256) {
|
||||
throw new FirmwareBuildError(
|
||||
`Downloaded stock firmware failed verification.\nexpected ${CFW_PATCH_SET.baseSha256}\ngot ${baseSha}`,
|
||||
);
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
async function downloadFirmware(): Promise<ArrayBuffer> {
|
||||
let response: Response;
|
||||
try {
|
||||
|
||||
@@ -10,6 +10,12 @@ import { type FirmwareInfo } from "../native/faceclaw-communicator";
|
||||
const MIN_FIRMWARE_VERSION = [2, 2, 4, 34];
|
||||
const REQUIRED_FIRMWARE_EXTENSION = "imgz";
|
||||
|
||||
// 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
|
||||
// unrecognized (its layout may differ from what our patch set targets).
|
||||
export const FLASHABLE_STOCK_VERSION = [2, 2, 4, 34];
|
||||
export const FLASHABLE_STOCK_VERSION_TEXT = FLASHABLE_STOCK_VERSION.join(".");
|
||||
|
||||
function parseDottedVersion(version: string): number[] {
|
||||
return version
|
||||
.trim()
|
||||
@@ -60,3 +66,41 @@ export function firmwareIncompatibilityMessage(info: FirmwareInfo): string | nul
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/** True when the glasses advertise Faceclaw's custom-firmware image extension. */
|
||||
export function hasCustomFirmware(info: FirmwareInfo): boolean {
|
||||
return info.capabilities.trim().split(/\s+/).includes(REQUIRED_FIRMWARE_EXTENSION);
|
||||
}
|
||||
|
||||
/** The higher of the two arms' reported versions, or "" if none reported. */
|
||||
export function reportedFirmwareVersion(info: FirmwareInfo): string {
|
||||
const versions = [info.leftVersion, info.rightVersion].map((v) => v.trim()).filter(Boolean);
|
||||
if (versions.length === 0) return "";
|
||||
return versions.reduce((highest, current) =>
|
||||
compareVersions(parseDottedVersion(current), parseDottedVersion(highest)) > 0 ? current : highest,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* How the pre-flash firmware check should treat the connected glasses:
|
||||
* - "custom": Faceclaw's firmware is already installed — nothing to flash.
|
||||
* - "flashable-stock": stock firmware at or below the version we build from.
|
||||
* - "newer-stock": 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" | "unknown";
|
||||
|
||||
export function classifyOnboardingFirmware(info: FirmwareInfo): {
|
||||
kind: OnboardingFirmwareKind;
|
||||
version: string;
|
||||
} {
|
||||
if (hasCustomFirmware(info)) {
|
||||
return { kind: "custom", version: reportedFirmwareVersion(info) };
|
||||
}
|
||||
const version = reportedFirmwareVersion(info);
|
||||
if (!version) {
|
||||
return { kind: "unknown", version: "" };
|
||||
}
|
||||
const comparison = compareVersions(parseDottedVersion(version), FLASHABLE_STOCK_VERSION);
|
||||
return { kind: comparison <= 0 ? "flashable-stock" : "newer-stock", version };
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
import { Utils } from "@nativescript/core";
|
||||
|
||||
declare const com: any;
|
||||
|
||||
export type DeviceInfo = {
|
||||
leftVersion: string;
|
||||
rightVersion: string;
|
||||
capabilities: string;
|
||||
};
|
||||
|
||||
export type DeviceInfoState = "connecting" | "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.
|
||||
*/
|
||||
export class DeviceInfoProbe {
|
||||
private readonly probe: any;
|
||||
private readonly listenerProxy: any;
|
||||
private readonly logListeners = new Set<(line: string) => void>();
|
||||
private readonly stateListeners = new Set<(state: DeviceInfoState, detail: string) => void>();
|
||||
|
||||
private settled = false;
|
||||
private resolveFn: ((info: DeviceInfo) => void) | null = null;
|
||||
private rejectFn: ((error: Error) => void) | null = null;
|
||||
|
||||
constructor(rightAddress: string) {
|
||||
const context = Utils.android.getApplicationContext();
|
||||
if (!context) throw new Error("Android application context unavailable");
|
||||
|
||||
this.probe = new com.faceclaw.app.FaceclawDeviceInfoProbe(context, rightAddress);
|
||||
this.listenerProxy = new com.faceclaw.app.FaceclawDeviceInfoProbeListener({
|
||||
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) =>
|
||||
this.settle(null, {
|
||||
leftVersion: String(leftVersion),
|
||||
rightVersion: String(rightVersion),
|
||||
capabilities: String(capabilities),
|
||||
}),
|
||||
onError: (message: string) => this.settle(new Error(String(message)), null),
|
||||
});
|
||||
this.probe.setListener(this.listenerProxy);
|
||||
}
|
||||
|
||||
onLog(listener: (line: string) => void): () => void {
|
||||
this.logListeners.add(listener);
|
||||
return () => this.logListeners.delete(listener);
|
||||
}
|
||||
|
||||
onStateChange(listener: (state: DeviceInfoState, detail: string) => void): () => void {
|
||||
this.stateListeners.add(listener);
|
||||
return () => this.stateListeners.delete(listener);
|
||||
}
|
||||
|
||||
run(): Promise<DeviceInfo> {
|
||||
return new Promise<DeviceInfo>((resolve, reject) => {
|
||||
this.resolveFn = resolve;
|
||||
this.rejectFn = reject;
|
||||
this.probe.start();
|
||||
});
|
||||
}
|
||||
|
||||
cancel(): void {
|
||||
try {
|
||||
this.probe.cancel();
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
close(): void {
|
||||
try {
|
||||
this.probe.close();
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
private settle(error: Error | null, info: DeviceInfo | null): void {
|
||||
if (this.settled) return;
|
||||
this.settled = true;
|
||||
this.close();
|
||||
if (error) {
|
||||
this.rejectFn?.(error);
|
||||
} else if (info) {
|
||||
this.resolveFn?.(info);
|
||||
}
|
||||
}
|
||||
|
||||
private emit<A extends unknown[]>(listeners: Set<(...args: A) => void>, ...args: A): void {
|
||||
const snapshot = Array.from(listeners);
|
||||
setTimeout(() => {
|
||||
for (const listener of snapshot) {
|
||||
listener(...args);
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
@@ -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