Voice: don't need an Activity to check already-granted permissions

ensurePermissions looked up the Activity before checking whether any
permission was missing, and getActivity() throws when there is none.
Android starts the app in the background with no Activity (a home-widget
update, a notification-listener rebind), and the glasses session runs
from there until the app is opened. So in that state every "Hey Even"
failed in ensureVoicePermissions even though the mic permission was
granted, and the voice dialog kept showing the idle "Voice control
stopped.". The same throw hit ensureBlePermissions.

The Activity is now only looked up when a permission actually has to be
requested. A capture that fails to start for any reason other than a
denied permission now says so in the dialog instead of leaving the idle
status up.
This commit is contained in:
Om Alve committed 2026-11-02 13:17:16 +05:30
1 parent 8ea3795f07
commit 9fac7a29ba
4 files changed
+89 -1

No files matched your search

+6 -1
View File
@@ -65,11 +65,16 @@ async function ensurePermissions(
): Promise<void> {
if (!global.isAndroid) return;
const activity = getActivity();
const missing = permissions.filter((permission) => !isPermissionGranted(permission));
if (missing.length === 0) return;
// Only a request needs an Activity. Checking must not: Android can start
// the app in the background (a home-widget update, a notification-listener
// rebind) with none, and the glasses session and voice input run from
// there until the app is opened.
const activity = getActivity();
await new Promise<void>((resolve, reject) => {
const callback = (args: {
requestCode: number;
+1
View File
@@ -2258,6 +2258,7 @@ class DashboardController {
.catch((error) => {
this.appendLog(`voice permission failed: ${this.formatError(error)}`);
if (!hasMicrophonePermission()) voiceControlBridge.reportPermissionDenied();
else voiceControlBridge.reportStartFailed(this.formatError(error));
});
}
+8
View File
@@ -199,6 +199,14 @@ export class FaceclawVoiceControlBridge {
);
}
/**
* Capture could not be started for a reason other than a denied permission.
* Without this the dialog keeps showing the idle "Voice control stopped."
*/
reportStartFailed(reason: string): void {
this.setStatus("Voice input couldn't start.", reason);
}
/** Begin push-to-talk capture (momentary; released with stopPushToTalk). */
startPushToTalk(options: PushToTalkOptions): void {
this.acquireCapture("ptt", options);