Fix issue for DnsResolver#query
1. Previously, getDnsNetId doesn't handle all the cases. Fix it with cosidering bypass private DNS flag. 2. Make getDnsNetId return Network instead of netId, and change name from getDnsNetId to getDnsNetwork Bug: 129530368 Test: atest DnsResolverTest DnsUtilsTest Change-Id: Ic8d45b802d72a266f9ec97bfea620c1ede6967e5
This commit is contained in:
parent
43b5e55334
commit
38342d863f
2 changed files with 17 additions and 12 deletions
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
package android.net;
|
||||
|
||||
import static android.net.NetworkUtils.getDnsNetId;
|
||||
import static android.net.NetworkUtils.getDnsNetwork;
|
||||
import static android.net.NetworkUtils.resNetworkCancel;
|
||||
import static android.net.NetworkUtils.resNetworkQuery;
|
||||
import static android.net.NetworkUtils.resNetworkResult;
|
||||
|
|
@ -333,7 +333,7 @@ public final class DnsResolver {
|
|||
final Object lock = new Object();
|
||||
final Network queryNetwork;
|
||||
try {
|
||||
queryNetwork = (network != null) ? network : new Network(getDnsNetId());
|
||||
queryNetwork = (network != null) ? network : getDnsNetwork();
|
||||
} catch (ErrnoException e) {
|
||||
executor.execute(() -> callback.onError(new DnsException(ERROR_SYSTEM, e)));
|
||||
return;
|
||||
|
|
@ -433,7 +433,7 @@ public final class DnsResolver {
|
|||
final FileDescriptor queryfd;
|
||||
final Network queryNetwork;
|
||||
try {
|
||||
queryNetwork = (network != null) ? network : new Network(getDnsNetId());
|
||||
queryNetwork = (network != null) ? network : getDnsNetwork();
|
||||
queryfd = resNetworkQuery(queryNetwork.getNetIdForResolv(), domain, CLASS_IN, nsType,
|
||||
flags);
|
||||
} catch (ErrnoException e) {
|
||||
|
|
|
|||
|
|
@ -153,10 +153,9 @@ public class NetworkUtils {
|
|||
|
||||
/**
|
||||
* DNS resolver series jni method.
|
||||
* Attempts to get netid of network which resolver will
|
||||
* use if no network is explicitly selected.
|
||||
* Attempts to get network which resolver will use if no network is explicitly selected.
|
||||
*/
|
||||
public static native int getDnsNetId() throws ErrnoException;
|
||||
public static native Network getDnsNetwork() throws ErrnoException;
|
||||
|
||||
/**
|
||||
* Get the tcp repair window associated with the {@code fd}.
|
||||
|
|
|
|||
Loading…
Reference in a new issue