Revert isDefaultNetworkActive behavior when there is no default network
aosp/2605757 updated isDefaultNetworkActive returns false when there is
no default network.
But this change was not merged to U release branch and this change was
not well tested by dogfooding.
So this CL reverts the isDefaultNetworkActivity behavior change.
Bug: 279380356
Bug: 291870075
Test: atest FrameworksNetTests
Change-Id: Id88662faea9eeaba93d59ab2729f6204a3631ab1
diff --git a/service/src/com/android/server/ConnectivityService.java b/service/src/com/android/server/ConnectivityService.java
index f5c6cc9..bc703a9 100755
--- a/service/src/com/android/server/ConnectivityService.java
+++ b/service/src/com/android/server/ConnectivityService.java
@@ -11138,7 +11138,9 @@
new RemoteCallbackList<>();
// Indicate the current system default network activity is active or not.
// This needs to be volatile to allow non handler threads to read this value without lock.
- private volatile boolean mIsDefaultNetworkActive;
+ // If there is no default network, default network is considered active to keep the existing
+ // behavior. Initial value is used until first connect to the default network.
+ private volatile boolean mIsDefaultNetworkActive = true;
private final ArrayMap<String, IdleTimerParams> mActiveIdleTimers = new ArrayMap<>();
private static class IdleTimerParams {
@@ -11321,8 +11323,9 @@
reportNetworkActive();
}
} else {
- // If there is no default network, default network is considered inactive.
- mIsDefaultNetworkActive = false;
+ // If there is no default network, default network is considered active to keep the
+ // existing behavior.
+ mIsDefaultNetworkActive = true;
}
}
diff --git a/tests/unit/java/com/android/server/ConnectivityServiceTest.java b/tests/unit/java/com/android/server/ConnectivityServiceTest.java
index 05aaae0..2db801d 100755
--- a/tests/unit/java/com/android/server/ConnectivityServiceTest.java
+++ b/tests/unit/java/com/android/server/ConnectivityServiceTest.java
@@ -11328,7 +11328,8 @@
@Test
public void testIsDefaultNetworkActiveNoDefaultNetwork() throws Exception {
- assertFalse(mCm.isDefaultNetworkActive());
+ // isDefaultNetworkActive returns true if there is no default network, which is known issue.
+ assertTrue(mCm.isDefaultNetworkActive());
final LinkProperties cellLp = new LinkProperties();
cellLp.setInterfaceName(MOBILE_IFNAME);
@@ -11340,7 +11341,7 @@
mCellAgent.disconnect();
waitForIdle();
- assertFalse(mCm.isDefaultNetworkActive());
+ assertTrue(mCm.isDefaultNetworkActive());
}
@Test