Loading packages/NetworkStack/src/com/android/server/connectivity/NetworkMonitor.java +8 −3 Original line number Diff line number Diff line Loading @@ -683,9 +683,9 @@ public class NetworkMonitor extends StateMachine { public void enter() { maybeLogEvaluationResult( networkEventType(validationStage(), EvaluationResult.VALIDATED)); // If the user has accepted that and HTTPS probing is disabled, then mark the network // as validated and partial so that settings can keep informing the user that the // connection is limited. // If the user has accepted partial connectivity and HTTPS probing is disabled, then // mark the network as validated and partial so that settings can keep informing the // user that the connection is limited. int result = NETWORK_VALIDATION_RESULT_VALID; if (!mUseHttps && mAcceptPartialConnectivity) { result |= NETWORK_VALIDATION_RESULT_PARTIAL; Loading Loading @@ -1054,6 +1054,11 @@ public class NetworkMonitor extends StateMachine { // TODO: Consider abandoning this state after a few attempts and // transitioning back to EvaluatingState, to perhaps give ourselves // 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); mPrivateDnsReevalDelayMs *= 2; if (mPrivateDnsReevalDelayMs > MAX_REEVALUATE_DELAY_MS) { Loading packages/NetworkStack/tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java +4 −0 Original line number Diff line number Diff line Loading @@ -941,6 +941,10 @@ public class NetworkMonitorTest { .notifyNetworkTested(intCaptor.capture(), any()); List<Integer> intArgs = intCaptor.getAllValues(); // None of these exact values can be known in advance except for intArgs.get(0) because the // HTTP and HTTPS probes race and the order in which they complete is non-deterministic. // Thus, check only exact value for intArgs.get(0) and only check the validation result for // the rest ones. assertEquals(Integer.valueOf(NETWORK_VALIDATION_PROBE_DNS | NETWORK_VALIDATION_PROBE_FALLBACK | NETWORK_VALIDATION_RESULT_VALID), intArgs.get(0)); Loading tests/net/java/com/android/server/ConnectivityServiceTest.java +6 −5 Original line number Diff line number Diff line Loading @@ -615,7 +615,7 @@ public class ConnectivityServiceTest { private void onValidationRequested() { try { if (mNmProvNotificationRequested && mNmValidationResult == VALIDATION_RESULT_VALID) { && ((mNmValidationResult & NETWORK_VALIDATION_RESULT_VALID) != 0)) { mNmCallbacks.hideProvisioningNotification(); mNmProvNotificationRequested = false; } Loading Loading @@ -2781,10 +2781,10 @@ public class ConnectivityServiceTest { // Bring up a network with a captive portal. // Expect onAvailable callback of listen for NET_CAPABILITY_CAPTIVE_PORTAL. mWiFiNetworkAgent = new MockNetworkAgent(TRANSPORT_WIFI); String firstRedirectUrl = "http://example.com/firstPath"; mWiFiNetworkAgent.connectWithCaptivePortal(firstRedirectUrl); String redirectUrl = "http://android.com/path"; mWiFiNetworkAgent.connectWithCaptivePortal(redirectUrl); captivePortalCallback.expectAvailableCallbacksUnvalidated(mWiFiNetworkAgent); assertEquals(mWiFiNetworkAgent.waitForRedirectUrl(), firstRedirectUrl); assertEquals(mWiFiNetworkAgent.waitForRedirectUrl(), redirectUrl); // Check that startCaptivePortalApp sends the expected command to NetworkMonitor. mCm.startCaptivePortalApp(mWiFiNetworkAgent.getNetwork()); Loading @@ -2794,7 +2794,7 @@ public class ConnectivityServiceTest { // Report that the captive portal is dismissed with partial connectivity, and check that // callbacks are fired. mWiFiNetworkAgent.setNetworkPartial(); mWiFiNetworkAgent.mNetworkMonitor.forceReevaluation(Process.myUid()); mCm.reportNetworkConnectivity(mWiFiNetworkAgent.getNetwork(), true); waitForIdle(); captivePortalCallback.expectCapabilitiesWith(NET_CAPABILITY_PARTIAL_CONNECTIVITY, mWiFiNetworkAgent); Loading @@ -2805,6 +2805,7 @@ public class ConnectivityServiceTest { false /* always */); waitForIdle(); mCm.reportNetworkConnectivity(mWiFiNetworkAgent.getNetwork(), true); captivePortalCallback.expectCallback(CallbackState.LOST, mWiFiNetworkAgent); validatedCallback.expectAvailableCallbacksValidated(mWiFiNetworkAgent); NetworkCapabilities nc = validatedCallback.expectCapabilitiesWith(NET_CAPABILITY_PARTIAL_CONNECTIVITY, Loading Loading
packages/NetworkStack/src/com/android/server/connectivity/NetworkMonitor.java +8 −3 Original line number Diff line number Diff line Loading @@ -683,9 +683,9 @@ public class NetworkMonitor extends StateMachine { public void enter() { maybeLogEvaluationResult( networkEventType(validationStage(), EvaluationResult.VALIDATED)); // If the user has accepted that and HTTPS probing is disabled, then mark the network // as validated and partial so that settings can keep informing the user that the // connection is limited. // If the user has accepted partial connectivity and HTTPS probing is disabled, then // mark the network as validated and partial so that settings can keep informing the // user that the connection is limited. int result = NETWORK_VALIDATION_RESULT_VALID; if (!mUseHttps && mAcceptPartialConnectivity) { result |= NETWORK_VALIDATION_RESULT_PARTIAL; Loading Loading @@ -1054,6 +1054,11 @@ public class NetworkMonitor extends StateMachine { // TODO: Consider abandoning this state after a few attempts and // transitioning back to EvaluatingState, to perhaps give ourselves // 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); mPrivateDnsReevalDelayMs *= 2; if (mPrivateDnsReevalDelayMs > MAX_REEVALUATE_DELAY_MS) { Loading
packages/NetworkStack/tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java +4 −0 Original line number Diff line number Diff line Loading @@ -941,6 +941,10 @@ public class NetworkMonitorTest { .notifyNetworkTested(intCaptor.capture(), any()); List<Integer> intArgs = intCaptor.getAllValues(); // None of these exact values can be known in advance except for intArgs.get(0) because the // HTTP and HTTPS probes race and the order in which they complete is non-deterministic. // Thus, check only exact value for intArgs.get(0) and only check the validation result for // the rest ones. assertEquals(Integer.valueOf(NETWORK_VALIDATION_PROBE_DNS | NETWORK_VALIDATION_PROBE_FALLBACK | NETWORK_VALIDATION_RESULT_VALID), intArgs.get(0)); Loading
tests/net/java/com/android/server/ConnectivityServiceTest.java +6 −5 Original line number Diff line number Diff line Loading @@ -615,7 +615,7 @@ public class ConnectivityServiceTest { private void onValidationRequested() { try { if (mNmProvNotificationRequested && mNmValidationResult == VALIDATION_RESULT_VALID) { && ((mNmValidationResult & NETWORK_VALIDATION_RESULT_VALID) != 0)) { mNmCallbacks.hideProvisioningNotification(); mNmProvNotificationRequested = false; } Loading Loading @@ -2781,10 +2781,10 @@ public class ConnectivityServiceTest { // Bring up a network with a captive portal. // Expect onAvailable callback of listen for NET_CAPABILITY_CAPTIVE_PORTAL. mWiFiNetworkAgent = new MockNetworkAgent(TRANSPORT_WIFI); String firstRedirectUrl = "http://example.com/firstPath"; mWiFiNetworkAgent.connectWithCaptivePortal(firstRedirectUrl); String redirectUrl = "http://android.com/path"; mWiFiNetworkAgent.connectWithCaptivePortal(redirectUrl); captivePortalCallback.expectAvailableCallbacksUnvalidated(mWiFiNetworkAgent); assertEquals(mWiFiNetworkAgent.waitForRedirectUrl(), firstRedirectUrl); assertEquals(mWiFiNetworkAgent.waitForRedirectUrl(), redirectUrl); // Check that startCaptivePortalApp sends the expected command to NetworkMonitor. mCm.startCaptivePortalApp(mWiFiNetworkAgent.getNetwork()); Loading @@ -2794,7 +2794,7 @@ public class ConnectivityServiceTest { // Report that the captive portal is dismissed with partial connectivity, and check that // callbacks are fired. mWiFiNetworkAgent.setNetworkPartial(); mWiFiNetworkAgent.mNetworkMonitor.forceReevaluation(Process.myUid()); mCm.reportNetworkConnectivity(mWiFiNetworkAgent.getNetwork(), true); waitForIdle(); captivePortalCallback.expectCapabilitiesWith(NET_CAPABILITY_PARTIAL_CONNECTIVITY, mWiFiNetworkAgent); Loading @@ -2805,6 +2805,7 @@ public class ConnectivityServiceTest { false /* always */); waitForIdle(); mCm.reportNetworkConnectivity(mWiFiNetworkAgent.getNetwork(), true); captivePortalCallback.expectCallback(CallbackState.LOST, mWiFiNetworkAgent); validatedCallback.expectAvailableCallbacksValidated(mWiFiNetworkAgent); NetworkCapabilities nc = validatedCallback.expectCapabilitiesWith(NET_CAPABILITY_PARTIAL_CONNECTIVITY, Loading