Enable policy ranking am: f4c48a4d5f

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1727818

Change-Id: I458b430aac9d633099787863bcc252ffd236725a
This commit is contained in:
Chalard Jean
2021-06-08 23:10:14 +00:00
committed by Automerger Merge Worker
3 changed files with 14 additions and 14 deletions

View File

@@ -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() { }

View File

@@ -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();

View File

@@ -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() {