android: Delay disconnecting on errors until user dismisses them

If e.g. reauthentication fails we don't want to close the TUN device
until the user acknowledged the error and is thus aware of the failure.
This commit is contained in:
Tobias Brunner
2014-07-22 10:55:51 +02:00
parent 08d545e29a
commit 394be2d556
2 changed files with 6 additions and 4 deletions
@@ -322,9 +322,8 @@ public class CharonVpnService extends VpnService implements Runnable
} }
/** /**
* Set an error on the state service and disconnect the current connection. * Set an error on the state service. Called by the handler thread and any
* This is not done by calling stopCurrentConnection() above, but instead * of charon's threads.
* is done asynchronously via state service.
* *
* @param error error state * @param error error state
*/ */
@@ -337,7 +336,6 @@ public class CharonVpnService extends VpnService implements Runnable
if (!mIsDisconnecting) if (!mIsDisconnecting)
{ {
mService.setError(error); mService.setError(error);
mService.disconnect();
} }
} }
} }
@@ -313,6 +313,10 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
private void clearError() private void clearError()
{ {
if (mService != null)
{
mService.disconnect();
}
mDismissedConnectionID = mErrorConnectionID; mDismissedConnectionID = mErrorConnectionID;
updateView(); updateView();
} }