Merge changes I86257bc8,I5c2221c5 into nyc-dev
* changes: Use Netd's binder interface to set resolver configuration. Add Gservices settings for resolver configuration.
This commit is contained in:
committed by
Android (Google) Code Review
commit
4a992cbde8
@@ -323,6 +323,11 @@ interface INetworkManagementService
|
|||||||
*/
|
*/
|
||||||
void removeIdleTimer(String iface);
|
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.
|
* Bind name servers to a network in the DNS resolver.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -6973,6 +6973,33 @@ public final class Settings {
|
|||||||
/** {@hide} */
|
/** {@hide} */
|
||||||
public static final String STORAGE_BENCHMARK_INTERVAL = "storage_benchmark_interval";
|
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.
|
* Whether to disable the automatic scheduling of system updates.
|
||||||
* 1 = system updates won't be automatically scheduled (will always
|
* 1 = system updates won't be automatically scheduled (will always
|
||||||
|
|||||||
@@ -4317,10 +4317,10 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
Collection<InetAddress> dnses = newLp.getDnsServers();
|
Collection<InetAddress> dnses = newLp.getDnsServers();
|
||||||
if (DBG) log("Setting DNS servers for network " + netId + " to " + dnses);
|
if (DBG) log("Setting DNS servers for network " + netId + " to " + dnses);
|
||||||
try {
|
try {
|
||||||
mNetd.setDnsServersForNetwork(
|
mNetd.setDnsConfigurationForNetwork(
|
||||||
netId, NetworkUtils.makeStrings(dnses), newLp.getDomains());
|
netId, NetworkUtils.makeStrings(dnses), newLp.getDomains());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
loge("Exception in setDnsServersForNetwork: " + e);
|
loge("Exception in setDnsConfigurationForNetwork: " + e);
|
||||||
}
|
}
|
||||||
final NetworkAgentInfo defaultNai = getDefaultNetwork();
|
final NetworkAgentInfo defaultNai = getDefaultNetwork();
|
||||||
if (defaultNai != null && defaultNai.network.netId == netId) {
|
if (defaultNai != null && defaultNai.network.netId == netId) {
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ import static com.android.server.NetworkManagementService.NetdResponseCode.TtyLi
|
|||||||
import static com.android.server.NetworkManagementSocketTagger.PROP_QTAGUID_ENABLED;
|
import static com.android.server.NetworkManagementSocketTagger.PROP_QTAGUID_ENABLED;
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.app.ActivityManagerNative;
|
import android.app.ActivityManagerNative;
|
||||||
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.INetd;
|
import android.net.INetd;
|
||||||
@@ -76,6 +77,7 @@ import android.os.ServiceSpecificException;
|
|||||||
import android.os.StrictMode;
|
import android.os.StrictMode;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.os.SystemProperties;
|
import android.os.SystemProperties;
|
||||||
|
import android.provider.Settings;
|
||||||
import android.telephony.DataConnectionRealTimeInfo;
|
import android.telephony.DataConnectionRealTimeInfo;
|
||||||
import android.telephony.PhoneStateListener;
|
import android.telephony.PhoneStateListener;
|
||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
@@ -175,6 +177,12 @@ public class NetworkManagementService extends INetworkManagementService.Stub
|
|||||||
public static final int StrictCleartext = 617;
|
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.
|
* String indicating a softap command.
|
||||||
*/
|
*/
|
||||||
@@ -1926,6 +1934,51 @@ public class NetworkManagementService extends INetworkManagementService.Stub
|
|||||||
return stats;
|
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
|
@Override
|
||||||
public void setDnsServersForNetwork(int netId, String[] servers, String domains) {
|
public void setDnsServersForNetwork(int netId, String[] servers, String domains) {
|
||||||
mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
|
mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
|
||||||
|
|||||||
Reference in New Issue
Block a user