From 48a2bd17577ffda8fff6b2d3089e559e8eb22144 Mon Sep 17 00:00:00 2001 From: James Babcock Date: Sun, 27 Sep 2026 18:27:38 -0700 Subject: [PATCH] Putting on the glasses auto-wakes the screen --- app/g2/dashboard-controller.ts | 22 +++++++++++++++++++++- app/g2/ios-preview-controller.ts | 4 ++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/app/g2/dashboard-controller.ts b/app/g2/dashboard-controller.ts index 1b5b0978..1f1c3648 100644 --- a/app/g2/dashboard-controller.ts +++ b/app/g2/dashboard-controller.ts @@ -149,6 +149,9 @@ const SHELL_REFRESH_INTERVAL_MS = 60_000; // schedules a refresh), so this just covers anything that slips through. const PREVIEW_INTERVAL_MS = 1_000; const SCREEN_TIMEOUT_CHECK_MS = 1_000; +// The lock screen is a short notice, not something to read at leisure; it +// ignores the screen-timeout setting (including "never"). +const LOCK_SCREEN_TIMEOUT_MS = 15_000; const EVENHUB_SCREEN_OFF_SUSPEND_DELAY_MS = 5_000; const EVENHUB_WAKE_READY_TIMEOUT_MS = 4_500; const FOREGROUND_NOTIFICATION_MIN_UPDATE_MS = 30_000; @@ -365,7 +368,8 @@ class DashboardController { // surface, so their repaints go through the shell render path. requestRender: () => this.requestShellRender(), }, - getScreenTimeoutMs: () => screenTimeoutSettingToMs(screenTimeoutSetting.get()), + getScreenTimeoutMs: () => + this.glassesLocked ? LOCK_SCREEN_TIMEOUT_MS : screenTimeoutSettingToMs(screenTimeoutSetting.get()), requestShellRender: () => this.requestShellRender(), prepareVoiceCapture: () => this.prepareVoiceCapture(), onKeyboardInputChanged: (session) => { @@ -626,6 +630,9 @@ class DashboardController { } private handleWearState(wearing: boolean): void { + // Only an observed OFF_HEAD -> ON_HEAD transition counts as putting the + // glasses on; the first snapshot of a session (null) is just the status. + const putOn = wearing && this.glassesWorn === false; this.glassesWorn = wearing; updateGlassesPresence({ worn: wearing }); this.appendLog(wearing ? "glasses wear state: ON_HEAD" : "glasses wear state: OFF_HEAD"); @@ -633,6 +640,19 @@ class DashboardController { if (!wearing && this.phoneLocked && lockScreenEnabledSetting.get()) { this.setGlassesLocked(true, "glasses removed while phone locked"); } + if (putOn) this.wakeForGlassesPutOn(); + } + + /** + * Putting the glasses on wakes the screen, like a double-tap would. While + * locked that shows the lock-screen notice (which then times out on its + * own short timer); otherwise it lands on the sidebar as a normal wake. + */ + private wakeForGlassesPutOn(): void { + if (this.phase !== "connected" || !this.communicator || shell.isScreenOn()) return; + // wake() -> onScreenStateChanged(true) dismisses a showing Glanceboard, + // runs the EvenHub wake barrier and repaints the shell. + if (shell.wake("sidebar")) this.appendLog("screen woken: glasses put on"); } private handlePhoneLockState(locked: boolean): void { diff --git a/app/g2/ios-preview-controller.ts b/app/g2/ios-preview-controller.ts index 7e8ec2dd..6cb89bf3 100644 --- a/app/g2/ios-preview-controller.ts +++ b/app/g2/ios-preview-controller.ts @@ -362,9 +362,13 @@ export class IosPreviewController { // Sample false to catch a notification missed during suspension. Do not // sample true here: WillBecomeUnavailable precedes the property transition. if (!UIApplication.sharedApplication.protectedDataAvailable) this.handlePhoneLockState(true) + // Putting the glasses on (an observed OFF_HEAD -> ON_HEAD transition, not + // a session's first snapshot) wakes the screen, to the lock notice if locked. + const putOn = wearing && this.glassesWorn === false this.glassesWorn = wearing this.logBluetooth(`Glasses wear state: ${wearing ? 'ON_HEAD' : 'OFF_HEAD'}`) if (!wearing && this.phoneLocked && this.lockEnabled) this.setGlassesLocked(true) + if (putOn && this.runtimeRunning && !shell.isScreenOn()) shell.wake('sidebar') } private setGlassesLocked(locked: boolean): void { if (locked === this.glassesLocked) return