Watch display shows if glasses are charging or silent mode

This commit is contained in:
James Babcock committed 2026-08-28 18:36:35 -07:00
1 parent ed8302bc6b
commit 6cd7d5fff9
10 files changed
+122 -20

No files matched your search

+32 -9
View File
@@ -66,6 +66,7 @@ import {
uninstallEvenHubPackage,
} from "../apps/evenhub/installed-apps";
import { closeRunningPackage, launchInstalledPackage } from "../apps/evenhub/manager";
import { glassesDisplayLabel } from "./glasses-display-state";
type ConnectionPhase = "disconnected" | "connecting" | "connected" | "charging" | "disconnecting";
@@ -300,12 +301,13 @@ class DashboardController {
requestShellRender: () => this.requestShellRender(),
onWindowsChanged: () => {
this.persistOpenApps();
this.wearRemote?.schedulePublish();
// The foreground title is mirrored on both remote-control faces.
this.emit();
},
onScreenStateChanged: (on) => {
this.handleScreenStateChanged(on);
if (on) this.requestShellRender();
this.wearRemote?.schedulePublish();
this.emit();
},
});
// Boot hooks register windows that exist from startup (the launcher,
@@ -353,6 +355,8 @@ class DashboardController {
status: this.status,
glassesLocked: this.glassesLocked,
glassesWorn: this.glassesWorn,
silentMode: this.silentMode,
lastHeadsetBattery: this.lastHeadsetBattery,
}),
appendLog: (line) => this.appendLog(line),
});
@@ -847,12 +851,15 @@ class DashboardController {
/**
* Message to show in place of the display preview, or "" to show the preview.
*
* Both cases look identical to a dead pair of glasses from the phone side:
* silent mode blanks the display and swallows input while the BLE session
* stays up, and a battery that just ran out simply stops answering.
* These states look identical to a dead pair of glasses from the phone side:
* charging and silent mode both make the display unavailable while BLE stays
* up, and a battery that just ran out simply stops answering.
*/
private displayPreviewMessage(): string {
if (this.silentMode && (this.phase === "connected" || this.phase === "charging")) {
if (this.phase === "charging") {
return this.glassesDisplayLabel();
}
if (this.silentMode && this.phase === "connected") {
return "Connected (Silent mode enabled)";
}
const connectionFailing = this.phase === "disconnected" || this.phase === "connecting";
@@ -866,6 +873,17 @@ class DashboardController {
return "";
}
/** What occupies the foreground-title line on the watch-style controls. */
glassesDisplayLabel(): string {
return glassesDisplayLabel({
phase: this.phase,
silentMode: this.silentMode,
screenOn: shell.isScreenOn(),
battery: this.lastHeadsetBattery,
foregroundTitle: shell.getForegroundApp()?.title ?? null,
});
}
/**
* Re-check the Doze exemption (cheap system call, but cached so snapshot()
* stays trivial). Called on connect, page load, and after the user answers
@@ -1047,16 +1065,21 @@ class DashboardController {
this.handlePhoneLockState(locked);
});
this.offBattery = communicator.onBatteryState((state) => {
this.lastHeadsetBattery = state.battery >= 0 ? state.battery : null;
// An unavailable reading must not erase the useful last-known value,
// especially while the glasses remain reachable in their case.
const hasBatteryLevel = Number.isInteger(state.battery) && state.battery >= 0 && state.battery <= 100;
if (hasBatteryLevel) this.lastHeadsetBattery = state.battery;
shell.setBatteryLevels({
headset: state.battery,
headset: hasBatteryLevel ? state.battery : this.lastHeadsetBattery,
headsetCharging: state.chargingStatus > 0,
});
if ((this.phase === "connected" || this.phase === "charging") && this.communicator) {
// Repaint the top bar (battery indicators live in the shell chrome).
this.requestShellRender();
}
this.wearRemote?.schedulePublish();
// Battery belongs in the charging stand-in on the phone as well as in
// the watch state, so refresh both consumers on every report.
this.emit();
});
this.offEvenAppConflict = communicator.onEvenAppConflict((message) => {
this.refreshEvenAppStatus();
+34
View File
@@ -0,0 +1,34 @@
export type GlassesDisplayState = {
phase: string;
silentMode: boolean;
screenOn: boolean;
battery: number | null;
foregroundTitle: string | null;
};
/** Compact status shown where the foreground-window title normally lives. */
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);
}
if (state.phase !== "connected") {
return "Glasses disconnected";
}
if (state.silentMode) {
return "Silent mode";
}
if (!state.screenOn) {
return "Display off";
}
return state.foregroundTitle || "Launcher";
}
export function chargingDisplayLabel(battery: number | null): string {
return validBatteryLevel(battery) ? `Charging · G2 ${battery}%` : "Charging";
}
function validBatteryLevel(battery: number | null): battery is number {
return battery !== null && Number.isInteger(battery) && battery >= 0 && battery <= 100;
}
+5 -2
View File
@@ -102,6 +102,8 @@ export type WearRemoteHost = {
status: string;
glassesLocked: boolean;
glassesWorn: boolean | null;
silentMode: boolean;
lastHeadsetBattery: number | null;
};
appendLog: (line: string) => void;
};
@@ -196,8 +198,9 @@ export class WearRemote {
locked: state.glassesLocked,
worn: state.glassesWorn,
listening: voiceActivity.isActive(),
battery: battery.headset,
charging: battery.headsetCharging === true,
battery: state.lastHeadsetBattery,
charging: state.phase === "charging" || battery.headsetCharging === true,
silentMode: state.silentMode,
foreground: foreground ? { appId: foreground.appId, title: foreground.title } : null,
windows: shell.getWindows().map((window) => ({
windowId: window.windowId,
+1 -4
View File
@@ -766,10 +766,7 @@ export class MainViewModel extends Observable {
/** What the next gesture lands on, as the watch pad shows it. */
get padFocusLine(): string {
if (this.phase !== "connected" && this.phase !== "charging") return "Glasses disconnected";
if (!shell.isScreenOn()) return "Display off";
const foreground = shell.getForegroundApp();
return foreground ? foreground.title : "Launcher";
return dashboardController.glassesDisplayLabel();
}
private refreshPadFocusLine(): void {