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

Commit d95069eb authored by Remi NGUYEN VAN's avatar Remi NGUYEN VAN
Browse files

Add logs on invalid test probe URLs

Log when a probe URL is present but expired, and when a probe URL has
invalid format.

This is helpful to investigate test failures where the test URL is not
being applied as expected.

The modified code will only run on devices that have
TEST_URL_EXPIRATION_TIME set, so not on production devices, unless they
were used to run automated tests (and the tests did not cleanup
properly), or the user used adb comments to set the values.

Test: atest NetworkMonitorTest CaptivePortalTest
Change-Id: Ifea4fb23e01f4f43eed6508b2ce09c858446d818
parent f3dd8d71
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -1986,11 +1986,17 @@ public class NetworkMonitor extends StateMachine {
        }

        final long now = System.currentTimeMillis();
        if (expTime < now || (expTime - now) > TEST_URL_EXPIRATION_MS) return null;
        if (expTime < now || (expTime - now) > TEST_URL_EXPIRATION_MS) {
            logw("Skipping test URL with expiration " + expTime + ", now " + now);
            return null;
        }

        final String strUrl = mDependencies.getDeviceConfigProperty(NAMESPACE_CONNECTIVITY,
                key, null /* defaultValue */);
        if (!isValidTestUrl(strUrl)) return null;
        if (!isValidTestUrl(strUrl)) {
            logw("Skipping invalid test URL " + strUrl);
            return null;
        }
        return makeURL(strUrl);
    }