[LT2] Fix release request while lingering.
Test: runtest framework-net Change-Id: Ic28c5653d16351903b792e76ba8b199b7ed1f8d4
This commit is contained in:
@@ -384,12 +384,15 @@ public class NetworkAgentInfo implements Comparable<NetworkAgentInfo> {
|
||||
|
||||
/**
|
||||
* Returns whether the network is a background network. A network is a background network if it
|
||||
* is satisfying no foreground requests and at least one background request. (If it did not have
|
||||
* a background request, it would be a speculative network that is only being kept up because
|
||||
* it might satisfy a request if it validated).
|
||||
* does not have the NET_CAPABILITY_FOREGROUND capability, which implies it is satisfying no
|
||||
* foreground request, is not lingering (i.e. kept for a while after being outscored), and is
|
||||
* not a speculative network (i.e. kept pending validation when validation would have it
|
||||
* outscore another foreground network). That implies it is being kept up by some background
|
||||
* request (otherwise it would be torn down), maybe the mobile always-on request.
|
||||
*/
|
||||
public boolean isBackgroundNetwork() {
|
||||
return !isVPN() && numForegroundNetworkRequests() == 0 && mNumBackgroundNetworkRequests > 0;
|
||||
return !isVPN() && numForegroundNetworkRequests() == 0 && mNumBackgroundNetworkRequests > 0
|
||||
&& !isLingering();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -50,6 +50,7 @@ import static android.net.NetworkCapabilities.TRANSPORT_WIFI;
|
||||
import static android.net.NetworkCapabilities.TRANSPORT_WIFI_AWARE;
|
||||
|
||||
import static com.android.internal.util.TestUtils.waitForIdleHandler;
|
||||
import static com.android.internal.util.TestUtils.waitForIdleLooper;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
@@ -85,6 +86,7 @@ import android.net.ConnectivityManager.NetworkCallback;
|
||||
import android.net.ConnectivityManager.PacketKeepalive;
|
||||
import android.net.ConnectivityManager.PacketKeepaliveCallback;
|
||||
import android.net.ConnectivityManager.TooManyRequestsException;
|
||||
import android.net.ConnectivityThread;
|
||||
import android.net.INetworkPolicyManager;
|
||||
import android.net.INetworkStatsService;
|
||||
import android.net.IpPrefix;
|
||||
@@ -279,6 +281,7 @@ public class ConnectivityServiceTest {
|
||||
waitForIdle(mWiFiNetworkAgent, timeoutMs);
|
||||
waitForIdle(mEthernetNetworkAgent, timeoutMs);
|
||||
waitForIdleHandler(mService.mHandlerThread, timeoutMs);
|
||||
waitForIdleLooper(ConnectivityThread.getInstanceLooper(), timeoutMs);
|
||||
}
|
||||
|
||||
public void waitForIdle(MockNetworkAgent agent, long timeoutMs) {
|
||||
@@ -1875,8 +1878,7 @@ public class ConnectivityServiceTest {
|
||||
callback.expectCallback(CallbackState.LOSING, mCellNetworkAgent);
|
||||
|
||||
// Let linger run its course.
|
||||
// TODO : the callback should be delayed by the linger delay. Fix this.
|
||||
// callback.assertNoCallback();
|
||||
callback.assertNoCallback();
|
||||
final int lingerTimeoutMs = TEST_LINGER_DELAY_MS + TEST_LINGER_DELAY_MS / 4;
|
||||
callback.expectCapabilitiesWithout(NET_CAPABILITY_FOREGROUND, mCellNetworkAgent,
|
||||
lingerTimeoutMs);
|
||||
|
||||
Reference in New Issue
Block a user