Merge "provide a resource overlay to configure customized DNS Server."
This commit is contained in:
@@ -35,4 +35,8 @@
|
||||
</string-array>
|
||||
<string-array name="config_captive_portal_fallback_probe_specs" translatable="false">
|
||||
</string-array>
|
||||
</resources>
|
||||
|
||||
<!-- Customized default DNS Servers address. -->
|
||||
<string-array name="config_default_dns_servers" translatable="false">
|
||||
</string-array>
|
||||
</resources>
|
||||
|
||||
@@ -45,6 +45,7 @@ import static com.android.server.util.NetworkStackConstants.IPV4_ADDR_ANY;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.DhcpResults;
|
||||
import android.net.InetAddresses;
|
||||
import android.net.TrafficStats;
|
||||
import android.net.ip.IpClient;
|
||||
import android.net.metrics.DhcpClientEvent;
|
||||
@@ -66,6 +67,7 @@ import com.android.internal.util.MessageUtils;
|
||||
import com.android.internal.util.State;
|
||||
import com.android.internal.util.StateMachine;
|
||||
import com.android.internal.util.WakeupMessage;
|
||||
import com.android.networkstack.R;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.IOException;
|
||||
@@ -498,6 +500,18 @@ public class DhcpClient extends StateMachine {
|
||||
|
||||
private void acceptDhcpResults(DhcpResults results, String msg) {
|
||||
mDhcpLease = results;
|
||||
if (mDhcpLease.dnsServers.isEmpty()) {
|
||||
// supplement customized dns servers
|
||||
String[] dnsServersList =
|
||||
mContext.getResources().getStringArray(R.array.config_default_dns_servers);
|
||||
for (final String dnsServer : dnsServersList) {
|
||||
try {
|
||||
mDhcpLease.dnsServers.add(InetAddresses.parseNumericAddress(dnsServer));
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log.e(TAG, "Invalid default DNS server: " + dnsServer, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
mOffer = null;
|
||||
Log.d(TAG, msg + " lease: " + mDhcpLease);
|
||||
notifySuccess();
|
||||
|
||||
Reference in New Issue
Block a user