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

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

Fix a ConcurrentModificationException crash.

This is a pinpoint fix against the bug listed below. While a client
is synchronously reading the LinkProperties of a network, the
ConnectivityServiceThread is updating its properties. Make sure
that update is done atomically.

This is a stopgap countermeasure against a problem that is
pervasive with usage of LinkProperties, but fixing the problem
itself will happen later.

Bug: 80077223
Test: runtest frameworks-net
Change-Id: I9302f8fb5303cb39aa82691d4f6d7f38707a41fa
parent 6433ac13
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -4674,7 +4674,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
    }

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

        // The NetworkAgentInfo does not know whether clatd is running on its network or not. Before
@@ -4708,6 +4708,9 @@ public class ConnectivityService extends IConnectivityManager.Stub
        }
        // TODO - move this check to cover the whole function
        if (!Objects.equals(newLp, oldLp)) {
            synchronized (networkAgent) {
                networkAgent.linkProperties = newLp;
            }
            notifyIfacesChangedForNetworkStats();
            notifyNetworkCallbacks(networkAgent, ConnectivityManager.CALLBACK_IP_CHANGED);
        }