[DRO-2646] Prevent keep-awake foreground-service crash - #160
Merged
Conversation
Contributor
🧪 Test Build ReadyAPK for PR #160 is available for testing. Download APK from workflow run Artifacts expire after 30 days. |
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
KeepAliveServiceimmediately inonCreate(), before publishing the live instance or registering listenersRoot cause
A valid rapid sequence—
—could stop a service created by
startForegroundService()before it calledstartForeground(), producingForegroundServiceDidNotStartInTimeExceptionand killing Portal. There was a second ordering hazard when a live service received a newer queued start: a plainstopSelf()or externalstopService()could consume that newer obligation.The service now promotes first, records the latest delivered
startId, posts stop decisions to its main thread, rechecks the persisted target state, and callsstopSelfResult(latestStartId). A pending service creation is allowed to reachonCreate(), promote, and then safely self-stop if the saved state is disabled.Compatibility
ACTION_STOP, disabled-state shutdown, wake-lock recovery, controller behavior, and enabledSTART_STICKYsemanticsValidation
Host (OpenJDK 17.0.20)
SwitchTintResourceTest.trackTintSeparatesCheckedAndUncheckedStatesfailurelintDebug: passedassembleDebug+ instrumentation APK assembly: passedgit diff --check: passedAndroid matrix
Across all devices:
enabled=true/serviceActive=true, service, notification ID 2004, andkeep_alive_steadywake lockRemoteServiceException, crash, ANR, process restart, or accessibility failureCloud tasks and the unrelated insufficient-balance condition were intentionally excluded.
Internal companion: mobilerun-portal-internal#80.
Related to DRO-2646.