Delay accessibility service init until user unlock#2153
Open
smh786 wants to merge 2 commits into
Open
Conversation
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
Delay KeyMapper accessibility-service controller initialization until Android reports that the user is unlocked.
When the accessibility service is started during Direct Boot, it can currently construct the controller/dependency graph and attempt to open the normal Room database under credential-encrypted storage:
/data/user/0/io.github.sds100.keymapper/databases/key_map_databaseBefore the first unlock after boot, that storage is not available, so the service can crash/restart repeatedly.
This change keeps the accessibility service connected but inert while
UserManager.isUserUnlocked == false. It does not create the controller until the user is unlocked. After unlock, the controller is initialized lazily fromonServiceConnected,onAccessibilityEvent, oronKeyEvent.Reproduction
Tested on a Zinwa Q25 running BenOS Uma.1.
Installed KeyMapper
4.2.0-fossfrom the latest GitHub release over the ROM-provided3.2.1-fosssystem app, with KeyMapper Accessibility enabled and no external workaround app installed.After reboot, before first unlock:
Logcat shows KeyMapper starting its accessibility service and then trying to open CE storage:
On this device, the repeated Direct Boot crash/restart state appears to corrupt lockscreen physical-keyboard handling until the first unlock. Examples observed before first unlock:
adb shell getevent -ltshowed only one hardware key down/up event, so duplication occurred above the Linux input layer.After first unlock, KeyMapper works normally again.
Notes
The app and IME paths already contain
UserManager.isUserUnlockedhandling. This applies the same Direct Boot boundary to the accessibility service path.Local verification
4.2.0-fossbefore this patch.\Usersis emitted into a Java comment and parsed as an illegal unicode escape. I could not complete a local compile in this workspace, so CI should be treated as the compile authority for this PR.