Fix boot start: run the boost in a foreground service instead of launching the UI#13
Open
dilbery wants to merge 3 commits into
Open
Fix boot start: run the boost in a foreground service instead of launching the UI#13dilbery wants to merge 3 commits into
dilbery wants to merge 3 commits into
Conversation
…ves the UI The previous boot-start implementation launched MainActivity from BOOT_COMPLETED, which Android 10+ blocks for background processes (the toggle silently did nothing), and the audio effects were released in MainActivity.onDestroy(), so the boost died as soon as the activity was destroyed. - New BoostService: a foreground service (specialUse type on API 34+, which unlike mediaPlayback is still allowed to start from BOOT_COMPLETED on Android 15) that restores the saved boost/volume and keeps the effects alive with a persistent low-priority notification. - BootReceiver now starts the service instead of the activity, and also handles the HTC quickboot action. - AudioController is a singleton so the activity and service share the same global effect instances instead of fighting over session 0. - MainActivity starts/stops the service (boost active or boot start enabled -> running) and only releases the effects when the service is not running. - Request POST_NOTIFICATIONS on API 33+ so the service notification is visible; new strings provided in English and Dutch.
Settings were only saved in onPause(), so a crash or force stop lost the boost level and the boot-start toggle. Save each preference as soon as the user changes it; the bulk save in onPause() remains as a backstop.
The foreground service changes user-visible behaviour (a persistent notification, boost surviving the UI), so describe what to expect and why the notification is there. Also add a troubleshooting note for system equalizers such as LineageOS' AudioFX: they attach an effect to the music app's session, which makes AudioFlinger suspend global session 0 effects, silently disabling the boost while the UI still shows it as applied. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DoGGpGCCn5126qgQYpZN8Y
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.
Problem
The boot-start feature added in #12 launches
MainActivitydirectly from theBOOT_COMPLETEDbroadcast. That has two problems:LoudnessEnhancer/DynamicsProcessing) are released inMainActivity.onDestroy(), so as soon as the activity is destroyed (user swipes the app away, or the OS reclaims it) the boost is gone — even though the app asks for a battery-optimization exemption to "run in the background".Even on devices where the activity launch works (≤ Android 9), booting into the full BoostX UI is intrusive — e.g. on wall-mounted tablets/displays it covers whatever the device is supposed to be showing.
Fix
Move the boost into a foreground service (
BoostService) that owns the audio effects:BootReceivernow starts the service (viaContextCompat.startForegroundService) instead of launching the activity. Works on all API levels ≥ minSdk 24, no UI shown. Also handles the HTC variant of the quickboot action.BoostServicerestores the saved boost + volume on start, holds the effects with a persistent low-priority notification, and isSTART_STICKY.specialUse(API 34+) rather thanmediaPlayback, because Android 15 disallows startingmediaPlayback-type foreground services fromBOOT_COMPLETED, which would have broken boot-start again on current devices.AudioControlleris now a singleton shared by the activity and the service, so they don't create two competing sets of global (session 0) effects.MainActivitystarts the service whenever boost > 0 or boot-start is enabled, stops it when neither applies, and only releases the effects if the service isn't running.POST_NOTIFICATIONSis requested on API 33+ so the service notification is visible; new strings are provided in English and Dutch.Second commit: settings are now persisted immediately when changed (previously only in
onPause(), so a crash or force-stop lost the boot-start toggle and boost level).Testing
assembleDebugclean).dumpsys:isForeground=true,createdFromFg=false) and the LoudnessEnhancer attached to global session 0, without the app UI ever opening.