forked from Blendman974/faceclaw
Wake the screen on wear faster after charging
This commit is contained in:
1 parent
2052e268b0
commit
deaa93fead
5 files changed
+71
-9
No files matched your search
@@ -291,6 +291,8 @@ class DashboardController {
|
|||||||
private customFirmwareConfirmed = false;
|
private customFirmwareConfirmed = false;
|
||||||
private faceclawWakeLeaseState: boolean | null = null;
|
private faceclawWakeLeaseState: boolean | null = null;
|
||||||
private glassesWorn: boolean | null = null;
|
private glassesWorn: boolean | null = null;
|
||||||
|
/** Put on while charging: Java reconnects on that, and the wake waits for the new session. */
|
||||||
|
private wakeAfterChargingReconnect = false;
|
||||||
private phoneLocked = false;
|
private phoneLocked = false;
|
||||||
private glassesLocked = false;
|
private glassesLocked = false;
|
||||||
// Wear OS watch remote; constructed last so it sees a fully wired shell.
|
// Wear OS watch remote; constructed last so it sees a fully wired shell.
|
||||||
@@ -654,7 +656,16 @@ class DashboardController {
|
|||||||
if (!wearing && this.phoneLocked && lockScreenEnabledSetting.get()) {
|
if (!wearing && this.phoneLocked && lockScreenEnabledSetting.get()) {
|
||||||
this.setGlassesLocked(true, "glasses removed while phone locked");
|
this.setGlassesLocked(true, "glasses removed while phone locked");
|
||||||
}
|
}
|
||||||
if (putOn) this.wakeForGlassesPutOn();
|
if (!wearing) this.wakeAfterChargingReconnect = false;
|
||||||
|
if (putOn && this.phase === "charging") {
|
||||||
|
// They can't be worn in the case, so charging is over even though no
|
||||||
|
// battery poll has said so yet. Java reconnects on this same report
|
||||||
|
// (the wake barrier needs the rebuilt session), so wake after that.
|
||||||
|
this.wakeAfterChargingReconnect = true;
|
||||||
|
this.appendLog("glasses put on while charging; waking after reconnect");
|
||||||
|
} else if (putOn) {
|
||||||
|
this.wakeForGlassesPutOn();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -669,6 +680,16 @@ class DashboardController {
|
|||||||
if (shell.wake("sidebar")) this.appendLog("screen woken: glasses put on");
|
if (shell.wake("sidebar")) this.appendLog("screen woken: glasses put on");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finish a put-on that arrived while charging. Each arm reports "connected"
|
||||||
|
* as it links, before the prelude; the ready session reports it again.
|
||||||
|
*/
|
||||||
|
private maybeWakeAfterChargingReconnect(): void {
|
||||||
|
if (!this.wakeAfterChargingReconnect || !this.communicator?.isSessionReady()) return;
|
||||||
|
this.wakeAfterChargingReconnect = false;
|
||||||
|
this.wakeForGlassesPutOn();
|
||||||
|
}
|
||||||
|
|
||||||
private handlePhoneLockState(locked: boolean): void {
|
private handlePhoneLockState(locked: boolean): void {
|
||||||
if (locked === this.phoneLocked) return;
|
if (locked === this.phoneLocked) return;
|
||||||
this.phoneLocked = locked;
|
this.phoneLocked = locked;
|
||||||
@@ -692,10 +713,13 @@ class DashboardController {
|
|||||||
|
|
||||||
private ensureWearStateTracking(): void {
|
private ensureWearStateTracking(): void {
|
||||||
const communicator = this.communicator;
|
const communicator = this.communicator;
|
||||||
|
// Charging counts: a session that starts in the case (firmware confirmed
|
||||||
|
// only after charging mode began) needs the OFF_HEAD snapshot so that
|
||||||
|
// putting the glasses on registers as a put-on.
|
||||||
if (
|
if (
|
||||||
!lockScreenEnabledSetting.get() ||
|
!lockScreenEnabledSetting.get() ||
|
||||||
!this.customFirmwareConfirmed ||
|
!this.customFirmwareConfirmed ||
|
||||||
this.phase !== "connected" ||
|
(this.phase !== "connected" && this.phase !== "charging") ||
|
||||||
!communicator
|
!communicator
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
@@ -1358,6 +1382,7 @@ class DashboardController {
|
|||||||
this.welcomeSoundArmed = isWelcomeSoundPending();
|
this.welcomeSoundArmed = isWelcomeSoundPending();
|
||||||
this.firmwareWarningMessage = "";
|
this.firmwareWarningMessage = "";
|
||||||
this.glassesWorn = null;
|
this.glassesWorn = null;
|
||||||
|
this.wakeAfterChargingReconnect = false;
|
||||||
this.glassesLocked = false;
|
this.glassesLocked = false;
|
||||||
this.refreshBatteryOptimizationStatus();
|
this.refreshBatteryOptimizationStatus();
|
||||||
this.refreshEvenAppStatus();
|
this.refreshEvenAppStatus();
|
||||||
@@ -1434,13 +1459,16 @@ class DashboardController {
|
|||||||
this.pushFirmwareDebugFlags();
|
this.pushFirmwareDebugFlags();
|
||||||
this.pushBrightness(true);
|
this.pushBrightness(true);
|
||||||
}
|
}
|
||||||
if (mappedPhase !== "connected") {
|
if (mappedPhase !== "connected" && mappedPhase !== "charging") {
|
||||||
// A wear snapshot is session-scoped. CFW reports a fresh value when
|
// A wear snapshot is session-scoped. CFW reports a fresh value when
|
||||||
// the transport comes back, so do not make lock decisions from a
|
// the transport comes back, so do not make lock decisions from a
|
||||||
// stale pre-disconnect value in the meantime.
|
// stale pre-disconnect value in the meantime. Charging keeps the
|
||||||
|
// link (and the value), so putting the glasses on registers.
|
||||||
this.glassesWorn = null;
|
this.glassesWorn = null;
|
||||||
updateGlassesPresence({ worn: null });
|
updateGlassesPresence({ worn: null });
|
||||||
// The mic enable was session-scoped too: park any live capture so
|
}
|
||||||
|
if (mappedPhase !== "connected") {
|
||||||
|
// The mic enable was session-scoped: park any live capture so
|
||||||
// the next session restarts it, instead of leaving a holder that
|
// the next session restarts it, instead of leaving a holder that
|
||||||
// makes every later request think the mic is already running.
|
// makes every later request think the mic is already running.
|
||||||
voiceControlBridge.handleSessionEnded();
|
voiceControlBridge.handleSessionEnded();
|
||||||
@@ -1450,6 +1478,7 @@ class DashboardController {
|
|||||||
if (mappedPhase === "connected") {
|
if (mappedPhase === "connected") {
|
||||||
this.syncEvenHubScreenOffSetting();
|
this.syncEvenHubScreenOffSetting();
|
||||||
this.ensureWearStateTracking();
|
this.ensureWearStateTracking();
|
||||||
|
this.maybeWakeAfterChargingReconnect();
|
||||||
} else if (mappedPhase !== "charging") {
|
} else if (mappedPhase !== "charging") {
|
||||||
this.cancelEvenHubSuspendTimer();
|
this.cancelEvenHubSuspendTimer();
|
||||||
this.evenHubSessionSuspended = false;
|
this.evenHubSessionSuspended = false;
|
||||||
|
|||||||
@@ -471,6 +471,11 @@ export class FaceclawCommunicatorBridge {
|
|||||||
await this.enqueueJavaCall(() => this.communicator.enableWearDetectionAndRequestState());
|
await this.enqueueJavaCall(() => this.communicator.enableWearDetectionAndRequestState());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Whether the transport prelude has finished (each arm reports "connected" before it). */
|
||||||
|
isSessionReady(): boolean {
|
||||||
|
return Boolean(this.communicator.isSessionReady());
|
||||||
|
}
|
||||||
|
|
||||||
/** Set the compositor's output frame size. Call before configuring surfaces. */
|
/** Set the compositor's output frame size. Call before configuring surfaces. */
|
||||||
async configureCompositorScreen(width: number, height: number): Promise<void> {
|
async configureCompositorScreen(width: number, height: number): Promise<void> {
|
||||||
await this.enqueueJavaCall(() => {
|
await this.enqueueJavaCall(() => {
|
||||||
|
|||||||
+16
@@ -1364,10 +1364,15 @@ class GlassesSessionCore(
|
|||||||
else
|
else
|
||||||
null
|
null
|
||||||
var emitWearState = false
|
var emitWearState = false
|
||||||
|
var putOnWhileCharging = false
|
||||||
var event: G2Event? = null
|
var event: G2Event? = null
|
||||||
monitor.withLock {
|
monitor.withLock {
|
||||||
lastIncomingAtMs = now()
|
lastIncomingAtMs = now()
|
||||||
if (decodedWearState >= 0 && decodedWearState != wearState) {
|
if (decodedWearState >= 0 && decodedWearState != wearState) {
|
||||||
|
// An observed OFF_HEAD -> ON_HEAD means charging is over, up
|
||||||
|
// to CHARGING_BATTERY_POLL_MS before a battery poll would say
|
||||||
|
// so. Like TS's put-on wake, a first snapshot doesn't count.
|
||||||
|
putOnWhileCharging = chargingMode && wearState == 0 && decodedWearState == 1
|
||||||
wearState = decodedWearState
|
wearState = decodedWearState
|
||||||
emitWearState = true
|
emitWearState = true
|
||||||
}
|
}
|
||||||
@@ -1540,6 +1545,11 @@ class GlassesSessionCore(
|
|||||||
logLine(if (decodedWearState > 0) "wear state ON_HEAD" else "wear state OFF_HEAD")
|
logLine(if (decodedWearState > 0) "wear state ON_HEAD" else "wear state OFF_HEAD")
|
||||||
emitWearState(decodedWearState > 0)
|
emitWearState(decodedWearState > 0)
|
||||||
}
|
}
|
||||||
|
if (putOnWhileCharging) {
|
||||||
|
// After the emit, so TS sees the put-on while still in its
|
||||||
|
// charging phase and wakes once the rebuilt session is ready.
|
||||||
|
monitor.withLock { endChargingModeLocked("glasses put on while charging") }
|
||||||
|
}
|
||||||
if (compassEvent != null) {
|
if (compassEvent != null) {
|
||||||
emitCompassEvent(compassEvent)
|
emitCompassEvent(compassEvent)
|
||||||
}
|
}
|
||||||
@@ -1649,6 +1659,12 @@ class GlassesSessionCore(
|
|||||||
// Connect sequence (worker thread)
|
// Connect sequence (worker thread)
|
||||||
|
|
||||||
internal fun connectLoopOnce() {
|
internal fun connectLoopOnce() {
|
||||||
|
monitor.withLock {
|
||||||
|
// TS treats a wear snapshot as per-transport and forgets it on a
|
||||||
|
// reconnect; forget ours too, or the new session's first report
|
||||||
|
// (the CFW query reply) is deduped away and TS never relearns it.
|
||||||
|
wearState = -1
|
||||||
|
}
|
||||||
setStateDisplay("connecting", "Connecting to the glasses...")
|
setStateDisplay("connecting", "Connecting to the glasses...")
|
||||||
try {
|
try {
|
||||||
connectArm(rightAddress, true)
|
connectArm(rightAddress, true)
|
||||||
|
|||||||
+15
-3
@@ -1003,12 +1003,24 @@ internal fun GlassesSessionCore.updateChargingModeLocked(charging: Boolean, batt
|
|||||||
logLine("glasses are charging; pausing display communication")
|
logLine("glasses are charging; pausing display communication")
|
||||||
setStateDisplay("charging", GlassesSessionCore.chargingStatusText(battery))
|
setStateDisplay("charging", GlassesSessionCore.chargingStatusText(battery))
|
||||||
} else {
|
} else {
|
||||||
chargingMode = false
|
endChargingModeLocked("glasses removed from charger")
|
||||||
logLine("glasses removed from charger; reconnecting")
|
|
||||||
handleTransportFailure("charging ended")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Leave charging mode, whether a battery poll or putting the glasses on
|
||||||
|
* (they can't be worn in the case) said charging is over. The rebuild goes
|
||||||
|
* through the normal reconnect loop.
|
||||||
|
*/
|
||||||
|
internal fun GlassesSessionCore.endChargingModeLocked(why: String) {
|
||||||
|
if (!chargingMode) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
chargingMode = false
|
||||||
|
logLine("$why; reconnecting")
|
||||||
|
handleTransportFailure("charging ended")
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Record, into the frame that is waiting, why it did not go out on this
|
* Record, into the frame that is waiting, why it did not go out on this
|
||||||
* pass of the send loop. Without this the export shows a bare multi-second
|
* pass of the send loop. Without this the export shows a bare multi-second
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ fun StatusScreen(link: PhoneLink, haptics: Haptics, onOpenSettings: () -> Unit)
|
|||||||
val phaseLabel = when {
|
val phaseLabel = when {
|
||||||
state == null -> "No status yet"
|
state == null -> "No status yet"
|
||||||
state?.charging == true || state?.phase == "charging" ->
|
state?.charging == true || state?.phase == "charging" ->
|
||||||
state?.battery?.let { "Charging · G2 $it%" } ?: "Charging"
|
state?.battery?.let { "Charging" } ?: "Charging"
|
||||||
connected -> "Connected"
|
connected -> "Connected"
|
||||||
state?.phase == "connecting" -> "Connecting…"
|
state?.phase == "connecting" -> "Connecting…"
|
||||||
state?.phase == "disconnecting" -> "Disconnecting…"
|
state?.phase == "disconnecting" -> "Disconnecting…"
|
||||||
|
|||||||
Reference in new issue
Block a user