Repository navigation
Rebind the notification listener after an update or a reboot - #773
Open
majkinetor wants to merge 3 commits into
Open
majkinetor wants to merge 3 commits into
majkinetor wants to merge 3 commits into
Conversation
07jasjeet
requested changes
Oct 26, 2026
Collaborator
There was a problem hiding this comment.
Hi, thanks for the opening a PR for the issue. Since I cannot reproduce the issue (but the service still works functionally same) on my side, I would like you to make the requested changes (functionally same) and we can go ahead.
Thanks for explicitly declaring use of AI.
Android unbinds the listener when the app is updated or its process is killed, and some phones (Honor/MagicOS, MIUI) don't bind it again until notification access is toggled. Track whether the listener is bound, request a rebind when it isn't (falling back to re-enabling the component), and run the check on BOOT_COMPLETED and MY_PACKAGE_REPLACED. Fixes metabrainz#772 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The rebind check slept 10 s every time the listener wasn't bound yet, which includes the normal cold start (the app starts before onListenerConnected), and the service start waited behind it. Make `connected` a StateFlow and wait for it with a 10 s timeout: a bind ends the wait at once, and forceRebind() runs only when none came. The check now runs after the service start, so nothing waits on it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TD3ZmdQpxeDwPUHJj2paND
ListenServiceState is the read-only interface for classes that only observe the state; MutableListenServiceState is the Koin singleton the service updates. Behaviour is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
majkinetor
force-pushed
the
fix-listener-rebind
branch
from
October 26, 2026 13:41
7588113 to
08a4cda
Compare
Author
Hi @07jasjeet, thanks for reviewing. Singleton added. I tested the new build and works as before. |
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.
Fixes #772.
After an app update, and sometimes after a reboot, Android unbinds
ListenSubmissionServiceas a notification listener, and some phones (Honor/MagicOS, MIUI and others) don't bind it again until notification access is toggled. The service may still be running, soisServiceRunning()says all is well while no listens are submitted.Changes
ListenSubmissionService: aconnectedflag, set inonListenerConnectedand cleared inonListenerDisconnected, tracks whether the listener is actually bound.rebind()callsrequestRebind()(API 24+);forceRebind()disables and re-enables the component withDONT_KILL_APP, which is what the toggle does.onListenerDisconnected()now asks for a rebind, as Android's docs suggest.App.startListenService(): when access is granted but the listener isn't bound, requests a rebind, and falls back toforceRebind()if it still isn't bound 10 s later.ListenServiceRestarter(new): a receiver forBOOT_COMPLETEDandMY_PACKAGE_REPLACEDthat runs the same check, so listening comes back without opening the app.AndroidManifest.xml: the receiver andRECEIVE_BOOT_COMPLETED.Tested
On a Honor Magic V5 (MagicOS), with a release build:
BOOT_COMPLETED, so the app recovers only when opened.Code written by Claude Code, reviewed and tested by me on the device.