Merge "Revert isDefaultNetworkActive behavior when there is no default network" into main

This commit is contained in:
Motomu Utsumi
2023-08-01 05:49:47 +00:00
committed by Gerrit Code Review
2 changed files with 9 additions and 5 deletions

View File

@@ -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<String, IdleTimerParams> 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;
}
}

View File

@@ -11330,7 +11330,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);
@@ -11342,7 +11343,7 @@ public class ConnectivityServiceTest {
mCellAgent.disconnect();
waitForIdle();
assertFalse(mCm.isDefaultNetworkActive());
assertTrue(mCm.isDefaultNetworkActive());
}
@Test