Merge silent-exit display recovery

# Conflicts:
#	docs/validation-silent-mode.md
This commit is contained in:
Blendman974 committed 2026-11-06 22:28:09 +01:00
commit f9d3edf58c
4 files changed
+57 -23

No files matched your search

+21 -5
View File
@@ -296,6 +296,7 @@ class DashboardController {
private displayPreviewCrop: ScreenRect | null = null; private displayPreviewCrop: ScreenRect | null = null;
private silentMode = false; private silentMode = false;
private silentModeFeedback = ""; private silentModeFeedback = "";
private silentModeFeedbackGeneration = 0;
private silentModeFeedbackTimer: ReturnType<typeof setTimeout> | null = null; private silentModeFeedbackTimer: ReturnType<typeof setTimeout> | null = null;
// Brightness value last pushed to the glasses; see pushBrightness. // Brightness value last pushed to the glasses; see pushBrightness.
private lastPushedBrightness: string | null = null; private lastPushedBrightness: string | null = null;
@@ -1206,17 +1207,16 @@ class DashboardController {
private handleSilentMode(silent: boolean): void { private handleSilentMode(silent: boolean): void {
if (this.silentMode === silent) return; if (this.silentMode === silent) return;
this.silentMode = silent; this.silentMode = silent;
const generation = ++this.silentModeFeedbackGeneration;
if (this.silentModeFeedbackTimer !== null) clearTimeout(this.silentModeFeedbackTimer); if (this.silentModeFeedbackTimer !== null) clearTimeout(this.silentModeFeedbackTimer);
this.silentModeFeedbackTimer = null; this.silentModeFeedbackTimer = null;
this.silentModeFeedback = silent this.silentModeFeedback = silent
? "Silent mode enabled — hold both touchpads to exit" ? "Silent mode enabled — hold both touchpads to exit"
: "Silent mode disabled"; : "Silent mode disabled";
if (!silent) { if (!silent) {
// Do not wake a sleeping/locked display merely to announce a state change. void this.showSilentModeExit(generation).catch(error => {
if (this.phase === "connected" && shell.isScreenOn() && !this.glassesLocked) { this.appendLog(`silent-mode exit feedback failed: ${this.formatError(error)}`);
shell.showAlert("Silent mode disabled"); });
shell.foregroundWindow()?.requestRender();
}
this.silentModeFeedbackTimer = setTimeout(() => { this.silentModeFeedbackTimer = setTimeout(() => {
this.silentModeFeedbackTimer = null; this.silentModeFeedbackTimer = null;
this.silentModeFeedback = ""; this.silentModeFeedback = "";
@@ -1226,6 +1226,21 @@ class DashboardController {
this.emit(); this.emit();
} }
private async showSilentModeExit(generation: number): Promise<void> {
if (this.phase !== "connected" || this.silentMode || this.glassesLocked) return;
// The firmware powered the lenses down, and Faceclaw may have gone to
// sleep/suspended EvenHub meanwhile. Reusing the ordinary wake barrier is
// essential: rendering an alert into the retained surface alone is invisible.
this.cancelEvenHubSuspendTimer();
shell.wake("sidebar");
const ready = await this.ensureEvenHubSessionActive();
if (!ready || generation !== this.silentModeFeedbackGeneration || this.silentMode ||
this.phase !== "connected" || this.glassesLocked) return;
shell.showAlert("Silent mode disabled");
shell.foregroundWindow()?.requestRender();
this.requestShellRender();
}
private displayPreviewMessage(): string { private displayPreviewMessage(): string {
if (this.phase === "charging") { if (this.phase === "charging") {
return chargingPreviewMessage(this.glassesDisplayState()); return chargingPreviewMessage(this.glassesDisplayState());
@@ -3029,6 +3044,7 @@ class DashboardController {
// Kept across "connecting": silent mode blocks app launches, so it can // Kept across "connecting": silent mode blocks app launches, so it can
// itself cause the reconnect churn, and Java re-reports it either way. // itself cause the reconnect churn, and Java re-reports it either way.
this.silentMode = false; this.silentMode = false;
this.silentModeFeedbackGeneration++;
if (this.silentModeFeedbackTimer !== null) clearTimeout(this.silentModeFeedbackTimer); if (this.silentModeFeedbackTimer !== null) clearTimeout(this.silentModeFeedbackTimer);
this.silentModeFeedbackTimer = null; this.silentModeFeedbackTimer = null;
this.silentModeFeedback = ""; this.silentModeFeedback = "";
+2 -2
View File
@@ -10,14 +10,14 @@ Each feature branch starts from this main and groups related changes, without un
| fix: align the llama native library for Android 16 KiB pages | `fix/android-16k-pages` | [#2](https://git.undefined-dev.fr/Blendman974/faceclaw/pulls/2) | 1061 passed, 2 skipped | | fix: align the llama native library for Android 16 KiB pages | `fix/android-16k-pages` | [#2](https://git.undefined-dev.fr/Blendman974/faceclaw/pulls/2) | 1061 passed, 2 skipped |
| feat: configurable notification defaults and bulk actions | `feat/notifications` | [#3](https://git.undefined-dev.fr/Blendman974/faceclaw/pulls/3) | 1067 passed, 2 skipped | | feat: configurable notification defaults and bulk actions | `feat/notifications` | [#3](https://git.undefined-dev.fr/Blendman974/faceclaw/pulls/3) | 1067 passed, 2 skipped |
| feat: share Android calendar selection across calendar readers | `feat/calendar-selection` | [#4](https://git.undefined-dev.fr/Blendman974/faceclaw/pulls/4) | 1065 passed, 2 skipped | | feat: share Android calendar selection across calendar readers | `feat/calendar-selection` | [#4](https://git.undefined-dev.fr/Blendman974/faceclaw/pulls/4) | 1065 passed, 2 skipped |
| feat: shared head-up/down controls and experimental angle measurement | `feat/head-up-wake` | [#5](https://git.undefined-dev.fr/Blendman974/faceclaw/pulls/5) | 1070 passed, 2 skipped | | feat: configure head-up wake and wake angle | `feat/head-up-wake` | [#5](https://git.undefined-dev.fr/Blendman974/faceclaw/pulls/5) | 1063 passed, 2 skipped |
| feat: system menu controls for app closing, full screen and keep awake | `feat/app-controls` | [#6](https://git.undefined-dev.fr/Blendman974/faceclaw/pulls/6) | 1076 passed, 2 skipped | | feat: system menu controls for app closing, full screen and keep awake | `feat/app-controls` | [#6](https://git.undefined-dev.fr/Blendman974/faceclaw/pulls/6) | 1076 passed, 2 skipped |
| feat: language selection for OpenAI and on-device Whisper | `feat/whisper-languages` | [#7](https://git.undefined-dev.fr/Blendman974/faceclaw/pulls/7) | 1067 passed, 2 skipped | | feat: language selection for OpenAI and on-device Whisper | `feat/whisper-languages` | [#7](https://git.undefined-dev.fr/Blendman974/faceclaw/pulls/7) | 1067 passed, 2 skipped |
| feat: configurable app and system menu hold gestures | `feat/menu-gesture-preference` | [#8](https://git.undefined-dev.fr/Blendman974/faceclaw/pulls/8) | 1072 passed, 2 skipped | | feat: configurable app and system menu hold gestures | `feat/menu-gesture-preference` | [#8](https://git.undefined-dev.fr/Blendman974/faceclaw/pulls/8) | 1072 passed, 2 skipped |
| feat: editable launcher folders, icon layout and open-window order | `feat/launcher-layout` | [#9](https://git.undefined-dev.fr/Blendman974/faceclaw/pulls/9) | 1080 passed, 2 skipped | | feat: editable launcher folders, icon layout and open-window order | `feat/launcher-layout` | [#9](https://git.undefined-dev.fr/Blendman974/faceclaw/pulls/9) | 1080 passed, 2 skipped |
| fix: silent-mode feedback and prompt exit-state refresh | `fix/silent-mode-feedback` | [#10](https://git.undefined-dev.fr/Blendman974/faceclaw/pulls/10) | 1065 passed, 2 skipped | | fix: silent-mode feedback and prompt exit-state refresh | `fix/silent-mode-feedback` | [#10](https://git.undefined-dev.fr/Blendman974/faceclaw/pulls/10) | 5 focused tests; combined suite passed |
All independent branches also passed `tsc --noEmit`. The head-up branch received a final import-only cleanup and was typechecked/linted again. All independent branches also passed `tsc --noEmit`. The head-up branch received a final import-only cleanup and was typechecked/linted again.
+4 -4
View File
@@ -1,13 +1,13 @@
# Silent-mode feedback # Silent-mode feedback
The firmware blanks the lenses and stops ordinary input while silent mode is active. App code cannot display an activation popup on lenses that the firmware has switched off. The phone now shows a persistent enabled banner with the exit gesture, and a five-second disabled banner on exit. Awake, unlocked glasses also show the existing alert popup on exit; no display is woken solely for feedback. Duplicate state reports do not repeat feedback, stale timers are cancelled, and disconnect clears the notice. The firmware blanks the lenses and stops ordinary input while silent mode is active. App code cannot display an activation popup on lenses that the firmware has switched off. The phone now shows a persistent enabled banner with the exit gesture, and a five-second disabled banner on exit. On exit, unlocked glasses wake through the normal screen/EvenHub barrier before the alert popup is rendered. This also handles the shell falling asleep during a long silent period. Locked glasses keep the phone feedback without being woken. A generation check suppresses stale notices after re-entry or disconnect. Duplicate state reports do not repeat feedback, stale timers are cancelled, and disconnect clears the notice.
Silent-off firmware pushes are not reliable. The existing fallback read used the five-minute battery cadence. While silent mode is known to be on, settings are now polled every two seconds when the session is ready and the message queues are idle. Normal battery cadence and shutdown guards are retained. This bounds ordinary missing-push recovery without assuming a touch gesture always means silent mode ended. Silent-off firmware pushes are not reliable. The existing fallback read used the five-minute battery cadence. While silent mode is known to be on, settings are now polled every two seconds when the session is ready and the message queues are idle. Normal battery cadence and shutdown guards are retained. This bounds ordinary missing-push recovery without assuming a touch gesture always means silent mode ended.
Independent JavaScript suite: 1065 passed, 2 skipped. TypeScript and changed-source lint passed. Controller tests cover enabled/disabled notices, duplicates, timer cancellation, disconnect and sleeping/locked displays. A Kotlin session test checks the two-second silent cadence, normal cadence and shutdown guard. Kotlin compilation and hardware checks are tracked with the combined integration validation. Initial independent JavaScript suite: 1065 passed, 2 skipped. The wake-barrier follow-up passes 5 focused tests and the combined suite. TypeScript and changed-source lint passed. Controller tests cover enabled/disabled notices, duplicates, timer cancellation, disconnect and sleeping-display recovery, locked displays, wake-barrier failure and stale async completion. A Kotlin session test checks the two-second silent cadence, normal cadence and shutdown guard. Kotlin compilation and hardware checks are tracked with the combined integration validation.
Hardware validation remains pending: both transitions via the temple gesture, missing exit push, phone background/foreground, lenses that are awake/asleep/locked, reconnect and charging. No firmware was flashed. Hardware validation remains pending: both transitions via the temple gesture, missing exit push, phone background/foreground, lenses that are awake/asleep/locked, reconnect and charging. No firmware was flashed.
Combined validation: 1135 JavaScript tests passed, 2 skipped; all 276 Kotlin Android host tests passed. TypeScript and changed-source lint passed. Hardware validation remains pending. Follow-up after device-log inspection: both silent transitions arrived, but the exit could occur after the normal idle timeout. Exit now cancels pending suspension, wakes the shell, awaits the existing EvenHub/screen wake barrier and only then shows the notice. It resets idle activity through the ordinary wake path. Re-entry, disconnect, locking or a failed resume suppress stale asynchronous notices. Activation still turns the lenses off in firmware; phone feedback does not claim a lens-side activation popup.
The combined Android release APK builds successfully; signature, non-debug manifest, ELF 16 KiB alignment and ZIP alignment checks passed. It was not installed during this task. Current combined validation after removing tilt-down/current-angle measurement: 1129 JavaScript tests passed, 2 skipped; 273 Kotlin Android host tests passed. TypeScript and changed-source lint passed. Android release build, signature and ELF/ZIP 16 KiB alignment checks passed. The rebuilt APK has not been installed during this follow-up; physical display confirmation remains pending.
+30 -12
View File
@@ -6,41 +6,59 @@ const ts = require('typescript');
function fixture() { function fixture() {
const source = ts.createSourceFile('controller.ts', fs.readFileSync('app/g2/dashboard-controller.ts', 'utf8'), ts.ScriptTarget.Latest, true); const source = ts.createSourceFile('controller.ts', fs.readFileSync('app/g2/dashboard-controller.ts', 'utf8'), ts.ScriptTarget.Latest, true);
const cls = source.statements.find(n => ts.isClassDeclaration(n) && n.name?.text === 'DashboardController'); const cls = source.statements.find(n => ts.isClassDeclaration(n) && n.name?.text === 'DashboardController');
const methods = cls.members.filter(n => ['handleSilentMode', 'setPhase'].includes(n.name?.getText(source))); const methods = cls.members.filter(n => ['handleSilentMode', 'showSilentModeExit', 'setPhase'].includes(n.name?.getText(source)));
const alerts = [], timers = new Map(); let next = 0, on = true; const alerts = [], timers = new Map(); let next = 0, on = true, wakes = 0;
const context = { exports: {}, setTimeout: fn => { timers.set(++next, fn); return next; }, clearTimeout: id => timers.delete(id), const context = { exports: {}, setTimeout: fn => { timers.set(++next, fn); return next; }, clearTimeout: id => timers.delete(id),
updateGlassesPresence() {}, shell: { isScreenOn: () => on, showAlert: text => alerts.push(text), updateGlassesPresence() {}, shell: { isScreenOn: () => on, wake: () => { on = true; wakes++; }, showAlert: text => alerts.push(text),
foregroundWindow: () => ({ requestRender() {} }), setBatteryLevels() {}, getBatteryLevels: () => ({}) } }; foregroundWindow: () => ({ requestRender() {} }), setBatteryLevels() {}, getBatteryLevels: () => ({}) } };
vm.runInNewContext(ts.transpileModule(`export class Controller { ${methods.map(n => n.getText(source)).join('\n')} }`, { vm.runInNewContext(ts.transpileModule(`export class Controller { ${methods.map(n => n.getText(source)).join('\n')} }`, {
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 }, compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
}).outputText, context); }).outputText, context);
const c = new context.exports.Controller(); const c = new context.exports.Controller();
Object.assign(c, { silentMode: false, silentModeFeedback: '', silentModeFeedbackTimer: null, phase: 'connected', emit() {} }); Object.assign(c, { silentMode: false, silentModeFeedback: '', silentModeFeedbackTimer: null, silentModeFeedbackGeneration: 0, phase: 'connected', emit() {},
return { c, alerts, timers, dark: () => { on = false; }, expire() { const callbacks = [...timers.values()]; timers.clear(); callbacks.forEach(fn => fn()); } }; cancelEvenHubSuspendTimer() {}, ensureEvenHubSessionActive: async () => true, requestShellRender() {},
appendLog() {}, formatError: error => String(error) });
return { c, alerts, timers, wakes: () => wakes, dark: () => { on = false; }, expire() { const callbacks = [...timers.values()]; timers.clear(); callbacks.forEach(fn => fn()); } };
} }
test('silent activation remains visible on phone; exit is visible on phone and awake glasses', () => { test('silent activation remains visible on phone; exit waits for the display wake barrier', async () => {
const h = fixture(); h.c.handleSilentMode(false); const h = fixture(); h.c.handleSilentMode(false);
assert.equal(h.c.silentModeFeedback, ''); assert.equal(h.c.silentModeFeedback, '');
h.c.handleSilentMode(true); h.c.handleSilentMode(true);
assert.match(h.c.silentModeFeedback, /enabled/); assert.equal(h.timers.size, 0); assert.equal(h.alerts.length, 0); assert.match(h.c.silentModeFeedback, /enabled/); assert.equal(h.timers.size, 0); assert.equal(h.alerts.length, 0);
h.c.handleSilentMode(false); h.c.handleSilentMode(false);
assert.equal(h.c.silentModeFeedback, 'Silent mode disabled'); assert.equal(h.c.silentModeFeedback, 'Silent mode disabled');
await new Promise(setImmediate);
assert.deepEqual(h.alerts, ['Silent mode disabled']); assert.deepEqual(h.alerts, ['Silent mode disabled']);
h.expire(); assert.equal(h.c.silentModeFeedback, ''); h.expire(); assert.equal(h.c.silentModeFeedback, '');
}); });
test('repeated state reports do not duplicate feedback; an old timer cannot clear a new activation', () => { test('repeated state reports do not duplicate feedback; an old timer cannot clear a new activation', async () => {
const h = fixture(); h.c.handleSilentMode(true); h.c.handleSilentMode(false); const h = fixture(); h.c.handleSilentMode(true); h.c.handleSilentMode(false);
h.c.handleSilentMode(false); assert.equal(h.alerts.length, 1); h.c.handleSilentMode(false); await new Promise(setImmediate); assert.equal(h.alerts.length, 1);
h.c.handleSilentMode(true); h.expire(); h.c.handleSilentMode(true); h.expire();
assert.match(h.c.silentModeFeedback, /enabled/); assert.match(h.c.silentModeFeedback, /enabled/);
}); });
test('silent exit never wakes a sleeping or locked display for its announcement', () => { test('silent exit wakes a sleeping display before showing feedback but leaves locked glasses alone', async () => {
for (const locked of [false, true]) { for (const locked of [false, true]) {
const h = fixture(); if (locked) h.c.glassesLocked = true; else h.dark(); const h = fixture(); h.c.glassesLocked = locked; h.dark();
h.c.handleSilentMode(true); h.c.handleSilentMode(false); h.c.handleSilentMode(true); h.c.handleSilentMode(false); await new Promise(setImmediate);
assert.equal(h.alerts.length, 0); assert.equal(h.c.silentModeFeedback, 'Silent mode disabled'); assert.equal(h.wakes(), locked ? 0 : 1);
assert.equal(h.alerts.length, locked ? 0 : 1);
assert.equal(h.c.silentModeFeedback, 'Silent mode disabled');
} }
}); });
test('an unavailable session, re-entry into silence or disconnect suppresses a stale exit popup', async () => {
for (const state of ['not-ready', 'silent', 'disconnected']) {
const h = fixture(); let finish;
h.c.ensureEvenHubSessionActive = () => new Promise(resolve => { finish = resolve; });
h.c.handleSilentMode(true); h.c.handleSilentMode(false);
assert.equal(h.alerts.length, 0);
if (state === 'silent') h.c.handleSilentMode(true);
if (state === 'disconnected') h.c.setPhase('disconnected');
finish(state !== 'not-ready'); await new Promise(setImmediate);
assert.equal(h.alerts.length, 0);
}
});
test('disconnect clears feedback and any pending timer without announcing a silent exit', () => { test('disconnect clears feedback and any pending timer without announcing a silent exit', () => {
const h = fixture(); h.c.handleSilentMode(true); h.c.handleSilentMode(false); const h = fixture(); h.c.handleSilentMode(true); h.c.handleSilentMode(false);
h.c.setPhase('disconnected'); h.c.setPhase('disconnected');