Skip to content

fix(voice): do not leave the plugin bound after a failed import or a busy idle unbind - #819

Merged
LeanBitLab merged 1 commit into
mainfrom
fix/voice-plugin-idle-unbind
Nov 15, 2026
Merged

LeanBitLab merged 1 commit into
mainfrom
fix/voice-plugin-idle-unbind

Conversation

@LeanBitLab

Copy link
Copy Markdown
Owner

Summary of Changes

Closes two ways the voice plugin could stay bound longer than intended.

Motivation & Context

Found while checking the earlier idle battery drain fixes (#803 and related):

  1. bindAndImport bound the plugin but only scheduled the idle unbind when the import succeeded. A connect timeout or RemoteException left it bound until the screen turned off.
  2. unbindAfterDelay cleared its schedule before checking canUnbind(). If the voice state was not IDLE or ERROR when the timer fired (for example mid-dictation), it gave up and the plugin stayed bound until the next keyboard hide or screen off.

Changes Made

  • VoicePluginManager.bindAndImport: schedule the 30 s idle unbind on the connect-failure, RemoteException and generic failure paths, only when the plugin was not already connected (a plugin already connected keeps the normal keep-loaded policy). The dead-service path already unbinds through handleDisconnection. The call is posted to the main thread, which owns the bind state, instead of running on the IO dispatcher.
  • VoicePluginManager.unbindAfterDelay: when canUnbind() is false, re-post every 15 s instead of dropping the schedule. cancelScheduledUnbind and unbind still cancel it.
  • Two unit tests: it retries while busy then unbinds once idle, and a cancelled retry stops.

Verification & Testing

  • helium314.keyboard.latin.voice.* unit tests pass (Robolectric, including the new ones)
  • The failed-import path has no unit test (it needs the plugin to be reported as installed); verified by reading only
  • Not measured on a device

Guidelines Checklist

  • This PR addresses a single focused concern.
  • Does not add unnecessary dependencies or binary blobs.
  • No em dashes used in comments, descriptions, or documentation.

…busy idle unbind

bindAndImport only scheduled an idle unbind when the import succeeded, so a
connect timeout or RemoteException left the plugin bound until screen off.
Schedule it on those paths too (only if the plugin was not already
connected), from the main thread that owns the bind state.

The scheduled idle unbind also gave up for good when the voice state was
busy at the moment it fired. Retry every 15 s instead.
@LeanBitLab
LeanBitLab merged commit 09c97fa into main Nov 15, 2026
1 check passed
@LeanBitLab
LeanBitLab deleted the fix/voice-plugin-idle-unbind branch November 15, 2026 07:03
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