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

+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);