Skip to content

fix: harden accessibility service lifecycle and add desync health check - #102

Merged
PranavPurwar merged 4 commits into
aload0:mainfrom
natakhot271:main
Oct 11, 2026
Merged

PranavPurwar merged 4 commits into
aload0:mainfrom
natakhot271:main

Conversation

@natakhot271

@natakhot271 natakhot271 commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • defer app initialization until the device is unlocked
  • avoid touching credential-protected/shared prefs during locked boot or direct-boot startup
  • resume initialization automatically on ACTION_USER_UNLOCKED
  • keep the accessibility service lifecycle resilient and add a desync health check
  • remove redundant manifest noise and harden Android receiver registration

Why

The root cause was a startup-time crash before unlock: Android refuses access to credential-encrypted/device-protected storage while the user is still locked. Reef was attempting to initialize prefs too early during app startup, which could crash the process and leave the accessibility setting enabled while the service was effectively dead. This patch defers startup until the user is unlocked and safely resumes once the device is ready.

We also keep the service-health hardening in place so stale or interrupted accessibility state is easier to detect and recover from.

Steps to reproduce the bug

  1. Start with Reef 4.3.0 with Mindful Launch set up.
  2. Phone dies
  3. User does NOT unlock phone in the first 20 sec after the boot
  4. See Reef crash from trying to launch before unlock. Reef pid missing, and Accessibility Service for Reef stays not bound, but binding and active.

I am running Shizuku and debugging though its aShell on my phone.

adb logcat -d | grep -iE "ReefApp|IllegalStateException|SharedPreferences|credential encrypted storage|user.*unlock"

Screenshot_20261004-010337.png

pidof dev.pranav.reef

Screenshot_20261004-010538.png

dumpsys accessibility | grep -E "Enabled services|Bound services" -A 2

Screenshot_20261004-010708.png

Fixes: #101, #88

Notes

  • editor diagnostics show no Kotlin/XML errors in the changed files
  • full Gradle compilation could not be run in this environment because no local Java runtime is installed

@natakhot271
natakhot271 marked this pull request as ready for review October 4, 2026 05:40
@natakhot271

Copy link
Copy Markdown
Contributor Author

Tested Mindful launch with a debug apk! It works after a reboot + wait 30 sec to unlock, and doesn't work in Reef 4.3.0.

@PranavPurwar
PranavPurwar merged commit 044358f into aload0:main Oct 11, 2026
1 check failed
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.

Mindful Launch doesn't work after a random number of days

2 participants