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

Commit f89d840c authored by Lorenzo Colitti's avatar Lorenzo Colitti Committed by Android Git Automerger
Browse files

am 5d1aeef0: am 28ca40ff: am 32f3518d: Merge "Only use mDefaultDns if the...

am 5d1aeef0: am 28ca40ff: am 32f3518d: Merge "Only use mDefaultDns if the network claims to offer Internet" into lmp-mr1-dev

* commit '5d1aeef0':
  Only use mDefaultDns if the network claims to offer Internet
parents f8225d3d 5d1aeef0
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -3593,8 +3593,14 @@ public class ConnectivityService extends IConnectivityManager.Stub
//            updateMtu(lp, null);
//        }
        updateTcpBufferSizes(networkAgent);

        // TODO: deprecate and remove mDefaultDns when we can do so safely.
        // For now, use it only when the network has Internet access. http://b/18327075
        final boolean useDefaultDns = networkAgent.networkCapabilities.hasCapability(
                NetworkCapabilities.NET_CAPABILITY_INTERNET);
        final boolean flushDns = updateRoutes(newLp, oldLp, netId);
        updateDnses(newLp, oldLp, netId, flushDns);
        updateDnses(newLp, oldLp, netId, flushDns, useDefaultDns);

        updateClat(newLp, oldLp, networkAgent);
        if (isDefaultNetwork(networkAgent)) handleApplyDefaultProxy(newLp.getHttpProxy());
        // TODO - move this check to cover the whole function
@@ -3688,10 +3694,11 @@ public class ConnectivityService extends IConnectivityManager.Stub
        }
        return !routeDiff.added.isEmpty() || !routeDiff.removed.isEmpty();
    }
    private void updateDnses(LinkProperties newLp, LinkProperties oldLp, int netId, boolean flush) {
    private void updateDnses(LinkProperties newLp, LinkProperties oldLp, int netId,
                             boolean flush, boolean useDefaultDns) {
        if (oldLp == null || (newLp.isIdenticalDnses(oldLp) == false)) {
            Collection<InetAddress> dnses = newLp.getDnsServers();
            if (dnses.size() == 0 && mDefaultDns != null) {
            if (dnses.size() == 0 && mDefaultDns != null && useDefaultDns) {
                dnses = new ArrayList();
                dnses.add(mDefaultDns);
                if (DBG) {
+11 −7
Original line number Diff line number Diff line
@@ -1710,15 +1710,19 @@ public class NetworkManagementService extends INetworkManagementService.Stub
    public void setDnsServersForNetwork(int netId, String[] servers, String domains) {
        mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);

        final Command cmd = new Command("resolver", "setnetdns", netId,
        Command cmd;
        if (servers.length > 0) {
            cmd = new Command("resolver", "setnetdns", netId,
                    (domains == null ? "" : domains));

            for (String s : servers) {
                InetAddress a = NetworkUtils.numericToInetAddress(s);
                if (a.isAnyLocalAddress() == false) {
                    cmd.appendArg(a.getHostAddress());
                }
            }
        } else {
            cmd = new Command("resolver", "clearnetdns", netId);
        }

        try {
            mConnector.execute(cmd);