From 51e7a60359b1b45719d30cd75418b39b7d380bfb Mon Sep 17 00:00:00 2001 From: Motomu Utsumi Date: Mon, 31 Jul 2023 19:26:18 +0900 Subject: [PATCH] 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 --- service/src/com/android/server/ConnectivityService.java | 9 ++++++--- .../java/com/android/server/ConnectivityServiceTest.java | 5 +++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/service/src/com/android/server/ConnectivityService.java b/service/src/com/android/server/ConnectivityService.java index f5c6cc9748..bc703a90c5 100755 --- a/service/src/com/android/server/ConnectivityService.java +++ b/service/src/com/android/server/ConnectivityService.java @@ -11138,7 +11138,9 @@ public class ConnectivityService extends IConnectivityManager.Stub 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 mActiveIdleTimers = new ArrayMap<>(); private static class IdleTimerParams { @@ -11321,8 +11323,9 @@ public class ConnectivityService extends IConnectivityManager.Stub 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 05aaae06ff..2db801dba1 100755 --- a/tests/unit/java/com/android/server/ConnectivityServiceTest.java +++ b/tests/unit/java/com/android/server/ConnectivityServiceTest.java @@ -11328,7 +11328,8 @@ public class ConnectivityServiceTest { @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 @@ public class ConnectivityServiceTest { mCellAgent.disconnect(); waitForIdle(); - assertFalse(mCm.isDefaultNetworkActive()); + assertTrue(mCm.isDefaultNetworkActive()); } @Test