Fixes #15. When tapping the toggle in rapid succession,
NebulaVpnService.onStartCommand is called twice, in serial. This
method includes logic to show an error to the user if they somehow
attempt to connect to a service while already connected.
However, this method of showing an error message (calling
announceExit) sends a signal to MainActivity telling it the service
has exited, and that it should set the UI state to "Disconnected." It
does not actually disconnect the service at this point, resulting in a
state mismatch in which you cannot actually disconnect the service.
The solution in this commit is to remove this signalling and simply
return out of onStartCommand to avoid processing the start request
twice.
Another potential solution is to call sendSimple(MSG_IS_RUNNING, 1)
before returning, which would ensure that the UI is synchronized with
the service state at this point, however I have no reason to believe it
could get out of sync aside from the processing delay.
Fixes #15. When tapping the toggle in rapid succession,
NebulaVpnService.onStartCommand
is called twice, in serial. This method includes logic to show an error to the user if they somehow attempt to connect to a service while already connected.However, this method of showing an error message (calling
announceExit
) sends a signal toMainActivity
telling it the service has exited, and that it should set the UI state to "Disconnected." It does not actually disconnect the service at this point, resulting in a state mismatch in which you cannot actually disconnect the service.The solution in this commit is to remove this signalling and simply return out of
onStartCommand
to avoid processing the start request twice.Another potential solution is to call
sendSimple(MSG_IS_RUNNING, 1)
before returning, which would ensure that the UI is synchronized with the service state at this point, however I have no reason to believe it could get out of sync aside from the processing delay.