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

Commit 5475abd3 authored by Chiachang Wang's avatar Chiachang Wang Committed by Automerger Merge Worker
Browse files

Merge "Fallback probe result should not be considered as HTTP success" am: 37063c50

Original change: https://android-review.googlesource.com/c/platform/packages/modules/NetworkStack/+/1498300

Change-Id: I7ee21fc01a3d01a98be2d5ef746818fae4759a42
parents 4761de4e 37063c50
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -2984,10 +2984,7 @@ public class NetworkMonitor extends StateMachine {
            httpsProbe.join();
            reportHttpProbeResult(NETWORK_VALIDATION_PROBE_HTTPS, httpsProbe.result());

            final boolean isHttpSuccessful =
                    (httpProbe.result().isSuccessful()
                    || (fallbackProbeResult != null && fallbackProbeResult.isSuccessful()));
            if (httpsProbe.result().isFailed() && isHttpSuccessful) {
            if (httpsProbe.result().isFailed() && httpProbe.result().isSuccessful()) {
                return CaptivePortalProbeResult.PARTIAL;
            }
            return httpsProbe.result();
+21 −9
Original line number Diff line number Diff line
@@ -1109,6 +1109,14 @@ public class NetworkMonitorTest {
        runPortalNetworkTest();
    }

    @Test
    public void testIsCaptivePortal_HttpSucceedFallbackProbeIsPortal() throws Exception {
        setSslException(mHttpsConnection);
        setStatus(mHttpConnection, 204);
        setPortal302(mFallbackConnection);
        runPortalNetworkTest();
    }

    @Test
    public void testIsCaptivePortal_FallbackProbeIsNotPortal() throws Exception {
        setSslException(mHttpsConnection);
@@ -1435,13 +1443,13 @@ public class NetworkMonitorTest {
    }

    @Test
    public void testIsCaptivePortal_FallbackSpecIsPartial() throws Exception {
    public void testIsCaptivePortal_FallbackSpecIsFail() throws Exception {
        setupFallbackSpec();
        set302(mOtherFallbackConnection, "https://www.google.com/test?q=3");

        // HTTPS failed, fallback spec went through -> partial connectivity
        runPartialConnectivityNetworkTest(
                NETWORK_VALIDATION_PROBE_DNS | NETWORK_VALIDATION_PROBE_FALLBACK);
        runNetworkTest(VALIDATION_RESULT_INVALID,
                NETWORK_VALIDATION_PROBE_DNS | NETWORK_VALIDATION_PROBE_FALLBACK,
                null /* redirectUrl */);
        verify(mOtherFallbackConnection, times(1)).getResponseCode();
        verify(mFallbackConnection, never()).getResponseCode();
    }
@@ -2208,13 +2216,16 @@ public class NetworkMonitorTest {
        setStatus(mFallbackConnection, 500);
        runPartialConnectivityNetworkTest(
                NETWORK_VALIDATION_PROBE_DNS | NETWORK_VALIDATION_PROBE_HTTP);
    }

        resetCallbacks();
    @Test
    public void testIsCaptivePortal_OnlyFallbackSucceed() throws Exception {
        setStatus(mHttpsConnection, 500);
        setStatus(mHttpConnection, 500);
        setStatus(mFallbackConnection, 204);
        runPartialConnectivityNetworkTest(
                NETWORK_VALIDATION_PROBE_DNS | NETWORK_VALIDATION_PROBE_FALLBACK);
        runNetworkTest(VALIDATION_RESULT_INVALID,
                NETWORK_VALIDATION_PROBE_DNS | NETWORK_VALIDATION_PROBE_FALLBACK,
                null /* redirectUrl */);
    }

    private void assertIpAddressArrayEquals(String[] expected, InetAddress[] actual) {
@@ -2274,8 +2285,9 @@ public class NetworkMonitorTest {
        setStatus(mFallbackConnection, 204);
        nm.forceReevaluation(Process.myUid());
        // Expect to send HTTP, HTTPs, FALLBACK and evaluation results.
        verifyNetworkTested(NETWORK_VALIDATION_RESULT_PARTIAL,
                NETWORK_VALIDATION_PROBE_DNS | NETWORK_VALIDATION_PROBE_FALLBACK);
        runNetworkTest(VALIDATION_RESULT_INVALID,
                NETWORK_VALIDATION_PROBE_DNS | NETWORK_VALIDATION_PROBE_FALLBACK,
                null /* redirectUrl */);
    }

    @Test