Merge "Fix issue for DnsResolver#query" into qt-dev

am: 23d7a55d18

Change-Id: I572d498fcbaf6df44a91a5b77552e497bc9f5cb7
This commit is contained in:
Luke Huang
2019-05-30 09:17:08 -07:00
committed by android-build-merger
3 changed files with 17 additions and 12 deletions

View File

@@ -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) {

View File

@@ -158,10 +158,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}.