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.
Description
This PR fixes the timer when relaunching the Android app after a silent server switch or a server location switch initiated by the user. (In both cases, we want the timer to continue counting up and not reset to zero. While this was working as expected while the app remained open, when the app was quit and re-launched the timer would change.)
There were two parts to this fix:
First - In
VPNService.kt
, do not reset the timer when it is a server switch.However, that didn't fix the bug. I ended up rabbit holing on this for quite a while. Eventually in the logs I noticed additional controller state changes when doing a server switch on Android that didn't exist in similar server switches on iOS. And then I realized the bug is Android's version of #9733. While the bug on Android isn't as catastrophic as it was on iOS (which is probably why it hung around for a bit longer), it has the same root cause - an additional state change that was recently added was affecting mobile clients' abilities to determine if an activation was coming from a server switch or not - because we rely on using the current state in
Controller::Reason stateToReason(Controller::State state)
to determine if it's a server switch... but by the time we were getting there, we were inStateConnecting
and notStateServerSwitching
.Reference
VPN-6710
Checklist