Loading src/com/android/server/connectivity/NetworkMonitor.java +7 −4 Original line number Original line Diff line number Diff line Loading @@ -681,6 +681,8 @@ public class NetworkMonitor extends StateMachine { // no resolved IP addresses, IPs unreachable, // no resolved IP addresses, IPs unreachable, // port 853 unreachable, port 853 is not running a // port 853 unreachable, port 853 is not running a // DNS-over-TLS server, et cetera). // DNS-over-TLS server, et cetera). // Cancel any outstanding CMD_EVALUATE_PRIVATE_DNS. removeMessages(CMD_EVALUATE_PRIVATE_DNS); sendMessage(CMD_EVALUATE_PRIVATE_DNS); sendMessage(CMD_EVALUATE_PRIVATE_DNS); break; break; } } Loading Loading @@ -1042,6 +1044,11 @@ public class NetworkMonitor extends StateMachine { // All good! // All good! transitionTo(mValidatedState); transitionTo(mValidatedState); break; break; case CMD_PRIVATE_DNS_SETTINGS_CHANGED: // When settings change the reevaluation timer must be reset. mPrivateDnsReevalDelayMs = INITIAL_REEVALUATE_DELAY_MS; // Let the message bubble up and be handled by parent states as usual. return NOT_HANDLED; default: default: return NOT_HANDLED; return NOT_HANDLED; } } Loading Loading @@ -1094,10 +1101,6 @@ public class NetworkMonitor extends StateMachine { // transitioning back to EvaluatingState, to perhaps give ourselves // transitioning back to EvaluatingState, to perhaps give ourselves // the opportunity to (re)detect a captive portal or something. // the opportunity to (re)detect a captive portal or something. // // // TODO: distinguish between CMD_EVALUATE_PRIVATE_DNS messages that are caused by server // lookup failures (which should continue to do exponential backoff) and // CMD_EVALUATE_PRIVATE_DNS messages that are caused by user reconfiguration (which // should be processed immediately. sendMessageDelayed(CMD_EVALUATE_PRIVATE_DNS, mPrivateDnsReevalDelayMs); sendMessageDelayed(CMD_EVALUATE_PRIVATE_DNS, mPrivateDnsReevalDelayMs); mPrivateDnsReevalDelayMs *= 2; mPrivateDnsReevalDelayMs *= 2; if (mPrivateDnsReevalDelayMs > MAX_REEVALUATE_DELAY_MS) { if (mPrivateDnsReevalDelayMs > MAX_REEVALUATE_DELAY_MS) { Loading tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java +4 −8 Original line number Original line Diff line number Diff line Loading @@ -868,10 +868,8 @@ public class NetworkMonitorTest { WrappedNetworkMonitor wnm = makeNotMeteredNetworkMonitor(); WrappedNetworkMonitor wnm = makeNotMeteredNetworkMonitor(); wnm.notifyPrivateDnsSettingsChanged(new PrivateDnsConfig("dns.google", new InetAddress[0])); wnm.notifyPrivateDnsSettingsChanged(new PrivateDnsConfig("dns.google", new InetAddress[0])); wnm.notifyNetworkConnected(TEST_LINK_PROPERTIES, NOT_METERED_CAPABILITIES); wnm.notifyNetworkConnected(TEST_LINK_PROPERTIES, NOT_METERED_CAPABILITIES); verify(mCallbacks, timeout(HANDLER_TIMEOUT_MS).atLeastOnce()) verify(mCallbacks, timeout(HANDLER_TIMEOUT_MS)).notifyNetworkTested( .notifyNetworkTested( eq(NETWORK_VALIDATION_PROBE_DNS | NETWORK_VALIDATION_PROBE_HTTPS), eq(null)); eq(NETWORK_VALIDATION_PROBE_DNS | NETWORK_VALIDATION_PROBE_HTTPS), eq(null)); verify(mCallbacks, timeout(HANDLER_TIMEOUT_MS).times(1)).notifyProbeStatusChanged( verify(mCallbacks, timeout(HANDLER_TIMEOUT_MS).times(1)).notifyProbeStatusChanged( eq(VALIDATION_RESULT_PRIVDNS_VALID), eq(NETWORK_VALIDATION_PROBE_DNS eq(VALIDATION_RESULT_PRIVDNS_VALID), eq(NETWORK_VALIDATION_PROBE_DNS | NETWORK_VALIDATION_PROBE_HTTPS)); | NETWORK_VALIDATION_PROBE_HTTPS)); Loading Loading @@ -907,10 +905,8 @@ public class NetworkMonitorTest { mFakeDns.setNonBypassPrivateDnsWorking(false); mFakeDns.setNonBypassPrivateDnsWorking(false); wnm.notifyPrivateDnsSettingsChanged(new PrivateDnsConfig("dns.google", wnm.notifyPrivateDnsSettingsChanged(new PrivateDnsConfig("dns.google", new InetAddress[0])); new InetAddress[0])); verify(mCallbacks, timeout(HANDLER_TIMEOUT_MS).atLeastOnce()) verify(mCallbacks, timeout(HANDLER_TIMEOUT_MS)).notifyNetworkTested( .notifyNetworkTested( eq(NETWORK_VALIDATION_PROBE_DNS | NETWORK_VALIDATION_PROBE_HTTPS), eq(null)); eq(NETWORK_VALIDATION_PROBE_DNS | NETWORK_VALIDATION_PROBE_HTTPS), eq(null)); // NetworkMonitor will check if the probes has changed or not, if the probes has not // NetworkMonitor will check if the probes has changed or not, if the probes has not // changed, the callback won't be fired. // changed, the callback won't be fired. verify(mCallbacks, never()).notifyProbeStatusChanged( verify(mCallbacks, never()).notifyProbeStatusChanged( Loading Loading
src/com/android/server/connectivity/NetworkMonitor.java +7 −4 Original line number Original line Diff line number Diff line Loading @@ -681,6 +681,8 @@ public class NetworkMonitor extends StateMachine { // no resolved IP addresses, IPs unreachable, // no resolved IP addresses, IPs unreachable, // port 853 unreachable, port 853 is not running a // port 853 unreachable, port 853 is not running a // DNS-over-TLS server, et cetera). // DNS-over-TLS server, et cetera). // Cancel any outstanding CMD_EVALUATE_PRIVATE_DNS. removeMessages(CMD_EVALUATE_PRIVATE_DNS); sendMessage(CMD_EVALUATE_PRIVATE_DNS); sendMessage(CMD_EVALUATE_PRIVATE_DNS); break; break; } } Loading Loading @@ -1042,6 +1044,11 @@ public class NetworkMonitor extends StateMachine { // All good! // All good! transitionTo(mValidatedState); transitionTo(mValidatedState); break; break; case CMD_PRIVATE_DNS_SETTINGS_CHANGED: // When settings change the reevaluation timer must be reset. mPrivateDnsReevalDelayMs = INITIAL_REEVALUATE_DELAY_MS; // Let the message bubble up and be handled by parent states as usual. return NOT_HANDLED; default: default: return NOT_HANDLED; return NOT_HANDLED; } } Loading Loading @@ -1094,10 +1101,6 @@ public class NetworkMonitor extends StateMachine { // transitioning back to EvaluatingState, to perhaps give ourselves // transitioning back to EvaluatingState, to perhaps give ourselves // the opportunity to (re)detect a captive portal or something. // the opportunity to (re)detect a captive portal or something. // // // TODO: distinguish between CMD_EVALUATE_PRIVATE_DNS messages that are caused by server // lookup failures (which should continue to do exponential backoff) and // CMD_EVALUATE_PRIVATE_DNS messages that are caused by user reconfiguration (which // should be processed immediately. sendMessageDelayed(CMD_EVALUATE_PRIVATE_DNS, mPrivateDnsReevalDelayMs); sendMessageDelayed(CMD_EVALUATE_PRIVATE_DNS, mPrivateDnsReevalDelayMs); mPrivateDnsReevalDelayMs *= 2; mPrivateDnsReevalDelayMs *= 2; if (mPrivateDnsReevalDelayMs > MAX_REEVALUATE_DELAY_MS) { if (mPrivateDnsReevalDelayMs > MAX_REEVALUATE_DELAY_MS) { Loading
tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java +4 −8 Original line number Original line Diff line number Diff line Loading @@ -868,10 +868,8 @@ public class NetworkMonitorTest { WrappedNetworkMonitor wnm = makeNotMeteredNetworkMonitor(); WrappedNetworkMonitor wnm = makeNotMeteredNetworkMonitor(); wnm.notifyPrivateDnsSettingsChanged(new PrivateDnsConfig("dns.google", new InetAddress[0])); wnm.notifyPrivateDnsSettingsChanged(new PrivateDnsConfig("dns.google", new InetAddress[0])); wnm.notifyNetworkConnected(TEST_LINK_PROPERTIES, NOT_METERED_CAPABILITIES); wnm.notifyNetworkConnected(TEST_LINK_PROPERTIES, NOT_METERED_CAPABILITIES); verify(mCallbacks, timeout(HANDLER_TIMEOUT_MS).atLeastOnce()) verify(mCallbacks, timeout(HANDLER_TIMEOUT_MS)).notifyNetworkTested( .notifyNetworkTested( eq(NETWORK_VALIDATION_PROBE_DNS | NETWORK_VALIDATION_PROBE_HTTPS), eq(null)); eq(NETWORK_VALIDATION_PROBE_DNS | NETWORK_VALIDATION_PROBE_HTTPS), eq(null)); verify(mCallbacks, timeout(HANDLER_TIMEOUT_MS).times(1)).notifyProbeStatusChanged( verify(mCallbacks, timeout(HANDLER_TIMEOUT_MS).times(1)).notifyProbeStatusChanged( eq(VALIDATION_RESULT_PRIVDNS_VALID), eq(NETWORK_VALIDATION_PROBE_DNS eq(VALIDATION_RESULT_PRIVDNS_VALID), eq(NETWORK_VALIDATION_PROBE_DNS | NETWORK_VALIDATION_PROBE_HTTPS)); | NETWORK_VALIDATION_PROBE_HTTPS)); Loading Loading @@ -907,10 +905,8 @@ public class NetworkMonitorTest { mFakeDns.setNonBypassPrivateDnsWorking(false); mFakeDns.setNonBypassPrivateDnsWorking(false); wnm.notifyPrivateDnsSettingsChanged(new PrivateDnsConfig("dns.google", wnm.notifyPrivateDnsSettingsChanged(new PrivateDnsConfig("dns.google", new InetAddress[0])); new InetAddress[0])); verify(mCallbacks, timeout(HANDLER_TIMEOUT_MS).atLeastOnce()) verify(mCallbacks, timeout(HANDLER_TIMEOUT_MS)).notifyNetworkTested( .notifyNetworkTested( eq(NETWORK_VALIDATION_PROBE_DNS | NETWORK_VALIDATION_PROBE_HTTPS), eq(null)); eq(NETWORK_VALIDATION_PROBE_DNS | NETWORK_VALIDATION_PROBE_HTTPS), eq(null)); // NetworkMonitor will check if the probes has changed or not, if the probes has not // NetworkMonitor will check if the probes has changed or not, if the probes has not // changed, the callback won't be fired. // changed, the callback won't be fired. verify(mCallbacks, never()).notifyProbeStatusChanged( verify(mCallbacks, never()).notifyProbeStatusChanged( Loading