Remove ResolveUtil from frameworks/base callers
Use the Private DNS bypass logic that was moved into Network.
Once all callers of ResolvUtil are updated to use this interface
ResolvUtil can be deleted.
Test: as follows
- built, flashed, booted
- runtest frameworks-net passes
- connection to captive portal network detects portal correctly
and the login activity functions as expected
Bug: 64133961
Bug: 72345192
Bug: 73872000
Bug: 78548486
Change-Id: If11ef2b5ffdc729f8449cf18dccd5f1eccbc51e6
This commit is contained in:
@@ -3840,7 +3840,7 @@ public class ConnectivityManager {
|
||||
@UnsupportedAppUsage
|
||||
public static boolean setProcessDefaultNetworkForHostResolution(Network network) {
|
||||
return NetworkUtils.bindProcessToNetworkForHostResolution(
|
||||
network == null ? NETID_UNSET : network.netId);
|
||||
(network == null) ? NETID_UNSET : network.getNetIdForResolv());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -100,21 +100,29 @@ public class Network implements Parcelable {
|
||||
// anytime and (b) receivers should be explicit about attempts to bypass
|
||||
// Private DNS so that the intent of the code is easily determined and
|
||||
// code search audits are possible.
|
||||
private boolean mPrivateDnsBypass = false;
|
||||
private final transient boolean mPrivateDnsBypass;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
public Network(int netId) {
|
||||
this(netId, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public Network(int netId, boolean privateDnsBypass) {
|
||||
this.netId = netId;
|
||||
this.mPrivateDnsBypass = privateDnsBypass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public Network(Network that) {
|
||||
this.netId = that.netId;
|
||||
this(that.netId, that.mPrivateDnsBypass);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,8 +141,7 @@ public class Network implements Parcelable {
|
||||
* Operates the same as {@code InetAddress.getByName} except that host
|
||||
* resolution is done on this network.
|
||||
*
|
||||
* @param host
|
||||
* the hostName to be resolved to an address or {@code null}.
|
||||
* @param host the hostname to be resolved to an address or {@code null}.
|
||||
* @return the {@code InetAddress} instance representing the host.
|
||||
* @throws UnknownHostException
|
||||
* if the address lookup fails.
|
||||
@@ -144,14 +151,14 @@ public class Network implements Parcelable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify whether or not Private DNS should be bypassed when attempting
|
||||
* Obtain a Network object for which Private DNS is to be bypassed when attempting
|
||||
* to use {@link #getAllByName(String)}/{@link #getByName(String)} methods on the given
|
||||
* instance for hostname resolution.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public void setPrivateDnsBypass(boolean bypass) {
|
||||
mPrivateDnsBypass = bypass;
|
||||
public Network getPrivateDnsBypassingCopy() {
|
||||
return new Network(netId, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,7 +35,6 @@ import android.net.LinkProperties;
|
||||
import android.net.Network;
|
||||
import android.net.NetworkUtils;
|
||||
import android.net.Uri;
|
||||
import android.net.dns.ResolvUtil;
|
||||
import android.os.Binder;
|
||||
import android.os.INetworkManagementService;
|
||||
import android.os.UserHandle;
|
||||
@@ -174,15 +173,6 @@ public class DnsManager {
|
||||
return new PrivateDnsConfig(useTls);
|
||||
}
|
||||
|
||||
public static PrivateDnsConfig tryBlockingResolveOf(Network network, String name) {
|
||||
try {
|
||||
final InetAddress[] ips = ResolvUtil.blockingResolveAllLocally(network, name);
|
||||
return new PrivateDnsConfig(name, ips);
|
||||
} catch (UnknownHostException uhe) {
|
||||
return new PrivateDnsConfig(name, null);
|
||||
}
|
||||
}
|
||||
|
||||
public static Uri[] getPrivateDnsSettingsUris() {
|
||||
return new Uri[]{
|
||||
Settings.Global.getUriFor(PRIVATE_DNS_DEFAULT_MODE),
|
||||
|
||||
Reference in New Issue
Block a user