Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7db2c51c authored by Chalard Jean's avatar Chalard Jean Committed by Android (Google) Code Review
Browse files

Merge "Enable policy ranking" into sc-dev

parents f2766e90 6f9f6a28
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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() { }

+3 −9
Original line number Diff line number Diff line
@@ -2974,15 +2974,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();
+10 −4
Original line number Diff line number Diff line
@@ -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,9 +34,13 @@ import kotlin.test.assertNull
class NetworkRankerTest {
    private val ranker = NetworkRanker()

    private fun makeNai(satisfy: Boolean, score: Int) = mock(NetworkAgentInfo::class.java).also {
    private fun makeNai(satisfy: Boolean, legacyScore: Int) =
            mock(NetworkAgentInfo::class.java).also {
                doReturn(satisfy).`when`(it).satisfies(any())
        doReturn(score).`when`(it).currentScore
                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