Refuse the flash with a reason when the glasses are in silent mode

Silent mode blanks the display and stops the firmware dispatching input while
BLE and GATT stay up, so the create-prompt page is written, accepted, and never
rendered. There is no touchpad event available to answer it with, and the flash
ends after four attempts on "prompt page not acked", which tells the wearer
nothing about what is wrong or what to do about it.

readBattery was already performing a sid-0x09 settings read whose ack carries
silentMode next to the battery, and the field was being discarded. readSettings
is factored out so one read serves both callers, and requireNotSilent runs it
before the prompt page is written. A positive report throws, and the existing
error path turns the message into what the wearer sees: that the glasses are in
silent mode, and that long-pressing both touchpads leaves it.

It refuses only on a positive report. An arm that does not answer, and firmware
whose ack omits the field, both fall through to the prompt exactly as before, so
older firmware is unaffected and a missing answer can never block a flash.

This replaces the phone-side confirmation fallback that was here before. An
unacked page is not by itself evidence that the prompt was never displayed, and
the on-lens step is what proves the glasses being flashed are the ones in front
of you, so overriding it on a timeout gave up more than it was worth.
This commit is contained in:
JMO committed 2026-09-23 08:12:19 -07:00
1 parent a7916a5479
commit 423f9fbcd1
3 files changed
+55 -95

No files matched your search

-62
View File
@@ -1,62 +0,0 @@
// The flash cannot always ask for confirmation on the lens: firmware older than
// the revision this build needs accepts the create-prompt write and then never
// answers it. Flashing is the only way off that firmware, so an unacked prompt
// must not be a dead end. These cover the decision at that seam.
const test = require('node:test');
const assert = require('node:assert/strict');
const { loader } = require('./helpers/load-typescript.cjs');
function fixture() {
class Observable { notifyPropertyChange() {} }
const load = loader({}, {
'@nativescript/core': { Observable, Frame: { topmost: () => null } },
'./onboarding-navigation': { finishOnboardingNavigation() {} },
'./onboarding-state': { setOnboardingCompleted() {}, setPreviewOnlyMode() {} },
'../native/ble-permissions': { ensureBlePermissions: async () => {} },
'../g2/device-addresses': {
isValidMacAddress: () => true,
loadDeviceAddresses: () => ({ right: 'R', left: 'L' }),
saveDeviceAddresses() {},
},
'../g2/firmware-builder': {
buildCustomFirmware: async () => '', buildStockFirmware: async () => '',
FirmwareBuildError: class extends Error {}, FirmwareProgress: {},
},
'../native/device-discovery': { buildAddressSet: () => new Set(), DeviceDiscoveryBridge: class {} },
'../native/firmware-flasher': { FirmwareFlasher: class {} },
'../native/flash-prompt-communicator': { FlashPromptCommunicator: class {} },
'../g2/reconnect-policy': { resumeAutoReconnect() {}, suppressAutoReconnect() {} },
'../util/format-error': { formatErrorMessage: (e) => String(e) },
});
const mod = load('app/phone-ui/onboarding-flash-view-model.ts');
const Model = mod.OnboardingFlashViewModel ?? Object.values(mod).find((v) => typeof v === 'function');
const model = new Model();
const beginArgs = [];
model.beginPrompt = async (options) => { beginArgs.push(options); };
return { model, beginArgs };
}
test('an unacked prompt page offers the phone-side confirmation instead of dead-ending', () => {
const { model, beginArgs } = fixture();
model.handlePromptState('error', 'prompt page not acked: AA:BB:CC:DD:EE:FF', false);
assert.equal(model.phase, 'error');
assert.equal(model.headline, 'Confirm On Your Phone');
assert.equal(model.primaryLabel, 'Confirm & Install', 'the action is a confirmation, not a retry');
assert.match(model.status, /can't show the confirmation prompt/i);
model.retryAction();
// The loader runs the module in its own vm realm, so the options object has that
// realm's prototype and deepStrictEqual would reject it. Compare the field.
assert.equal(beginArgs.length, 1);
assert.equal(beginArgs[0].skipPrompt, true, 'confirming must skip the lens prompt, not re-ask for it');
});
test('any other prompt failure still reports as an ordinary retry', () => {
const { model, beginArgs } = fixture();
model.handlePromptState('error', 'discoverServices failed: right arm', false);
assert.equal(model.phase, 'error');
assert.equal(model.headline, 'Something Went Wrong');
assert.equal(model.primaryLabel, 'Retry');
model.retryAction();
assert.equal(beginArgs.length, 1);
assert.equal(beginArgs[0].skipPrompt, false, 'an ordinary failure must not silently skip the lens prompt');
});