Battery indicators and other places no longer say "G2" when a G1 or iO is paired

This commit is contained in:
James Babcock committed 2026-11-07 22:56:31 -08:00
1 parent ac68ba5991
commit e103b89510
21 files changed
+101 -46

No files matched your search

+2 -1
View File
@@ -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);
}
+2 -1
View File
@@ -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,
+10 -8
View File
@@ -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],
];
+2
View File
@@ -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,
+2 -2
View File
@@ -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<TextView>('keyboardInputField')
const controller = new IosPreviewController((image, label) => {
mirror.imageSource = image; model.set('padFocusLine', label)
+2
View File
@@ -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;
+1 -1
View File
@@ -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 ?? "?"}`,
+1 -1
View File
@@ -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;
+8 -1
View File
@@ -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<GlassesType, string> = { 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<AppSwitcherPosition, string> = {
left: "Left",
right: "Right",
+3 -1
View File
@@ -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),
]);
},
+2 -1
View File
@@ -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)
+3 -3
View File
@@ -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"
}
/**
+4 -1
View File
@@ -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
+13 -4
View File
@@ -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';
+8
View File
@@ -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');
+19 -12
View File
@@ -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% ⚡");
});
+1 -1
View File
@@ -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' },
+5
View File
@@ -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);
+6 -4
View File
@@ -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,
@@ -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"),
@@ -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