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

Commit 25a4ec35 authored by lucaslin's avatar lucaslin Committed by Lucas Lin
Browse files

Update LinkProperties to NetworkAgentInfo only when it's changed

In previous design, it will always assign newLp to nai in
handleUpdateLinkProperties(). And Private dns configuration
will be missing when the same LinkProperties are updated
because the updated LinkProperties is not assigned back to
NetworkAgentInfo.

Bug: 118518971
Test: 1.Build pass.
      2.runtest frameworks-net

Change-Id: I405c8f29497fec438082a2cf30eb5c7b9497e1c4
parent 67c6ab38
Loading
Loading
Loading
Loading
+16 −17
Original line number Diff line number Diff line
@@ -2073,12 +2073,14 @@ public class ConnectivityService extends IConnectivityManager.Stub
        return new MockableSystemProperties();
    }

    private void updateTcpBufferSizes(NetworkAgentInfo nai) {
    // TODO: Replace nai and newLp with TcpBufferSizes and check default network before calling
    // this method.
    private void updateTcpBufferSizes(NetworkAgentInfo nai, LinkProperties newLp) {
        if (isDefaultNetwork(nai) == false) {
            return;
        }

        String tcpBufferSizes = nai.linkProperties.getTcpBufferSizes();
        String tcpBufferSizes = newLp.getTcpBufferSizes();
        String[] values = null;
        if (tcpBufferSizes != null) {
            values = tcpBufferSizes.split(",");
@@ -4728,8 +4730,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
        updateUids(nai, null, nai.networkCapabilities);
    }

    private void updateLinkProperties(NetworkAgentInfo networkAgent, LinkProperties oldLp) {
        LinkProperties newLp = new LinkProperties(networkAgent.linkProperties);
    private void updateLinkProperties(NetworkAgentInfo networkAgent, LinkProperties newLp,
            LinkProperties oldLp) {
        int netId = networkAgent.network.netId;

        // The NetworkAgentInfo does not know whether clatd is running on its network or not. Before
@@ -4744,7 +4746,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
//        for (LinkProperties lp : newLp.getStackedLinks()) {
//            updateMtu(lp, null);
//        }
        updateTcpBufferSizes(networkAgent);
        updateTcpBufferSizes(networkAgent, newLp);

        updateRoutes(newLp, oldLp, netId);
        updateDnses(newLp, oldLp, netId);
@@ -4754,8 +4756,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
        // updateDnses will fetch the private DNS configuration from DnsManager.
        mDnsManager.updatePrivateDnsStatus(netId, newLp);

        // Start or stop clat accordingly to network state.
        networkAgent.updateClat(mNMS);
        if (isDefaultNetwork(networkAgent)) {
            handleApplyDefaultProxy(newLp.getHttpProxy());
        } else {
@@ -4766,9 +4766,13 @@ public class ConnectivityService extends IConnectivityManager.Stub
            synchronized (networkAgent) {
                networkAgent.linkProperties = newLp;
            }
            // Start or stop clat accordingly to network state.
            networkAgent.updateClat(mNMS);
            notifyIfacesChangedForNetworkStats();
            if (networkAgent.everConnected) {
                notifyNetworkCallbacks(networkAgent, ConnectivityManager.CALLBACK_IP_CHANGED);
            }
        }

        mKeepaliveTracker.handleCheckKeepalivesStillValid(networkAgent);
    }
@@ -5072,13 +5076,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
                    "; created=" + nai.created +
                    "; everConnected=" + nai.everConnected);
        }
        LinkProperties oldLp = nai.linkProperties;
        synchronized (nai) {
            nai.linkProperties = newLp;
        }
        if (nai.everConnected) {
            updateLinkProperties(nai, oldLp);
        }
        updateLinkProperties(nai, newLp, new LinkProperties(nai.linkProperties));
    }

    private void sendUpdatedScoreToFactories(NetworkAgentInfo nai) {
@@ -5239,7 +5237,7 @@ public class ConnectivityService extends IConnectivityManager.Stub

        notifyLockdownVpn(newNetwork);
        handleApplyDefaultProxy(newNetwork.linkProperties.getHttpProxy());
        updateTcpBufferSizes(newNetwork);
        updateTcpBufferSizes(newNetwork, new LinkProperties(newNetwork.linkProperties));
        mDnsManager.setDefaultDnsSystemProperties(newNetwork.linkProperties.getDnsServers());
        notifyIfacesChangedForNetworkStats();
    }
@@ -5654,7 +5652,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
            }

            handlePerNetworkPrivateDnsConfig(networkAgent, mDnsManager.getPrivateDnsConfig());
            updateLinkProperties(networkAgent, null);
            updateLinkProperties(networkAgent, new LinkProperties(networkAgent.linkProperties),
                    null);

            networkAgent.networkMonitor.sendMessage(NetworkMonitor.CMD_NETWORK_CONNECTED);
            scheduleUnvalidatedPrompt(networkAgent);