android: Delay disconnecting on errors until user dismisses them
authorTobias Brunner <tobias@strongswan.org>
Mon, 14 Jul 2014 13:43:06 +0000 (15:43 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 22 Jul 2014 08:55:51 +0000 (10:55 +0200)
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.

src/frontends/android/src/org/strongswan/android/logic/CharonVpnService.java
src/frontends/android/src/org/strongswan/android/ui/VpnStateFragment.java

index 1302451..d53d478 100644 (file)
@@ -322,9 +322,8 @@ public class CharonVpnService extends VpnService implements Runnable
        }
 
        /**
-        * Set an error on the state service and disconnect the current connection.
-        * This is not done by calling stopCurrentConnection() above, but instead
-        * is done asynchronously via state service.
+        * Set an error on the state service. Called by the handler thread and any
+        * of charon's threads.
         *
         * @param error error state
         */
@@ -337,7 +336,6 @@ public class CharonVpnService extends VpnService implements Runnable
                                if (!mIsDisconnecting)
                                {
                                        mService.setError(error);
-                                       mService.disconnect();
                                }
                        }
                }
index f0a03a5..160ba95 100644 (file)
@@ -313,6 +313,10 @@ public class VpnStateFragment extends Fragment implements VpnStateListener
 
        private void clearError()
        {
+               if (mService != null)
+               {
+                       mService.disconnect();
+               }
                mDismissedConnectionID = mErrorConnectionID;
                updateView();
        }