Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f46a8f62 authored by Chiachang Wang's avatar Chiachang Wang Committed by android-build-merger
Browse files

Keep only one CMD_EVALUATE_PRIVATE_DNS in the queue am: ed5f5198 am: 0ec9d5bb am: d1c4a5be

am: 43377c31

Change-Id: I4880fa9d6c6f7198c0f50fb7c57c32ae189c37a8
parents a2e8f1a1 43377c31
Loading
Loading
Loading
Loading
+7 −4
Original line number Original line Diff line number Diff line
@@ -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;
                }
                }
@@ -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;
            }
            }
@@ -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) {
+4 −8
Original line number Original line Diff line number Diff line
@@ -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));
@@ -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(