diff options
author | junyulai <junyulai@google.com> | 2021-03-26 00:40:48 +0800 |
---|---|---|
committer | junyulai <junyulai@google.com> | 2021-04-08 18:29:28 +0800 |
commit | 4ad53edc824161bf3fe357f1da2be89c59dcae7b (patch) | |
tree | 744dfd400965c2fcd5a282ffa730e0cc50a09765 /tests/net/java/com/android/server/ConnectivityServiceTest.java | |
parent | ceaff3862faf944bdd8ade3986092ae19eeee981 (diff) |
Fix nascent timer never get removed
By design, the nascent timer will be removed after a network
satisfied first request. However, this never happens.
Because the mInactive is false when that happens, so isNascent
is never true.
Furthermore, when removing a nascent timer, the inactivity
state can never be updated since no condition in the
updateInactivityState will be met to update the state correctly.
Thus, update inactive state accordingly when adding/removing the
nascent timer.
Test: TH
Bug: 184227264
Ignore-AOSP-First: prevent merge conflict
Change-Id: I4c1521b6e0ef68ac489771a2ab6b09ef3e381577
Diffstat (limited to 'tests/net/java/com/android/server/ConnectivityServiceTest.java')
-rw-r--r-- | tests/net/java/com/android/server/ConnectivityServiceTest.java | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/tests/net/java/com/android/server/ConnectivityServiceTest.java b/tests/net/java/com/android/server/ConnectivityServiceTest.java index af7eb59a3d55..ada20d3d565b 100644 --- a/tests/net/java/com/android/server/ConnectivityServiceTest.java +++ b/tests/net/java/com/android/server/ConnectivityServiceTest.java @@ -4547,9 +4547,8 @@ public class ConnectivityServiceTest { expectNoRequestChanged(testFactory); testFactory.assertRequestCountEquals(0); assertFalse(testFactory.getMyStartRequested()); - // ... and cell data to be torn down after nascent network timeout. - cellNetworkCallback.expectCallback(CallbackEntry.LOST, mCellNetworkAgent, - mService.mNascentDelayMs + TEST_CALLBACK_TIMEOUT_MS); + // ... and cell data to be torn down immediately since it is no longer nascent. + cellNetworkCallback.expectCallback(CallbackEntry.LOST, mCellNetworkAgent); waitForIdle(); assertLength(1, mCm.getAllNetworks()); } finally { @@ -11788,6 +11787,11 @@ public class ConnectivityServiceTest { internetFactory.expectRequestRemove(); internetFactory.assertRequestCountEquals(0); + // Create a request that holds the upcoming wifi network. + final TestNetworkCallback wifiCallback = new TestNetworkCallback(); + mCm.requestNetwork(new NetworkRequest.Builder().addTransportType(TRANSPORT_WIFI).build(), + wifiCallback); + // Now WiFi connects and it's unmetered, but it's weaker than cell. mWiFiNetworkAgent = new TestNetworkAgentWrapper(TRANSPORT_WIFI); mWiFiNetworkAgent.addCapability(NET_CAPABILITY_NOT_METERED); @@ -11796,7 +11800,7 @@ public class ConnectivityServiceTest { mWiFiNetworkAgent.connect(true); // The OEM_PAID preference prefers an unmetered network to an OEM_PAID network, so - // the oemPaidFactory can't beat this no matter how high its score. + // the oemPaidFactory can't beat wifi no matter how high its score. oemPaidFactory.expectRequestRemove(); expectNoRequestChanged(internetFactory); @@ -11807,6 +11811,7 @@ public class ConnectivityServiceTest { // unmetered network, so the oemPaidNetworkFactory still can't beat this. expectNoRequestChanged(oemPaidFactory); internetFactory.expectRequestAdd(); + mCm.unregisterNetworkCallback(wifiCallback); } /** |