forked from Blendman974/faceclaw
Merge upstream main preserving custom feature integrations
This commit is contained in:
commit
6150a1ac57
228 files changed
+16844
-1388
No files matched your search
@@ -152,8 +152,10 @@ export class AncsClient {
|
||||
if (flags & 2) {
|
||||
const data = new Uint8Array(this.fragments); this.fragments = []; this.packetKind = -1
|
||||
if (kind === 0) {
|
||||
if (data.length !== 1 || data[0] > 2) { this.recover(); return true }
|
||||
if (data.length !== 1 || data[0] > 3) { this.recover(); return true }
|
||||
if (data[0] === 2) { this.recover('Glasses reported a notification relay error. Retrying…'); return true }
|
||||
// Only a G1's firmware looks for ANCS itself, so only it can say the phone isn't offering it.
|
||||
if (data[0] === 3) { this.recover('iPhone is not sharing notifications with the glasses. Enable Share System Notifications in Settings → Bluetooth → right arm. Retrying…'); return true }
|
||||
if (data[0] === 0) { this.resetReceived = true; this.log('Glasses accepted notification relay START; awaiting subscription') }
|
||||
if (data[0] === 1) {
|
||||
if (this.timer !== null) clearTimeout(this.timer)
|
||||
|
||||
+1
-14
@@ -27,7 +27,7 @@
|
||||
*
|
||||
* It is **not** a measurement. A hand over the temple, a pocket, or a body
|
||||
* between phone and glasses moves the estimate by metres. The wearer therefore
|
||||
* only ever sees a coarse zone (glyph + label), never a number in metres they
|
||||
* only ever sees a coarse zone (a signal-strength glyph), never a number in metres they
|
||||
* might over-trust; the metres value exists purely to rank and bucket.
|
||||
*
|
||||
* This module is pure (no NativeScript imports) so it can run under node tests.
|
||||
@@ -75,19 +75,6 @@ export function zoneFromMeters(meters: number): ProximityZone {
|
||||
return "distant";
|
||||
}
|
||||
|
||||
export function zoneLabel(zone: ProximityZone): string {
|
||||
switch (zone) {
|
||||
case "immediate":
|
||||
return "In your hand";
|
||||
case "near":
|
||||
return "Nearby";
|
||||
case "far":
|
||||
return "Across the room";
|
||||
case "distant":
|
||||
return "Far away";
|
||||
}
|
||||
}
|
||||
|
||||
/** A glyph for the zone; SF Symbols have no Android equivalent, so plain text. */
|
||||
export function zoneGlyph(zone: ProximityZone): string {
|
||||
switch (zone) {
|
||||
|
||||
@@ -1,5 +1,18 @@
|
||||
export const DEFAULT_BRIGHTNESS_CURVE = "0:0,0.2:7,1.5:33,5:100";
|
||||
const PREVIOUS_DEFAULT_CURVE = "0:0,1:10,10:30,100:65,1000:100";
|
||||
/**
|
||||
* The RayNeo iO's sensor reads real lux, far above the G2's behind-the-lens values, so the
|
||||
* G2's curve would sit at maximum in any lit room. These knots put the default 20–100 range on
|
||||
* the stock firmware's own scene levels: 29, 41, 41, 53, 65, 76, 94 and 100 percent at 3, 10,
|
||||
* 200, 300, 600, 1000, 4000 and 5000 lux.
|
||||
*/
|
||||
export const RAYNEO_IO_BRIGHTNESS_CURVE = "0:0,3:11,10:26,200:26,300:41,600:56,1000:70,4000:93,5000:100";
|
||||
|
||||
/**
|
||||
* An Even G1's OPT3007 also reads lux (centilux on the wire). These knots are the stock firmware's table: levels 0, 10, 25,
|
||||
* 41 and 42 of 42 at 0, 50, 200, 1000 and 2000 lux (g1_firmware/docs/VM.md §6.7).
|
||||
*/
|
||||
export const G1_BRIGHTNESS_CURVE = "0:0,50:24,200:60,1000:98,2000:100";
|
||||
|
||||
/** Percent of the configured range; defaults (20–100) give 20/26/46/100. */
|
||||
export function brightnessCurveError(value: string): string | null {
|
||||
|
||||
@@ -16,7 +16,6 @@ import { mediaControllerBridge } from "../native/media-controller";
|
||||
import { nightscoutBridge } from "../native/nightscout-bridge";
|
||||
import { weatherBridge } from "../native/weather";
|
||||
import { ALL_NOTIFICATIONS, onAndroidNotificationPosted, onAndroidNotificationRemoved, readActiveNotifications } from "../native/notification-icons";
|
||||
import { shouldShowNotificationOnGlasses } from "../native/notification-sources";
|
||||
import { watchNotificationListenerBinding } from "../native/notification-access";
|
||||
import { openEvenAppSettings, readEvenAppNotificationState } from "../native/even-app-conflict";
|
||||
import { defaultRingName, setGlassesRingLink } from "../native/ring-status";
|
||||
@@ -56,7 +55,7 @@ import { claimGlassesOnboardingAutoLaunch, ONBOARDING_APP_ID } from "../apps/onb
|
||||
import { beginRenderPass, endRenderPass } from "../util/render-freshness";
|
||||
import { voiceControlBridge } from "../native/voice-control";
|
||||
import { voiceActivity } from "../ui/shell/voice-activity";
|
||||
import { G2_LENS_HEIGHT, G2_LENS_WIDTH, GrayImage } from "../graphics/image";
|
||||
import { GrayImage } from "../graphics/image";
|
||||
import { flattenPlanesWithDraws, planesFingerprint, type Plane } from "../graphics/plane";
|
||||
import { prepareFrameDraws } from "../graphics/glyph-wire";
|
||||
import { createLockScreenImage, LOCK_SCREEN_SURFACE_ID } from "./lock-screen";
|
||||
@@ -75,10 +74,10 @@ import { ALL_APPS } from "../apps/all-apps";
|
||||
import { type AppContext, type AppDefinition, type AppLaunchParams, type TextEditorHost } from "../apps/app-definition";
|
||||
import { type InProcessAppOptions, type InProcessWindow } from "../ui/shell/in-process-window";
|
||||
import { loadPersistedOpenApps, savePersistedOpenApps } from "../ui/shell/open-apps-persistence";
|
||||
import { appViewportRect, isOnSwitcherEdge, sidebarStripVisible, type ScreenRect, type WindowHeightMode } from "../ui/shell/geometry";
|
||||
import { appViewportRect, isOnSwitcherEdge, screenHeight, screenWidth, sidebarStripVisible, type ScreenRect, type WindowHeightMode } from "../ui/shell/geometry";
|
||||
import { type ContinuousCaptureOptions, type LayerActions, type TextSettingsEditToggle, type TranscriptionChoice } from "../ui/layers";
|
||||
import { type KeyboardInputSession } from "../ui/shell/keyboard-input";
|
||||
import { appSwitcherPositionSetting, statusBarPositionSetting, statusBarVisibilitySetting, windowBorderSetting, assistantAllowProactiveSetting, assistantBackendSetting, assistantBridgeHostSetting, assistantBridgePortSetting, assistantBridgeTokenSetting, getBrightnessPreferences, getHeadUpPreferences, displayLayoutSetting, navigateDisplayLayoutSetting, terminalDisplayLayoutSetting, elevenLabsApiKeySetting, getStringSettingById, openAiApiKeySetting, openAiTranscriptionModelSetting, nightscoutApiTokenSetting, firmwareDebugFlagsSetting, whisperServerApiKeySetting, getVoiceTranscriptionLanguage, whisperServerModelSetting, whisperServerUrlSetting, lockScreenEnabledSetting, nightscoutSiteUrlSetting, onAnySettingChanged, previewColorSetting, ringConnectionModeSetting, type RingConnectionMode, saveVoiceRecordingsSetting, sonioxApiKeySetting, screenTimeoutSetting, screenTimeoutSettingToMs, suspendEvenHubWhenScreenOffSetting, voiceProviderSetting, wakeWordActionSetting, type ConfigSettingString } from "../ui/dashboard-settings";
|
||||
import { appSwitcherPositionSetting, glassesModelName, glassesTypeSetting, statusBarPositionSetting, statusBarVisibilitySetting, windowBorderSetting, assistantAllowProactiveSetting, assistantBackendSetting, assistantBridgeHostSetting, assistantBridgePortSetting, assistantBridgeTokenSetting, getBrightnessPreferences, getHeadUpPreferences, displayLayoutSetting, navigateDisplayLayoutSetting, terminalDisplayLayoutSetting, elevenLabsApiKeySetting, getStringSettingById, openAiApiKeySetting, openAiTranscriptionModelSetting, nightscoutApiTokenSetting, firmwareDebugFlagsSetting, whisperServerApiKeySetting, getVoiceTranscriptionLanguage, whisperServerModelSetting, whisperServerUrlSetting, lockScreenEnabledSetting, nightscoutSiteUrlSetting, onAnySettingChanged, previewColorSetting, effectiveRingConnectionMode, type RingConnectionMode, saveVoiceRecordingsSetting, sonioxApiKeySetting, screenTimeoutSetting, screenTimeoutSettingToMs, shouldPopUpNewNotification, suspendEvenHubWhenScreenOffSetting, voiceProviderSetting, wakeWordActionSetting, type ConfigSettingString } from "../ui/dashboard-settings";
|
||||
import { isIgnoringBatteryOptimizations, requestIgnoreBatteryOptimizations } from "../native/battery-optimization";
|
||||
import {
|
||||
getInstalledEvenHubAppById,
|
||||
@@ -196,12 +195,12 @@ const LOW_BATTERY_PERCENT = 5;
|
||||
const EVEN_APP_DETECTED_MESSAGE =
|
||||
"The Even Realities app appears to be running. If Faceclaw has trouble connecting, open its app settings and force stop it.";
|
||||
|
||||
// The launcher grid's app list; also fixes the app ids apps.launch accepts.
|
||||
const LAUNCHABLE_APPS = ALL_APPS.filter((app) => app.showInLauncher !== false);
|
||||
// The launcher grid's app list for the paired glasses; also fixes the app ids apps.launch accepts.
|
||||
const launchableApps = () => ALL_APPS.filter((app) => app.showInLauncher !== false && app.isSupported?.() !== false);
|
||||
|
||||
/**
|
||||
* The global settings window viewport sizes depend on: the display mode's
|
||||
* size (a band's position only moves windows), whether the app switcher
|
||||
* The global settings window viewport sizes depend on: the paired glasses'
|
||||
* screen, the display mode's size (a band's position only moves windows), whether the app switcher
|
||||
* takes width beside windows, height below them or neither (a popup), and
|
||||
* the chrome rows each window loses to it: below them, whether the status
|
||||
* bar joins the row (dropping the top bar); with a popup, whether the
|
||||
@@ -214,7 +213,7 @@ function viewportSizesKey(): string {
|
||||
: position === "popup" ? `popup|${statusBarVisibilitySetting.get()}|${windowBorderSetting.get()}`
|
||||
: "strip";
|
||||
const layout = displayLayoutSetting.get();
|
||||
return `${layout.startsWith("band-") ? "band" : layout}|${switcher}`;
|
||||
return `${screenWidth()}x${screenHeight()}|${layout.startsWith("band-") ? "band" : layout}|${switcher}`;
|
||||
}
|
||||
|
||||
/** The global settings that move window surfaces without resizing them. */
|
||||
@@ -223,7 +222,7 @@ function windowPlacementKey(): string {
|
||||
}
|
||||
|
||||
function createInitialDisplayPreview(): ImageSource | null {
|
||||
return grayImageToPreviewSource(new GrayImage(G2_LENS_WIDTH, G2_LENS_HEIGHT, 0));
|
||||
return grayImageToPreviewSource(new GrayImage(screenWidth(), screenHeight(), 0));
|
||||
}
|
||||
|
||||
/** Echo the controller's appendLog() trace to the console. */
|
||||
@@ -427,7 +426,7 @@ class DashboardController {
|
||||
registerRoamTools((appId) => this.launchApp(appId));
|
||||
// apps.* tools mirror the launcher grid and sidebar (launch, focus, close).
|
||||
registerWindowTools({
|
||||
apps: LAUNCHABLE_APPS,
|
||||
apps: launchableApps,
|
||||
launchApp: (appId) => this.launchApp(appId),
|
||||
requestShellRender: () => this.requestShellRender(),
|
||||
});
|
||||
@@ -454,7 +453,8 @@ class DashboardController {
|
||||
this.emit();
|
||||
},
|
||||
openNotificationsWindow: () =>
|
||||
this.openInProcessAppInBackground(NOTIFICATIONS_WINDOW_ID, NOTIFICATIONS_SURFACE_ID, createNotificationsAppWindow),
|
||||
this.openInProcessAppInBackground(NOTIFICATIONS_WINDOW_ID, NOTIFICATIONS_SURFACE_ID,
|
||||
(options) => createNotificationsAppWindow(options, (section) => this.openSettings(section))),
|
||||
onSwitcherBarHeightChanged: () => this.applySwitcherBarHeight(),
|
||||
onWindowLayoutChanged: () => this.applySwitcherBarHeight(),
|
||||
isLocked: () => this.glassesLocked,
|
||||
@@ -485,6 +485,7 @@ class DashboardController {
|
||||
this.pushBrightness();
|
||||
this.pushHeadUpPreferences();
|
||||
this.syncEvenHubScreenOffSetting();
|
||||
this.syncVoiceWake();
|
||||
// Display mode size first: a reflow repositions every surface too, so
|
||||
// the band-position check after it then has nothing left to do.
|
||||
this.applyDisplayModeIfChanged();
|
||||
@@ -514,7 +515,7 @@ class DashboardController {
|
||||
assistant: text => shell.sendToAssistant(text),
|
||||
});
|
||||
this.wearRemote = new WearRemote({
|
||||
apps: LAUNCHABLE_APPS,
|
||||
apps: launchableApps,
|
||||
injectInput: (kind) => this.injectSyntheticRingInput(kind, "watch"),
|
||||
launchApp: (appId) => this.launchApp(appId),
|
||||
connect: () => this.connect(),
|
||||
@@ -627,14 +628,28 @@ class DashboardController {
|
||||
* are. Windows that can't resize keep the surface they have, the switcher
|
||||
* covering any of it that it now overlaps, rather than being relaunched
|
||||
* for it.
|
||||
*
|
||||
* A window is judged by its own size as well as its surface's rect: other
|
||||
* paths (connect, a launch) configure surfaces from the geometry without
|
||||
* resizing windows, so a window laid out before the row's height was known
|
||||
* (restored at startup, at the default height) can sit behind a surface
|
||||
* that already matches, and its frames would not fit it.
|
||||
*/
|
||||
private applySwitcherBarHeight(): void {
|
||||
void (async () => {
|
||||
for (const window of Array.from(shell.getWindows())) {
|
||||
const rect = JSON.stringify(appViewportRect(window.heightMode, window.appId));
|
||||
if (!window.relayout || this.windowSurfaceRects.get(window.surfaceId) === rect) continue;
|
||||
window.relayout();
|
||||
await this.configureWindowSurface(window.surfaceId, this.isForegroundWindow(window.windowId), window.heightMode);
|
||||
if (!window.relayout) continue;
|
||||
const rect = appViewportRect(window.heightMode, window.appId);
|
||||
const size = window.layoutSize?.();
|
||||
const resized = !!size && (size.width !== rect.width || size.height !== rect.height);
|
||||
if (!resized && this.windowSurfaceRects.get(window.surfaceId) === JSON.stringify(rect)) continue;
|
||||
try {
|
||||
window.relayout();
|
||||
await this.configureWindowSurface(window.surfaceId, this.isForegroundWindow(window.windowId), window.heightMode);
|
||||
} catch (error) {
|
||||
// The rest still need to follow the row.
|
||||
this.appendLog(`switcher height change failed for ${window.windowId}: ${this.formatError(error)}`);
|
||||
}
|
||||
}
|
||||
shell.foregroundWindow()?.requestRender();
|
||||
this.requestShellRender();
|
||||
@@ -825,8 +840,8 @@ class DashboardController {
|
||||
await communicator.configureSurface(LOCK_SCREEN_SURFACE_ID, {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: G2_LENS_WIDTH,
|
||||
height: G2_LENS_HEIGHT,
|
||||
width: screenWidth(),
|
||||
height: screenHeight(),
|
||||
zOrder: 1000,
|
||||
transparency: "opaque",
|
||||
});
|
||||
@@ -934,6 +949,24 @@ class DashboardController {
|
||||
return applied;
|
||||
}
|
||||
|
||||
/** What the communicator was last told about the glasses' own wake word (null: not yet). */
|
||||
private voiceWakeSent: boolean | null = null;
|
||||
|
||||
/**
|
||||
* The glasses' own wake word follows the wake action: on a RayNeo iO, its
|
||||
* "Hey RayNeo" switch (G2 glasses use the wake lease, syncFaceclawWakeLease).
|
||||
*/
|
||||
private syncVoiceWake(communicator = this.communicator): void {
|
||||
if (!communicator) return;
|
||||
const enabled = wakeWordActionSetting.get() !== "off";
|
||||
if (this.voiceWakeSent === enabled) return;
|
||||
this.voiceWakeSent = enabled;
|
||||
void communicator.setVoiceWakeEnabled(enabled).catch((error) => {
|
||||
this.voiceWakeSent = null;
|
||||
this.appendLog(`wake word sync failed: ${this.formatError(error)}`);
|
||||
});
|
||||
}
|
||||
|
||||
private syncEvenHubScreenOffSetting(): void {
|
||||
void this.syncFaceclawWakeLease().catch((error) => {
|
||||
this.appendLog(`wake takeover lease sync failed: ${this.formatError(error)}`);
|
||||
@@ -1051,9 +1084,11 @@ class DashboardController {
|
||||
|
||||
/**
|
||||
* A Direct-mode session may have unpaired the R1 from the glasses (see
|
||||
* GlassesSessionRing.releaseRingFromGlassesLocked). The first session in
|
||||
* another mode asks the glasses to connect to it again; the ring's own
|
||||
* glasses targets were cleared, so it accepts them. Called on connect.
|
||||
* GlassesSessionRing.releaseRingFromGlassesLocked), and a RayNeo iO
|
||||
* session (always Direct) may have cleared the ring's glasses targets.
|
||||
* The first G2 session in another mode asks the glasses to connect to it
|
||||
* again; the ring's own glasses targets were cleared, so it accepts them.
|
||||
* Called on connect.
|
||||
*/
|
||||
private handRingBackToGlassesIfNeeded(): void {
|
||||
if (this.ringModeAtConnect === "direct" || !getBooleanSetting(RING_TAKEN_FROM_GLASSES_KEY, false)) return;
|
||||
@@ -1094,7 +1129,7 @@ class DashboardController {
|
||||
}
|
||||
|
||||
private pushHeadUpPreferences(force = false): void {
|
||||
if (!global.isAndroid || !this.communicator) return;
|
||||
if (!global.isAndroid || glassesTypeSetting.get() !== "g2" || !this.communicator) return;
|
||||
const { enabled, angle } = getHeadUpPreferences();
|
||||
if (enabled < 0 && angle < 0) return;
|
||||
const value = JSON.stringify({ enabled, angle });
|
||||
@@ -1292,6 +1327,7 @@ class DashboardController {
|
||||
silentMode: this.silentMode,
|
||||
screenOn: shell.isScreenOn(),
|
||||
battery: this.lastHeadsetBattery,
|
||||
glassesModel: glassesModelName(),
|
||||
caseBattery: batteries.case,
|
||||
caseCharging: batteries.caseCharging,
|
||||
foregroundTitle: shell.getForegroundApp()?.title ?? null,
|
||||
@@ -1464,12 +1500,12 @@ class DashboardController {
|
||||
// is in place before any real render can reach the compositor.
|
||||
this.previewTarget = target;
|
||||
try {
|
||||
await target.configureCompositorScreen(G2_LENS_WIDTH, G2_LENS_HEIGHT);
|
||||
await target.configureCompositorScreen(screenWidth(), screenHeight());
|
||||
await target.configureSurface(SHELL_SURFACE_ID, {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: G2_LENS_WIDTH,
|
||||
height: G2_LENS_HEIGHT,
|
||||
width: screenWidth(),
|
||||
height: screenHeight(),
|
||||
zOrder: SHELL_SURFACE_Z_ORDER,
|
||||
transparency: "color-key",
|
||||
});
|
||||
@@ -1552,17 +1588,21 @@ class DashboardController {
|
||||
this.refreshEvenAppStatus();
|
||||
this.setPhase("connecting");
|
||||
this.setStatus("Connecting to the glasses...");
|
||||
// "Only via glasses" (the default) means the phone never opens its own
|
||||
// link to the ring: the glasses relay its gestures to us anyway. An empty
|
||||
// address disables every direct-ring code path in the communicator.
|
||||
const ringMode = ringConnectionModeSetting.get();
|
||||
// "Only via glasses" (the G2's default) means the phone never opens its
|
||||
// own link to the ring: the glasses relay its gestures to us anyway. An
|
||||
// empty address disables every direct-ring code path in the communicator.
|
||||
// A RayNeo iO (one link, its address in both arm slots) can't relay a
|
||||
// ring, so with one the phone always takes the ring directly.
|
||||
const ringMode = effectiveRingConnectionMode();
|
||||
this.ringModeAtConnect = ringMode;
|
||||
const glassesType = glassesTypeSetting.get();
|
||||
const ringAddress = ringMode !== "glasses" ? addresses.ring : "";
|
||||
// Direct mode may unpair the ring from the glasses; remember to hand it
|
||||
// back once a later session runs in another mode.
|
||||
if (ringMode === "direct" && ringAddress) setBooleanSetting(RING_TAKEN_FROM_GLASSES_KEY, true);
|
||||
this.appendLog(
|
||||
`Using configured arms: R=${addresses.right} L=${addresses.left}${ringAddress ? ` ring=${ringAddress}` : ""}`,
|
||||
this.appendLog((glassesType === "rayneo-io"
|
||||
? `Using configured RayNeo iO: ${addresses.right}`
|
||||
: `Using configured arms: R=${addresses.right} L=${addresses.left}`) + (ringAddress ? ` ring=${ringAddress}` : ""),
|
||||
);
|
||||
|
||||
let communicator: FaceclawCommunicatorBridge | null = null;
|
||||
@@ -1584,6 +1624,7 @@ class DashboardController {
|
||||
// sync needs the phone role, which the session borrows briefly for
|
||||
// each pull (GlassesSessionRing.beginRingHealthWindowLocked).
|
||||
ringRole: ringMode === "direct" ? "glasses" : "phone",
|
||||
glassesType,
|
||||
});
|
||||
this.communicator = communicator;
|
||||
// Size the compositor before anything else is awaited: windows opened
|
||||
@@ -1591,9 +1632,12 @@ class DashboardController {
|
||||
// configure their surfaces through this.communicator, and the Java call
|
||||
// queue is FIFO, so enqueuing the screen size first guarantees it lands
|
||||
// ahead of them. Mirrors ensurePreviewDisplay.
|
||||
await communicator.configureCompositorScreen(G2_LENS_WIDTH, G2_LENS_HEIGHT);
|
||||
// The paired glasses' screen: the G2's 640x480 or the RayNeo iO's 540x220.
|
||||
await communicator.configureCompositorScreen(screenWidth(), screenHeight());
|
||||
await communicator.configureBrightness(getBrightnessPreferences());
|
||||
this.pushHeadUpPreferences(true);
|
||||
this.voiceWakeSent = null;
|
||||
this.syncVoiceWake(communicator);
|
||||
this.offState = communicator.onStateChange((state) => {
|
||||
if (state.phase !== "connected") resetRingInputFilter();
|
||||
if (isHaltedSessionPhase(state.phase)) {
|
||||
@@ -1784,8 +1828,8 @@ class DashboardController {
|
||||
await communicator.configureSurface(SHELL_SURFACE_ID, {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: G2_LENS_WIDTH,
|
||||
height: G2_LENS_HEIGHT,
|
||||
width: screenWidth(),
|
||||
height: screenHeight(),
|
||||
zOrder: SHELL_SURFACE_Z_ORDER,
|
||||
transparency: "color-key",
|
||||
});
|
||||
@@ -2092,8 +2136,8 @@ class DashboardController {
|
||||
return;
|
||||
}
|
||||
const at = mirrorToPanelFraction(this.displayPreviewCrop, nx, ny);
|
||||
const x = Math.round(Math.min(1, Math.max(0, at.nx)) * G2_LENS_WIDTH);
|
||||
const y = Math.round(Math.min(1, Math.max(0, at.ny)) * G2_LENS_HEIGHT);
|
||||
const x = Math.round(Math.min(1, Math.max(0, at.nx)) * screenWidth());
|
||||
const y = Math.round(Math.min(1, Math.max(0, at.ny)) * screenHeight());
|
||||
const foreground = shell.foregroundWindow();
|
||||
const stripShown = sidebarStripVisible(shell.getFocus(), foreground?.appId);
|
||||
this.appendLog(`mirror tap at ${x},${y}`);
|
||||
@@ -2661,11 +2705,7 @@ class DashboardController {
|
||||
setSurfaceVisible: (surfaceId, visible) => this.setWindowSurfaceVisible(surfaceId, visible),
|
||||
removeSurface: (surfaceId) => this.removeWindowSurface(surfaceId),
|
||||
requestShellRender: () => this.requestShellRender(),
|
||||
openSettings: (section) => {
|
||||
void this.launchApp("settings", { section }).catch((error) => {
|
||||
this.appendLog(`settings launch failed: ${this.formatError(error)}`);
|
||||
});
|
||||
},
|
||||
openSettings: (section) => this.openSettings(section),
|
||||
startTextSettingEdit: (settingId) => {
|
||||
const setting = getStringSettingById(settingId);
|
||||
if (setting) {
|
||||
@@ -2749,6 +2789,13 @@ class DashboardController {
|
||||
this.requestShellRender();
|
||||
}
|
||||
|
||||
/** Open or focus the Settings app, optionally on a section (by label). */
|
||||
private openSettings(section?: string): void {
|
||||
void this.launchApp("settings", { section }).catch((error) => {
|
||||
this.appendLog(`settings launch failed: ${this.formatError(error)}`);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Launch an app by id: the launcher grid, assistant tools, window-menu
|
||||
* Settings item, and open-apps restore all come through here. Apps with an
|
||||
@@ -2965,7 +3012,7 @@ class DashboardController {
|
||||
// The tray shows the notification at once; its popup waits out a short
|
||||
// delay, so one withdrawn right away (see NotificationPopupDelay) never shows.
|
||||
const notification = readActiveNotifications(ALL_NOTIFICATIONS).find((item) => item.key === notificationKey);
|
||||
if (notification && shouldShowNotificationOnGlasses(notification.packageName)) {
|
||||
if (notification && shouldPopUpNewNotification(notification.packageName)) {
|
||||
this.notificationPopups.post(notificationKey, notificationPopupDelayMs(notification));
|
||||
}
|
||||
this.requestShellRender();
|
||||
@@ -2987,7 +3034,7 @@ class DashboardController {
|
||||
private popUpAndroidNotification(notificationKey: string): void {
|
||||
try {
|
||||
const notification = readActiveNotifications(ALL_NOTIFICATIONS).find((item) => item.key === notificationKey);
|
||||
if (!notification || !shouldShowNotificationOnGlasses(notification.packageName)) return;
|
||||
if (!notification || !shouldPopUpNewNotification(notification.packageName)) return;
|
||||
// New notifications open a shell modal over the app viewport; if the
|
||||
// screen was off, wake for it and go back to sleep when it is closed.
|
||||
// Waking while already on would steal focus, so only wake from sleep.
|
||||
|
||||
@@ -30,7 +30,10 @@ export { bytesToHex, hexToBytes };
|
||||
/** Even Realities' manufacturer-data company identifier (`"ER"` read little-endian). */
|
||||
export const EVEN_COMPANY_IDENTIFIER = 0x5245;
|
||||
|
||||
export type EvenDeviceRole = "left" | "right" | "ring";
|
||||
export type EvenDeviceRole = "left" | "right" | "ring" | "rayneo-io";
|
||||
|
||||
/** The firmware an Even G1 arm advertises: Even's, or Faceclaw's g1v0 (in safe mode: only updates work). */
|
||||
export type G1Firmware = "stock" | "g1v0" | "g1v0-safe";
|
||||
|
||||
/** True when the manufacturer data opens with Even's `"ER"` marker. */
|
||||
export function hasEvenManufacturerSignature(mfg: Uint8Array): boolean {
|
||||
@@ -71,6 +74,61 @@ export function extractG2AdvertisementFlag(mfg: Uint8Array): number | null {
|
||||
return mfg[22]!;
|
||||
}
|
||||
|
||||
/**
|
||||
* ## Even G1 arm
|
||||
*
|
||||
* On Even's firmware the name is `Even G1_<token>_<L|R>_<hex6>` and the manufacturer data `[01 right | 02 left]` +
|
||||
* the ASCII serial, zero-padded (the first two bytes read as a "company id" that differs per arm). On g1v0 the name
|
||||
* is `G1CFW_<L|R>_<hex6>` with the same digits and address as stock's, and the scan response holds company 0xFFFF, a
|
||||
* format byte (2), a flags byte (bit 3: safe mode), the firmware's version in three bytes, and the pair ID in ASCII:
|
||||
* the frame serial, the same on both arms. Before 0.5.66: `G1v0_L` or `G1v0_R` (`G1v0S_…` in safe mode), format 1, no
|
||||
* version.
|
||||
*/
|
||||
export function g1FromName(name: string | null | undefined): { side: "left" | "right"; firmware: G1Firmware } | null {
|
||||
if (!name) return null;
|
||||
const custom = /^G1CFW_([LR])_[0-9A-F]{6}$/i.exec(name.trim());
|
||||
if (custom) return { side: custom[1]!.toUpperCase() === "L" ? "left" : "right", firmware: "g1v0" };
|
||||
const g1v0 = /^G1V0(S?)_([LR])$/i.exec(name.trim());
|
||||
if (g1v0) {
|
||||
return {
|
||||
side: g1v0[2]!.toUpperCase() === "L" ? "left" : "right",
|
||||
firmware: g1v0[1] ? "g1v0-safe" : "g1v0",
|
||||
};
|
||||
}
|
||||
if (!/^EVEN G1_/i.test(name.trim())) return null;
|
||||
const side = g2SideFromName(name);
|
||||
return side ? { side, firmware: "stock" } : null;
|
||||
}
|
||||
|
||||
/** What g1v0's pair record says beyond the serial; null when there is no record of a format that says it. */
|
||||
export function parseG1Record(mfg: Uint8Array): { version: string; safeMode: boolean } | null {
|
||||
if (mfg.length < 7 || mfg[0] !== 0xff || mfg[1] !== 0xff || mfg[2] !== 2) return null;
|
||||
return { version: `${mfg[4]}.${mfg[5]}.${mfg[6]}`, safeMode: (mfg[3]! & 8) !== 0 };
|
||||
}
|
||||
|
||||
/** The pair's serial from an arm's manufacturer data, on either firmware; null when absent. */
|
||||
export function extractG1Serial(mfg: Uint8Array, firmware: G1Firmware): string | null {
|
||||
const record = mfg.length >= 4 && mfg[0] === 0xff && mfg[1] === 0xff;
|
||||
const start = firmware === "stock" ? 1 : record && mfg[2] === 2 ? 7 : record && mfg[2] === 1 ? 4 : -1;
|
||||
if (start < 0 || mfg.length <= start) return null;
|
||||
let serial = "";
|
||||
for (let i = start; i < mfg.length; i++) {
|
||||
const byte = mfg[i]!;
|
||||
if (byte === 0) break;
|
||||
if (byte < 0x20 || byte > 0x7e) return null;
|
||||
serial += String.fromCharCode(byte);
|
||||
}
|
||||
return serial.length ? serial : null;
|
||||
}
|
||||
|
||||
/** RayNeo iO manufacturer data (company 0x5716, little-endian first): `[07][MAC x6]...`, outside pairing mode. */
|
||||
export const RAYNEO_COMPANY_IDENTIFIER = 0x5716;
|
||||
|
||||
export function extractRayNeoMac(mfg: Uint8Array): string | null {
|
||||
if (mfg.length < 9 || mfg[0] !== 0x16 || mfg[1] !== 0x57 || mfg[2] !== 0x07) return null;
|
||||
return Array.from(mfg.subarray(3, 9), (byte) => byte.toString(16).padStart(2, "0").toUpperCase()).join(":");
|
||||
}
|
||||
|
||||
/**
|
||||
* Which side a G2 temple advertisement belongs to, from the local name.
|
||||
* Null when the name carries neither or both markers.
|
||||
@@ -210,6 +268,10 @@ export type EvenAdvertisement = {
|
||||
manufacturerData: string;
|
||||
/** Why an otherwise Even-looking advertisement could not be fully parsed. */
|
||||
note: string | null;
|
||||
/** Set on an Even G1 arm (role left or right): its firmware. */
|
||||
g1Firmware?: G1Firmware;
|
||||
/** The version g1v0 advertises (0.5.66+); absent when it doesn't say. */
|
||||
g1Version?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -230,8 +292,58 @@ export function classifyAdvertisement(raw: RawAdvertisement): EvenAdvertisement
|
||||
const hasSignature = hasEvenManufacturerSignature(mfg);
|
||||
const looksLikeRing = /^EVEN R1([_ ]|$)/.test(upper);
|
||||
const looksLikeG2 = upper.includes("G2");
|
||||
const rayneoMac = extractRayNeoMac(mfg);
|
||||
const looksLikeRayNeo = upper.startsWith("RAYNEO") || rayneoMac !== null;
|
||||
|
||||
if (!looksLikeRing && !looksLikeG2 && !hasSignature) return null;
|
||||
const g1 = g1FromName(name);
|
||||
if (g1) {
|
||||
const serial = extractG1Serial(mfg, g1.firmware);
|
||||
const record = g1.firmware === "stock" ? null : parseG1Record(mfg);
|
||||
return {
|
||||
address: normalizeMacAddress(raw.address),
|
||||
name,
|
||||
role: g1.side,
|
||||
serial,
|
||||
embeddedMac: null,
|
||||
embeddedMacMismatch: false,
|
||||
flag: null,
|
||||
ringSerialSuffix: null,
|
||||
rssi: raw.rssi,
|
||||
txPower: raw.txPower,
|
||||
connectable: raw.connectable,
|
||||
bonded: raw.bonded,
|
||||
source: raw.source,
|
||||
seenAtMs: raw.seenAtMs,
|
||||
manufacturerData: raw.manufacturerData ?? "",
|
||||
note: serial ? null : "no serial in the advertisement (it may still be arriving)",
|
||||
g1Firmware: record?.safeMode ? "g1v0-safe" : g1.firmware,
|
||||
...(record ? { g1Version: record.version } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
if (!looksLikeRing && !looksLikeG2 && !hasSignature && !looksLikeRayNeo) return null;
|
||||
|
||||
if (looksLikeRayNeo && !hasSignature) {
|
||||
const address = normalizeMacAddress(raw.address);
|
||||
return {
|
||||
address,
|
||||
name,
|
||||
role: "rayneo-io",
|
||||
serial: null,
|
||||
embeddedMac: rayneoMac,
|
||||
embeddedMacMismatch: !!rayneoMac && rayneoMac !== address,
|
||||
flag: null,
|
||||
ringSerialSuffix: null,
|
||||
rssi: raw.rssi,
|
||||
txPower: raw.txPower,
|
||||
connectable: raw.connectable,
|
||||
bonded: raw.bonded,
|
||||
source: raw.source,
|
||||
seenAtMs: raw.seenAtMs,
|
||||
manufacturerData: raw.manufacturerData ?? "",
|
||||
note: null,
|
||||
};
|
||||
}
|
||||
|
||||
const base = {
|
||||
address: normalizeMacAddress(raw.address),
|
||||
|
||||
@@ -117,6 +117,11 @@ export function firmwareIncompatibilityMessage(info: FirmwareInfo): string | nul
|
||||
const versionsText = `L=${info.leftVersion || "unknown"} R=${info.rightVersion || "unknown"}`;
|
||||
const required = `Faceclaw firmware revision ${REQUIRED_FACECLAW_FIRMWARE_VERSION}`;
|
||||
|
||||
// A G1's session names what the arms run instead of a revision (GlassesSessionG1.kt).
|
||||
if (extension.kind === "none" && reportedVersions.some((version) => /^(g1v0|Even's firmware)/.test(version))) {
|
||||
return `These G1 glasses run ${versionsText}. This version of Faceclaw needs the firmware it comes with: install it to continue.`;
|
||||
}
|
||||
|
||||
switch (extension.kind) {
|
||||
case "faceclaw":
|
||||
if (extension.version >= REQUIRED_FACECLAW_FIRMWARE_VERSION) return null;
|
||||
|
||||
@@ -3,6 +3,8 @@ export type GlassesDisplayState = {
|
||||
silentMode: boolean;
|
||||
screenOn: boolean;
|
||||
battery: number | null;
|
||||
/** The paired glasses' model, e.g. "G2" (glassesModelName). */
|
||||
glassesModel: string;
|
||||
/**
|
||||
* The charging case's last-known level, and whether it is on USB (null
|
||||
* while the glasses are out of the case). Shown only while charging, when
|
||||
@@ -20,7 +22,7 @@ export function glassesDisplayLabel(state: GlassesDisplayState): string {
|
||||
// Charging wins over every session-local state: the glasses are in their
|
||||
// case, so neither the lock screen nor the foreground window is visible.
|
||||
if (state.phase === "charging") {
|
||||
return chargingDisplayLabel(state.battery);
|
||||
return chargingDisplayLabel(state.battery, state.glassesModel);
|
||||
}
|
||||
// Preview mode has a live (simulated) screen despite the disconnected
|
||||
// phase, so fall through to the screen-state/foreground labels.
|
||||
@@ -63,8 +65,8 @@ export function glassesDisplayAsleep(state: GlassesDisplayState): boolean {
|
||||
);
|
||||
}
|
||||
|
||||
export function chargingDisplayLabel(battery: number | null): string {
|
||||
return validBatteryLevel(battery) ? `Charging · G2 ${battery}%` : "Charging";
|
||||
export function chargingDisplayLabel(battery: number | null, glassesModel: string): string {
|
||||
return validBatteryLevel(battery) ? `Charging: ${glassesModel} ${battery}%` : "Charging";
|
||||
}
|
||||
|
||||
/** The shell's last-known battery levels (ShellChromeState["battery"]), as far as the phone shows them. */
|
||||
@@ -81,13 +83,13 @@ export type BatteryLevels = {
|
||||
* The phone Settings tab's battery row: each device whose level is known,
|
||||
* e.g. "G2 100% · Case 98% ⚡ · R1 72%" (⚡ = charging), or "" when none
|
||||
* is. Levels are the last known ones (the case only reports while the glasses
|
||||
* are docked), so ⚡ appears only while it is live: G2 and Case only with a
|
||||
* link to the glasses (`glassesLinked`: connected or charging), and Case only
|
||||
* while they are docked (caseCharging is null otherwise).
|
||||
* are docked), so ⚡ appears only while it is live: the glasses and Case only
|
||||
* with a link to the glasses (`glassesLinked`: connected or charging), and Case
|
||||
* only while they are docked (caseCharging is null otherwise).
|
||||
*/
|
||||
export function formatBatteryLine(levels: BatteryLevels, glassesLinked: boolean): string {
|
||||
export function formatBatteryLine(levels: BatteryLevels, glassesLinked: boolean, glassesModel: string): string {
|
||||
const devices: Array<[string, number | null, boolean | null]> = [
|
||||
["G2", levels.headset, glassesLinked && levels.headsetCharging],
|
||||
[glassesModel, levels.headset, glassesLinked && levels.headsetCharging],
|
||||
["Case", levels.case, glassesLinked && levels.caseCharging],
|
||||
["R1", levels.ring, levels.ringCharging],
|
||||
];
|
||||
|
||||
@@ -1,12 +1,26 @@
|
||||
import { classifyAdvertisement, hasEvenManufacturerSignature, type EvenAdvertisement } from './even-advertisement'
|
||||
import { classifyAdvertisement, g1FromName, hasEvenManufacturerSignature, type EvenAdvertisement } from './even-advertisement'
|
||||
import { hexToBytes } from '../util/hex-util'
|
||||
|
||||
export type IosAdvertisement = { identifier: string; name: string; manufacturerData: string; rssi: number; connectable: boolean }
|
||||
export type IosDevice = EvenAdvertisement & { identifier: string }
|
||||
|
||||
/**
|
||||
* A G1 arm advertises no full MAC, and CoreBluetooth hides the real one. Faceclaw's addresses are MAC-shaped everywhere, so its
|
||||
* address on this phone is made from the peripheral identifier. It's stable as long as the identifier is, which on firmware
|
||||
* 0.5.66 and later is across installs too, and it only has to mean something on this phone: nobody types it in.
|
||||
*/
|
||||
export function g1IosAddress(identifier: string): string {
|
||||
return identifier.replace(/-/g, '').slice(0, 12).toUpperCase().replace(/(..)(?=.)/g, '$1:')
|
||||
}
|
||||
|
||||
/** Only a full vendor-advertised MAC may bind a manually entered address. */
|
||||
export function identifyIosPeripheral(raw: IosAdvertisement): IosDevice | null {
|
||||
if (!/^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i.test(raw.identifier)) return null
|
||||
if (g1FromName(raw.name)) {
|
||||
const arm = classifyAdvertisement({ ...raw, address: g1IosAddress(raw.identifier), source: 'scan', bonded: false,
|
||||
txPower: null, seenAtMs: Date.now() })
|
||||
return arm && { ...arm, identifier: raw.identifier.toUpperCase() }
|
||||
}
|
||||
if (!hasEvenManufacturerSignature(hexToBytes(raw.manufacturerData))) return null
|
||||
const candidate = classifyAdvertisement({ ...raw, address: '', source: 'scan', bonded: false,
|
||||
txPower: null, seenAtMs: Date.now() })
|
||||
|
||||
@@ -2,7 +2,6 @@ import { startRemoteInput } from "../remote/service"
|
||||
import type { KeyboardInputSession } from '../ui/shell/keyboard-input'
|
||||
import { acceptInput, resetRingInputFilter } from "../ui/input-monitor";
|
||||
import { bindIosNotifications, iosNotificationsChanged, onIosNotificationPopup, readActiveNotifications } from '../native/notification-icons.ios'
|
||||
import { shouldShowNotificationOnGlasses } from '../native/notification-sources'
|
||||
import { launcherEntries } from '../apps/launcher'
|
||||
import { discardZeroedEvenHubPackage, getInstalledEvenHubAppById, installedEvenHubPackageId, uninstallEvenHubPackage } from '../apps/evenhub/installed-apps'
|
||||
import { isInstalledPackagePresent } from '../apps/evenhub/updates'
|
||||
@@ -23,6 +22,7 @@ import { weatherBridge } from '../native/weather'
|
||||
import { FaceclawCommunicatorBridge, resolveIosPeripherals, type CommunicatorState, type RawInputEvent } from '../native/faceclaw-communicator.ios'
|
||||
import { PreviewDisplayTarget, type DisplayTarget } from '../native/preview-display.ios'
|
||||
import { AncsClient, ANCS_FIRMWARE_VERSION } from './ancs-client'
|
||||
import { G1V0_IMAGE } from '../g1/firmware/g1v0-image'
|
||||
import { GlanceHost, type GlanceDisplay } from './glance-host'
|
||||
import { createLockScreenImage, LOCK_SCREEN_SURFACE_ID } from './lock-screen'
|
||||
import { OsEventTypeList } from './events'
|
||||
@@ -53,7 +53,7 @@ import { onAnySettingChanged,
|
||||
previewColorSetting, lockScreenEnabledSetting, getBrightnessPreferences, getStringSettingById,
|
||||
nightscoutSiteUrlSetting, nightscoutApiTokenSetting, voiceProviderSetting, elevenLabsApiKeySetting,
|
||||
openAiApiKeySetting, openAiTranscriptionModelSetting, sonioxApiKeySetting, whisperServerApiKeySetting, getVoiceTranscriptionLanguage,
|
||||
whisperServerModelSetting, whisperServerUrlSetting, ringConnectionModeSetting, saveTranscribeAudioSetting } from '../ui/dashboard-settings'
|
||||
whisperServerModelSetting, whisperServerUrlSetting, ringConnectionModeSetting, saveTranscribeAudioSetting, glassesTypeSetting, shouldPopUpNewNotification } from '../ui/dashboard-settings'
|
||||
import { transcriptionKey, type VoiceProviderSelection } from '../native/cloud-stt-provider'
|
||||
import type { PhoneGesture } from '../phone-ui/phone-gestures'
|
||||
import { claimGlassesOnboardingAutoLaunch, ONBOARDING_APP_ID } from '../apps/onboarding/onboarding-progress'
|
||||
@@ -215,7 +215,8 @@ export class IosPreviewController {
|
||||
requestShellRender: () => this.requestShellRender(),
|
||||
onWindowsChanged: () => { this.requestShellRender(); this.syncEvenHubPhoneUi(); this.wearRemote?.schedulePublish() },
|
||||
openNotificationsWindow: () =>
|
||||
this.openInProcessAppInBackground(NOTIFICATIONS_WINDOW_ID, NOTIFICATIONS_SURFACE_ID, createNotificationsAppWindow),
|
||||
this.openInProcessAppInBackground(NOTIFICATIONS_WINDOW_ID, NOTIFICATIONS_SURFACE_ID,
|
||||
options => createNotificationsAppWindow(options, section => { void this.launchApp('settings', { section }) })),
|
||||
onSwitcherBarHeightChanged: () => {
|
||||
this.relayout()
|
||||
shell.foregroundWindow()?.requestRender()
|
||||
@@ -253,7 +254,7 @@ export class IosPreviewController {
|
||||
shell.focusWindow(launcher.windowId)
|
||||
onIosNotificationPopup(key => {
|
||||
const notification = readActiveNotifications(128).find(n => n.key === key)
|
||||
if (this.glassesLocked || !notification || !shouldShowNotificationOnGlasses(notification.packageName)) return
|
||||
if (this.glassesLocked || !notification || !shouldPopUpNewNotification(notification.packageName)) return
|
||||
const woke = !shell.isScreenOn() && shell.wake('sidebar')
|
||||
shell.openNotificationModal(key, woke)
|
||||
this.requestShellRender()
|
||||
@@ -278,7 +279,7 @@ export class IosPreviewController {
|
||||
// The header's EvenHub phone-UI button hides while that UI is showing.
|
||||
onPhoneShownChanged(() => this.syncEvenHubPhoneUi())
|
||||
registerSystemTools()
|
||||
registerWindowTools({ apps: ALL_APPS.filter(app => !iosAppUnavailableReason(app.appId)),
|
||||
registerWindowTools({ apps: () => ALL_APPS.filter(app => app.isSupported?.() !== false && !iosAppUnavailableReason(app.appId)),
|
||||
launchApp: id => this.launchApp(id), requestShellRender: () => this.requestShellRender() })
|
||||
registerNavigateTools(id => this.launchApp(id))
|
||||
registerRoamTools(id => this.launchApp(id))
|
||||
@@ -286,7 +287,7 @@ export class IosPreviewController {
|
||||
iosVoiceInput.onSpeechEnd(() => this.syncContinuousCapture())
|
||||
for (const app of ALL_APPS) if (app.appId !== 'launcher' && !iosAppUnavailableReason(app.appId)) app.boot?.(this.buildAppContext(app))
|
||||
this.wearRemote = new WearRemote({
|
||||
apps: ALL_APPS.filter(app => app.showInLauncher !== false && !iosAppUnavailableReason(app.appId)),
|
||||
apps: () => ALL_APPS.filter(app => app.showInLauncher !== false && app.isSupported?.() !== false && !iosAppUnavailableReason(app.appId)),
|
||||
injectInput: kind => this.injectWatchInput(kind),
|
||||
launchApp: id => this.launchApp(id),
|
||||
// The watch's Connect/Disconnect are explicit user choices, like the phone's own buttons.
|
||||
@@ -808,7 +809,7 @@ export class IosPreviewController {
|
||||
const display = this.display
|
||||
if (!display) return
|
||||
await display.configureSurface(id, { ...appViewportRect(heightMode, appId), zOrder: 0, transparency: 'opaque' })
|
||||
await display.setSurfaceVisible(id, visible)
|
||||
await display.setSurfaceVisible(id, typeof visible === 'function' ? visible() : visible)
|
||||
},
|
||||
setSurfaceVisible: (id, visible) => this.setWindowSurfaceVisible(id, visible),
|
||||
removeSurface: id => this.removeWindowSurface(id),
|
||||
@@ -887,7 +888,7 @@ export class IosPreviewController {
|
||||
return
|
||||
}
|
||||
if (this.communicator) await this.closeCommunicator()
|
||||
const communicator = new FaceclawCommunicatorBridge(identifiers)
|
||||
const communicator = new FaceclawCommunicatorBridge({ ...identifiers, glassesType: glassesTypeSetting.get() })
|
||||
this.teardownPreviewDisplay()
|
||||
this.communicator = communicator
|
||||
this.wearDetectionRequested = false
|
||||
@@ -991,6 +992,8 @@ export class IosPreviewController {
|
||||
// (or re-pairs / installs the custom firmware, which lift the suppression).
|
||||
if (isHaltedSessionPhase(state.phase)) suppressAutoReconnect()
|
||||
const phase: SessionPhase = state.phase === 'charging' ? 'connected' : isHaltedSessionPhase(state.phase) ? 'error' : state.phase
|
||||
// The relay ends with the link, so a reconnected session has to ask for it again (syncNotifications).
|
||||
if (phase !== 'connected' && this.notifications && this.notifications.state !== 'disconnected') this.notifications.stop()
|
||||
// Wear state is a per-transport snapshot: ask again on every new session.
|
||||
if (phase !== 'connected') this.wearDetectionRequested = false
|
||||
this.update(phase, state.status)
|
||||
@@ -1034,6 +1037,11 @@ export class IosPreviewController {
|
||||
if (this.state.capabilities) notifications.stop(`Update glasses to Faceclaw firmware ${ANCS_FIRMWARE_VERSION} or newer for iPhone notifications.`)
|
||||
return
|
||||
}
|
||||
// A G1 reports no revision that says so: its session knows from what the right arm answered.
|
||||
if (!communicator.ancsRelayAvailable()) {
|
||||
notifications.stop(`Update the glasses to Faceclaw's firmware ${G1V0_IMAGE.version} for iPhone notifications, then reconnect.`)
|
||||
return
|
||||
}
|
||||
if (notifications.state !== 'disconnected') return
|
||||
notifications.start((Date.now() ^ Math.floor(Math.random() * 0xffffffff)) >>> 0, communicator.rightWriteLimit())
|
||||
}
|
||||
|
||||
@@ -1,23 +1,26 @@
|
||||
import { GrayImage, G2_LENS_WIDTH, G2_LENS_HEIGHT } from "../graphics/image";
|
||||
import { GrayImage } from "../graphics/image";
|
||||
import { screenHeight, screenWidth } from "../graphics/screen-size";
|
||||
import { getDefaultMediumFont } from "../graphics/ui-fonts";
|
||||
import { wrapText } from "../graphics/textwrap";
|
||||
|
||||
export const LOCK_SCREEN_SURFACE_ID = "lock-screen";
|
||||
const LOCK_SCREEN_MESSAGE = "Glasses locked; unlock the phone to unlock the glasses.";
|
||||
|
||||
/** The paired glasses' whole screen, black, with the message in a box at its centre. */
|
||||
export function createLockScreenImage(): GrayImage {
|
||||
const image = new GrayImage(G2_LENS_WIDTH, G2_LENS_HEIGHT, 0);
|
||||
const width = screenWidth(), height = screenHeight();
|
||||
const image = new GrayImage(width, height, 0);
|
||||
const font = getDefaultMediumFont();
|
||||
const boxWidth = 480;
|
||||
const boxHeight = 150;
|
||||
const boxX = Math.round((G2_LENS_WIDTH - boxWidth) / 2);
|
||||
const boxY = Math.round((G2_LENS_HEIGHT - boxHeight) / 2);
|
||||
const boxX = Math.round((width - boxWidth) / 2);
|
||||
const boxY = Math.round((height - boxHeight) / 2);
|
||||
image.drawRoundedRect(boxX, boxY, boxWidth, boxHeight, 150, 12);
|
||||
const lines = wrapText(font, LOCK_SCREEN_MESSAGE, boxWidth - 64);
|
||||
const textHeight = lines.length * font.lineHeight;
|
||||
const firstY = boxY + Math.round((boxHeight - textHeight) / 2);
|
||||
lines.forEach((line, index) => {
|
||||
const x = Math.round((G2_LENS_WIDTH - font.measureText(line)) / 2);
|
||||
const x = Math.round((width - font.measureText(line)) / 2);
|
||||
image.drawText(font, x, firstY + index * font.lineHeight, line, 230);
|
||||
});
|
||||
return image;
|
||||
|
||||
+104
-10
@@ -16,12 +16,11 @@ import {
|
||||
RING_CALIBRATION,
|
||||
sortedByProximity,
|
||||
zoneGlyph,
|
||||
zoneLabel,
|
||||
type ProximityEstimate,
|
||||
type ProximityZone,
|
||||
} from "./ble-proximity";
|
||||
import { classifyAdvertisement, normalizeMacAddress, type EvenAdvertisement, type RawAdvertisement } from "./even-advertisement";
|
||||
import { glassesImagePath, R1_IMAGE_PATH } from "./glasses-artwork";
|
||||
import { classifyAdvertisement, normalizeMacAddress, type EvenAdvertisement, type G1Firmware, type RawAdvertisement } from "./even-advertisement";
|
||||
import { GENERIC_G2_IMAGE_PATH, glassesImagePath, R1_IMAGE_PATH } from "./glasses-artwork";
|
||||
import {
|
||||
colorwayDisplayName,
|
||||
colorwaySwatchHex,
|
||||
@@ -48,6 +47,8 @@ export type GlassesPairCandidate = {
|
||||
rssi: number | null;
|
||||
proximity: ProximityEstimate | null;
|
||||
lastSeenMs: number;
|
||||
/** An Even G1 pair: the arms' firmware, the "lower" of the two (stock, then safe mode). Absent on a G2. */
|
||||
g1Firmware?: G1Firmware;
|
||||
/**
|
||||
* Set when this lone arm and a lone arm of the other side carry different
|
||||
* serials — the mixed-pair situation the serial check exists to name.
|
||||
@@ -56,6 +57,15 @@ export type GlassesPairCandidate = {
|
||||
mismatchWarning: string | null;
|
||||
};
|
||||
|
||||
/** A RayNeo iO: one device, one address (no arms to join). */
|
||||
export type RayNeoCandidate = {
|
||||
id: string;
|
||||
advertisement: EvenAdvertisement;
|
||||
rssi: number | null;
|
||||
proximity: ProximityEstimate | null;
|
||||
lastSeenMs: number;
|
||||
};
|
||||
|
||||
export type RingCandidate = {
|
||||
id: string;
|
||||
advertisement: EvenAdvertisement;
|
||||
@@ -176,9 +186,10 @@ export class DiscoveryAggregator {
|
||||
pairs(): GlassesPairCandidate[] {
|
||||
const groups = new Map<string, { left: (EvenAdvertisement & { smoothedRssi: number | null }) | null; right: (EvenAdvertisement & { smoothedRssi: number | null }) | null }>();
|
||||
for (const record of this.byAddress.values()) {
|
||||
if (record.role === "ring") continue;
|
||||
if (record.role === "ring" || record.role === "rayneo-io") continue;
|
||||
const canonical = serialKey(record.serial);
|
||||
const key = canonical ? `serial:${canonical}` : `arm:${record.address}`;
|
||||
const family = record.g1Firmware ? "g1:" : "";
|
||||
const key = canonical ? `${family}serial:${canonical}` : `arm:${record.address}`;
|
||||
const group = groups.get(key) ?? { left: null, right: null };
|
||||
const slot = record.role === "left" ? "left" : "right";
|
||||
const incumbent = group[slot];
|
||||
@@ -199,7 +210,9 @@ export class DiscoveryAggregator {
|
||||
pairs.push({
|
||||
id: serialKey(serial) ?? `arm:${any.address}`,
|
||||
serial,
|
||||
identity: GlassesHardwareIdentity.decode(serial),
|
||||
// Even's G2 serial scheme; a G1's says nothing to it.
|
||||
identity: any.g1Firmware ? null : GlassesHardwareIdentity.decode(serial),
|
||||
...(any.g1Firmware ? { g1Firmware: g1PairFirmware(left, right) } : {}),
|
||||
left: left ? stripSmoothing(left) : null,
|
||||
right: right ? stripSmoothing(right) : null,
|
||||
completeness: left && right ? "complete" : left ? "left-only" : "right-only",
|
||||
@@ -225,6 +238,22 @@ export class DiscoveryAggregator {
|
||||
}
|
||||
|
||||
/** Every R1 ring seen, closest first. */
|
||||
rayneos(): RayNeoCandidate[] {
|
||||
const found: RayNeoCandidate[] = [];
|
||||
for (const record of this.byAddress.values()) {
|
||||
if (record.role !== "rayneo-io") continue;
|
||||
const rssi = record.smoothedRssi != null ? Math.round(record.smoothedRssi) : null;
|
||||
found.push({
|
||||
id: `rayneo:${record.address}`,
|
||||
advertisement: stripSmoothing(record),
|
||||
rssi,
|
||||
proximity: estimateProximity(rssi, GLASSES_CALIBRATION),
|
||||
lastSeenMs: record.seenAtMs,
|
||||
});
|
||||
}
|
||||
return sortedByProximity(found, (candidate) => candidate.proximity, (candidate) => candidate.id);
|
||||
}
|
||||
|
||||
rings(): RingCandidate[] {
|
||||
const rings: RingCandidate[] = [];
|
||||
for (const record of this.byAddress.values()) {
|
||||
@@ -281,7 +310,7 @@ export function isPreviouslyPaired(name: string | null | undefined, pairedSerial
|
||||
|
||||
export type PairingRowPresentation = {
|
||||
id: string;
|
||||
kind: "glasses" | "ring";
|
||||
kind: "glasses" | "ring" | "rayneo-io";
|
||||
/** "Even G2 B" / "Even R1" / fallback product name. */
|
||||
modelTitle: string;
|
||||
/** The serial (glasses) or local name (ring). */
|
||||
@@ -299,7 +328,6 @@ export type PairingRowPresentation = {
|
||||
isPreviouslyPaired: boolean;
|
||||
/** "Yours" / "Closest" / "". */
|
||||
badge: string;
|
||||
proximitySummary: string;
|
||||
proximityGlyph: string;
|
||||
zone: ProximityZone | null;
|
||||
/** "Left + right arms found", "Only the left arm has been seen", …; "" when there is nothing worth a line (an unbonded ring). */
|
||||
@@ -325,12 +353,11 @@ function presentationBase(
|
||||
isNearest: boolean,
|
||||
isPaired: boolean,
|
||||
warnings: readonly string[],
|
||||
): Pick<PairingRowPresentation, "isNearest" | "isPreviouslyPaired" | "badge" | "proximitySummary" | "proximityGlyph" | "zone" | "warning"> {
|
||||
): Pick<PairingRowPresentation, "isNearest" | "isPreviouslyPaired" | "badge" | "proximityGlyph" | "zone" | "warning"> {
|
||||
return {
|
||||
isNearest,
|
||||
isPreviouslyPaired: isPaired,
|
||||
badge: isPaired ? "Yours" : isNearest ? "Closest" : "",
|
||||
proximitySummary: proximity ? zoneLabel(proximity.zone) : "Signal unknown",
|
||||
proximityGlyph: proximity ? zoneGlyph(proximity.zone) : "○○○○",
|
||||
zone: proximity?.zone ?? null,
|
||||
warning: warnings.join(" "),
|
||||
@@ -342,7 +369,52 @@ function embeddedMacMismatchWarning(subject: string, ad: EvenAdvertisement | nul
|
||||
return `${subject} advertised address ${ad.embeddedMac} differs from its radio address ${ad.address}.`;
|
||||
}
|
||||
|
||||
/** The pair can only do what its less capable arm can. */
|
||||
function g1PairFirmware(left: EvenAdvertisement | null, right: EvenAdvertisement | null): G1Firmware {
|
||||
const firmwares = [left?.g1Firmware, right?.g1Firmware];
|
||||
if (firmwares.includes("stock")) return "stock";
|
||||
return firmwares.includes("g1v0-safe") ? "g1v0-safe" : "g1v0";
|
||||
}
|
||||
|
||||
export function g1Row(pair: GlassesPairCandidate, context: RowContext = {}): PairingRowPresentation {
|
||||
const isPreviouslyPairedRow = isPreviouslyPaired(pair.serial, context.pairedSerial);
|
||||
const isNearest = !!context.nearestId && context.nearestId === pair.id;
|
||||
const warnings: string[] = [];
|
||||
if (pair.mismatchWarning) warnings.push(pair.mismatchWarning);
|
||||
let armsSummary: string;
|
||||
let canSelect = false;
|
||||
if (pair.completeness !== "complete") {
|
||||
armsSummary = pair.completeness === "left-only"
|
||||
? "Only the left arm has been seen — waiting for the right"
|
||||
: "Only the right arm has been seen — waiting for the left";
|
||||
} else if (pair.g1Firmware === "stock") {
|
||||
armsSummary = "Runs Even's firmware. Faceclaw will install its own, with the glasses in the case";
|
||||
canSelect = true;
|
||||
} else if (pair.g1Firmware === "g1v0-safe") {
|
||||
armsSummary = "In safe mode: the firmware restarted repeatedly. Faceclaw can install it again, with the glasses in the case";
|
||||
canSelect = true;
|
||||
} else {
|
||||
armsSummary = "Left + right arms found. To pair, keep them in the case with the lid open";
|
||||
canSelect = true;
|
||||
}
|
||||
return {
|
||||
id: pair.id,
|
||||
kind: "glasses",
|
||||
modelTitle: "Even Realities G1",
|
||||
deviceName: pair.serial ?? (pair.left ?? pair.right)!.name,
|
||||
variantSummary: null,
|
||||
colorway: null,
|
||||
swatchHex: null,
|
||||
imagePath: GENERIC_G2_IMAGE_PATH,
|
||||
hasVariantImage: false,
|
||||
...presentationBase(pair.proximity, isNearest, isPreviouslyPairedRow, warnings),
|
||||
armsSummary,
|
||||
canSelect,
|
||||
};
|
||||
}
|
||||
|
||||
export function glassesRow(pair: GlassesPairCandidate, context: RowContext = {}): PairingRowPresentation {
|
||||
if (pair.g1Firmware) return g1Row(pair, context);
|
||||
const identity = pair.identity;
|
||||
const imagePath = glassesImagePath(identity);
|
||||
const isPreviouslyPairedRow = isPreviouslyPaired(pair.serial, context.pairedSerial);
|
||||
@@ -416,6 +488,28 @@ export function ringRow(ring: RingCandidate, context: RowContext = {}): PairingR
|
||||
};
|
||||
}
|
||||
|
||||
export function rayneoRow(candidate: RayNeoCandidate, context: { pairedAddress?: string; nearestId?: string | null } = {}): PairingRowPresentation {
|
||||
const ad = candidate.advertisement;
|
||||
const isPaired = !!context.pairedAddress && normalizeMacAddress(context.pairedAddress) === ad.address;
|
||||
const isNearest = !!context.nearestId && context.nearestId === candidate.id;
|
||||
const warnings: string[] = [];
|
||||
if (ad.embeddedMacMismatch) warnings.push(`It advertises ${ad.embeddedMac} but was heard as ${ad.address}.`);
|
||||
return {
|
||||
id: candidate.id,
|
||||
kind: "rayneo-io",
|
||||
modelTitle: "RayNeo iO",
|
||||
deviceName: ad.name || ad.address,
|
||||
variantSummary: null,
|
||||
colorway: null,
|
||||
swatchHex: null,
|
||||
imagePath: GENERIC_G2_IMAGE_PATH,
|
||||
hasVariantImage: false,
|
||||
...presentationBase(candidate.proximity, isNearest, isPaired, warnings),
|
||||
armsSummary: "Needs the Faceclaw custom firmware. First time: put it in pairing mode (on the charger, hold the button ~5 s until the light blinks blue).",
|
||||
canSelect: true,
|
||||
};
|
||||
}
|
||||
|
||||
/** Convenience: a colourway's display text, for rows that show the swatch alone. */
|
||||
export function colorwayLabel(colorway: GlassesColorway | null): string {
|
||||
return colorway ? colorwayDisplayName(colorway) : "";
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { G2_LENS_HEIGHT, G2_LENS_WIDTH } from "../graphics/image";
|
||||
import { previewScalingSetting } from "../ui/dashboard-settings";
|
||||
import { phonePreviewRect, usedScreenRect, type ScreenRect } from "../ui/shell/geometry";
|
||||
import { phonePreviewRect, screenHeight, screenWidth, usedScreenRect, type ScreenRect } from "../ui/shell/geometry";
|
||||
import { shell } from "../ui/shell/shell";
|
||||
|
||||
/**
|
||||
@@ -14,7 +13,7 @@ export function phonePreviewCrop(locked: boolean, glanceRect: ScreenRect | null)
|
||||
if (locked || previewScalingSetting.get() === "raw") return null;
|
||||
const window = shell.foregroundWindow();
|
||||
const crop = phonePreviewRect(glanceRect ?? usedScreenRect(window?.heightMode ?? "min", window?.appId));
|
||||
const wholePanel = crop.x === 0 && crop.y === 0 && crop.width === G2_LENS_WIDTH && crop.height === G2_LENS_HEIGHT;
|
||||
const wholePanel = crop.x === 0 && crop.y === 0 && crop.width === screenWidth() && crop.height === screenHeight();
|
||||
return wholePanel ? null : crop;
|
||||
}
|
||||
|
||||
@@ -27,7 +26,7 @@ export function phonePreviewCrop(locked: boolean, glanceRect: ScreenRect | null)
|
||||
export function mirrorToPanelFraction(crop: ScreenRect | null, nx: number, ny: number): { nx: number; ny: number } {
|
||||
if (!crop) return { nx, ny };
|
||||
return {
|
||||
nx: (crop.x + nx * crop.width) / G2_LENS_WIDTH,
|
||||
ny: (crop.y + ny * crop.height) / G2_LENS_HEIGHT,
|
||||
nx: (crop.x + nx * crop.width) / screenWidth(),
|
||||
ny: (crop.y + ny * crop.height) / screenHeight(),
|
||||
};
|
||||
}
|
||||
@@ -32,6 +32,7 @@ import { type AppDefinition } from "../apps/app-definition";
|
||||
import { getInstalledEvenHubApps, installedEvenHubAppId } from "../apps/evenhub/installed-apps";
|
||||
import { WEAR_PATHS, wearBridge, type WearMessage } from "../native/wear-bridge";
|
||||
import {
|
||||
glassesModelName,
|
||||
onAnySettingChanged,
|
||||
watchCanUnlockSetting,
|
||||
watchCrownClockwiseNextSetting,
|
||||
@@ -115,8 +116,8 @@ const WATCH_BATTERY_MAX_AGE_MS = 4 * 60 * 60_000;
|
||||
|
||||
/** What the dashboard controller lends the watch remote. */
|
||||
export type WearRemoteHost = {
|
||||
/** The launcher-grid apps; installed EvenHub packages are added dynamically. */
|
||||
apps: readonly AppDefinition[];
|
||||
/** The launcher-grid apps for the paired glasses; installed EvenHub packages are added dynamically. */
|
||||
apps: () => readonly AppDefinition[];
|
||||
injectInput: (kind: WearRemoteInputKind) => Promise<void>;
|
||||
launchApp: (appId: string) => Promise<void>;
|
||||
connect: () => Promise<void>;
|
||||
@@ -294,6 +295,7 @@ export class WearRemote {
|
||||
worn: state.glassesWorn,
|
||||
listening: voiceActivity.isActive(),
|
||||
battery: state.lastHeadsetBattery,
|
||||
glassesModel: glassesModelName(),
|
||||
charging: state.phase === "charging" || battery.headsetCharging === true,
|
||||
caseBattery: battery.case,
|
||||
caseCharging: battery.caseCharging,
|
||||
@@ -320,7 +322,7 @@ export class WearRemote {
|
||||
|
||||
/** Launchable apps, matching the launcher grid and the apps.launch tool. */
|
||||
private listApps(): Array<{ appId: string; title: string }> {
|
||||
const apps = this.host.apps.map((app) => ({ appId: app.appId, title: app.title }));
|
||||
const apps = this.host.apps().map((app) => ({ appId: app.appId, title: app.title }));
|
||||
for (const installed of getInstalledEvenHubApps()) {
|
||||
apps.push({ appId: installedEvenHubAppId(installed.packageId), title: installed.name });
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user