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

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

Update CapportData in CapportApiProbeResult to be nullable am: aa55058c am:...

Update CapportData in CapportApiProbeResult to be nullable am: aa55058c am: 35e74711 am: 48edb278 am: 54a4913f am: 5b879147

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

Change-Id: I65ef58e89affbf02dc982cccff27964f3355220a
parents 1c638f1e 5b879147
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -25,11 +25,12 @@ import com.android.networkstack.apishim.common.CaptivePortalDataShim;
 * @hide
 */
public class CapportApiProbeResult extends CaptivePortalProbeResult {
    @NonNull
    // CaptivePortalData may be null if the capport API does not send any valid reply.
    @Nullable
    private final CaptivePortalDataShim mCapportData;

    public CapportApiProbeResult(@NonNull CaptivePortalProbeResult result,
            @NonNull CaptivePortalDataShim capportData) {
            @Nullable CaptivePortalDataShim capportData) {
        this(result.mHttpResponseCode, result.redirectUrl, result.detectUrl, capportData,
                result.probeType);
    }
+1 −1
Original line number Diff line number Diff line
@@ -2626,7 +2626,7 @@ public class NetworkMonitor extends StateMachine {
                    validationLog("Missing user-portal-url from capport response");
                    return new CapportApiProbeResult(
                            sendDnsAndHttpProbes(mProxy, mUrl, ValidationProbeEvent.PROBE_HTTP),
                            capportData);
                            null /* capportData */);
                }
                final String loginUrlString = capportData.getUserPortalUrl().toString();
                // Starting from R (where CaptivePortalData was introduced), the captive portal app
+23 −1
Original line number Diff line number Diff line
@@ -1153,7 +1153,29 @@ public class NetworkMonitorTest {
    }

    @Test
    public void testIsCaptivePortal_CapportApiIsPortal() throws Exception {
    public void testIsCaptivePortal_CapportApiIsPortalWithNullPortalUrl() throws Exception {
        assumeTrue(CaptivePortalDataShimImpl.isSupported());
        setSslException(mHttpsConnection);
        final long bytesRemaining = 10_000L;
        final long secondsRemaining = 500L;
        // Set content without partal url.
        setApiContent(mCapportApiConnection, "{'captive': true,"
                + "'venue-info-url': '" + TEST_VENUE_INFO_URL + "',"
                + "'bytes-remaining': " + bytesRemaining + ","
                + "'seconds-remaining': " + secondsRemaining + "}");
        setPortal302(mHttpConnection);

        runNetworkTest(makeCapportLPs(), CELL_METERED_CAPABILITIES, VALIDATION_RESULT_PORTAL,
                0 /* probesSucceeded*/, TEST_LOGIN_URL);

        verify(mCapportApiConnection).getResponseCode();

        verify(mHttpConnection, times(1)).getResponseCode();
        verify(mCallbacks, never()).notifyCaptivePortalDataChanged(any());
    }

    @Test
    public void testIsCaptivePortal_CapportApiIsPortalWithValidPortalUrl() throws Exception {
        assumeTrue(CaptivePortalDataShimImpl.isSupported());
        setSslException(mHttpsConnection);
        final long bytesRemaining = 10_000L;