Loading core/java/android/os/INetworkManagementService.aidl +5 −0 Original line number Diff line number Diff line Loading @@ -323,6 +323,11 @@ interface INetworkManagementService */ void removeIdleTimer(String iface); /** * Configure name servers, search paths, and resolver parameters for the given network. */ void setDnsConfigurationForNetwork(int netId, in String[] servers, String domains); /** * Bind name servers to a network in the DNS resolver. */ Loading core/java/android/provider/Settings.java +27 −0 Original line number Diff line number Diff line Loading @@ -6973,6 +6973,33 @@ public final class Settings { /** {@hide} */ public static final String STORAGE_BENCHMARK_INTERVAL = "storage_benchmark_interval"; /** * Sample validity in seconds to configure for the system DNS resolver. * {@hide} */ public static final String DNS_RESOLVER_SAMPLE_VALIDITY_SECONDS = "dns_resolver_sample_validity_seconds"; /** * Success threshold in percent for use with the system DNS resolver. * {@hide} */ public static final String DNS_RESOLVER_SUCCESS_THRESHOLD_PERCENT = "dns_resolver_success_threshold_percent"; /** * Minimum number of samples needed for statistics to be considered meaningful in the * system DNS resolver. * {@hide} */ public static final String DNS_RESOLVER_MIN_SAMPLES = "dns_resolver_min_samples"; /** * Maximum number taken into account for statistics purposes in the system DNS resolver. * {@hide} */ public static final String DNS_RESOLVER_MAX_SAMPLES = "dns_resolver_max_samples"; /** * Whether to disable the automatic scheduling of system updates. * 1 = system updates won't be automatically scheduled (will always Loading services/core/java/com/android/server/ConnectivityService.java +2 −2 Original line number Diff line number Diff line Loading @@ -4320,10 +4320,10 @@ public class ConnectivityService extends IConnectivityManager.Stub Collection<InetAddress> dnses = newLp.getDnsServers(); if (DBG) log("Setting DNS servers for network " + netId + " to " + dnses); try { mNetd.setDnsServersForNetwork( mNetd.setDnsConfigurationForNetwork( netId, NetworkUtils.makeStrings(dnses), newLp.getDomains()); } catch (Exception e) { loge("Exception in setDnsServersForNetwork: " + e); loge("Exception in setDnsConfigurationForNetwork: " + e); } final NetworkAgentInfo defaultNai = getDefaultNetwork(); if (defaultNai != null && defaultNai.network.netId == netId) { Loading services/core/java/com/android/server/NetworkManagementService.java +53 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import static com.android.server.NetworkManagementService.NetdResponseCode.TtyLi import static com.android.server.NetworkManagementSocketTagger.PROP_QTAGUID_ENABLED; import android.annotation.NonNull; import android.app.ActivityManagerNative; import android.content.ContentResolver; import android.content.Context; import android.net.ConnectivityManager; import android.net.INetd; Loading Loading @@ -76,6 +77,7 @@ import android.os.ServiceSpecificException; import android.os.StrictMode; import android.os.SystemClock; import android.os.SystemProperties; import android.provider.Settings; import android.telephony.DataConnectionRealTimeInfo; import android.telephony.PhoneStateListener; import android.telephony.SubscriptionManager; Loading Loading @@ -175,6 +177,12 @@ public class NetworkManagementService extends INetworkManagementService.Stub public static final int StrictCleartext = 617; } /* Defaults for resolver parameters. */ public static final int DNS_RESOLVER_DEFAULT_SAMPLE_VALIDITY_SECONDS = 1800; public static final int DNS_RESOLVER_DEFAULT_SUCCESS_THRESHOLD_PERCENT = 25; public static final int DNS_RESOLVER_DEFAULT_MIN_SAMPLES = 8; public static final int DNS_RESOLVER_DEFAULT_MAX_SAMPLES = 64; /** * String indicating a softap command. */ Loading Loading @@ -1926,6 +1934,51 @@ public class NetworkManagementService extends INetworkManagementService.Stub return stats; } @Override public void setDnsConfigurationForNetwork(int netId, String[] servers, String domains) { mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); ContentResolver resolver = mContext.getContentResolver(); int sampleValidity = Settings.Global.getInt(resolver, Settings.Global.DNS_RESOLVER_SAMPLE_VALIDITY_SECONDS, DNS_RESOLVER_DEFAULT_SAMPLE_VALIDITY_SECONDS); if (sampleValidity < 0 || sampleValidity > 65535) { Slog.w(TAG, "Invalid sampleValidity=" + sampleValidity + ", using default=" + DNS_RESOLVER_DEFAULT_SAMPLE_VALIDITY_SECONDS); sampleValidity = DNS_RESOLVER_DEFAULT_SAMPLE_VALIDITY_SECONDS; } int successThreshold = Settings.Global.getInt(resolver, Settings.Global.DNS_RESOLVER_SUCCESS_THRESHOLD_PERCENT, DNS_RESOLVER_DEFAULT_SUCCESS_THRESHOLD_PERCENT); if (successThreshold < 0 || successThreshold > 100) { Slog.w(TAG, "Invalid successThreshold=" + successThreshold + ", using default=" + DNS_RESOLVER_DEFAULT_SUCCESS_THRESHOLD_PERCENT); successThreshold = DNS_RESOLVER_DEFAULT_SUCCESS_THRESHOLD_PERCENT; } int minSamples = Settings.Global.getInt(resolver, Settings.Global.DNS_RESOLVER_MIN_SAMPLES, DNS_RESOLVER_DEFAULT_MIN_SAMPLES); int maxSamples = Settings.Global.getInt(resolver, Settings.Global.DNS_RESOLVER_MAX_SAMPLES, DNS_RESOLVER_DEFAULT_MAX_SAMPLES); if (minSamples < 0 || minSamples > maxSamples || maxSamples > 64) { Slog.w(TAG, "Invalid sample count (min, max)=(" + minSamples + ", " + maxSamples + "), using default=(" + DNS_RESOLVER_DEFAULT_MIN_SAMPLES + ", " + DNS_RESOLVER_DEFAULT_MAX_SAMPLES + ")"); minSamples = DNS_RESOLVER_DEFAULT_MIN_SAMPLES; maxSamples = DNS_RESOLVER_DEFAULT_MAX_SAMPLES; } final String[] domainStrs = domains == null ? new String[0] : domains.split(" "); final int[] params = { sampleValidity, successThreshold, minSamples, maxSamples }; try { mNetdService.setResolverConfiguration(netId, servers, domainStrs, params); } catch (RemoteException e) { throw new RuntimeException(e); } } @Override public void setDnsServersForNetwork(int netId, String[] servers, String domains) { mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); Loading Loading
core/java/android/os/INetworkManagementService.aidl +5 −0 Original line number Diff line number Diff line Loading @@ -323,6 +323,11 @@ interface INetworkManagementService */ void removeIdleTimer(String iface); /** * Configure name servers, search paths, and resolver parameters for the given network. */ void setDnsConfigurationForNetwork(int netId, in String[] servers, String domains); /** * Bind name servers to a network in the DNS resolver. */ Loading
core/java/android/provider/Settings.java +27 −0 Original line number Diff line number Diff line Loading @@ -6973,6 +6973,33 @@ public final class Settings { /** {@hide} */ public static final String STORAGE_BENCHMARK_INTERVAL = "storage_benchmark_interval"; /** * Sample validity in seconds to configure for the system DNS resolver. * {@hide} */ public static final String DNS_RESOLVER_SAMPLE_VALIDITY_SECONDS = "dns_resolver_sample_validity_seconds"; /** * Success threshold in percent for use with the system DNS resolver. * {@hide} */ public static final String DNS_RESOLVER_SUCCESS_THRESHOLD_PERCENT = "dns_resolver_success_threshold_percent"; /** * Minimum number of samples needed for statistics to be considered meaningful in the * system DNS resolver. * {@hide} */ public static final String DNS_RESOLVER_MIN_SAMPLES = "dns_resolver_min_samples"; /** * Maximum number taken into account for statistics purposes in the system DNS resolver. * {@hide} */ public static final String DNS_RESOLVER_MAX_SAMPLES = "dns_resolver_max_samples"; /** * Whether to disable the automatic scheduling of system updates. * 1 = system updates won't be automatically scheduled (will always Loading
services/core/java/com/android/server/ConnectivityService.java +2 −2 Original line number Diff line number Diff line Loading @@ -4320,10 +4320,10 @@ public class ConnectivityService extends IConnectivityManager.Stub Collection<InetAddress> dnses = newLp.getDnsServers(); if (DBG) log("Setting DNS servers for network " + netId + " to " + dnses); try { mNetd.setDnsServersForNetwork( mNetd.setDnsConfigurationForNetwork( netId, NetworkUtils.makeStrings(dnses), newLp.getDomains()); } catch (Exception e) { loge("Exception in setDnsServersForNetwork: " + e); loge("Exception in setDnsConfigurationForNetwork: " + e); } final NetworkAgentInfo defaultNai = getDefaultNetwork(); if (defaultNai != null && defaultNai.network.netId == netId) { Loading
services/core/java/com/android/server/NetworkManagementService.java +53 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import static com.android.server.NetworkManagementService.NetdResponseCode.TtyLi import static com.android.server.NetworkManagementSocketTagger.PROP_QTAGUID_ENABLED; import android.annotation.NonNull; import android.app.ActivityManagerNative; import android.content.ContentResolver; import android.content.Context; import android.net.ConnectivityManager; import android.net.INetd; Loading Loading @@ -76,6 +77,7 @@ import android.os.ServiceSpecificException; import android.os.StrictMode; import android.os.SystemClock; import android.os.SystemProperties; import android.provider.Settings; import android.telephony.DataConnectionRealTimeInfo; import android.telephony.PhoneStateListener; import android.telephony.SubscriptionManager; Loading Loading @@ -175,6 +177,12 @@ public class NetworkManagementService extends INetworkManagementService.Stub public static final int StrictCleartext = 617; } /* Defaults for resolver parameters. */ public static final int DNS_RESOLVER_DEFAULT_SAMPLE_VALIDITY_SECONDS = 1800; public static final int DNS_RESOLVER_DEFAULT_SUCCESS_THRESHOLD_PERCENT = 25; public static final int DNS_RESOLVER_DEFAULT_MIN_SAMPLES = 8; public static final int DNS_RESOLVER_DEFAULT_MAX_SAMPLES = 64; /** * String indicating a softap command. */ Loading Loading @@ -1926,6 +1934,51 @@ public class NetworkManagementService extends INetworkManagementService.Stub return stats; } @Override public void setDnsConfigurationForNetwork(int netId, String[] servers, String domains) { mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); ContentResolver resolver = mContext.getContentResolver(); int sampleValidity = Settings.Global.getInt(resolver, Settings.Global.DNS_RESOLVER_SAMPLE_VALIDITY_SECONDS, DNS_RESOLVER_DEFAULT_SAMPLE_VALIDITY_SECONDS); if (sampleValidity < 0 || sampleValidity > 65535) { Slog.w(TAG, "Invalid sampleValidity=" + sampleValidity + ", using default=" + DNS_RESOLVER_DEFAULT_SAMPLE_VALIDITY_SECONDS); sampleValidity = DNS_RESOLVER_DEFAULT_SAMPLE_VALIDITY_SECONDS; } int successThreshold = Settings.Global.getInt(resolver, Settings.Global.DNS_RESOLVER_SUCCESS_THRESHOLD_PERCENT, DNS_RESOLVER_DEFAULT_SUCCESS_THRESHOLD_PERCENT); if (successThreshold < 0 || successThreshold > 100) { Slog.w(TAG, "Invalid successThreshold=" + successThreshold + ", using default=" + DNS_RESOLVER_DEFAULT_SUCCESS_THRESHOLD_PERCENT); successThreshold = DNS_RESOLVER_DEFAULT_SUCCESS_THRESHOLD_PERCENT; } int minSamples = Settings.Global.getInt(resolver, Settings.Global.DNS_RESOLVER_MIN_SAMPLES, DNS_RESOLVER_DEFAULT_MIN_SAMPLES); int maxSamples = Settings.Global.getInt(resolver, Settings.Global.DNS_RESOLVER_MAX_SAMPLES, DNS_RESOLVER_DEFAULT_MAX_SAMPLES); if (minSamples < 0 || minSamples > maxSamples || maxSamples > 64) { Slog.w(TAG, "Invalid sample count (min, max)=(" + minSamples + ", " + maxSamples + "), using default=(" + DNS_RESOLVER_DEFAULT_MIN_SAMPLES + ", " + DNS_RESOLVER_DEFAULT_MAX_SAMPLES + ")"); minSamples = DNS_RESOLVER_DEFAULT_MIN_SAMPLES; maxSamples = DNS_RESOLVER_DEFAULT_MAX_SAMPLES; } final String[] domainStrs = domains == null ? new String[0] : domains.split(" "); final int[] params = { sampleValidity, successThreshold, minSamples, maxSamples }; try { mNetdService.setResolverConfiguration(netId, servers, domainStrs, params); } catch (RemoteException e) { throw new RuntimeException(e); } } @Override public void setDnsServersForNetwork(int netId, String[] servers, String domains) { mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG); Loading