Skip to content

feat: wake word robustness — FG service, overlay launch, lifecycle refresh#19

Merged
0xharkirat merged 2 commits into
mainfrom
feature/wake-word-robustness
Apr 12, 2026
Merged

feat: wake word robustness — FG service, overlay launch, lifecycle refresh#19
0xharkirat merged 2 commits into
mainfrom
feature/wake-word-robustness

Conversation

@0xharkirat
Copy link
Copy Markdown
Contributor

Summary

Four robustness improvements to the wake word feature that shipped in #18:

  • Wake word foreground service. WakeWordService now owns the WakeWordDetector with FOREGROUND_SERVICE_TYPE_MICROPHONE, a persistent notification, and START_STICKY — hardens against OEM kill behavior and makes the "mic is on" state visible to the user.
  • Wake word → overlay launch. Detection now calls VoiceInteractionService.showSession() (the system-sanctioned background-launch path) so saying "Hey Hark" from any screen opens the assistant panel. Previously it only started the mic on the main engine with no UI.
  • Recents cleanup. OverlayActivity gains excludeFromRecents + noHistory so it no longer shows up as a duplicate task entry in Recents.
  • Capability freshness. AppLifecycleListener in ChatNotifier invalidates capabilityRegistryProvider and re-warms embeddings on app resume, so uninstalled OACP apps drop out of the registry without a restart.

Also included:

  • Runtime POST_NOTIFICATIONS request on Android 13+ so the FG notification is visible.
  • Monochrome ic_notification vector drawable (Hark robot silhouette) — required by Android for notification small icons.
  • "Stop" action on the notification so users can release the mic without relaunching the app. Returns START_NOT_STICKY on explicit stop so Android doesn't auto-restart.

Test plan

  • flutter analyze clean
  • Swipe assist gesture → only one Hark task in Recents
  • adb shell dumpsys activity services | grep WakeWordisForeground=true, types=microphone
  • Persistent notification visible in status bar with robot silhouette small icon
  • "Hey Hark" from background → overlay appears, mic auto-starts (verified via adb logcat: WakeWordDetector → HarkApplication → HarkSession → OverlayActivity)
  • "Hey Hark" back-to-back → onNewIntent refreshes overlay session
  • Detection paused during STT, resumed after
  • App resume refresh fires (adb logcat | grep "app resumed, refreshing")
  • Notification "Stop" action releases mic and removes notification

- Wake word detector now runs in a foreground Service (WakeWordService)
  with persistent notification and START_STICKY for OEM robustness.
- Wake word detection launches the overlay via VoiceInteractionService
  .showSession() — the system-sanctioned background-launch path.
- OverlayActivity hidden from Recents (excludeFromRecents + noHistory)
  so it no longer shows as a duplicate task entry.
- Capability registry refreshes on app resume via AppLifecycleListener,
  so uninstalled OACP apps drop out of the registry without a restart.
- POST_NOTIFICATIONS requested at init so the FG notification is visible
  on Android 13+.
- Add ic_notification vector drawable (Hark robot silhouette) so the
  notification small icon follows Android's monochrome-silhouette rule
  instead of rendering as a white blob from the colorful launcher PNG.
- Add "Stop" action button on the wake word notification so users can
  release the mic without relaunching the app.
- Return START_NOT_STICKY on explicit stop so Android doesn't auto-restart
  the service after the user chose to stop it.
@0xharkirat 0xharkirat merged commit 0d045a9 into main Apr 12, 2026
@0xharkirat 0xharkirat deleted the feature/wake-word-robustness branch April 12, 2026 08:28
0xharkirat added a commit that referenced this pull request Apr 12, 2026
- ROADMAP.md: full rewrite. Mark wake word foreground service + overlay
  launch + lifecycle refresh as shipped. Replace stale "self-hosted /
  BYOK / Gemma 4 / model loading" priorities with the current list
  (Settings, action chips, wake word polish, STT, release packaging).
  Move deferred items to a Deferred section with rationale.
- README.md: refresh Wake Word section (FG service, overlay launch, Stop
  action) and the Roadmap bullets at the bottom.
- AGENTS.md: update file map (WakeWordService in app module, WakeWordDetector
  in plugin module) and replace the "planned next phase" wake word note with
  the shipped architecture summary.
- Add inline TODO comments for four review findings from PR #19 (VIS
  instance @volatile, always-call startForeground on re-start, order of
  POST_NOTIFICATIONS request, untested fallback Activity launch path).
0xharkirat added a commit that referenced this pull request Apr 12, 2026
- ROADMAP.md: full rewrite. Mark wake word foreground service + overlay
  launch + lifecycle refresh as shipped. Replace stale "self-hosted /
  BYOK / Gemma 4 / model loading" priorities with the current list
  (Settings, action chips, wake word polish, STT, release packaging).
  Move deferred items to a Deferred section with rationale.
- README.md: refresh Wake Word section (FG service, overlay launch, Stop
  action) and the Roadmap bullets at the bottom.
- AGENTS.md: update file map (WakeWordService in app module, WakeWordDetector
  in plugin module) and replace the "planned next phase" wake word note with
  the shipped architecture summary.
- Add inline TODO comments for four review findings from PR #19 (VIS
  instance @volatile, always-call startForeground on re-start, order of
  POST_NOTIFICATIONS request, untested fallback Activity launch path).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant