From e103b895103f66649c00df53f07811bef4fc5081 Mon Sep 17 00:00:00 2001 From: James Babcock Date: Sat, 7 Nov 2026 12:29:01 -0800 Subject: [PATCH] Battery indicators and other places no longer say "G2" when a G1 or iO is paired --- app/apps/glanceboard/widgets/system-card.ts | 3 +- app/g2/dashboard-controller.ts | 3 +- app/g2/glasses-display-state.ts | 18 ++++++----- app/g2/wear-remote.ts | 2 ++ app/phone-ui/main-page.ios.ts | 4 +-- app/phone-ui/main-view-model.ts | 2 ++ app/phone-ui/pairing-view-model.ts | 2 +- app/phone-ui/remote-controls.css | 2 +- app/ui/dashboard-settings.ts | 9 +++++- app/ui/dashboard/settings-menus.ts | 4 ++- app/ui/shell/chrome-layer.ts | 3 +- apple-watch/Faceclaw/PadStatus.swift | 6 ++-- apple-watch/Faceclaw/Protocol.swift | 5 ++- tests/app-layout.test.cjs | 17 +++++++--- tests/display-layout-setting.test.cjs | 8 +++++ tests/glasses-display-state.test.cjs | 31 ++++++++++++------- tests/ios-app-host.test.cjs | 2 +- tests/ios-watch-remote.test.cjs | 5 +++ wear/PROTOCOL.md | 10 +++--- .../main/kotlin/com/faceclaw/wear/Protocol.kt | 5 ++- .../kotlin/com/faceclaw/wear/ui/Common.kt | 6 ++-- 21 files changed, 101 insertions(+), 46 deletions(-) diff --git a/app/apps/glanceboard/widgets/system-card.ts b/app/apps/glanceboard/widgets/system-card.ts index 2ef3515a..90fb5056 100644 --- a/app/apps/glanceboard/widgets/system-card.ts +++ b/app/apps/glanceboard/widgets/system-card.ts @@ -18,6 +18,7 @@ import { batteryIndicatorVisible, ConfigSettingBoolean, glassesBatteryVisibilitySetting, + glassesModelName, onAnySettingChanged, phoneBatteryVisibilitySetting, ringBatteryVisibilitySetting, @@ -328,7 +329,7 @@ function collectBatteryItems(): BatteryItem[] { push(phoneBatteryVisibilitySetting.get(), "Phone", "phone", phone.battery, phone.charging); const levels = shell.getBatteryLevels(); push(watchBatteryVisibilitySetting.get(), "Watch", "watch", levels.watch, levels.watchCharging); - push(glassesBatteryVisibilitySetting.get(), "G2", "glasses", levels.headset, levels.headsetCharging); + push(glassesBatteryVisibilitySetting.get(), glassesModelName(), "glasses", levels.headset, levels.headsetCharging); if (levels.ring !== null && Number.isInteger(levels.ring) && levels.ring >= 0 && levels.ring <= 100) { push(ringBatteryVisibilitySetting.get(), "R1", "ring", levels.ring, levels.ringCharging); } diff --git a/app/g2/dashboard-controller.ts b/app/g2/dashboard-controller.ts index b15d0f2d..9935b6f3 100644 --- a/app/g2/dashboard-controller.ts +++ b/app/g2/dashboard-controller.ts @@ -77,7 +77,7 @@ import { loadPersistedOpenApps, savePersistedOpenApps } from "../ui/shell/open-a 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, glassesTypeSetting, statusBarPositionSetting, statusBarVisibilitySetting, windowBorderSetting, assistantAllowProactiveSetting, assistantBackendSetting, assistantBridgeHostSetting, assistantBridgePortSetting, assistantBridgeTokenSetting, getBrightnessPreferences, displayLayoutSetting, navigateDisplayLayoutSetting, terminalDisplayLayoutSetting, elevenLabsApiKeySetting, getStringSettingById, openAiApiKeySetting, nightscoutApiTokenSetting, firmwareDebugFlagsSetting, whisperServerApiKeySetting, whisperServerLanguageSetting, whisperServerModelSetting, whisperServerUrlSetting, lockScreenEnabledSetting, nightscoutSiteUrlSetting, onAnySettingChanged, previewColorSetting, effectiveRingConnectionMode, type RingConnectionMode, saveVoiceRecordingsSetting, sonioxApiKeySetting, screenTimeoutSetting, screenTimeoutSettingToMs, shouldPopUpNewNotification, suspendEvenHubWhenScreenOffSetting, voiceProviderSetting, wakeWordActionSetting, type ConfigSettingString } from "../ui/dashboard-settings"; +import { appSwitcherPositionSetting, glassesModelName, glassesTypeSetting, statusBarPositionSetting, statusBarVisibilitySetting, windowBorderSetting, assistantAllowProactiveSetting, assistantBackendSetting, assistantBridgeHostSetting, assistantBridgePortSetting, assistantBridgeTokenSetting, getBrightnessPreferences, displayLayoutSetting, navigateDisplayLayoutSetting, terminalDisplayLayoutSetting, elevenLabsApiKeySetting, getStringSettingById, openAiApiKeySetting, nightscoutApiTokenSetting, firmwareDebugFlagsSetting, whisperServerApiKeySetting, whisperServerLanguageSetting, 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, @@ -1267,6 +1267,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, diff --git a/app/g2/glasses-display-state.ts b/app/g2/glasses-display-state.ts index 20a7a736..ab1e673e 100644 --- a/app/g2/glasses-display-state.ts +++ b/app/g2/glasses-display-state.ts @@ -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], ]; diff --git a/app/g2/wear-remote.ts b/app/g2/wear-remote.ts index e865b32a..07571947 100644 --- a/app/g2/wear-remote.ts +++ b/app/g2/wear-remote.ts @@ -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, @@ -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, diff --git a/app/phone-ui/main-page.ios.ts b/app/phone-ui/main-page.ios.ts index 5f647c99..f42f9181 100644 --- a/app/phone-ui/main-page.ios.ts +++ b/app/phone-ui/main-page.ios.ts @@ -7,7 +7,7 @@ import { IosPreviewController } from '../g2/ios-preview-controller' import { PhoneGestureRecognizer } from './phone-gestures' import { BleBandwidthMeter } from './ble-bandwidth-meter' import { sampleBleTraffic } from '../native/ble-traffic' -import { onAnySettingChanged, mirrorTouchSetting, showBleBandwidthSetting } from '../ui/dashboard-settings' +import { glassesModelName, onAnySettingChanged, mirrorTouchSetting, showBleBandwidthSetting } from '../ui/dashboard-settings' import { loadDeviceAddresses } from '../g2/device-addresses' import { deviceAddressError } from '../g2/ios-peripheral-identity' import { formatBatteryLine } from '../g2/glasses-display-state' @@ -75,7 +75,7 @@ export function createMainPage(): Page { // The Settings tab's battery row. iOS reports charging sessions as // connected, so "connected" is the whole live-link condition here. let glassesLinked = false - const refreshBatteryLine = () => { model.batteryLine = formatBatteryLine(shell.getBatteryLevels(), glassesLinked) } + const refreshBatteryLine = () => { model.batteryLine = formatBatteryLine(shell.getBatteryLevels(), glassesLinked, glassesModelName()) } const keyboardField = () => keyboardPanel.getViewById('keyboardInputField') const controller = new IosPreviewController((image, label) => { mirror.imageSource = image; model.set('padFocusLine', label) diff --git a/app/phone-ui/main-view-model.ts b/app/phone-ui/main-view-model.ts index 5018f5b3..7df22327 100644 --- a/app/phone-ui/main-view-model.ts +++ b/app/phone-ui/main-view-model.ts @@ -17,6 +17,7 @@ import { import { dashboardController, type MirrorTouchKind } from "../g2/dashboard-controller"; import { formatBatteryLine } from "../g2/glasses-display-state"; import { + glassesModelName, mirrorTouchSetting, onAnySettingChanged, showBleBandwidthSetting, @@ -97,6 +98,7 @@ export class MainViewModel extends RemoteControlsViewModel { this.batteryLine = formatBatteryLine( snapshot.batteries, snapshot.phase === "connected" || snapshot.phase === "charging", + glassesModelName(), ); this.activeTextSettingId = snapshot.activeTextSettingId; this.activeTextEditorTitle = snapshot.activeTextEditorTitle; diff --git a/app/phone-ui/pairing-view-model.ts b/app/phone-ui/pairing-view-model.ts index cce2d110..78c743e3 100644 --- a/app/phone-ui/pairing-view-model.ts +++ b/app/phone-ui/pairing-view-model.ts @@ -293,7 +293,7 @@ export class PairingViewModel extends Observable { } if (this.selectedPair) { const identity = this.selectedPair.identity; - const label = identity ? identity.displayName : "Even Realities G2"; + const label = identity ? identity.displayName : this.selectedPair.g1Firmware ? "Even Realities G1" : "Even Realities G2"; parts.push( `${label} · serial ${this.selectedPair.serial ?? "unknown"}\n` + `Left ${this.selectedPair.left?.address ?? "?"} · Right ${this.selectedPair.right?.address ?? "?"}`, diff --git a/app/phone-ui/remote-controls.css b/app/phone-ui/remote-controls.css index 474e61c5..d096bb6d 100644 --- a/app/phone-ui/remote-controls.css +++ b/app/phone-ui/remote-controls.css @@ -116,7 +116,7 @@ color: #6a6a6a; margin-top: 4; } -/* The charging case's level under "Charging · G2 n%". */ +/* The charging case's level under "Charging: G2 n%". */ .pad-detail { font-size: 15; color: #b0b0b0; diff --git a/app/ui/dashboard-settings.ts b/app/ui/dashboard-settings.ts index 12c40d68..fdf914e0 100644 --- a/app/ui/dashboard-settings.ts +++ b/app/ui/dashboard-settings.ts @@ -313,7 +313,7 @@ export const phoneBatteryVisibilitySetting = batteryVisibilitySetting( "phoneBatteryVisibility", "Phone", "display.battery.phoneVisibility", ); export const glassesBatteryVisibilitySetting = batteryVisibilitySetting( - "glassesBatteryVisibility", "G2", "display.battery.glassesVisibility", + "glassesBatteryVisibility", "Glasses", "display.battery.glassesVisibility", ); export const ringBatteryVisibilitySetting = batteryVisibilitySetting( "ringBatteryVisibility", "R1", "display.battery.ringVisibility", @@ -408,6 +408,13 @@ export function glassesHaveCompass(): boolean { return glassesTypeSetting.get() === "g2"; } +const GLASSES_MODEL_NAMES: Record = { g2: "G2", g1: "G1", "rayneo-io": "iO" }; + +/** The paired glasses' model without the brand, short enough for battery labels and a watch's one-line charging status. */ +export function glassesModelName(): string { + return GLASSES_MODEL_NAMES[glassesTypeSetting.get()]; +} + const APP_SWITCHER_POSITION_LABELS: Record = { left: "Left", right: "Right", diff --git a/app/ui/dashboard/settings-menus.ts b/app/ui/dashboard/settings-menus.ts index cfa94bf0..d57f3cfb 100644 --- a/app/ui/dashboard/settings-menus.ts +++ b/app/ui/dashboard/settings-menus.ts @@ -54,6 +54,7 @@ import { dataCollectionSetting, distanceUnitSetting, glassesBatteryVisibilitySetting, + glassesModelName, phoneBatteryVisibilitySetting, ringBatteryVisibilitySetting, watchBatteryVisibilitySetting, @@ -387,7 +388,8 @@ function batteryIndicatorsMenuItem(): MenuItem { enumSettingMenuItem(batteryDisplayModeSetting), enumSettingMenuItem(phoneBatteryVisibilitySetting), enumSettingMenuItem(watchBatteryVisibilitySetting), - enumSettingMenuItem(glassesBatteryVisibilitySetting), + // Named as the top bar names this indicator. + enumSettingMenuItem(glassesBatteryVisibilitySetting, { label: glassesModelName() }), enumSettingMenuItem(ringBatteryVisibilitySetting), ]); }, diff --git a/app/ui/shell/chrome-layer.ts b/app/ui/shell/chrome-layer.ts index 54b1acd0..33d152d3 100644 --- a/app/ui/shell/chrome-layer.ts +++ b/app/ui/shell/chrome-layer.ts @@ -15,6 +15,7 @@ import { batteryDisplayModeSetting, batteryIndicatorVisible, glassesBatteryVisibilitySetting, + glassesModelName, phoneBatteryVisibilitySetting, ringBatteryVisibilitySetting, watchBatteryVisibilitySetting, @@ -1089,7 +1090,7 @@ function batteryItems(state: ShellChromeState): BatteryItem[] { Boolean(state.battery.watchCharging)); } if (state.battery.headset !== null && Number.isFinite(state.battery.headset)) { - pushBatteryItem(items, glassesBatteryVisibilitySetting.get(), "G2", "glasses", state.battery.headset, + pushBatteryItem(items, glassesBatteryVisibilitySetting.get(), glassesModelName(), "glasses", state.battery.headset, Boolean(state.battery.headsetCharging)); } if (state.battery.ring !== null && Number.isInteger(state.battery.ring) diff --git a/apple-watch/Faceclaw/PadStatus.swift b/apple-watch/Faceclaw/PadStatus.swift index 5007efa0..669fa5e5 100644 --- a/apple-watch/Faceclaw/PadStatus.swift +++ b/apple-watch/Faceclaw/PadStatus.swift @@ -42,7 +42,7 @@ func padLine(state: PhoneState?, link: LinkStatus) -> StatusLine { if !state.remoteEnabled { return StatusLine(text: "Watch control off", tone: .problem) } if state.connected { if state.charging || state.phase == "charging" { - return StatusLine(text: chargingLine(state.battery), tone: .busy, detail: caseLine(state)) + return StatusLine(text: chargingLine(state), tone: .busy, detail: caseLine(state)) } if state.silentMode { return StatusLine(text: "Silent mode", tone: .off) } if state.locked { return StatusLine(text: "Locked", tone: .off) } @@ -64,8 +64,8 @@ func padLine(state: PhoneState?, link: LinkStatus) -> StatusLine { return StatusLine(text: "Disconnected", tone: .off) } -private func chargingLine(_ battery: Int?) -> String { - battery.map { "Charging · G2 \($0)%" } ?? "Charging" +private func chargingLine(_ state: PhoneState) -> String { + state.battery.map { "Charging: \(state.glassesModel) \($0)%" } ?? "Charging" } /** diff --git a/apple-watch/Faceclaw/Protocol.swift b/apple-watch/Faceclaw/Protocol.swift index b7574d69..7ce85d7b 100644 --- a/apple-watch/Faceclaw/Protocol.swift +++ b/apple-watch/Faceclaw/Protocol.swift @@ -103,8 +103,10 @@ struct PhoneState: Equatable { var locked = false var worn: Bool? var listening = false - /** Current or last-known G2 charge percentage. */ + /** The glasses' current or last-known charge percentage. */ var battery: Int? + /** The paired glasses' model, as the charging line names it. */ + var glassesModel = "G2" var charging = false /** Last-known charging-case percentage; live only while the glasses are docked. */ var caseBattery: Int? @@ -139,6 +141,7 @@ struct PhoneState: Equatable { state.worn = o["worn"] as? Bool state.listening = o["listening"] as? Bool ?? false state.battery = percent(o["battery"]) + state.glassesModel = o["glassesModel"] as? String ?? "G2" state.charging = o["charging"] as? Bool ?? false state.caseBattery = percent(o["caseBattery"]) state.caseCharging = o["caseCharging"] as? Bool diff --git a/tests/app-layout.test.cjs b/tests/app-layout.test.cjs index 745e1cd8..23503aca 100644 --- a/tests/app-layout.test.cjs +++ b/tests/app-layout.test.cjs @@ -429,8 +429,9 @@ const shellScene = require('../.test-build/app/graphics/shell-scene.js'); const displayList = require('../.test-build/app/graphics/display-list.js'); const notificationTypes = require('../.test-build/app/native/notification-types.js'); const ICON = notificationTypes.NOTIFICATION_ICON_SIZE; -function chromeLayer(g, { notifications = 0, phoneBattery = null, windows = 1, trayIcons = [] } = {}) { - const font = { lineHeight: 12, ascent: 10, measureText: (text) => text.length * 4, +function chromeLayer(g, { notifications = 0, phoneBattery = null, windows = 1, trayIcons = [], glassesModel = 'G2' } = {}) { + const measuredText = []; + const font = { lineHeight: 12, ascent: 10, measureText: (text) => { measuredText.push(text); return text.length * 4; }, drawText: (image, x, y, text, value) => { for (let i = 0; i < text.length; i++) image.fillRect(x + i * 4, y + 2, 2, 6, value); } }; let nextKey = 100; const requested = []; @@ -451,7 +452,7 @@ function chromeLayer(g, { notifications = 0, phoneBattery = null, windows = 1, t '../../native/phone-battery': { readPhoneBatteryState: () => ({ battery: phoneBattery, charging: false }) }, '../../util/render-freshness': { renderPassAllowsStaleData: () => false }, '../dashboard-settings': { batteryDisplayModeSetting: { get: () => 'icon' }, phoneBatteryVisibilitySetting: settings, - batteryIndicatorVisible: () => true }, + glassesBatteryVisibilitySetting: settings, glassesModelName: () => glassesModel, batteryIndicatorVisible: () => true }, '../clock-format': { formatClockDate: () => 'Thu Oct 2', formatClockTime: () => '9:41' }, '../layers': { LayerStack: { allocateShellKey: () => nextKey++ } }, // As in menu.ts. @@ -469,11 +470,19 @@ function chromeLayer(g, { notifications = 0, phoneBattery = null, windows = 1, t }; let heightChanges = 0; const chrome = new context.exports.ShellChromeLayer(() => state, () => heightChanges++); - return { chrome, state, requested, planBottomBar: context.exports.planBottomBar, heightChanges: () => heightChanges }; + return { chrome, state, requested, measuredText, planBottomBar: context.exports.planBottomBar, heightChanges: () => heightChanges }; } const notification = (key) => ({ kind: 'notification', key }); const keysOf = (items) => Array.from(items, (item) => item.key); +test('the top bar labels the glasses battery with the paired model', () => { + const { chrome, state, measuredText } = chromeLayer(geometry(), { glassesModel: 'G1' }); + state.battery.headset = 72; + chrome.paintParts(); + assert.ok(measuredText.includes('G1')); + assert.ok(!measuredText.includes('G2')); +}); + test('a bottom app switcher frames the foreground window\'s content in a rounded border', () => { const g = geometry(); g.settings.appSwitcherPositionSetting.value = 'bottom'; diff --git a/tests/display-layout-setting.test.cjs b/tests/display-layout-setting.test.cjs index 8c583682..d9027ddf 100644 --- a/tests/display-layout-setting.test.cjs +++ b/tests/display-layout-setting.test.cjs @@ -35,6 +35,14 @@ test('the display mode starts as the middle band, or carries over the old mode a assert.equal(api.displayLayoutSetting.get(), 'band-bottom'); }); +test('the glasses model name follows the paired glasses type', () => { + const model = (entries) => settingsFixture(new Map(entries)).glassesModelName(); + assert.equal(model([]), 'G2'); + assert.equal(model([['deviceType', 'g2']]), 'G2'); + assert.equal(model([['deviceType', 'g1']]), 'G1'); + assert.equal(model([['deviceType', 'rayneo-io']]), 'iO'); +}); + test('per-app display modes carry over their old mode and position where the merged values can say it', () => { const app = (appId, entries) => settingsFixture(new Map(entries))[`${appId}DisplayLayoutSetting`].get(); assert.equal(app('navigate', []), 'global'); diff --git a/tests/glasses-display-state.test.cjs b/tests/glasses-display-state.test.cjs index 369bf045..355ea9ee 100644 --- a/tests/glasses-display-state.test.cjs +++ b/tests/glasses-display-state.test.cjs @@ -15,6 +15,7 @@ const connected = { silentMode: false, screenOn: true, battery: 72, + glassesModel: "G2", caseBattery: null, caseCharging: null, foregroundTitle: "Music", @@ -37,22 +38,23 @@ test("only the Display off state counts as asleep (the watch face's wake hint)", assert.equal(glassesDisplayAsleep({ ...connected, phase: "disconnected", screenOn: false }), false); }); -test("charging takes precedence and includes the last-known G2 battery", () => { +test("charging takes precedence and includes the glasses' model and last-known battery", () => { assert.equal( glassesDisplayLabel({ ...connected, phase: "charging", silentMode: true, screenOn: false }), - "Charging · G2 72%", + "Charging: G2 72%", ); - assert.equal(chargingDisplayLabel(null), "Charging"); - assert.equal(chargingDisplayLabel(-1), "Charging"); - assert.equal(chargingDisplayLabel(101), "Charging"); + assert.equal(glassesDisplayLabel({ ...connected, phase: "charging", glassesModel: "G1" }), "Charging: G1 72%"); + assert.equal(chargingDisplayLabel(null, "G2"), "Charging"); + assert.equal(chargingDisplayLabel(-1, "G2"), "Charging"); + assert.equal(chargingDisplayLabel(101, "G2"), "Charging"); }); test("while charging, the case level is the watch face's second line and joins the mirror's message", () => { const charging = { ...connected, phase: "charging", caseBattery: 64, caseCharging: false }; - assert.equal(glassesDisplayLabel(charging), "Charging · G2 72%"); + assert.equal(glassesDisplayLabel(charging), "Charging: G2 72%"); assert.equal(glassesDisplayDetail(charging), "Case 64%"); assert.equal(glassesDisplayDetail({ ...charging, caseCharging: true }), "Case 64% ⚡"); - assert.equal(chargingPreviewMessage(charging), "Charging · G2 72% · Case 64%"); + assert.equal(chargingPreviewMessage(charging), "Charging: G2 72% · Case 64%"); // No case level yet: the label alone. assert.equal(glassesDisplayDetail({ ...charging, caseBattery: null }), ""); assert.equal(chargingPreviewMessage({ ...charging, caseBattery: null, battery: null }), "Charging"); @@ -65,14 +67,19 @@ const levels = { }; test("the Settings battery line lists each known level, with ⚡ only while the reading is live", () => { - assert.equal(formatBatteryLine(levels, true), "G2 87% ⚡ · Case 64% ⚡ · R1 72%"); + assert.equal(formatBatteryLine(levels, true, "G2"), "G2 87% ⚡ · Case 64% ⚡ · R1 72%"); // Without a link to the glasses their charging state and the case's are stale. - assert.equal(formatBatteryLine({ ...levels, ringCharging: true }, false), "G2 87% · Case 64% · R1 72% ⚡"); + assert.equal(formatBatteryLine({ ...levels, ringCharging: true }, false, "G2"), "G2 87% · Case 64% · R1 72% ⚡"); // caseCharging is null while the glasses are out of the case. - assert.equal(formatBatteryLine({ ...levels, caseCharging: null }, true), "G2 87% ⚡ · Case 64% · R1 72%"); - assert.equal(formatBatteryLine({ ...levels, case: null, ring: null }, true), "G2 87% ⚡"); + assert.equal(formatBatteryLine({ ...levels, caseCharging: null }, true, "G2"), "G2 87% ⚡ · Case 64% · R1 72%"); + assert.equal(formatBatteryLine({ ...levels, case: null, ring: null }, true, "G2"), "G2 87% ⚡"); assert.equal( - formatBatteryLine({ headset: null, headsetCharging: null, case: null, caseCharging: null, ring: null, ringCharging: null }, true), + formatBatteryLine({ headset: null, headsetCharging: null, case: null, caseCharging: null, ring: null, ringCharging: null }, true, "G2"), "", ); }); + +test("the Settings battery line names the paired glasses", () => { + assert.equal(formatBatteryLine({ ...levels, case: null, ring: null }, true, "G1"), "G1 87% ⚡"); + assert.equal(formatBatteryLine({ ...levels, case: null, ring: null }, true, "iO"), "iO 87% ⚡"); +}); diff --git a/tests/ios-app-host.test.cjs b/tests/ios-app-host.test.cjs index 37cf988f..2b50043b 100644 --- a/tests/ios-app-host.test.cjs +++ b/tests/ios-app-host.test.cjs @@ -212,7 +212,7 @@ test('iOS bandwidth footer toggles live, polls only in foreground and resets its './phone-gestures': { PhoneGestureRecognizer: class { cancel() {} } }, './ble-bandwidth-meter': require('../.test-build/app/phone-ui/ble-bandwidth-meter.js'), '../native/ble-traffic': { sampleBleTraffic: () => totals }, - '../ui/dashboard-settings': { brightnessSetting: { get: () => 'auto' }, displayLayoutSetting: { displayValue: () => 'Tall' }, showBleBandwidthSetting: { get: () => enabled }, + '../ui/dashboard-settings': { brightnessSetting: { get: () => 'auto' }, displayLayoutSetting: { displayValue: () => 'Tall' }, showBleBandwidthSetting: { get: () => enabled }, glassesModelName: () => 'G2', onAnySettingChanged: fn => { settingListeners.add(fn); return () => settingListeners.delete(fn); } }, '../g2/device-addresses': { loadDeviceAddresses: () => ({}) }, '../g2/ios-peripheral-identity': { deviceAddressError: () => 'no test devices' }, diff --git a/tests/ios-watch-remote.test.cjs b/tests/ios-watch-remote.test.cjs index 57047b60..f656885c 100644 --- a/tests/ios-watch-remote.test.cjs +++ b/tests/ios-watch-remote.test.cjs @@ -125,6 +125,7 @@ function loadRemote({ phase = 'disconnected', preview = false, now = 1_800_000_0 '../apps/evenhub/installed-apps': { getInstalledEvenHubApps: () => [], installedEvenHubAppId: id => id }, '../native/wear-bridge': { wearBridge: bridge, WEAR_PATHS: types().WEAR_PATHS }, '../ui/dashboard-settings': { + glassesModelName: () => 'G1', onAnySettingChanged() {}, watchCanUnlockSetting: setting(true), watchCrownClockwiseNextSetting: setting(false), watchMirrorAssistantSetting: setting(true), watchRemoteEnabledSetting: setting(true), watchVibrateOnInputSetting: setting(true), watchSoundEffectsSetting: setting(false), @@ -214,6 +215,10 @@ test('the mirrored state carries the Apple Watch feedback settings', () => { assert.equal(state.soundEffects, false); }); +test('the mirrored state names the glasses for the charging line', () => { + assert.equal(loadRemote({ phase: 'charging' }).remote.buildState().glassesModel, 'G1'); +}); + test('the mirrored state says when gestures are landing on the preview', () => { const state = loadRemote({ preview: true }).remote.buildState(); assert.equal(state.preview, true); diff --git a/wear/PROTOCOL.md b/wear/PROTOCOL.md index 02316c92..b70459a1 100644 --- a/wear/PROTOCOL.md +++ b/wear/PROTOCOL.md @@ -62,7 +62,7 @@ dashboard state, re-sent whenever it changes (and at least every 30 s): "protocol": 1, "version": "…", "phase": "connected", "status": "…", "connected": true, "preview": false, "screenOn": true, "locked": false, "worn": true, "listening": false, - "battery": 78, "charging": false, "silentMode": false, + "battery": 78, "glassesModel": "G2", "charging": false, "silentMode": false, "caseBattery": 64, "caseCharging": true, "foreground": {"appId": "music", "title": "Music"}, "windows": [{"windowId": "…", "title": "…", "appId": "…", "focused": true, "closeable": true, "acceptsText": false}], @@ -74,9 +74,11 @@ dashboard state, re-sent whenever it changes (and at least every 30 s): } ``` -`battery` is the current or last-known G2 percentage. `charging` and -`silentMode` identify the two states in which the glasses display is not -visible even though the BLE session remains available. +`battery` is the glasses' current or last-known percentage, and `glassesModel` +is what the charging line calls them: `G2`, `G1` or `iO` (a watch treats a +missing one, from an older phone app, as `G2`). `charging` and `silentMode` +identify the two states in which the glasses display is not visible even though +the BLE session remains available. `caseBattery` is the last-known charging-case percentage, or null until the glasses have reported one; the case only reports while the glasses are docked, diff --git a/wear/app/src/main/kotlin/com/faceclaw/wear/Protocol.kt b/wear/app/src/main/kotlin/com/faceclaw/wear/Protocol.kt index a3dd0413..35c27cf8 100644 --- a/wear/app/src/main/kotlin/com/faceclaw/wear/Protocol.kt +++ b/wear/app/src/main/kotlin/com/faceclaw/wear/Protocol.kt @@ -92,8 +92,10 @@ data class PhoneState( val locked: Boolean, val worn: Boolean?, val listening: Boolean, - /** Current or last-known G2 charge percentage. */ + /** The glasses' current or last-known charge percentage. */ val battery: Int?, + /** The paired glasses' model, as the charging line names it. */ + val glassesModel: String, val charging: Boolean, /** Last-known charging-case percentage; live only while the glasses are docked. */ val caseBattery: Int?, @@ -126,6 +128,7 @@ data class PhoneState( worn = if (o.isNull("worn")) null else o.optBoolean("worn"), listening = o.optBoolean("listening", false), battery = if (o.isNull("battery")) null else o.optInt("battery", -1).takeIf { it in 0..100 }, + glassesModel = o.optString("glassesModel", "G2"), charging = o.optBoolean("charging", false), caseBattery = if (o.isNull("caseBattery")) null else o.optInt("caseBattery", -1).takeIf { it in 0..100 }, caseCharging = if (o.isNull("caseCharging")) null else o.optBoolean("caseCharging"), diff --git a/wear/app/src/main/kotlin/com/faceclaw/wear/ui/Common.kt b/wear/app/src/main/kotlin/com/faceclaw/wear/ui/Common.kt index 0d5037f7..1875e7e4 100644 --- a/wear/app/src/main/kotlin/com/faceclaw/wear/ui/Common.kt +++ b/wear/app/src/main/kotlin/com/faceclaw/wear/ui/Common.kt @@ -81,7 +81,7 @@ fun padLine(state: PhoneState?, link: LinkStatus): StatusLine = when { state.remoteEnabled == false -> StatusLine("Watch control off", StatusTone.PROBLEM) state.connected -> when { state.charging || state.phase == "charging" -> - StatusLine(chargingLine(state.battery), StatusTone.BUSY, caseLine(state)) + StatusLine(chargingLine(state), StatusTone.BUSY, caseLine(state)) state.silentMode -> StatusLine("Silent mode", StatusTone.OFF) state.locked -> StatusLine("Locked", StatusTone.OFF) !state.screenOn -> StatusLine("●● Wake", StatusTone.OFF) @@ -93,8 +93,8 @@ fun padLine(state: PhoneState?, link: LinkStatus): StatusLine = when { else -> StatusLine("Disconnected", StatusTone.OFF) } -private fun chargingLine(battery: Int?): String = - if (battery != null) "Charging · G2 $battery%" else "Charging" +private fun chargingLine(state: PhoneState): String = + state.battery?.let { "Charging: ${state.glassesModel} $it%" } ?: "Charging" /** * "Case 64%", with ⚡ while the case is on USB; null when the level is