Repository navigation
fix(client/android): prevent ForegroundServiceDidNotStartInTimeException on autostart - #2879
Open
sentry[bot] wants to merge 3 commits into
Open
sentry[bot] wants to merge 3 commits into
sentry[bot] wants to merge 3 commits into
Conversation
|
Collaborator
Co-authored-by: sentry[bot] <39604003+sentry[bot]@users.noreply.github.com>
This branch has not been deployed
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.
This PR builds upon #2886 to further harden the
VpnTunnelService's foreground service lifecycle, preventingForegroundServiceDidNotStartInTimeExceptionand ensuring robust notification handling.While #2886 correctly moved the
startForegroundWithNotification()call to the beginning of auto-connect paths, this PR addresses additional edge cases wherestartForeground()could still fail or be rejected by the system, leading to crashes or silent failures.Key changes include:
getSmallIconResId()to ensure that all notifications (primary and fallback) always have a valid small icon. This preventsstartForeground()from failing if the app'ssmall_icondrawable is missing (e.g., in Capacitor builds).FLAG_IMMUTABLEfor PendingIntent: AddedPendingIntent.FLAG_IMMUTABLEto thePendingIntentcreated for the notification. This is required for apps targeting Android 12 (API 31) and above, preventinggetActivity()from throwing and thus ensuring the notification can be built successfully.startForeground(): ImplementedstartForegroundCompat()which attempts to callstartForeground(). If the initial attempt with the primary notification fails (e.g., due to system rejection), the service now retries once with a minimal fallback notification. This ensures thestartForegroundService()contract is met, even if the primary notification cannot be displayed.startForeground()is correctly called without a service type for Android versions below API 29, addressing a previous oversight where it was skipped entirely on these versions.SEVERElevel, providing better visibility into potential issues.Fixes OUTLINE-CLIENTS-C2NDW
@sentry <feedback>: Autofix iterates on these changes@sentry stop iterating: Autofix stops iterating on this runThis PR was automatically generated by Sentry at no cost. You can adjust this setting at any time.