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";
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";
/**
* 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
*/
"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
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
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;
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;
}
private boolean dataStallEvaluateTypeEnabled(int type) {
- return (mDataStallEvaluationType & (1 << type)) != 0;
+ return (mDataStallEvaluationType & type) != 0;
}
@VisibleForTesting
}
// 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,
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;
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;
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);
}