Merge branch 'main' into rayneo-io-support

This commit is contained in:
James Babcock committed 2026-11-03 14:06:19 -08:00
commit b2b6c5c8d8
36 files changed
+822 -39

No files matched your search

+6 -1
View File
@@ -65,11 +65,16 @@ async function ensurePermissions(
): Promise<void> {
if (!global.isAndroid) return;
const activity = getActivity();
const missing = permissions.filter((permission) => !isPermissionGranted(permission));
if (missing.length === 0) return;
// Only a request needs an Activity. Checking must not: the glasses session
// outlives it (swiping the app away in Recents destroys the Activity while
// the foreground service keeps the process running), and voice input
// checks the microphone permission on every start.
const activity = getActivity();
await new Promise<void>((resolve, reject) => {
const callback = (args: {
requestCode: number;
+36 -2
View File
@@ -98,13 +98,21 @@ import { createNotificationsAppWindow, NOTIFICATIONS_SURFACE_ID, NOTIFICATIONS_W
import { isInstalledPackagePresent } from "../apps/evenhub/updates";
import { wearerVerificationOptions } from "../apps/microphones/speakers";
import { micSession } from "../apps/microphones/mic-session";
import { glassesDisplayAsleep, glassesDisplayLabel, type GlassesDisplayState } from "./glasses-display-state";
import {
chargingPreviewMessage,
glassesDisplayAsleep,
glassesDisplayDetail,
glassesDisplayLabel,
type GlassesDisplayState,
} from "./glasses-display-state";
import { PreviewDisplayTarget, type DisplayTarget } from "../native/preview-display";
type ConnectionPhase = "disconnected" | "connecting" | "connected" | "charging" | "disconnecting";
export type DashboardSnapshot = {
phase: ConnectionPhase;
/** Last-known battery levels: the glasses, their charging case, the R1 ring and a Wear OS watch. */
batteries: ReturnType<typeof shell.getBatteryLevels>;
status: string;
displayPreview: ImageSource | null;
/**
@@ -340,6 +348,7 @@ class DashboardController {
private offState: (() => void) | null = null;
private offRing: (() => void) | null = null;
private offBattery: (() => void) | null = null;
private offCaseBattery: (() => void) | null = null;
private offSilentMode: (() => void) | null = null;
private offWearState: (() => void) | null = null;
private offPhoneLockState: (() => void) | null = null;
@@ -1191,6 +1200,7 @@ class DashboardController {
alarmReliabilityMessage: this.alarmReliabilityMessage,
previewMode: this.isPreviewDisplayActive(),
evenHubPhoneUi: phoneUiButton(),
batteries: shell.getBatteryLevels(),
};
}
@@ -1208,7 +1218,7 @@ class DashboardController {
*/
private displayPreviewMessage(): string {
if (this.phase === "charging") {
return this.glassesDisplayLabel();
return chargingPreviewMessage(this.glassesDisplayState());
}
if (this.silentMode && this.phase === "connected") {
// Say how to leave it. Silent mode is entered and exited only by the
@@ -1240,17 +1250,25 @@ class DashboardController {
return glassesDisplayLabel(this.glassesDisplayState());
}
/** The smaller line the watch face shows under that one, or "" (the case level while charging). */
glassesDisplayDetail(): string {
return glassesDisplayDetail(this.glassesDisplayState());
}
/** Whether that line reads "Display off" (the watch face adds a wake hint under it). */
glassesDisplayAsleep(): boolean {
return glassesDisplayAsleep(this.glassesDisplayState());
}
private glassesDisplayState(): GlassesDisplayState {
const batteries = shell.getBatteryLevels();
return {
phase: this.phase,
silentMode: this.silentMode,
screenOn: shell.isScreenOn(),
battery: this.lastHeadsetBattery,
caseBattery: batteries.case,
caseCharging: batteries.caseCharging,
foregroundTitle: shell.getForegroundApp()?.title ?? null,
previewMode: this.isPreviewDisplayActive(),
};
@@ -1662,6 +1680,17 @@ class DashboardController {
// the watch state, so refresh both consumers on every report.
this.emit();
});
this.offCaseBattery = communicator.onCaseState((state) => {
// The level is kept when a reading has none (the glasses left the case)
// and across disconnects: the case only reports while the glasses are
// docked and only drains while charging them, so the last level holds.
// Whether the case is on USB is only known while they are docked.
shell.setBatteryLevels({
...(state.battery !== null ? { case: state.battery } : {}),
caseCharging: state.docked ? state.charging : null,
});
this.emit();
});
this.offEvenAppConflict = communicator.onEvenAppConflict((message) => {
this.refreshEvenAppStatus();
if (!this.evenNotificationActive) {
@@ -1782,6 +1811,8 @@ class DashboardController {
this.offRing = null;
this.offBattery?.();
this.offBattery = null;
this.offCaseBattery?.();
this.offCaseBattery = null;
this.offSilentMode?.();
this.offSilentMode = null;
this.offWearState?.();
@@ -1894,6 +1925,8 @@ class DashboardController {
this.offRing = null;
this.offBattery?.();
this.offBattery = null;
this.offCaseBattery?.();
this.offCaseBattery = null;
this.offSilentMode?.();
this.offSilentMode = null;
this.offWearState?.();
@@ -2301,6 +2334,7 @@ class DashboardController {
.catch((error) => {
this.appendLog(`voice permission failed: ${this.formatError(error)}`);
if (!hasMicrophonePermission()) voiceControlBridge.reportPermissionDenied();
else voiceControlBridge.reportStartFailed(this.formatError(error));
});
}
+55
View File
@@ -3,6 +3,13 @@ export type GlassesDisplayState = {
silentMode: boolean;
screenOn: boolean;
battery: number | null;
/**
* 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
* the glasses are docked and the case reading is live.
*/
caseBattery: number | null;
caseCharging: boolean | null;
foregroundTitle: string | null;
/** The headless preview display is standing in for a connection (preview-only mode). */
previewMode: boolean;
@@ -29,6 +36,20 @@ export function glassesDisplayLabel(state: GlassesDisplayState): string {
return state.foregroundTitle || "Launcher";
}
/**
* The smaller line under that label on the watch face, or "": the case
* level while the glasses charge in it.
*/
export function glassesDisplayDetail(state: GlassesDisplayState): string {
if (state.phase !== "charging") return "";
return validBatteryLevel(state.caseBattery) ? batteryEntry("Case", state.caseBattery, state.caseCharging) : "";
}
/** The phone mirror's stand-in while charging: the label and its detail on one line. */
export function chargingPreviewMessage(state: GlassesDisplayState): string {
return [glassesDisplayLabel(state), glassesDisplayDetail(state)].filter(Boolean).join(" · ");
}
/**
* True when the label reads "Display off": the screen is dark but the glasses
* (or the preview standing in for them) would light it on a wake gesture.
@@ -46,6 +67,40 @@ export function chargingDisplayLabel(battery: number | null): string {
return validBatteryLevel(battery) ? `Charging · G2 ${battery}%` : "Charging";
}
/** The shell's last-known battery levels (ShellChromeState["battery"]), as far as the phone shows them. */
export type BatteryLevels = {
headset: number | null;
headsetCharging: boolean | null;
case: number | null;
caseCharging: boolean | null;
ring: number | null;
ringCharging: boolean | null;
};
/**
* 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).
*/
export function formatBatteryLine(levels: BatteryLevels, glassesLinked: boolean): string {
const devices: Array<[string, number | null, boolean | null]> = [
["G2", levels.headset, glassesLinked && levels.headsetCharging],
["Case", levels.case, glassesLinked && levels.caseCharging],
["R1", levels.ring, levels.ringCharging],
];
return devices
.filter((device): device is [string, number, boolean | null] => validBatteryLevel(device[1]))
.map(([label, level, charging]) => batteryEntry(label, level, charging))
.join(" · ");
}
function batteryEntry(label: string, level: number, charging: boolean | null): string {
return `${label} ${level}%${charging ? " ⚡" : ""}`;
}
function validBatteryLevel(battery: number | null): battery is number {
return battery !== null && Number.isInteger(battery) && battery >= 0 && battery <= 100;
}
+7
View File
@@ -883,6 +883,13 @@ export class IosPreviewController {
if (this.active) this.onConnectionState({ ...this.state })
this.requestShellRender()
}),
communicator.onCaseState(state => {
if (this.communicator !== communicator) return
// As on Android: keep the last level when a reading has none (out of the case);
// the case's own charging is only known while the glasses are docked.
shell.setBatteryLevels({ ...(state.battery !== null ? { case: state.battery } : {}),
caseCharging: state.docked ? state.charging : null })
}),
communicator.onFirmwareInfo(info => {
if (this.communicator !== communicator) return
this.logBluetooth(`Firmware: L=${info.leftVersion || '?'} R=${info.rightVersion || '?'}` +
+2
View File
@@ -263,6 +263,8 @@ export class WearRemote {
listening: voiceActivity.isActive(),
battery: state.lastHeadsetBattery,
charging: state.phase === "charging" || battery.headsetCharging === true,
caseBattery: battery.case,
caseCharging: battery.caseCharging,
silentMode: state.silentMode,
foreground: foreground ? { appId: foreground.appId, title: foreground.title } : null,
windows: shell.getWindows().map((window) => ({