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

Commit 7a4c2485 authored by Lorenzo Colitti's avatar Lorenzo Colitti Committed by Gerrit Code Review
Browse files

Merge "More cleanly separate requests and listens."

parents 57a531fd 97d09a26
Loading
Loading
Loading
Loading
+1 −19
Original line number Diff line number Diff line
@@ -435,25 +435,7 @@ public class NetworkRequest implements Parcelable {
     * @hide
     */
    public boolean isRequest() {
        return isForegroundRequest() || isBackgroundRequest();
    }

    /**
     * Returns true iff. the contained NetworkRequest is one that:
     *
     *     - should be associated with at most one satisfying network
     *       at a time;
     *
     *     - should cause a network to be kept up and in the foreground if
     *       it is the best network which can satisfy the NetworkRequest.
     *
     * For full detail of how isRequest() is used for pairing Networks with
     * NetworkRequests read rematchNetworkAndRequests().
     *
     * @hide
     */
    public boolean isForegroundRequest() {
        return type == Type.TRACK_DEFAULT || type == Type.REQUEST;
        return type == Type.REQUEST || type == Type.BACKGROUND_REQUEST;
    }

    /**
+9 −12
Original line number Diff line number Diff line
@@ -3589,10 +3589,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
        // As this request was not satisfied on rematch and thus never had any scores sent to the
        // factories, send null now for each request of type REQUEST.
        for (final NetworkRequest req : nri.mRequests) {
            if (!req.isRequest()) {
                continue;
            }
            sendUpdatedScoreToFactories(req, null);
            if (req.isRequest()) sendUpdatedScoreToFactories(req, null);
        }
    }

@@ -3769,7 +3766,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
        mNetworkRequestInfoLogs.log("RELEASE " + nri);

        if (null != nri.getActiveRequest()) {
            if (nri.getActiveRequest().isRequest()) {
            if (!nri.getActiveRequest().isListen()) {
                removeSatisfiedNetworkRequestFromNetwork(nri);
            } else {
                nri.setSatisfier(null, null);
@@ -5517,7 +5514,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
        }

        // The network currently satisfying this NRI. Only one request in an NRI can have a
        // satisfier. For non-multilayer requests, only REQUEST-type requests can have a satisfier.
        // satisfier. For non-multilayer requests, only non-listen requests can have a satisfier.
        @Nullable
        private NetworkAgentInfo mSatisfier;
        NetworkAgentInfo getSatisfier() {
@@ -7005,8 +7002,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
    private void sendUpdatedScoreToFactories(NetworkAgentInfo nai) {
        for (int i = 0; i < nai.numNetworkRequests(); i++) {
            NetworkRequest nr = nai.requestAt(i);
            // Don't send listening requests to factories. b/17393458
            if (nr.isListen()) continue;
            // Don't send listening or track default request to factories. b/17393458
            if (!nr.isRequest()) continue;
            sendUpdatedScoreToFactories(nr, nai);
        }
    }
@@ -7068,10 +7065,10 @@ public class ConnectivityService extends IConnectivityManager.Stub
        ensureRunningOnConnectivityServiceThread();
        for (final NetworkRequestInfo nri : getNrisFromGlobalRequests()) {
            for (final NetworkRequest req : nri.mRequests) {
                if (req.isListen() && nri.getActiveRequest() == req) {
                if (!req.isRequest() && nri.getActiveRequest() == req) {
                    break;
                }
                if (req.isListen()) {
                if (!req.isRequest()) {
                    continue;
                }
                // Only set the nai for the request it is satisfying.
@@ -7221,8 +7218,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
        if (nai.numRequestNetworkRequests() != 0) {
            for (int i = 0; i < nai.numNetworkRequests(); i++) {
                NetworkRequest nr = nai.requestAt(i);
                // Ignore listening requests.
                if (nr.isListen()) continue;
                // Ignore listening and track default requests.
                if (!nr.isRequest()) continue;
                loge("Dead network still had at least " + nr);
                break;
            }