Loading src/com/android/networkstack/util/DnsUtils.java +17 −6 Original line number Diff line number Diff line Loading @@ -55,12 +55,23 @@ public class DnsUtils { throws UnknownHostException { final List<InetAddress> result = new ArrayList<InetAddress>(); try { result.addAll(Arrays.asList( getAllByName(dnsResolver, network, host, TYPE_AAAA, FLAG_NO_CACHE_LOOKUP, timeout))); } catch (UnknownHostException e) { // Might happen if the host is v4-only, still need to query TYPE_A } try { result.addAll(Arrays.asList( getAllByName(dnsResolver, network, host, TYPE_A, FLAG_NO_CACHE_LOOKUP, timeout))); } catch (UnknownHostException e) { // Might happen if the host is v6-only, still need to return AAAA answers } if (result.size() == 0) { throw new UnknownHostException(host); } return result.toArray(new InetAddress[0]); } Loading tests/src/com/android/server/connectivity/NetworkMonitorTest.java +3 −2 Original line number Diff line number Diff line Loading @@ -297,9 +297,10 @@ public class NetworkMonitorTest { setOtherFallbackUrls(TEST_OTHER_FALLBACK_URL); setFallbackSpecs(null); // Test with no fallback spec by default when(mRandom.nextInt()).thenReturn(0); // DNS probe timeout should not be defined more than half of HANDLER_TIMEOUT_MS. Otherwise, // it will fail the test because of timeout expired for querying AAAA and A sequentially. when(mResources.getInteger(eq(R.integer.config_captive_portal_dns_probe_timeout))) .thenReturn(500); .thenReturn(200); doAnswer((invocation) -> { URL url = invocation.getArgument(0); Loading Loading
src/com/android/networkstack/util/DnsUtils.java +17 −6 Original line number Diff line number Diff line Loading @@ -55,12 +55,23 @@ public class DnsUtils { throws UnknownHostException { final List<InetAddress> result = new ArrayList<InetAddress>(); try { result.addAll(Arrays.asList( getAllByName(dnsResolver, network, host, TYPE_AAAA, FLAG_NO_CACHE_LOOKUP, timeout))); } catch (UnknownHostException e) { // Might happen if the host is v4-only, still need to query TYPE_A } try { result.addAll(Arrays.asList( getAllByName(dnsResolver, network, host, TYPE_A, FLAG_NO_CACHE_LOOKUP, timeout))); } catch (UnknownHostException e) { // Might happen if the host is v6-only, still need to return AAAA answers } if (result.size() == 0) { throw new UnknownHostException(host); } return result.toArray(new InetAddress[0]); } Loading
tests/src/com/android/server/connectivity/NetworkMonitorTest.java +3 −2 Original line number Diff line number Diff line Loading @@ -297,9 +297,10 @@ public class NetworkMonitorTest { setOtherFallbackUrls(TEST_OTHER_FALLBACK_URL); setFallbackSpecs(null); // Test with no fallback spec by default when(mRandom.nextInt()).thenReturn(0); // DNS probe timeout should not be defined more than half of HANDLER_TIMEOUT_MS. Otherwise, // it will fail the test because of timeout expired for querying AAAA and A sequentially. when(mResources.getInteger(eq(R.integer.config_captive_portal_dns_probe_timeout))) .thenReturn(500); .thenReturn(200); doAnswer((invocation) -> { URL url = invocation.getArgument(0); Loading