summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChiachang Wang <chiachangwang@google.com>2020-01-21 14:47:34 +0800
committerChiachang Wang <chiachangwang@google.com>2020-02-04 12:01:57 +0000
commitb6dbfb4e627c2843a77ca8fc85e3b9822c589ca3 (patch)
treee9f04f54a2f6dcd2912c8201d029878b3001cb2d
parent8e23204cdd56e7cf68f34938c31afe9804c70077 (diff)
Skip data stall check on unnecessary network
Except validation required networks, validation will be skipped. Even there is signal comes from those networks, the validation will not be proceeded and come back to ValidatedState. Thus, skip the unnecessary state transition. Bug: 144488209 Bug: 145275899 Test: atest NetworkStackTests NetworkStackNextTests Change-Id: I6271cf812bc438882bfba94ca91673471814061c
-rw-r--r--src/com/android/server/connectivity/NetworkMonitor.java4
-rw-r--r--tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java13
2 files changed, 17 insertions, 0 deletions
diff --git a/src/com/android/server/connectivity/NetworkMonitor.java b/src/com/android/server/connectivity/NetworkMonitor.java
index e8fe2ca..a4f934f 100644
--- a/src/com/android/server/connectivity/NetworkMonitor.java
+++ b/src/com/android/server/connectivity/NetworkMonitor.java
@@ -2253,6 +2253,10 @@ public class NetworkMonitor extends StateMachine {
@VisibleForTesting
protected boolean isDataStall() {
+ if (!isValidationRequired()) {
+ return false;
+ }
+
Boolean result = null;
final StringJoiner msg = (DBG || VDBG_STALL) ? new StringJoiner(", ") : null;
// Reevaluation will generate traffic. Thus, set a minimal reevaluation timer to limit the
diff --git a/tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java b/tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java
index 35cdb11..469284b 100644
--- a/tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java
+++ b/tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java
@@ -815,6 +815,19 @@ public class NetworkMonitorTest {
}
@Test
+ public void testIsDataStall_SkipEvaluateOnValidationNotRequiredNetwork() {
+ // Make DNS and TCP stall condition satisfied.
+ setDataStallEvaluationType(DATA_STALL_EVALUATION_TYPE_DNS | DATA_STALL_EVALUATION_TYPE_TCP);
+ when(mTstDependencies.isTcpInfoParsingSupported()).thenReturn(true);
+ when(mTst.getLatestReceivedCount()).thenReturn(0);
+ when(mTst.isDataStallSuspected()).thenReturn(true);
+ final WrappedNetworkMonitor nm = makeMonitor(NO_INTERNET_CAPABILITIES);
+ nm.setLastProbeTime(SystemClock.elapsedRealtime() - 1000);
+ makeDnsTimeoutEvent(nm, DEFAULT_DNS_TIMEOUT_THRESHOLD);
+ assertFalse(nm.isDataStall());
+ }
+
+ @Test
public void testIsDataStall_EvaluationDnsWithDnsTimeThreshold() {
// Test dns events happened in valid dns time threshold.
WrappedNetworkMonitor wrappedMonitor = makeMeteredNetworkMonitor();