Fix Direct Boot accessibility startup#2153
Conversation
|
Update: I was able to build and test this on the affected Zinwa Q25. The original service-only guard was not enough. The confirmed root cause was With the latest branch:
This was tested without the external Q25 boot-fix workaround app installed. |
|
Do i understand correctly that accessibility services always run doing direct mode, even if you do not specify Otherwise, why would our accessibility service be running during Direct Boot |
Not quite. My understanding is that accessibility services do not automatically run during Direct Boot unless the component is Direct-Boot-aware. The reason this happened here is probably that the app had The other confirmed path was So this PR does two things:
The service guard is mostly defensive; the main root cause I saw in logs was CE database initialisation before first unlock. |
Summary
Fix Direct Boot startup so KeyMapper does not initialize credential-encrypted database-backed components before the user has unlocked the device.
The root cause found during Q25 testing was that
LOCKED_BOOT_COMPLETEDstarted the app process and then calledBaseKeyMapperApp.onBootUnlocked(), which initialized normal app components while user 0 was stillRUNNING_LOCKED. That path could open/data/user/0/.../databases/key_map_databasebefore credential-encrypted storage was available, causing repeatedSQLiteCantOpenDatabaseExceptioncrashes.This PR now:
UserManager.isUserUnlockedonBootUnlocked()fromLOCKED_BOOT_COMPLETEDonBootUnlocked()from normalBOOT_COMPLETED, which is delivered after unlockReproduction
Tested on a Zinwa Q25 running BenOS Uma.1.
Installed KeyMapper
4.2.0-fossover 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 trying to open CE storage before unlock:
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.Device verification
Built and tested locally on the same Q25 using a debug build installed as
io.github.sds100.keymapper.debug.Before first unlock, after this fix:
BaseKeyMapperApplogsDelay init because lockedkey_map_databaseopen attempt or SQLite fatal occurs before unlockAfter first unlock:
onBootUnlockedthenInitWhy
This keeps KeyMapper available after the first unlock while preventing the broken Direct Boot/locked-user startup window from touching credential-encrypted app storage.