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

Commit b69a4169 authored by Chalard Jean's avatar Chalard Jean
Browse files

[NS09] Implement the new ranking code

At this stage, this is turned off. Unit tests will be
in a followup change.

Test: In a followup
Bug: 167544279
Change-Id: I4448a3546fbc1a3dddf757982c031c5f39ba2889
parent 59634a7f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -170,7 +170,7 @@ public final class NetworkScore implements Parcelable {

    @Override
    public String toString() {
        return "Score(" + mLegacyInt + ")";
        return "Score(" + mLegacyInt + " ; Policies : " + mPolicies + ")";
    }

    @Override
+0 −1
Original line number Diff line number Diff line
@@ -225,7 +225,6 @@ filegroup {
        "java/com/android/server/NetIdManager.java",
        "java/com/android/server/TestNetworkService.java",
        "java/com/android/server/connectivity/AutodestructReference.java",
        "java/com/android/server/connectivity/ConnectivityConstants.java",
        "java/com/android/server/connectivity/DnsManager.java",
        "java/com/android/server/connectivity/FullScore.java",
        "java/com/android/server/connectivity/KeepaliveTracker.java",
+2 −3
Original line number Diff line number Diff line
@@ -7742,7 +7742,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
            NetworkAgentInfo bestNetwork = null;
            NetworkRequest bestRequest = null;
            for (final NetworkRequest req : nri.mRequests) {
                bestNetwork = mNetworkRanker.getBestNetwork(req, nais);
                bestNetwork = mNetworkRanker.getBestNetwork(req, nais, nri.getSatisfier());
                // Stop evaluating as the highest possible priority request is satisfied.
                if (null != bestNetwork) {
                    bestRequest = req;
@@ -7995,7 +7995,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
            @NonNull final NetworkOffer offer, @NonNull final NetworkRanker networkRanker) {
        final NetworkRequest activeRequest = nri.isBeingSatisfied() ? nri.getActiveRequest() : null;
        final NetworkAgentInfo satisfier = null != activeRequest ? nri.getSatisfier() : null;
        final FullScore satisfierScore = null != satisfier ? satisfier.getScore() : null;

        // Multi-layer requests have a currently active request, the one being satisfied.
        // Since the system will try to bring up a better network than is currently satisfying
@@ -8034,7 +8033,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
                    && satisfier.factorySerialNumber == offer.providerId;
            final boolean newNeeded = (currentlyServing
                    || (activeRequest.canBeSatisfiedBy(offer.caps)
                            && networkRanker.mightBeat(activeRequest, satisfierScore, offer)));
                            && networkRanker.mightBeat(activeRequest, satisfier, offer)));
            if (newNeeded != oldNeeded) {
                if (newNeeded) {
                    offer.onNetworkNeeded(activeRequest);
+0 −28
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.server.connectivity;

/**
 * A class encapsulating various constants used by Connectivity.
 * TODO : remove this class.
 * @hide
 */
public class ConnectivityConstants {
    // VPNs typically have priority over other networks. Give them a score that will
    // let them win every single time.
    public static final int VPN_DEFAULT_SCORE = 101;
}
+2 −2
Original line number Diff line number Diff line
@@ -193,14 +193,14 @@ public class FullScore {
    // telephony factory, so that it depends on the carrier. For now this is handled by
    // connectivity for backward compatibility.
    public FullScore mixInScore(@NonNull final NetworkCapabilities caps,
            @NonNull final NetworkAgentConfig config, final boolean avoidBadWiFi) {
            @NonNull final NetworkAgentConfig config, final boolean yieldToBadWifi) {
        return withPolicies(mLegacyInt, mPolicies, mKeepConnectedReason,
                caps.hasCapability(NET_CAPABILITY_VALIDATED),
                caps.hasTransport(TRANSPORT_VPN),
                caps.hasCapability(NET_CAPABILITY_NOT_METERED),
                config.explicitlySelected,
                config.acceptUnvalidated,
                avoidBadWiFi);
                yieldToBadWifi);
    }

    // TODO : this shouldn't manage bad wifi avoidance – instead this should be done by the
Loading