Merge "Fix nascent timer never get removed" into sc-dev
This commit is contained in:
@@ -7769,6 +7769,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
// all networks except in the case of an underlying network for a VCN.
|
// all networks except in the case of an underlying network for a VCN.
|
||||||
if (newSatisfier.isNascent()) {
|
if (newSatisfier.isNascent()) {
|
||||||
newSatisfier.unlingerRequest(NetworkRequest.REQUEST_ID_NONE);
|
newSatisfier.unlingerRequest(NetworkRequest.REQUEST_ID_NONE);
|
||||||
|
newSatisfier.unsetInactive();
|
||||||
}
|
}
|
||||||
|
|
||||||
// if newSatisfier is not null, then newRequest may not be null.
|
// if newSatisfier is not null, then newRequest may not be null.
|
||||||
@@ -8273,6 +8274,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
// But it will be removed as soon as the network satisfies a request for the first time.
|
// But it will be removed as soon as the network satisfies a request for the first time.
|
||||||
networkAgent.lingerRequest(NetworkRequest.REQUEST_ID_NONE,
|
networkAgent.lingerRequest(NetworkRequest.REQUEST_ID_NONE,
|
||||||
SystemClock.elapsedRealtime(), mNascentDelayMs);
|
SystemClock.elapsedRealtime(), mNascentDelayMs);
|
||||||
|
networkAgent.setInactive();
|
||||||
|
|
||||||
// Consider network even though it is not yet validated.
|
// Consider network even though it is not yet validated.
|
||||||
rematchAllNetworksAndRequests();
|
rematchAllNetworksAndRequests();
|
||||||
|
|||||||
@@ -4555,9 +4555,8 @@ public class ConnectivityServiceTest {
|
|||||||
expectNoRequestChanged(testFactory);
|
expectNoRequestChanged(testFactory);
|
||||||
testFactory.assertRequestCountEquals(0);
|
testFactory.assertRequestCountEquals(0);
|
||||||
assertFalse(testFactory.getMyStartRequested());
|
assertFalse(testFactory.getMyStartRequested());
|
||||||
// ... and cell data to be torn down after nascent network timeout.
|
// ... and cell data to be torn down immediately since it is no longer nascent.
|
||||||
cellNetworkCallback.expectCallback(CallbackEntry.LOST, mCellNetworkAgent,
|
cellNetworkCallback.expectCallback(CallbackEntry.LOST, mCellNetworkAgent);
|
||||||
mService.mNascentDelayMs + TEST_CALLBACK_TIMEOUT_MS);
|
|
||||||
waitForIdle();
|
waitForIdle();
|
||||||
assertLength(1, mCm.getAllNetworks());
|
assertLength(1, mCm.getAllNetworks());
|
||||||
} finally {
|
} finally {
|
||||||
@@ -11778,6 +11777,11 @@ public class ConnectivityServiceTest {
|
|||||||
internetFactory.expectRequestRemove();
|
internetFactory.expectRequestRemove();
|
||||||
internetFactory.assertRequestCountEquals(0);
|
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.
|
// Now WiFi connects and it's unmetered, but it's weaker than cell.
|
||||||
mWiFiNetworkAgent = new TestNetworkAgentWrapper(TRANSPORT_WIFI);
|
mWiFiNetworkAgent = new TestNetworkAgentWrapper(TRANSPORT_WIFI);
|
||||||
mWiFiNetworkAgent.addCapability(NET_CAPABILITY_NOT_METERED);
|
mWiFiNetworkAgent.addCapability(NET_CAPABILITY_NOT_METERED);
|
||||||
@@ -11786,7 +11790,7 @@ public class ConnectivityServiceTest {
|
|||||||
mWiFiNetworkAgent.connect(true);
|
mWiFiNetworkAgent.connect(true);
|
||||||
|
|
||||||
// The OEM_PAID preference prefers an unmetered network to an OEM_PAID network, so
|
// 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();
|
oemPaidFactory.expectRequestRemove();
|
||||||
expectNoRequestChanged(internetFactory);
|
expectNoRequestChanged(internetFactory);
|
||||||
|
|
||||||
@@ -11797,6 +11801,7 @@ public class ConnectivityServiceTest {
|
|||||||
// unmetered network, so the oemPaidNetworkFactory still can't beat this.
|
// unmetered network, so the oemPaidNetworkFactory still can't beat this.
|
||||||
expectNoRequestChanged(oemPaidFactory);
|
expectNoRequestChanged(oemPaidFactory);
|
||||||
internetFactory.expectRequestAdd();
|
internetFactory.expectRequestAdd();
|
||||||
|
mCm.unregisterNetworkCallback(wifiCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user