forked from Blendman974/faceclaw
Turn on screen when Android notifications are received
This commit is contained in:
1 parent
468291aac3
commit
5a92637537
7 files changed
+205
-12
No files matched your search
@@ -6,6 +6,7 @@ import { FaceclawCommunicatorBridge, type FrameMetrics, type RawInputEvent } fro
|
||||
import { startForegroundNotification, stopForegroundNotification, updateForegroundNotification } from "../native/foreground-service";
|
||||
import { mediaControllerBridge } from "../native/media-controller";
|
||||
import { nightscoutBridge } from "../native/nightscout";
|
||||
import { onAndroidNotificationPosted } from "../native/notification-icons";
|
||||
import { openEvenAppSettings, readEvenAppNotificationState } from "../native/even-app-conflict";
|
||||
import { grayImageToPreviewSource, grayImageToPreviewSourceWithBitmapFactory } from "../native/gray-image-preview";
|
||||
import { voiceControlBridge } from "../native/voice-control";
|
||||
@@ -18,6 +19,7 @@ import {
|
||||
getDashboardSystemCardName,
|
||||
isDashboardVoiceControlEnabled,
|
||||
noteDashboardPhoneTextInput,
|
||||
openAndroidNotificationFromSleep,
|
||||
openTelepromptDocument,
|
||||
receiveInput,
|
||||
resetDashboardSleepTimerAndWake,
|
||||
@@ -137,6 +139,7 @@ class DashboardController {
|
||||
private offNightscout: (() => void) | null = null;
|
||||
private offVoiceStatus: (() => void) | null = null;
|
||||
private offVoiceWakeWord: (() => void) | null = null;
|
||||
private offAndroidNotification: (() => void) | null = null;
|
||||
private lastInput = "waiting...";
|
||||
private lastSys = "none yet";
|
||||
private renderInProgress = false;
|
||||
@@ -160,6 +163,11 @@ class DashboardController {
|
||||
startDedicatedVoiceInput: (mode) => this.startDedicatedVoiceInput(mode),
|
||||
stopDedicatedVoiceInput: () => this.stopDedicatedVoiceInput(),
|
||||
});
|
||||
this.offAndroidNotification = onAndroidNotificationPosted((notificationKey) => {
|
||||
void this.handleAndroidNotificationPosted(notificationKey).catch((error) => {
|
||||
this.appendLog(`notification wake failed: ${this.formatError(error)}`);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
subscribe(listener: DashboardListener): () => void {
|
||||
@@ -701,6 +709,24 @@ class DashboardController {
|
||||
}
|
||||
}
|
||||
|
||||
private async handleAndroidNotificationPosted(notificationKey: string): Promise<void> {
|
||||
const changed = openAndroidNotificationFromSleep(notificationKey);
|
||||
if (!changed) {
|
||||
if (this.phase === "connected" && this.communicator) {
|
||||
await this.requestRender("interval");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
this.appendLog("android notification woke dashboard");
|
||||
if (this.phase === "connected" && this.communicator) {
|
||||
await this.requestRender("initial");
|
||||
return;
|
||||
}
|
||||
const image = drawDashboard();
|
||||
this.updateDisplayPreviewFromImage(image);
|
||||
}
|
||||
|
||||
private startVoiceControlIfEnabled(): void {
|
||||
if (!this.communicator) return;
|
||||
if (!isDashboardVoiceControlEnabled()) return;
|
||||
|
||||
Reference in new issue
Block a user