Repository navigation
fix(client/android): ensure VpnTunnelService calls startForeground on all auto-start paths - #2886
Merged
Merged
Conversation
… all auto-start paths
|
…ion and stale notification on auto-connect failure
fortuna
requested changes
Oct 8, 2026
| if (tunnel == null) { | ||
| LOG.info("Last successful tunnel not found. User not connected at shutdown/install."); | ||
| tunnelStore.setTunnelStatus(TunnelStatus.DISCONNECTED); | ||
| QuickSettingsTileService.requestTileUpdate(this); |
Collaborator
There was a problem hiding this comment.
This doesn't look like a good design. disconnecting the tunnel, updating the tile, stopping the foreground notification and stopself all feel part of the same lifecycle transition. We shouldn't have to repeat this sequence everywhere.
At a minimum we need perhaps a disconnect method that does all those actions. But it perhaps needs a deeper look into the apis to simplify and cleanup
… early exits Co-authored-by: sentry[bot] <39604003+sentry[bot]@users.noreply.github.com>
fortuna
approved these changes
Oct 8, 2026
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 change addresses
ForegroundServiceDidNotStartInTimeExceptionon Android 12+ devices, which occurred when theVpnTunnelServicewas started viastartForegroundService()but failed to callstartForeground()within 5 seconds.The root cause was that the
startLastSuccessfulTunnel()method, invoked during auto-connect scenarios (e.g., boot, always-on VPN), had early-exit paths (no saved tunnel, VPN permission not granted, or configuration parsing errors) that returned or stopped the service without first callingstartForegroundWithNotification().The fix involves:
startForegroundWithNotification()to the very beginning ofstartLastSuccessfulTunnel(), ensuring it is always executed within the required timeframe, regardless of subsequent logic.abortAutoConnect(). This method now handles setting the tunnel status to disconnected, updating the Quick Settings tile, explicitly callingstopForeground(true)to dismiss the notification, and finallystopSelf().startLastSuccessfulTunnel()now callabortAutoConnect()to ensure a consistent and clean shutdown, including proper notification dismissal, even if the service remains bound.This prevents crashes related to the foreground service lifecycle and ensures the UI (specifically the persistent notification) accurately reflects the VPN's disconnected state when auto-connect fails.
Fixes OUTLINE-CLIENTS-NDYK6
@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.