diff options
| author | 2019-03-06 00:49:20 +0000 | |
|---|---|---|
| committer | 2019-03-06 00:49:20 +0000 | |
| commit | f397b39442f302cde2026fb13075dec20b398bdf (patch) | |
| tree | 8f7e313a150f6ff565120b87723cecab9883d167 | |
| parent | 8bf13f06d71f01b79752965526cbdf598c1067fd (diff) | |
| parent | 4349dc08c902a90f2c775f9c3a227ccef4ee3e1a (diff) | |
Merge "Update description based on API feedback"
5 files changed, 25 insertions, 10 deletions
diff --git a/api/system-current.txt b/api/system-current.txt index 1f58de8e6c74..96cd11179d40 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -4655,6 +4655,7 @@ package android.provider { field public static final String CARRIER_APP_WHITELIST = "carrier_app_whitelist"; field public static final String DATA_STALL_CONSECUTIVE_DNS_TIMEOUT_THRESHOLD = "data_stall_consecutive_dns_timeout_threshold"; field public static final String DATA_STALL_EVALUATION_TYPE = "data_stall_evaluation_type"; + field public static final int DATA_STALL_EVALUATION_TYPE_DNS = 1; // 0x1 field public static final String DATA_STALL_MIN_EVALUATE_INTERVAL = "data_stall_min_evaluate_interval"; field public static final String DATA_STALL_VALID_DNS_TIME_THRESHOLD = "data_stall_valid_dns_time_threshold"; field public static final String DEFAULT_SM_DP_PLUS = "default_sm_dp_plus"; diff --git a/api/test-current.txt b/api/test-current.txt index 23009062dad2..dcd23b7c77ae 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -1227,6 +1227,7 @@ package android.provider { field public static final String CAPTIVE_PORTAL_USE_HTTPS = "captive_portal_use_https"; field public static final String DATA_STALL_CONSECUTIVE_DNS_TIMEOUT_THRESHOLD = "data_stall_consecutive_dns_timeout_threshold"; field public static final String DATA_STALL_EVALUATION_TYPE = "data_stall_evaluation_type"; + field public static final int DATA_STALL_EVALUATION_TYPE_DNS = 1; // 0x1 field public static final String DATA_STALL_MIN_EVALUATE_INTERVAL = "data_stall_min_evaluate_interval"; field public static final String DATA_STALL_VALID_DNS_TIME_THRESHOLD = "data_stall_valid_dns_time_threshold"; field public static final String HIDDEN_API_BLACKLIST_EXEMPTIONS = "hidden_api_blacklist_exemptions"; diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index e945c5fb12fb..946d38667fea 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -10475,8 +10475,9 @@ public final class Settings { /** * The threshold value for the number of consecutive dns timeout events received to be a - * signal of data stall. Set the value to 0 or less than 0 to disable. Note that the value - * should be larger than 0 if the DNS data stall detection is enabled. + * signal of data stall. The number of consecutive timeouts needs to be {@code >=} this + * threshold to be considered a data stall. Set the value to {@code <= 0} to disable. Note + * that the value should be {@code > 0} if the DNS data stall detection is enabled. * * @hide */ @@ -10507,9 +10508,12 @@ public final class Settings { "data_stall_valid_dns_time_threshold"; /** - * Which data stall detection signal to use. Possible values are a union of the powers of 2 - * of DATA_STALL_EVALUATION_TYPE_*. + * Which data stall detection signal to use. This is a bitmask constructed by bitwise-or-ing + * (i.e. {@code |}) the DATA_STALL_EVALUATION_TYPE_* values. * + * Type: int + * Valid values: + * {@link #DATA_STALL_EVALUATION_TYPE_DNS} : Use dns as a signal. * @hide */ @SystemApi @@ -10517,6 +10521,15 @@ public final class Settings { public static final String DATA_STALL_EVALUATION_TYPE = "data_stall_evaluation_type"; /** + * Use dns timeout counts to detect data stall. + * + * @hide + */ + @SystemApi + @TestApi + public static final int DATA_STALL_EVALUATION_TYPE_DNS = 1; + + /** * Whether to try cellular data recovery when a bad network is reported. * * @hide diff --git a/packages/NetworkStack/src/com/android/server/connectivity/NetworkMonitor.java b/packages/NetworkStack/src/com/android/server/connectivity/NetworkMonitor.java index e82a5d7b4881..c3447fdb3d78 100644 --- a/packages/NetworkStack/src/com/android/server/connectivity/NetworkMonitor.java +++ b/packages/NetworkStack/src/com/android/server/connectivity/NetworkMonitor.java @@ -32,6 +32,7 @@ import static android.net.metrics.ValidationProbeEvent.DNS_SUCCESS; import static android.net.metrics.ValidationProbeEvent.PROBE_FALLBACK; import static android.net.metrics.ValidationProbeEvent.PROBE_PRIVDNS; import static android.net.util.NetworkStackUtils.isEmpty; +import static android.provider.Settings.Global.DATA_STALL_EVALUATION_TYPE_DNS; import android.annotation.NonNull; import android.annotation.Nullable; @@ -128,9 +129,8 @@ public class NetworkMonitor extends StateMachine { private static final int DEFAULT_DATA_STALL_MIN_EVALUATE_TIME_MS = 60 * 1000; private static final int DEFAULT_DATA_STALL_VALID_DNS_TIME_THRESHOLD_MS = 30 * 60 * 1000; - private static final int DATA_STALL_EVALUATION_TYPE_DNS = 1; private static final int DEFAULT_DATA_STALL_EVALUATION_TYPES = - (1 << DATA_STALL_EVALUATION_TYPE_DNS); + DATA_STALL_EVALUATION_TYPE_DNS; // Reevaluate it as intending to increase the number. Larger log size may cause statsd // log buffer bust and have stats log lost. private static final int DEFAULT_DNS_LOG_SIZE = 20; @@ -1772,7 +1772,7 @@ public class NetworkMonitor extends StateMachine { } private boolean dataStallEvaluateTypeEnabled(int type) { - return (mDataStallEvaluationType & (1 << type)) != 0; + return (mDataStallEvaluationType & type) != 0; } @VisibleForTesting @@ -1792,7 +1792,7 @@ public class NetworkMonitor extends StateMachine { } // Check dns signal. Suspect it may be a data stall if both : - // 1. The number of consecutive DNS query timeouts > mConsecutiveDnsTimeoutThreshold. + // 1. The number of consecutive DNS query timeouts >= mConsecutiveDnsTimeoutThreshold. // 2. Those consecutive DNS queries happened in the last mValidDataStallDnsTimeThreshold ms. if (dataStallEvaluateTypeEnabled(DATA_STALL_EVALUATION_TYPE_DNS)) { if (mDnsStallDetector.isDataStallSuspected(mConsecutiveDnsTimeoutThreshold, diff --git a/packages/NetworkStack/tests/src/com/android/server/connectivity/NetworkMonitorTest.java b/packages/NetworkStack/tests/src/com/android/server/connectivity/NetworkMonitorTest.java index 04b906b4b9b1..ee2baf20bb8e 100644 --- a/packages/NetworkStack/tests/src/com/android/server/connectivity/NetworkMonitorTest.java +++ b/packages/NetworkStack/tests/src/com/android/server/connectivity/NetworkMonitorTest.java @@ -20,6 +20,7 @@ import static android.net.CaptivePortal.APP_RETURN_DISMISSED; import static android.net.INetworkMonitor.NETWORK_TEST_RESULT_INVALID; import static android.net.INetworkMonitor.NETWORK_TEST_RESULT_VALID; import static android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET; +import static android.provider.Settings.Global.DATA_STALL_EVALUATION_TYPE_DNS; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertFalse; @@ -114,7 +115,6 @@ public class NetworkMonitorTest { private static final String TEST_OTHER_FALLBACK_URL = "http://otherfallback.google.com/gen_204"; private static final String TEST_MCCMNC = "123456"; - private static final int DATA_STALL_EVALUATION_TYPE_DNS = 1; private static final int RETURN_CODE_DNS_SUCCESS = 0; private static final int RETURN_CODE_DNS_TIMEOUT = 255; private static final int DEFAULT_DNS_TIMEOUT_THRESHOLD = 5; @@ -186,7 +186,7 @@ public class NetworkMonitorTest { when(mCm.getNetworkCapabilities(any())).thenReturn(METERED_CAPABILITIES); setMinDataStallEvaluateInterval(500); - setDataStallEvaluationType(1 << DATA_STALL_EVALUATION_TYPE_DNS); + setDataStallEvaluationType(DATA_STALL_EVALUATION_TYPE_DNS); setValidDataStallDnsTimeThreshold(500); setConsecutiveDnsTimeoutThreshold(5); } |