summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChiachang Wang <chiachangwang@google.com>2019-05-25 08:42:17 -0700
committerChiachang Wang <chiachangwang@google.com>2019-05-27 00:54:53 +0000
commit37fe18f9cb60a0bf8b3e34807a67bbaa552bf67b (patch)
tree8860653d52ec6be0688df8d4cf947cb56ffc5079
parentae343fc3a7cda11c763c2a8f007a1495a462dd42 (diff)
Clean up for multiple validation result update
This is a follow-up commit for aosp/955431 to update commets and minor updates in unit test. Test: atest com.android.server.ConnectivityServiceTest#testCaptivePortalOnPartialConnectivity Bug: 130683832 Change-Id: I581eae8daeddd2c4c186e7b40e27fef2aaa7ab43 Merged-In: I9087ef791b3fee5399ba8e83ef9d8a544845a4dd Merged-In: I4424663292c5ad29eb7a888fa6975835721a5d2e (cherry picked from commit 3d3a9fff7b7fa0df4ee627cb082668e642d6f754)
-rw-r--r--src/com/android/server/connectivity/NetworkMonitor.java11
-rw-r--r--tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java4
2 files changed, 12 insertions, 3 deletions
diff --git a/src/com/android/server/connectivity/NetworkMonitor.java b/src/com/android/server/connectivity/NetworkMonitor.java
index 8090d14..4e40ba4 100644
--- a/src/com/android/server/connectivity/NetworkMonitor.java
+++ b/src/com/android/server/connectivity/NetworkMonitor.java
@@ -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;
@@ -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) {
diff --git a/tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java b/tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java
index cc8f2c0..262641d 100644
--- a/tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java
+++ b/tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java
@@ -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));