Repository navigation
fix(voice): do not leave the plugin bound after a failed import or a busy idle unbind - #819
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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):
bindAndImportbound the plugin but only scheduled the idle unbind when the import succeeded. A connect timeout orRemoteExceptionleft it bound until the screen turned off.unbindAfterDelaycleared its schedule before checkingcanUnbind(). 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,RemoteExceptionand 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 throughhandleDisconnection. The call is posted to the main thread, which owns the bind state, instead of running on the IO dispatcher.VoicePluginManager.unbindAfterDelay: whencanUnbind()is false, re-post every 15 s instead of dropping the schedule.cancelScheduledUnbindandunbindstill cancel it.Verification & Testing
helium314.keyboard.latin.voice.*unit tests pass (Robolectric, including the new ones)Guidelines Checklist