Phone CPU usage optimization

This commit is contained in:
James Babcock committed 2026-09-22 14:19:23 -07:00
1 parent 44eddedc01
commit 9560f3ac8d
26 files changed
+606 -167

No files matched your search

-9
View File
@@ -137,7 +137,6 @@ export class FaceclawCommunicatorBridge {
// does not race against finishes that land before the wait starts.
private readonly finishedFrameOutcomes = new Map<number, string>();
private readonly frameFinishedWaiters = new Map<number, Set<(outcome: string) => void>>();
private readonly logListeners = new Set<(line: string) => void>();
private readonly stateListeners = new Set<(state: CommunicatorState) => void>();
private readonly ringListeners = new Set<(event: RawInputEvent) => void>();
private readonly batteryListeners = new Set<(state: HeadsetBatteryState) => void>();
@@ -161,9 +160,6 @@ export class FaceclawCommunicatorBridge {
addresses.ring ?? "",
);
this.listenerProxy = new com.faceclaw.app.FaceclawBleCommunicatorListener({
onLog: (line: string) => {
this.emitAsync(this.logListeners, String(line));
},
onStateChange: (phase: string, status: string) => {
const state = {
phase: String(phase) as CommunicatorPhase,
@@ -293,11 +289,6 @@ export class FaceclawCommunicatorBridge {
return result;
}
onLog(listener: (line: string) => void): () => void {
this.logListeners.add(listener);
return () => this.logListeners.delete(listener);
}
onStateChange(listener: (state: CommunicatorState) => void): () => void {
this.stateListeners.add(listener);
return () => this.stateListeners.delete(listener);
+3 -2
View File
@@ -1,9 +1,10 @@
import { createListenerPool, type InterfaceAddress } from '../remote/listeners';
declare const FaceclawRemoteInput: any;
export function remoteNative() {
export function remoteNative(onRequestReady: () => void) {
return createListenerPool(() => {
const native = FaceclawRemoteInput.alloc().init();
return { start: (port, address) => String(native.startAddress(port, address)), stop: () => native.stop(),
native.setRequestListener(onRequestReady);
return { start: (port, address) => String(native.startAddress(port, address)), stop: () => { native.setRequestListener(null); native.stop(); },
nextRequest: () => native.nextRequest(), complete: (id, response) => native.completeResponse(id, response) };
});
}
+4 -2
View File
@@ -1,10 +1,12 @@
import { createListenerPool, type InterfaceAddress } from '../remote/listeners';
import { Utils } from '@nativescript/core';
declare const com: any;
export function remoteNative() {
export function remoteNative(onRequestReady: () => void) {
return createListenerPool(() => {
const native = new com.faceclaw.app.FaceclawRemoteInput();
return { start: (port, address) => String(native.startAddress(port, address)), stop: () => native.stop(),
const ready = new java.lang.Runnable({ run: onRequestReady });
native.setRequestListener(ready);
return { start: (port, address) => String(native.startAddress(port, address)), stop: () => { native.setRequestListener(null); native.stop(); },
nextRequest: () => native.nextRequest(), complete: (id, response) => native.complete(id, response) };
});
}