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

Commit c28c8b59 authored by Lucas Lin's avatar Lucas Lin Committed by android-build-merger
Browse files

Merge "Improve partial connectivity"

am: f6cbc2d533

Change-Id: I19c41c88d32643f82531c7afc3d4248ef9b44b53
parents c1e4f725 a80308aa
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -277,9 +277,9 @@ public class NetworkStackService extends Service {
        }

        @Override
        public void notifyAcceptPartialConnectivity() {
        public void setAcceptPartialConnectivity() {
            checkNetworkStackCallingPermission();
            mNm.notifyAcceptPartialConnectivity();
            mNm.setAcceptPartialConnectivity();
        }

        @Override
+24 −7
Original line number Diff line number Diff line
@@ -319,7 +319,8 @@ public class NetworkMonitor extends StateMachine {
    private final DnsStallDetector mDnsStallDetector;
    private long mLastProbeTime;
    // Set to true if data stall is suspected and reset to false after metrics are sent to statsd.
    private boolean mCollectDataStallMetrics = false;
    private boolean mCollectDataStallMetrics;
    private boolean mAcceptPartialConnectivity;

    public NetworkMonitor(Context context, INetworkMonitorCallbacks cb, Network network,
            SharedLog validationLog) {
@@ -386,10 +387,11 @@ public class NetworkMonitor extends StateMachine {
    }

    /**
     * ConnectivityService notifies NetworkMonitor that the user accepts partial connectivity and
     * NetworkMonitor should ignore the https probe.
     * ConnectivityService notifies NetworkMonitor that the user already accepted partial
     * connectivity previously, so NetworkMonitor can validate the network even if it has partial
     * connectivity.
     */
    public void notifyAcceptPartialConnectivity() {
    public void setAcceptPartialConnectivity() {
        sendMessage(EVENT_ACCEPT_PARTIAL_CONNECTIVITY);
    }

@@ -651,9 +653,11 @@ public class NetworkMonitor extends StateMachine {
                case EVENT_DNS_NOTIFICATION:
                    mDnsStallDetector.accumulateConsecutiveDnsTimeoutCount(message.arg1);
                    break;
                // Set mAcceptPartialConnectivity to true and if network start evaluating or
                // re-evaluating and get the result of partial connectivity, ProbingState will
                // disable HTTPS probe and transition to EvaluatingPrivateDnsState.
                case EVENT_ACCEPT_PARTIAL_CONNECTIVITY:
                    mUseHttps = false;
                    transitionTo(mEvaluatingPrivateDnsState);
                    mAcceptPartialConnectivity = true;
                    break;
                default:
                    break;
@@ -849,6 +853,14 @@ public class NetworkMonitor extends StateMachine {
                    // ignore any re-evaluation requests. After, restart the
                    // evaluation process via EvaluatingState#enter.
                    return (mEvaluateAttempts < IGNORE_REEVALUATE_ATTEMPTS) ? HANDLED : NOT_HANDLED;
                // Disable HTTPS probe and transition to EvaluatingPrivateDnsState because:
                // 1. Network is connected and finish the network validation.
                // 2. NetworkMonitor detects network is partial connectivity and user accepts it.
                case EVENT_ACCEPT_PARTIAL_CONNECTIVITY:
                    mAcceptPartialConnectivity = true;
                    mUseHttps = false;
                    transitionTo(mEvaluatingPrivateDnsState);
                    return HANDLED;
                default:
                    return NOT_HANDLED;
            }
@@ -1081,7 +1093,12 @@ public class NetworkMonitor extends StateMachine {
                        logNetworkEvent(NetworkEvent.NETWORK_PARTIAL_CONNECTIVITY);
                        notifyNetworkTested(NETWORK_TEST_RESULT_PARTIAL_CONNECTIVITY,
                                probeResult.redirectUrl);
                        if (mAcceptPartialConnectivity) {
                            mUseHttps = false;
                            transitionTo(mEvaluatingPrivateDnsState);
                        } else {
                            transitionTo(mWaitingForNextProbeState);
                        }
                    } else {
                        logNetworkEvent(NetworkEvent.NETWORK_VALIDATION_FAILED);
                        notifyNetworkTested(NETWORK_TEST_RESULT_INVALID, probeResult.redirectUrl);
+1 −1
Original line number Diff line number Diff line
@@ -583,7 +583,7 @@ public class NetworkMonitorTest {
        verify(mCallbacks, timeout(HANDLER_TIMEOUT_MS).times(1))
                .notifyNetworkTested(NETWORK_TEST_RESULT_PARTIAL_CONNECTIVITY, null);

        nm.notifyAcceptPartialConnectivity();
        nm.setAcceptPartialConnectivity();
        verify(mCallbacks, timeout(HANDLER_TIMEOUT_MS).times(1))
                .notifyNetworkTested(NETWORK_TEST_RESULT_VALID, null);
    }