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

Commit d1797013 authored by Paul Jensen's avatar Paul Jensen Committed by Android Git Automerger
Browse files

am 4636b4af: Stop ConnectivityService from talking to netd about uncreated networks.

* commit '4636b4afd5b8f4bc48ab9c477ea5a648026c7df4':
  Stop ConnectivityService from talking to netd about uncreated networks.
parents 87bf04db eec75412
Loading
Loading
Loading
Loading
+16 −15
Original line number Diff line number Diff line
@@ -1790,12 +1790,15 @@ public class ConnectivityService extends IConnectivityManager.Stub {
                    if (nai == null) {
                        loge("NetworkAgent not found for EVENT_NETWORK_PROPERTIES_CHANGED");
                    } else {
                        if (VDBG) log("Update of Linkproperties for " + nai.name());
                        if (VDBG) {
                            log("Update of Linkproperties for " + nai.name() +
                                    "; created=" + nai.created);
                        }
                        LinkProperties oldLp = nai.linkProperties;
                        synchronized (nai) {
                            nai.linkProperties = (LinkProperties)msg.obj;
                        }
                        updateLinkProperties(nai, oldLp);
                        if (nai.created) updateLinkProperties(nai, oldLp);
                    }
                    break;
                }
@@ -2032,6 +2035,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
                log(nai.name() + " got DISCONNECTED, was satisfying " + nai.networkRequests.size());
            }
            // A network agent has disconnected.
            if (nai.created) {
                // Tell netd to clean up the configuration for this network
                // (routing rules, DNS, etc).
                try {
@@ -2039,6 +2043,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
                } catch (Exception e) {
                    loge("Exception removing network: " + e);
                }
            }
            // TODO - if we move the logic to the network agent (have them disconnect
            // because they lost all their requests or because their score isn't good)
            // then they would disconnect organically, report their new state and then
@@ -4622,13 +4627,9 @@ public class ConnectivityService extends IConnectivityManager.Stub {
                    " to " + state);
        }

        if (state == NetworkInfo.State.CONNECTED) {
        if (state == NetworkInfo.State.CONNECTED && !networkAgent.created) {
            try {
                // This is likely caused by the fact that this network already
                // exists. An example is when a network goes from CONNECTED to
                // CONNECTING and back (like wifi on DHCP renew).
                // TODO: keep track of which networks we've created, or ask netd
                // to tell us whether we've already created this network or not.
                // This should never fail.  Specifying an already in use NetID will cause failure.
                if (networkAgent.isVPN()) {
                    mNetd.createVirtualNetwork(networkAgent.network.netId,
                            !networkAgent.linkProperties.getDnsServers().isEmpty(),
@@ -4642,7 +4643,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
                        + e.getMessage());
                return;
            }

            networkAgent.created = true;
            updateLinkProperties(networkAgent, null);
            notifyNetworkCallbacks(networkAgent, ConnectivityManager.CALLBACK_PRECHECK);
            networkAgent.networkMonitor.sendMessage(NetworkMonitor.CMD_NETWORK_CONNECTED);
+2 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ public class NetworkAgentInfo {
    public int currentScore;
    public final NetworkMonitor networkMonitor;
    public final NetworkMisc networkMisc;
    public boolean created;

    // The list of NetworkRequests being satisfied by this Network.
    public final SparseArray<NetworkRequest> networkRequests = new SparseArray<NetworkRequest>();
@@ -66,6 +67,7 @@ public class NetworkAgentInfo {
        currentScore = score;
        networkMonitor = new NetworkMonitor(context, handler, this);
        networkMisc = misc;
        created = false;
    }

    public void addRequest(NetworkRequest networkRequest) {