Fix agents disconnecting in SUSPENDED state.
Network state is not changed to disconnected when a networkagent
is disconnected and network state is SUSPENDED.
So the function requiresClat return true. Clat is not stoped.
Bug: 277682237
Test: atest FrameworksNetTests
Change-Id: I5edfcf64aca5d2d34325d722dd29fab41bcf2600
diff --git a/framework/src/android/net/NetworkInfo.java b/framework/src/android/net/NetworkInfo.java
index b7ec519..7aa9847 100644
--- a/framework/src/android/net/NetworkInfo.java
+++ b/framework/src/android/net/NetworkInfo.java
@@ -334,6 +334,24 @@
}
/**
+ * Indicates whether this network is suspended.
+ * @deprecated Apps should instead use the
+ * {@link android.net.ConnectivityManager.NetworkCallback} API to
+ * learn about connectivity changes. See
+ * {@link ConnectivityManager#registerDefaultNetworkCallback} and
+ * {@link ConnectivityManager#registerNetworkCallback}. These will
+ * give a more accurate picture of the connectivity state of
+ * the device and let apps react more easily and quickly to changes.
+ * @hide
+ */
+ @Deprecated
+ public boolean isSuspended() {
+ synchronized (this) {
+ return mState == State.SUSPENDED;
+ }
+ }
+
+ /**
* Indicates whether network connectivity is possible. A network is unavailable
* when a persistent or semi-persistent condition prevents the possibility
* of connecting to that network. Examples include
diff --git a/service/src/com/android/server/ConnectivityService.java b/service/src/com/android/server/ConnectivityService.java
index b17af99..c667d72 100755
--- a/service/src/com/android/server/ConnectivityService.java
+++ b/service/src/com/android/server/ConnectivityService.java
@@ -4546,7 +4546,7 @@
// because they lost all their requests or because their score isn't good)
// then they would disconnect organically, report their new state and then
// disconnect the channel.
- if (nai.networkInfo.isConnected()) {
+ if (nai.networkInfo.isConnected() || nai.networkInfo.isSuspended()) {
nai.networkInfo.setDetailedState(NetworkInfo.DetailedState.DISCONNECTED,
null, null);
}
diff --git a/tests/unit/java/com/android/server/ConnectivityServiceTest.java b/tests/unit/java/com/android/server/ConnectivityServiceTest.java
index a0d0647..e6ffecd 100755
--- a/tests/unit/java/com/android/server/ConnectivityServiceTest.java
+++ b/tests/unit/java/com/android/server/ConnectivityServiceTest.java
@@ -18014,7 +18014,6 @@
mCellAgent.expectDisconnected();
waitForIdle();
- // TODO (aosp/2583410): update following check to verifyClatdStop
- verifyNeverClatdStop(null /* inOrder */, MOBILE_IFNAME);
+ verifyClatdStop(null /* inOrder */, MOBILE_IFNAME);
}
}