summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Chiachang Wang <chiachangwang@google.com> 2022-09-21 23:04:30 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2022-09-21 23:04:30 +0000
commitb883281ecc7f23992abee297760b91006c30f04f (patch)
tree836e08a0f1bc09abefe04a82f09aee956a84b852
parent151ac184209b15e9cad8404d1f5725a8246119f5 (diff)
parenta03e3f9a75afb11cc16bbf49e6db7e07b49da965 (diff)
Merge "Disconnect VPN when the underlying network is lost" am: f55958fcfd am: a03e3f9a75
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2222603 Change-Id: I3bd7d6de0e0825bc1a595418b597458ded626e6f Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--services/core/java/com/android/server/connectivity/Vpn.java69
1 files changed, 36 insertions, 33 deletions
diff --git a/services/core/java/com/android/server/connectivity/Vpn.java b/services/core/java/com/android/server/connectivity/Vpn.java
index ff154e463cb6..6a53978175af 100644
--- a/services/core/java/com/android/server/connectivity/Vpn.java
+++ b/services/core/java/com/android/server/connectivity/Vpn.java
@@ -3210,41 +3210,44 @@ public class Vpn {
return;
}
- if (mSession != null && mMobikeEnabled) {
- Log.d(
- TAG,
- "IKE Session has mobility. Delay handleSessionLost for losing network "
- + network
- + " on session with token "
- + mCurrentToken);
-
- final int token = mCurrentToken;
- // Delay the teardown in case a new network will be available soon. For example,
- // during handover between two WiFi networks, Android will disconnect from the
- // first WiFi and then connects to the second WiFi.
- mScheduledHandleNetworkLostFuture =
- mExecutor.schedule(
- () -> {
- if (isActiveToken(token)) {
- handleSessionLost(null /* exception */, network);
- } else {
- Log.d(
- TAG,
- "Scheduled handleSessionLost fired for "
- + "obsolete token "
- + token);
+ Log.d(TAG, "Schedule a delay handleSessionLost for losing network "
+ + network
+ + " on session with token "
+ + mCurrentToken);
+
+ final int token = mCurrentToken;
+ // Delay the teardown in case a new network will be available soon. For example,
+ // during handover between two WiFi networks, Android will disconnect from the
+ // first WiFi and then connects to the second WiFi.
+ mScheduledHandleNetworkLostFuture =
+ mExecutor.schedule(
+ () -> {
+ if (isActiveToken(token)) {
+ handleSessionLost(new IkeNetworkLostException(network),
+ network);
+
+ synchronized (Vpn.this) {
+ // Ignore stale runner.
+ if (mVpnRunner != this) return;
+
+ updateState(DetailedState.DISCONNECTED,
+ "Network lost");
}
+ } else {
+ Log.d(
+ TAG,
+ "Scheduled handleSessionLost fired for "
+ + "obsolete token "
+ + token);
+ }
+
+ // Reset mScheduledHandleNetworkLostFuture since it's
+ // already run on executor thread.
+ mScheduledHandleNetworkLostFuture = null;
+ },
+ NETWORK_LOST_TIMEOUT_MS,
+ TimeUnit.MILLISECONDS);
- // Reset mScheduledHandleNetworkLostFuture since it's
- // already run on executor thread.
- mScheduledHandleNetworkLostFuture = null;
- },
- NETWORK_LOST_TIMEOUT_MS,
- TimeUnit.MILLISECONDS);
- } else {
- Log.d(TAG, "Call handleSessionLost for losing network " + network);
- handleSessionLost(null /* exception */, network);
- }
}
private void cancelHandleNetworkLostTimeout() {