Enable policy ranking
Test: Passes all presubmits, been tested in labs Bug: 184834350 Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f Merged-In: If33884aa245bcc8817bbc9c2fdfab035249e7301 Change-Id: If33884aa245bcc8817bbc9c2fdfab035249e7301 (cherry-picked from ag/14150470)
This commit is contained in:
@@ -63,7 +63,7 @@ public class NetworkRanker {
|
||||
NetworkCapabilities getCapsNoCopy();
|
||||
}
|
||||
|
||||
private static final boolean USE_POLICY_RANKING = false;
|
||||
private static final boolean USE_POLICY_RANKING = true;
|
||||
|
||||
public NetworkRanker() { }
|
||||
|
||||
|
||||
@@ -3000,15 +3000,9 @@ public class ConnectivityServiceTest {
|
||||
|
||||
mEthernetNetworkAgent = new TestNetworkAgentWrapper(TRANSPORT_ETHERNET);
|
||||
mEthernetNetworkAgent.connect(true);
|
||||
// BUG: with the legacy int-based scoring code, the network will no longer linger, even
|
||||
// though it's validated and outscored.
|
||||
// The new policy-based scoring code fixes this.
|
||||
// TODO: remove the line below and replace with the three commented lines when
|
||||
// the policy-based scoring code is turned on.
|
||||
callback.expectAvailableThenValidatedCallbacks(mEthernetNetworkAgent);
|
||||
// callback.expectAvailableCallbacksUnvalidated(mEthernetNetworkAgent);
|
||||
// callback.expectCallback(CallbackEntry.LOSING, mWiFiNetworkAgent);
|
||||
// callback.expectCapabilitiesWith(NET_CAPABILITY_VALIDATED, mEthernetNetworkAgent);
|
||||
callback.expectAvailableCallbacksUnvalidated(mEthernetNetworkAgent);
|
||||
callback.expectCallback(CallbackEntry.LOSING, mWiFiNetworkAgent);
|
||||
callback.expectCapabilitiesWith(NET_CAPABILITY_VALIDATED, mEthernetNetworkAgent);
|
||||
assertEquals(mEthernetNetworkAgent.getNetwork(), mCm.getActiveNetwork());
|
||||
callback.assertNoCallback();
|
||||
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
|
||||
package com.android.server.connectivity
|
||||
|
||||
import android.net.NetworkCapabilities
|
||||
import android.net.NetworkRequest
|
||||
import android.net.NetworkScore.KEEP_CONNECTED_NONE
|
||||
import androidx.test.filters.SmallTest
|
||||
import androidx.test.runner.AndroidJUnit4
|
||||
import org.junit.Test
|
||||
@@ -32,10 +34,14 @@ import kotlin.test.assertNull
|
||||
class NetworkRankerTest {
|
||||
private val ranker = NetworkRanker()
|
||||
|
||||
private fun makeNai(satisfy: Boolean, score: Int) = mock(NetworkAgentInfo::class.java).also {
|
||||
doReturn(satisfy).`when`(it).satisfies(any())
|
||||
doReturn(score).`when`(it).currentScore
|
||||
}
|
||||
private fun makeNai(satisfy: Boolean, legacyScore: Int) =
|
||||
mock(NetworkAgentInfo::class.java).also {
|
||||
doReturn(satisfy).`when`(it).satisfies(any())
|
||||
val fs = FullScore(legacyScore, 0 /* policies */, KEEP_CONNECTED_NONE)
|
||||
doReturn(fs).`when`(it).getScore()
|
||||
val nc = NetworkCapabilities.Builder().build()
|
||||
doReturn(nc).`when`(it).getCapsNoCopy()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testGetBestNetwork() {
|
||||
|
||||
Reference in New Issue
Block a user