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

Commit f7f8ab4c authored by frank PREEL's avatar frank PREEL Committed by Alexandre Roux
Browse files

Override DNS

Change-Id: I141bc65b6d921189f9f8e00f2234748d43028d14
parent a902ace5
Loading
Loading
Loading
Loading
+25 −0
Original line number Original line Diff line number Diff line
/*
/*
 * Copyright (C) 2014 The Android Open Source Project
 * Copyright (C) 2014 The Android Open Source Project
 * Copyright (C) 2019 e.foundation
 *
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * you may not use this file except in compliance with the License.
@@ -44,6 +45,8 @@ import java.util.Objects;
import java.util.SortedSet;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.TreeSet;


import java.net.InetAddress;

/**
/**
 * A bag class used by ConnectivityService for holding a collection of most recent
 * A bag class used by ConnectivityService for holding a collection of most recent
 * information published by a particular NetworkAgent as well as the
 * information published by a particular NetworkAgent as well as the
@@ -263,6 +266,28 @@ public class NetworkAgentInfo implements Comparable<NetworkAgentInfo> {
        asyncChannel = ac;
        asyncChannel = ac;
        network = net;
        network = net;
        networkInfo = info;
        networkInfo = info;

        int useNwDNS = android.provider.Settings.System.getInt(mContext.getContentResolver(), "USE_NETWORK_DNS", 1);

        if ( 0 != useNwDNS ) {

        } else {
            java.util.Collection<InetAddress> dnses = new java.util.ArrayList<InetAddress>();
            try {
                String s = android.provider.Settings.System.getString(mContext.getContentResolver(), "OVERRIDE_DNS_IP_V4");
                if (s == null) s = "9.9.9.9";
                //if (DBG) log("Override dnses>"+s+"<");

                InetAddress addr = InetAddress.getByName(s);
                dnses.add(addr);

                lp.setDnsServers(dnses);
                lp.setDomains("");
            } catch (Exception e) {
                //loge("Cannot set custom DNS: " + e);
            }
        }

        linkProperties = lp;
        linkProperties = lp;
        networkCapabilities = nc;
        networkCapabilities = nc;
        currentScore = score;
        currentScore = score;