forked from Blendman974/faceclaw
Compatibility check; notification icon fixes
* Display a warning if paired glasses do not have a compatible custo firmware * Fix certain notification icons being missing on system card * Rescale large notification icons with proper sampling; don't send unnecessary
This commit is contained in:
1 parent
c9fe92dc1c
commit
3532b1f437
13 files changed
+383
-18
No files matched your search
@@ -26,6 +26,12 @@ export type FrameMetrics = {
|
||||
tileCount: number;
|
||||
};
|
||||
|
||||
export type FirmwareInfo = {
|
||||
leftVersion: string;
|
||||
rightVersion: string;
|
||||
capabilities: string;
|
||||
};
|
||||
|
||||
export type RawInputEvent =
|
||||
| {
|
||||
kind: "list-click";
|
||||
@@ -72,6 +78,7 @@ export class FaceclawCommunicatorBridge {
|
||||
private readonly batteryListeners = new Set<(state: HeadsetBatteryState) => void>();
|
||||
private readonly evenAppConflictListeners = new Set<(message: string) => void>();
|
||||
private readonly frameMetricsListeners = new Set<(metrics: FrameMetrics) => void>();
|
||||
private readonly firmwareInfoListeners = new Set<(info: FirmwareInfo) => void>();
|
||||
|
||||
constructor(addresses: { right: string; left: string; ring?: string }) {
|
||||
const context = Utils.android.getApplicationContext();
|
||||
@@ -139,6 +146,14 @@ export class FaceclawCommunicatorBridge {
|
||||
onFrameFinished: (frameId: number, outcome: string) => {
|
||||
this.recordFrameFinished(Number(frameId), String(outcome));
|
||||
},
|
||||
onFirmwareInfo: (leftVersion: string, rightVersion: string, capabilities: string) => {
|
||||
const info = {
|
||||
leftVersion: String(leftVersion),
|
||||
rightVersion: String(rightVersion),
|
||||
capabilities: String(capabilities),
|
||||
};
|
||||
this.emitAsync(this.firmwareInfoListeners, info);
|
||||
},
|
||||
});
|
||||
this.communicator.setListener(this.listenerProxy);
|
||||
}
|
||||
@@ -202,6 +217,11 @@ export class FaceclawCommunicatorBridge {
|
||||
return () => this.frameMetricsListeners.delete(listener);
|
||||
}
|
||||
|
||||
onFirmwareInfo(listener: (info: FirmwareInfo) => void): () => void {
|
||||
this.firmwareInfoListeners.add(listener);
|
||||
return () => this.firmwareInfoListeners.delete(listener);
|
||||
}
|
||||
|
||||
getNativeCommunicator(): any {
|
||||
return this.communicator;
|
||||
}
|
||||
|
||||
@@ -35,13 +35,31 @@ export type AndroidNotification = {
|
||||
actions: AndroidNotificationAction[];
|
||||
};
|
||||
|
||||
export function readActiveNotificationIcons(maxIcons: number): GrayImage[] {
|
||||
if (!global.isAndroid || maxIcons <= 0) return [];
|
||||
export type NotificationIconsResult = {
|
||||
icons: GrayImage[];
|
||||
/** True when the icons came from an expired (or empty) cache under allowStale. */
|
||||
stale: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
* With allowStale, this always returns immediately: expired cached icons (or
|
||||
* none at all, right after startup or a cache invalidation) come back with
|
||||
* stale=true, and the caller is expected to repaint with allowStale=false
|
||||
* once the current frame is done. Only an allowStale=false call actually
|
||||
* fetches from the notification listener service, which can be slow depending
|
||||
* on what is in the tray.
|
||||
*/
|
||||
export function readActiveNotificationIcons(maxIcons: number, allowStale: boolean): NotificationIconsResult {
|
||||
if (!global.isAndroid || maxIcons <= 0) return { icons: [], stale: false };
|
||||
|
||||
const now = Date.now();
|
||||
if (now - cachedAtMs < ICON_CACHE_MS) {
|
||||
if (cachedAtMs > 0 && now - cachedAtMs < ICON_CACHE_MS) {
|
||||
logCurrent("notification icons served from cache");
|
||||
return cachedIcons.map(icon => icon.clone());
|
||||
return { icons: cachedIcons.map(icon => icon.clone()), stale: false };
|
||||
}
|
||||
if (allowStale) {
|
||||
logCurrent("notification icons served stale");
|
||||
return { icons: cachedIcons.map(icon => icon.clone()), stale: true };
|
||||
}
|
||||
|
||||
const bytes = spanCurrent("fetch-notification-icons", () =>
|
||||
@@ -63,7 +81,7 @@ export function readActiveNotificationIcons(maxIcons: number): GrayImage[] {
|
||||
|
||||
cachedIcons = icons;
|
||||
cachedAtMs = now;
|
||||
return icons.map(icon => icon.clone());
|
||||
return { icons: icons.map(icon => icon.clone()), stale: false };
|
||||
}
|
||||
|
||||
export function readActiveNotifications(maxNotifications = 50): AndroidNotification[] {
|
||||
|
||||
Reference in new issue
Block a user