1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.server.wifi; 18 19 import static com.android.server.wifi.util.InformationElementUtil.BssLoad.CHANNEL_UTILIZATION_SCALE; 20 21 import android.content.Context; 22 import android.os.Handler; 23 import android.provider.DeviceConfig; 24 import android.util.ArraySet; 25 26 import com.android.internal.annotations.VisibleForTesting; 27 28 import java.util.Collections; 29 import java.util.Set; 30 import java.util.concurrent.TimeUnit; 31 32 /** 33 * This class allows getting all configurable flags from DeviceConfig. 34 */ 35 public class DeviceConfigFacade { 36 private Context mContext; 37 private final WifiMetrics mWifiMetrics; 38 39 private static final String NAMESPACE = "wifi"; 40 41 // Default values of fields 42 @VisibleForTesting 43 protected static final int DEFAULT_ABNORMAL_CONNECTION_DURATION_MS = 44 (int) TimeUnit.SECONDS.toMillis(30); 45 // Default duration for evaluating Wifi condition to trigger a data stall 46 // measured in milliseconds 47 public static final int DEFAULT_DATA_STALL_DURATION_MS = 1500; 48 // Default threshold of Tx throughput below which to trigger a data stall measured in Kbps 49 public static final int DEFAULT_DATA_STALL_TX_TPUT_THR_KBPS = 2000; 50 // Default threshold of Rx throughput below which to trigger a data stall measured in Kbps 51 public static final int DEFAULT_DATA_STALL_RX_TPUT_THR_KBPS = 2000; 52 // Default threshold of Tx packet error rate above which to trigger a data stall in percentage 53 public static final int DEFAULT_DATA_STALL_TX_PER_THR = 90; 54 // Default threshold of CCA level above which to trigger a data stall 55 public static final int DEFAULT_DATA_STALL_CCA_LEVEL_THR = CHANNEL_UTILIZATION_SCALE; 56 // Default low threshold of L2 sufficient Tx throughput in Kbps 57 public static final int DEFAULT_TX_TPUT_SUFFICIENT_THR_LOW_KBPS = 2000; 58 // Default high threshold of L2 sufficient Tx throughput in Kbps 59 public static final int DEFAULT_TX_TPUT_SUFFICIENT_THR_HIGH_KBPS = 8000; 60 // Default low threshold of L2 sufficient Rx throughput in Kbps 61 public static final int DEFAULT_RX_TPUT_SUFFICIENT_THR_LOW_KBPS = 2000; 62 // Default high threshold of L2 sufficient Rx throughput in Kbps 63 public static final int DEFAULT_RX_TPUT_SUFFICIENT_THR_HIGH_KBPS = 8000; 64 // Numerator part of default threshold of L2 throughput over L3 throughput ratio 65 public static final int DEFAULT_TPUT_SUFFICIENT_RATIO_THR_NUM = 2; 66 // Denominator part of default threshold of L2 throughput over L3 throughput ratio 67 public static final int DEFAULT_TPUT_SUFFICIENT_RATIO_THR_DEN = 1; 68 // Default threshold of Tx packet per second 69 public static final int DEFAULT_TX_PACKET_PER_SECOND_THR = 2; 70 // Default threshold of Rx packet per second 71 public static final int DEFAULT_RX_PACKET_PER_SECOND_THR = 2; 72 // Default high threshold values for various connection/disconnection cases 73 // All of them are in percent with respect to connection attempts 74 static final int DEFAULT_CONNECTION_FAILURE_HIGH_THR_PERCENT = 40; 75 static final int DEFAULT_CONNECTION_FAILURE_DISCONNECTION_HIGH_THR_PERCENT = 30; 76 static final int DEFAULT_ASSOC_REJECTION_HIGH_THR_PERCENT = 30; 77 static final int DEFAULT_ASSOC_TIMEOUT_HIGH_THR_PERCENT = 30; 78 static final int DEFAULT_AUTH_FAILURE_HIGH_THR_PERCENT = 30; 79 static final int DEFAULT_SHORT_CONNECTION_NONLOCAL_HIGH_THR_PERCENT = 20; 80 static final int DEFAULT_DISCONNECTION_NONLOCAL_HIGH_THR_PERCENT = 25; 81 // Default health monitor abnormal count minimum for various cases 82 static final int DEFAULT_CONNECTION_FAILURE_COUNT_MIN = 6; 83 static final int DEFAULT_CONNECTION_FAILURE_DISCONNECTION_COUNT_MIN = 5; 84 static final int DEFAULT_ASSOC_REJECTION_COUNT_MIN = 3; 85 static final int DEFAULT_ASSOC_TIMEOUT_COUNT_MIN = 3; 86 static final int DEFAULT_AUTH_FAILURE_COUNT_MIN = 3; 87 static final int DEFAULT_SHORT_CONNECTION_NONLOCAL_COUNT_MIN = 3; 88 static final int DEFAULT_DISCONNECTION_NONLOCAL_COUNT_MIN = 3; 89 // Numerator part of default ratio threshold values for all cases 90 static final int DEFAULT_HEALTH_MONITOR_RATIO_THR_NUMERATOR = 4; 91 // Denominator part of ratio threshold for all cases 92 static final int HEALTH_MONITOR_RATIO_THR_DENOMINATOR = 2; 93 // Minimum RSSI in dBm for connection stats collection 94 // Connection or disconnection events with RSSI below this threshold are not 95 // included in connection stats collection. 96 static final int DEFAULT_HEALTH_MONITOR_MIN_RSSI_THR_DBM = -68; 97 // Default minimum number of connection attempts to qualify daily detection 98 static final int DEFAULT_HEALTH_MONITOR_MIN_NUM_CONNECTION_ATTEMPT = 10; 99 // Default minimum wait time between two bug report captures 100 static final int DEFAULT_BUG_REPORT_MIN_WINDOW_MS = 3_600_000; 101 // Default report-high threshold to take-bug-report threshold ratio. 102 // It should be larger than 1 since the bar to take bugreport should be higher. 103 static final int DEFAULT_BUG_REPORT_THRESHOLD_EXTRA_RATIO = 2; 104 // Default overlapping connection duration threshold in ms to trigger bug report 105 static final int DEFAULT_OVERLAPPING_CONNECTION_DURATION_THRESHOLD_MS = 75_000; 106 // At low traffic, Tx link speed values below the following threshold 107 // are ignored because it could be due to low rate management frames 108 static final int DEFAULT_TX_LINK_SPEED_LOW_THRESHOLD_MBPS = 9; 109 // At low traffic, Rx link speed values below the following threshold 110 // are ignored because it could be due to low rate management frames 111 static final int DEFAULT_RX_LINK_SPEED_LOW_THRESHOLD_MBPS = 9; 112 // Default health monitor short connection duration threshold in ms 113 static final int DEFAULT_HEALTH_MONITOR_SHORT_CONNECTION_DURATION_THR_MS = 20_000; 114 115 // Default mask for abnormal disconnection reason codes. 116 // Each bit of mask corresponds to a reason code defined in 802.11 standard section 9.4.1.7 117 // For example, b0 for reason code 0, b1 for reason code 1, etc. 118 // Bits below are abnormal disconnection reasons and thus are set to 1 119 // b0: reserved (e.g., STA heartbeat failure) 120 // b2: invalid auth 121 // b4: disassociated due to inactivity 122 // b6 and b7: invalid class 2 and 3 frames 123 // b34: disassociated due to missing ACKs 124 static final long DEFAULT_ABNORMAL_DISCONNECTION_REASON_CODE_MASK = 0x4_0000_00d5L; 125 // Default maximum interval between last RSSI poll and disconnection 126 static final int DEFAULT_HEALTH_MONITOR_RSSI_POLL_VALID_TIME_MS = 2_100; 127 // Default maximum interval between scan and connection attempt in non-stationary state 128 static final int DEFAULT_NONSTATIONARY_SCAN_RSSI_VALID_TIME_MS = 5_000; 129 // Default maximum interval between scan and connection attempt in stationary state 130 static final int DEFAULT_STATIONARY_SCAN_RSSI_VALID_TIME_MS = 8_000; 131 // Default health monitor firmware alert valid time. 132 // -1 disables firmware alert time check 133 static final int DEFAULT_HEALTH_MONITOR_FW_ALERT_VALID_TIME_MS = -1; 134 // Default minimum confirmation duration for sending network score to connectivity service 135 // when score breaches low. The actual confirmation duration is longer in general and it 136 // depends on the score evaluation period normally controlled by 137 // 'com.android.wifi.resources.R' config_wifiPollRssiIntervalMilliseconds. 138 static final int DEFAULT_MIN_CONFIRMATION_DURATION_SEND_LOW_SCORE_MS = 5000; 139 // Default minimum confirmation duration for sending network score to connectivity service 140 // when score breaches high. The actual confirmation duration is longer in general and it 141 // depends on the score evaluation period normally controlled by 142 // 'com.android.wifi.resources.R' config_wifiPollRssiIntervalMilliseconds. 143 static final int DEFAULT_MIN_CONFIRMATION_DURATION_SEND_HIGH_SCORE_MS = 0; 144 // Default RSSI threshold in dBm above which low score is not sent to connectivity service 145 // when external scorer takes action. 146 static final int DEFAULT_RSSI_THRESHOLD_NOT_SEND_LOW_SCORE_TO_CS_DBM = -67; 147 // Maximum traffic stats threshold for link bandwidth estimator 148 static final int DEFAULT_TRAFFIC_STATS_THRESHOLD_MAX_KB = 8000; 149 static final int DEFAULT_BANDWIDTH_ESTIMATOR_TIME_CONSTANT_LARGE_SEC = 6; 150 // Cached values of fields updated via updateDeviceConfigFlags() 151 private boolean mIsAbnormalConnectionBugreportEnabled; 152 private int mAbnormalConnectionDurationMs; 153 private int mDataStallDurationMs; 154 private int mDataStallTxTputThrKbps; 155 private int mDataStallRxTputThrKbps; 156 private int mDataStallTxPerThr; 157 private int mDataStallCcaLevelThr; 158 private int mTxTputSufficientLowThrKbps; 159 private int mTxTputSufficientHighThrKbps; 160 private int mRxTputSufficientLowThrKbps; 161 private int mRxTputSufficientHighThrKbps; 162 private int mTputSufficientRatioThrNum; 163 private int mTputSufficientRatioThrDen; 164 private int mTxPktPerSecondThr; 165 private int mRxPktPerSecondThr; 166 private int mConnectionFailureHighThrPercent; 167 private int mConnectionFailureCountMin; 168 private int mConnectionFailureDisconnectionHighThrPercent; 169 private int mConnectionFailureDisconnectionCountMin; 170 private int mAssocRejectionHighThrPercent; 171 private int mAssocRejectionCountMin; 172 private int mAssocTimeoutHighThrPercent; 173 private int mAssocTimeoutCountMin; 174 private int mAuthFailureHighThrPercent; 175 private int mAuthFailureCountMin; 176 private int mShortConnectionNonlocalHighThrPercent; 177 private int mShortConnectionNonlocalCountMin; 178 private int mDisconnectionNonlocalHighThrPercent; 179 private int mDisconnectionNonlocalCountMin; 180 private int mHealthMonitorRatioThrNumerator; 181 private int mHealthMonitorMinRssiThrDbm; 182 private Set<String> mRandomizationFlakySsidHotlist; 183 private Set<String> mNonPersistentMacRandomizationSsidAllowlist; 184 private Set<String> mNonPersistentMacRandomizationSsidBlocklist; 185 private boolean mIsAbnormalConnectionFailureBugreportEnabled; 186 private boolean mIsAbnormalDisconnectionBugreportEnabled; 187 private int mHealthMonitorMinNumConnectionAttempt; 188 private int mBugReportMinWindowMs; 189 private int mBugReportThresholdExtraRatio; 190 private boolean mWifiBatterySaverEnabled; 191 private boolean mIsOverlappingConnectionBugreportEnabled; 192 private int mOverlappingConnectionDurationThresholdMs; 193 private int mTxLinkSpeedLowThresholdMbps; 194 private int mRxLinkSpeedLowThresholdMbps; 195 private int mHealthMonitorShortConnectionDurationThrMs; 196 private long mAbnormalDisconnectionReasonCodeMask; 197 private int mHealthMonitorRssiPollValidTimeMs; 198 private int mNonstationaryScanRssiValidTimeMs; 199 private int mStationaryScanRssiValidTimeMs; 200 private int mHealthMonitorFwAlertValidTimeMs; 201 private int mMinConfirmationDurationSendLowScoreMs; 202 private int mMinConfirmationDurationSendHighScoreMs; 203 private int mRssiThresholdNotSendLowScoreToCsDbm; 204 private boolean mAllowNonPersistentMacRandomizationOnOpenSsids; 205 private int mTrafficStatsThresholdMaxKbyte; 206 private int mBandwidthEstimatorLargeTimeConstantSec; 207 private boolean mInterfaceFailureBugreportEnabled; 208 DeviceConfigFacade(Context context, Handler handler, WifiMetrics wifiMetrics)209 public DeviceConfigFacade(Context context, Handler handler, WifiMetrics wifiMetrics) { 210 mContext = context; 211 mWifiMetrics = wifiMetrics; 212 213 updateDeviceConfigFlags(); 214 DeviceConfig.addOnPropertiesChangedListener( 215 NAMESPACE, 216 command -> handler.post(command), 217 properties -> { 218 updateDeviceConfigFlags(); 219 }); 220 } 221 updateDeviceConfigFlags()222 private void updateDeviceConfigFlags() { 223 mIsAbnormalConnectionBugreportEnabled = DeviceConfig.getBoolean(NAMESPACE, 224 "abnormal_connection_bugreport_enabled", false); 225 mAbnormalConnectionDurationMs = DeviceConfig.getInt(NAMESPACE, 226 "abnormal_connection_duration_ms", 227 DEFAULT_ABNORMAL_CONNECTION_DURATION_MS); 228 229 mDataStallDurationMs = DeviceConfig.getInt(NAMESPACE, 230 "data_stall_duration_ms", DEFAULT_DATA_STALL_DURATION_MS); 231 mDataStallTxTputThrKbps = DeviceConfig.getInt(NAMESPACE, 232 "data_stall_tx_tput_thr_kbps", DEFAULT_DATA_STALL_TX_TPUT_THR_KBPS); 233 mDataStallRxTputThrKbps = DeviceConfig.getInt(NAMESPACE, 234 "data_stall_rx_tput_thr_kbps", DEFAULT_DATA_STALL_RX_TPUT_THR_KBPS); 235 mDataStallTxPerThr = DeviceConfig.getInt(NAMESPACE, 236 "data_stall_tx_per_thr", DEFAULT_DATA_STALL_TX_PER_THR); 237 mDataStallCcaLevelThr = DeviceConfig.getInt(NAMESPACE, 238 "data_stall_cca_level_thr", DEFAULT_DATA_STALL_CCA_LEVEL_THR); 239 mWifiMetrics.setDataStallDurationMs(mDataStallDurationMs); 240 mWifiMetrics.setDataStallTxTputThrKbps(mDataStallTxTputThrKbps); 241 mWifiMetrics.setDataStallRxTputThrKbps(mDataStallRxTputThrKbps); 242 mWifiMetrics.setDataStallTxPerThr(mDataStallTxPerThr); 243 mWifiMetrics.setDataStallCcaLevelThr(mDataStallCcaLevelThr); 244 245 mTxTputSufficientLowThrKbps = DeviceConfig.getInt(NAMESPACE, 246 "tput_sufficient_low_thr_kbps", DEFAULT_TX_TPUT_SUFFICIENT_THR_LOW_KBPS); 247 mTxTputSufficientHighThrKbps = DeviceConfig.getInt(NAMESPACE, 248 "tput_sufficient_high_thr_kbps", DEFAULT_TX_TPUT_SUFFICIENT_THR_HIGH_KBPS); 249 mRxTputSufficientLowThrKbps = DeviceConfig.getInt(NAMESPACE, 250 "rx_tput_sufficient_low_thr_kbps", DEFAULT_RX_TPUT_SUFFICIENT_THR_LOW_KBPS); 251 mRxTputSufficientHighThrKbps = DeviceConfig.getInt(NAMESPACE, 252 "rx_tput_sufficient_high_thr_kbps", DEFAULT_RX_TPUT_SUFFICIENT_THR_HIGH_KBPS); 253 mTputSufficientRatioThrNum = DeviceConfig.getInt(NAMESPACE, 254 "tput_sufficient_ratio_thr_num", DEFAULT_TPUT_SUFFICIENT_RATIO_THR_NUM); 255 mTputSufficientRatioThrDen = DeviceConfig.getInt(NAMESPACE, 256 "tput_sufficient_ratio_thr_den", DEFAULT_TPUT_SUFFICIENT_RATIO_THR_DEN); 257 mTxPktPerSecondThr = DeviceConfig.getInt(NAMESPACE, 258 "tx_pkt_per_second_thr", DEFAULT_TX_PACKET_PER_SECOND_THR); 259 mRxPktPerSecondThr = DeviceConfig.getInt(NAMESPACE, 260 "rx_pkt_per_second_thr", DEFAULT_RX_PACKET_PER_SECOND_THR); 261 262 mConnectionFailureHighThrPercent = DeviceConfig.getInt(NAMESPACE, 263 "connection_failure_high_thr_percent", 264 DEFAULT_CONNECTION_FAILURE_HIGH_THR_PERCENT); 265 mConnectionFailureCountMin = DeviceConfig.getInt(NAMESPACE, 266 "connection_failure_count_min", 267 DEFAULT_CONNECTION_FAILURE_COUNT_MIN); 268 mConnectionFailureDisconnectionHighThrPercent = DeviceConfig.getInt(NAMESPACE, 269 "connection_failure_disconnection_high_thr_percent", 270 DEFAULT_CONNECTION_FAILURE_DISCONNECTION_HIGH_THR_PERCENT); 271 mConnectionFailureDisconnectionCountMin = DeviceConfig.getInt(NAMESPACE, 272 "connection_failure_disconnection_count_min", 273 DEFAULT_CONNECTION_FAILURE_DISCONNECTION_COUNT_MIN); 274 mAssocRejectionHighThrPercent = DeviceConfig.getInt(NAMESPACE, 275 "assoc_rejection_high_thr_percent", 276 DEFAULT_ASSOC_REJECTION_HIGH_THR_PERCENT); 277 mAssocRejectionCountMin = DeviceConfig.getInt(NAMESPACE, 278 "assoc_rejection_count_min", 279 DEFAULT_ASSOC_REJECTION_COUNT_MIN); 280 mAssocTimeoutHighThrPercent = DeviceConfig.getInt(NAMESPACE, 281 "assoc_timeout_high_thr_percent", 282 DEFAULT_ASSOC_TIMEOUT_HIGH_THR_PERCENT); 283 mAssocTimeoutCountMin = DeviceConfig.getInt(NAMESPACE, 284 "assoc_timeout_count_min", 285 DEFAULT_ASSOC_TIMEOUT_COUNT_MIN); 286 mAuthFailureHighThrPercent = DeviceConfig.getInt(NAMESPACE, 287 "auth_failure_high_thr_percent", 288 DEFAULT_AUTH_FAILURE_HIGH_THR_PERCENT); 289 mAuthFailureCountMin = DeviceConfig.getInt(NAMESPACE, 290 "auth_failure_count_min", 291 DEFAULT_AUTH_FAILURE_COUNT_MIN); 292 mShortConnectionNonlocalHighThrPercent = DeviceConfig.getInt(NAMESPACE, 293 "short_connection_nonlocal_high_thr_percent", 294 DEFAULT_SHORT_CONNECTION_NONLOCAL_HIGH_THR_PERCENT); 295 mShortConnectionNonlocalCountMin = DeviceConfig.getInt(NAMESPACE, 296 "short_connection_nonlocal_count_min", 297 DEFAULT_SHORT_CONNECTION_NONLOCAL_COUNT_MIN); 298 mDisconnectionNonlocalHighThrPercent = DeviceConfig.getInt(NAMESPACE, 299 "disconnection_nonlocal_high_thr_percent", 300 DEFAULT_DISCONNECTION_NONLOCAL_HIGH_THR_PERCENT); 301 mDisconnectionNonlocalCountMin = DeviceConfig.getInt(NAMESPACE, 302 "disconnection_nonlocal_count_min", 303 DEFAULT_DISCONNECTION_NONLOCAL_COUNT_MIN); 304 mHealthMonitorRatioThrNumerator = DeviceConfig.getInt(NAMESPACE, 305 "health_monitor_ratio_thr_numerator", 306 DEFAULT_HEALTH_MONITOR_RATIO_THR_NUMERATOR); 307 mHealthMonitorMinRssiThrDbm = DeviceConfig.getInt(NAMESPACE, 308 "health_monitor_min_rssi_thr_dbm", 309 DEFAULT_HEALTH_MONITOR_MIN_RSSI_THR_DBM); 310 311 mRandomizationFlakySsidHotlist = 312 getUnmodifiableSetQuoted("randomization_flaky_ssid_hotlist"); 313 mNonPersistentMacRandomizationSsidAllowlist = 314 getUnmodifiableSetQuoted("aggressive_randomization_ssid_allowlist"); 315 mNonPersistentMacRandomizationSsidBlocklist = 316 getUnmodifiableSetQuoted("aggressive_randomization_ssid_blocklist"); 317 318 mIsAbnormalConnectionFailureBugreportEnabled = DeviceConfig.getBoolean(NAMESPACE, 319 "abnormal_connection_failure_bugreport_enabled", false); 320 mIsAbnormalDisconnectionBugreportEnabled = DeviceConfig.getBoolean(NAMESPACE, 321 "abnormal_disconnection_bugreport_enabled", false); 322 mHealthMonitorMinNumConnectionAttempt = DeviceConfig.getInt(NAMESPACE, 323 "health_monitor_min_num_connection_attempt", 324 DEFAULT_HEALTH_MONITOR_MIN_NUM_CONNECTION_ATTEMPT); 325 mBugReportMinWindowMs = DeviceConfig.getInt(NAMESPACE, 326 "bug_report_min_window_ms", 327 DEFAULT_BUG_REPORT_MIN_WINDOW_MS); 328 mBugReportThresholdExtraRatio = DeviceConfig.getInt(NAMESPACE, 329 "report_bug_report_threshold_extra_ratio", 330 DEFAULT_BUG_REPORT_THRESHOLD_EXTRA_RATIO); 331 mIsOverlappingConnectionBugreportEnabled = DeviceConfig.getBoolean(NAMESPACE, 332 "overlapping_connection_bugreport_enabled", false); 333 mOverlappingConnectionDurationThresholdMs = DeviceConfig.getInt(NAMESPACE, 334 "overlapping_connection_duration_threshold_ms", 335 DEFAULT_OVERLAPPING_CONNECTION_DURATION_THRESHOLD_MS); 336 mTxLinkSpeedLowThresholdMbps = DeviceConfig.getInt(NAMESPACE, 337 "tx_link_speed_low_threshold_mbps", 338 DEFAULT_TX_LINK_SPEED_LOW_THRESHOLD_MBPS); 339 mRxLinkSpeedLowThresholdMbps = DeviceConfig.getInt(NAMESPACE, 340 "rx_link_speed_low_threshold_mbps", 341 DEFAULT_RX_LINK_SPEED_LOW_THRESHOLD_MBPS); 342 mWifiBatterySaverEnabled = DeviceConfig.getBoolean(NAMESPACE, "battery_saver_enabled", 343 false); 344 mHealthMonitorShortConnectionDurationThrMs = DeviceConfig.getInt(NAMESPACE, 345 "health_monitor_short_connection_duration_thr_ms", 346 DEFAULT_HEALTH_MONITOR_SHORT_CONNECTION_DURATION_THR_MS); 347 mAbnormalDisconnectionReasonCodeMask = DeviceConfig.getLong(NAMESPACE, 348 "abnormal_disconnection_reason_code_mask", 349 DEFAULT_ABNORMAL_DISCONNECTION_REASON_CODE_MASK); 350 mHealthMonitorRssiPollValidTimeMs = DeviceConfig.getInt(NAMESPACE, 351 "health_monitor_rssi_poll_valid_time_ms", 352 DEFAULT_HEALTH_MONITOR_RSSI_POLL_VALID_TIME_MS); 353 mNonstationaryScanRssiValidTimeMs = DeviceConfig.getInt(NAMESPACE, 354 "nonstationary_scan_rssi_valid_time_ms", 355 DEFAULT_NONSTATIONARY_SCAN_RSSI_VALID_TIME_MS); 356 mStationaryScanRssiValidTimeMs = DeviceConfig.getInt(NAMESPACE, 357 "stationary_scan_rssi_valid_time_ms", 358 DEFAULT_STATIONARY_SCAN_RSSI_VALID_TIME_MS); 359 mHealthMonitorFwAlertValidTimeMs = DeviceConfig.getInt(NAMESPACE, 360 "health_monitor_fw_alert_valid_time_ms", 361 DEFAULT_HEALTH_MONITOR_FW_ALERT_VALID_TIME_MS); 362 mWifiMetrics.setHealthMonitorRssiPollValidTimeMs(mHealthMonitorRssiPollValidTimeMs); 363 mMinConfirmationDurationSendLowScoreMs = DeviceConfig.getInt(NAMESPACE, 364 "min_confirmation_duration_send_low_score_ms", 365 DEFAULT_MIN_CONFIRMATION_DURATION_SEND_LOW_SCORE_MS); 366 mMinConfirmationDurationSendHighScoreMs = DeviceConfig.getInt(NAMESPACE, 367 "min_confirmation_duration_send_high_score_ms", 368 DEFAULT_MIN_CONFIRMATION_DURATION_SEND_HIGH_SCORE_MS); 369 mRssiThresholdNotSendLowScoreToCsDbm = DeviceConfig.getInt(NAMESPACE, 370 "rssi_threshold_not_send_low_score_to_cs_dbm", 371 DEFAULT_RSSI_THRESHOLD_NOT_SEND_LOW_SCORE_TO_CS_DBM); 372 mAllowNonPersistentMacRandomizationOnOpenSsids = DeviceConfig.getBoolean(NAMESPACE, 373 "allow_enhanced_mac_randomization_on_open_ssids", false); 374 mTrafficStatsThresholdMaxKbyte = DeviceConfig.getInt(NAMESPACE, 375 "traffic_stats_threshold_max_kbyte", DEFAULT_TRAFFIC_STATS_THRESHOLD_MAX_KB); 376 mBandwidthEstimatorLargeTimeConstantSec = DeviceConfig.getInt(NAMESPACE, 377 "bandwidth_estimator_time_constant_large_sec", 378 DEFAULT_BANDWIDTH_ESTIMATOR_TIME_CONSTANT_LARGE_SEC); 379 mInterfaceFailureBugreportEnabled = DeviceConfig.getBoolean(NAMESPACE, 380 "interface_failure_bugreport_enabled", false); 381 382 } 383 getUnmodifiableSetQuoted(String key)384 private Set<String> getUnmodifiableSetQuoted(String key) { 385 String rawList = DeviceConfig.getString(NAMESPACE, key, ""); 386 Set<String> result = new ArraySet<>(); 387 String[] list = rawList.split(","); 388 for (String cur : list) { 389 if (cur.length() == 0) { 390 continue; 391 } 392 result.add("\"" + cur + "\""); 393 } 394 return Collections.unmodifiableSet(result); 395 } 396 397 /** 398 * Gets the feature flag for reporting abnormally long connections. 399 */ isAbnormalConnectionBugreportEnabled()400 public boolean isAbnormalConnectionBugreportEnabled() { 401 return mIsAbnormalConnectionBugreportEnabled; 402 } 403 404 /** 405 * Gets the threshold for classifying abnormally long connections. 406 */ getAbnormalConnectionDurationMs()407 public int getAbnormalConnectionDurationMs() { 408 return mAbnormalConnectionDurationMs; 409 } 410 411 /** 412 * Gets the duration of evaluating Wifi condition to trigger a data stall. 413 */ getDataStallDurationMs()414 public int getDataStallDurationMs() { 415 return mDataStallDurationMs; 416 } 417 418 /** 419 * Gets the threshold of Tx throughput below which to trigger a data stall. 420 */ getDataStallTxTputThrKbps()421 public int getDataStallTxTputThrKbps() { 422 return mDataStallTxTputThrKbps; 423 } 424 425 /** 426 * Gets the threshold of Rx throughput below which to trigger a data stall. 427 */ getDataStallRxTputThrKbps()428 public int getDataStallRxTputThrKbps() { 429 return mDataStallRxTputThrKbps; 430 } 431 432 /** 433 * Gets the threshold of Tx packet error rate above which to trigger a data stall. 434 */ getDataStallTxPerThr()435 public int getDataStallTxPerThr() { 436 return mDataStallTxPerThr; 437 } 438 439 /** 440 * Gets the threshold of CCA level above which to trigger a data stall. 441 */ getDataStallCcaLevelThr()442 public int getDataStallCcaLevelThr() { 443 return mDataStallCcaLevelThr; 444 } 445 446 /** 447 * Gets the low threshold of L2 throughput below which L2 throughput is always insufficient 448 */ getTxTputSufficientLowThrKbps()449 public int getTxTputSufficientLowThrKbps() { 450 return mTxTputSufficientLowThrKbps; 451 } 452 453 /** 454 * Gets the high threshold of L2 throughput above which L2 throughput is always sufficient 455 */ getTxTputSufficientHighThrKbps()456 public int getTxTputSufficientHighThrKbps() { 457 return mTxTputSufficientHighThrKbps; 458 } 459 460 /** 461 * Gets the low threshold of L2 throughput below which L2 Rx throughput is always insufficient 462 */ getRxTputSufficientLowThrKbps()463 public int getRxTputSufficientLowThrKbps() { 464 return mRxTputSufficientLowThrKbps; 465 } 466 467 /** 468 * Gets the high threshold of L2 throughput above which L2 Rx throughput is always sufficient 469 */ getRxTputSufficientHighThrKbps()470 public int getRxTputSufficientHighThrKbps() { 471 return mRxTputSufficientHighThrKbps; 472 } 473 474 /** 475 * Gets the numerator part of L2 throughput over L3 throughput ratio sufficiency threshold 476 * above which L2 throughput is sufficient 477 */ getTputSufficientRatioThrNum()478 public int getTputSufficientRatioThrNum() { 479 return mTputSufficientRatioThrNum; 480 } 481 482 /** 483 * Gets the denominator part of L2 throughput over L3 throughput ratio sufficiency threshold 484 * above which L2 throughput is sufficient 485 */ getTputSufficientRatioThrDen()486 public int getTputSufficientRatioThrDen() { 487 return mTputSufficientRatioThrDen; 488 } 489 490 /** 491 * Gets the threshold of Tx packet per second 492 * below which Tx throughput sufficiency check will always pass 493 */ getTxPktPerSecondThr()494 public int getTxPktPerSecondThr() { 495 return mTxPktPerSecondThr; 496 } 497 498 /** 499 * Gets the threshold of Rx packet per second 500 * below which Rx throughput sufficiency check will always pass 501 */ getRxPktPerSecondThr()502 public int getRxPktPerSecondThr() { 503 return mRxPktPerSecondThr; 504 } 505 506 /** 507 * Gets the high threshold of connection failure rate in percent 508 */ getConnectionFailureHighThrPercent()509 public int getConnectionFailureHighThrPercent() { 510 return mConnectionFailureHighThrPercent; 511 } 512 513 /** 514 * Gets connection-failure-due-to-disconnection min count 515 */ getConnectionFailureDisconnectionCountMin()516 public int getConnectionFailureDisconnectionCountMin() { 517 return mConnectionFailureDisconnectionCountMin; 518 } 519 520 /** 521 * Gets the high threshold of connection-failure-due-to-disconnection rate in percent 522 */ getConnectionFailureDisconnectionHighThrPercent()523 public int getConnectionFailureDisconnectionHighThrPercent() { 524 return mConnectionFailureDisconnectionHighThrPercent; 525 } 526 527 /** 528 * Gets connection failure min count 529 */ getConnectionFailureCountMin()530 public int getConnectionFailureCountMin() { 531 return mConnectionFailureCountMin; 532 } 533 534 /** 535 * Gets the high threshold of association rejection rate in percent 536 */ getAssocRejectionHighThrPercent()537 public int getAssocRejectionHighThrPercent() { 538 return mAssocRejectionHighThrPercent; 539 } 540 541 /** 542 * Gets association rejection min count 543 */ getAssocRejectionCountMin()544 public int getAssocRejectionCountMin() { 545 return mAssocRejectionCountMin; 546 } 547 548 /** 549 * Gets the high threshold of association timeout rate in percent 550 */ getAssocTimeoutHighThrPercent()551 public int getAssocTimeoutHighThrPercent() { 552 return mAssocTimeoutHighThrPercent; 553 } 554 555 /** 556 * Gets association timeout min count 557 */ getAssocTimeoutCountMin()558 public int getAssocTimeoutCountMin() { 559 return mAssocTimeoutCountMin; 560 } 561 562 563 /** 564 * Gets the high threshold of authentication failure rate in percent 565 */ getAuthFailureHighThrPercent()566 public int getAuthFailureHighThrPercent() { 567 return mAuthFailureHighThrPercent; 568 } 569 570 /** 571 * Gets authentication failure min count 572 */ getAuthFailureCountMin()573 public int getAuthFailureCountMin() { 574 return mAuthFailureCountMin; 575 } 576 577 /** 578 * Gets the high threshold of nonlocal short connection rate in percent 579 */ getShortConnectionNonlocalHighThrPercent()580 public int getShortConnectionNonlocalHighThrPercent() { 581 return mShortConnectionNonlocalHighThrPercent; 582 } 583 584 /** 585 * Gets nonlocal short connection min count 586 */ getShortConnectionNonlocalCountMin()587 public int getShortConnectionNonlocalCountMin() { 588 return mShortConnectionNonlocalCountMin; 589 } 590 591 /** 592 * Gets the high threshold of nonlocal disconnection rate in percent 593 */ getDisconnectionNonlocalHighThrPercent()594 public int getDisconnectionNonlocalHighThrPercent() { 595 return mDisconnectionNonlocalHighThrPercent; 596 } 597 598 /** 599 * Gets nonlocal disconnection min count 600 */ getDisconnectionNonlocalCountMin()601 public int getDisconnectionNonlocalCountMin() { 602 return mDisconnectionNonlocalCountMin; 603 } 604 605 /** 606 * Gets health monitor ratio threshold, numerator part 607 */ getHealthMonitorRatioThrNumerator()608 public int getHealthMonitorRatioThrNumerator() { 609 return mHealthMonitorRatioThrNumerator; 610 } 611 612 /** 613 * Gets health monitor min RSSI threshold in dBm 614 */ getHealthMonitorMinRssiThrDbm()615 public int getHealthMonitorMinRssiThrDbm() { 616 return mHealthMonitorMinRssiThrDbm; 617 } 618 619 /** 620 * Gets the Set of SSIDs in the flaky SSID hotlist. 621 */ getRandomizationFlakySsidHotlist()622 public Set<String> getRandomizationFlakySsidHotlist() { 623 return mRandomizationFlakySsidHotlist; 624 } 625 626 /** 627 * Gets the list of SSIDs for non-persistent MAC randomization. 628 */ getNonPersistentMacRandomizationSsidAllowlist()629 public Set<String> getNonPersistentMacRandomizationSsidAllowlist() { 630 return mNonPersistentMacRandomizationSsidAllowlist; 631 } 632 633 /** 634 * Gets the list of SSIDs that non-persistent MAC randomization should not be used for. 635 */ getNonPersistentMacRandomizationSsidBlocklist()636 public Set<String> getNonPersistentMacRandomizationSsidBlocklist() { 637 return mNonPersistentMacRandomizationSsidBlocklist; 638 } 639 /** 640 * Gets the feature flag for reporting abnormal connection failure. 641 */ isAbnormalConnectionFailureBugreportEnabled()642 public boolean isAbnormalConnectionFailureBugreportEnabled() { 643 return mIsAbnormalConnectionFailureBugreportEnabled; 644 } 645 646 /** 647 * Gets the feature flag for reporting abnormal disconnection. 648 */ isAbnormalDisconnectionBugreportEnabled()649 public boolean isAbnormalDisconnectionBugreportEnabled() { 650 return mIsAbnormalDisconnectionBugreportEnabled; 651 } 652 653 /** 654 * Gets health monitor min number of connection attempt threshold 655 */ getHealthMonitorMinNumConnectionAttempt()656 public int getHealthMonitorMinNumConnectionAttempt() { 657 return mHealthMonitorMinNumConnectionAttempt; 658 } 659 660 /** 661 * Gets minimum wait time between two bug report captures 662 */ getBugReportMinWindowMs()663 public int getBugReportMinWindowMs() { 664 return mBugReportMinWindowMs; 665 } 666 667 /** 668 * Gets the extra ratio of threshold to trigger bug report. 669 */ getBugReportThresholdExtraRatio()670 public int getBugReportThresholdExtraRatio() { 671 return mBugReportThresholdExtraRatio; 672 } 673 674 /** 675 * Gets the feature flag for reporting overlapping connection. 676 */ isOverlappingConnectionBugreportEnabled()677 public boolean isOverlappingConnectionBugreportEnabled() { 678 return mIsOverlappingConnectionBugreportEnabled; 679 } 680 681 /** 682 * Gets overlapping connection duration threshold in ms 683 */ getOverlappingConnectionDurationThresholdMs()684 public int getOverlappingConnectionDurationThresholdMs() { 685 return mOverlappingConnectionDurationThresholdMs; 686 } 687 688 /** 689 * Gets the threshold of link speed below which Tx link speed is ignored at low traffic 690 */ getTxLinkSpeedLowThresholdMbps()691 public int getTxLinkSpeedLowThresholdMbps() { 692 return mTxLinkSpeedLowThresholdMbps; 693 } 694 695 /** 696 * Gets the threshold of link speed below which Rx link speed is ignored at low traffic 697 */ getRxLinkSpeedLowThresholdMbps()698 public int getRxLinkSpeedLowThresholdMbps() { 699 return mRxLinkSpeedLowThresholdMbps; 700 } 701 702 /** 703 * Gets the feature flag for Wifi battery saver. 704 */ isWifiBatterySaverEnabled()705 public boolean isWifiBatterySaverEnabled() { 706 return mWifiBatterySaverEnabled; 707 } 708 709 /** 710 * Gets health monitor short connection duration threshold in ms 711 */ getHealthMonitorShortConnectionDurationThrMs()712 public int getHealthMonitorShortConnectionDurationThrMs() { 713 return mHealthMonitorShortConnectionDurationThrMs; 714 } 715 716 /** 717 * Gets abnormal disconnection reason code mask 718 */ getAbnormalDisconnectionReasonCodeMask()719 public long getAbnormalDisconnectionReasonCodeMask() { 720 return mAbnormalDisconnectionReasonCodeMask; 721 } 722 723 /** 724 * Gets health monitor RSSI poll valid time in ms 725 */ getHealthMonitorRssiPollValidTimeMs()726 public int getHealthMonitorRssiPollValidTimeMs() { 727 return mHealthMonitorRssiPollValidTimeMs; 728 } 729 730 /** 731 * Gets scan rssi valid time in ms when device is in non-stationary state 732 */ getNonstationaryScanRssiValidTimeMs()733 public int getNonstationaryScanRssiValidTimeMs() { 734 return mNonstationaryScanRssiValidTimeMs; 735 } 736 737 /** 738 * Gets scan rssi valid time in ms when device is in stationary state 739 */ getStationaryScanRssiValidTimeMs()740 public int getStationaryScanRssiValidTimeMs() { 741 return mStationaryScanRssiValidTimeMs; 742 } 743 744 /** 745 * Gets health monitor firmware alert valid time in ms, 746 * -1 disables firmware alert time check 747 */ getHealthMonitorFwAlertValidTimeMs()748 public int getHealthMonitorFwAlertValidTimeMs() { 749 return mHealthMonitorFwAlertValidTimeMs; 750 } 751 752 /** 753 * Gets the minimum confirmation duration for sending network score to connectivity service 754 * when score breaches low. 755 */ getMinConfirmationDurationSendLowScoreMs()756 public int getMinConfirmationDurationSendLowScoreMs() { 757 return mMinConfirmationDurationSendLowScoreMs; 758 } 759 760 /** 761 * Gets the minimum confirmation duration for sending network score to connectivity service 762 * when score breaches high. 763 */ getMinConfirmationDurationSendHighScoreMs()764 public int getMinConfirmationDurationSendHighScoreMs() { 765 return mMinConfirmationDurationSendHighScoreMs; 766 } 767 768 /** 769 * Gets the RSSI threshold above which low score is not sent to connectivity service when 770 * external scorer takes action. 771 */ getRssiThresholdNotSendLowScoreToCsDbm()772 public int getRssiThresholdNotSendLowScoreToCsDbm() { 773 return mRssiThresholdNotSendLowScoreToCsDbm; 774 } 775 776 /** 777 * Gets whether non-persistent MAC randomization should be allowed on open networks. 778 */ allowNonPersistentMacRandomizationOnOpenSsids()779 public boolean allowNonPersistentMacRandomizationOnOpenSsids() { 780 return mAllowNonPersistentMacRandomizationOnOpenSsids; 781 } 782 783 /** 784 * Gets traffic stats maximum threshold in KByte 785 */ getTrafficStatsThresholdMaxKbyte()786 public int getTrafficStatsThresholdMaxKbyte() { 787 return mTrafficStatsThresholdMaxKbyte; 788 } 789 790 /** 791 * Gets bandwidth estimator large time constant in second 792 */ getBandwidthEstimatorLargeTimeConstantSec()793 public int getBandwidthEstimatorLargeTimeConstantSec() { 794 return mBandwidthEstimatorLargeTimeConstantSec; 795 } 796 797 /** 798 * Gets the feature flag for reporting interface setup failure 799 */ isInterfaceFailureBugreportEnabled()800 public boolean isInterfaceFailureBugreportEnabled() { 801 return mInterfaceFailureBugreportEnabled; 802 } 803 } 804