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> mAggressiveMacRandomizationSsidAllowlist; 184 private Set<String> mAggressiveMacRandomizationSsidBlocklist; 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 mAllowEnhancedMacRandomizationOnOpenSsids; 205 private int mTrafficStatsThresholdMaxKbyte; 206 private int mBandwidthEstimatorLargeTimeConstantSec; 207 DeviceConfigFacade(Context context, Handler handler, WifiMetrics wifiMetrics)208 public DeviceConfigFacade(Context context, Handler handler, WifiMetrics wifiMetrics) { 209 mContext = context; 210 mWifiMetrics = wifiMetrics; 211 212 updateDeviceConfigFlags(); 213 DeviceConfig.addOnPropertiesChangedListener( 214 NAMESPACE, 215 command -> handler.post(command), 216 properties -> { 217 updateDeviceConfigFlags(); 218 }); 219 } 220 updateDeviceConfigFlags()221 private void updateDeviceConfigFlags() { 222 mIsAbnormalConnectionBugreportEnabled = DeviceConfig.getBoolean(NAMESPACE, 223 "abnormal_connection_bugreport_enabled", false); 224 mAbnormalConnectionDurationMs = DeviceConfig.getInt(NAMESPACE, 225 "abnormal_connection_duration_ms", 226 DEFAULT_ABNORMAL_CONNECTION_DURATION_MS); 227 228 mDataStallDurationMs = DeviceConfig.getInt(NAMESPACE, 229 "data_stall_duration_ms", DEFAULT_DATA_STALL_DURATION_MS); 230 mDataStallTxTputThrKbps = DeviceConfig.getInt(NAMESPACE, 231 "data_stall_tx_tput_thr_kbps", DEFAULT_DATA_STALL_TX_TPUT_THR_KBPS); 232 mDataStallRxTputThrKbps = DeviceConfig.getInt(NAMESPACE, 233 "data_stall_rx_tput_thr_kbps", DEFAULT_DATA_STALL_RX_TPUT_THR_KBPS); 234 mDataStallTxPerThr = DeviceConfig.getInt(NAMESPACE, 235 "data_stall_tx_per_thr", DEFAULT_DATA_STALL_TX_PER_THR); 236 mDataStallCcaLevelThr = DeviceConfig.getInt(NAMESPACE, 237 "data_stall_cca_level_thr", DEFAULT_DATA_STALL_CCA_LEVEL_THR); 238 mWifiMetrics.setDataStallDurationMs(mDataStallDurationMs); 239 mWifiMetrics.setDataStallTxTputThrKbps(mDataStallTxTputThrKbps); 240 mWifiMetrics.setDataStallRxTputThrKbps(mDataStallRxTputThrKbps); 241 mWifiMetrics.setDataStallTxPerThr(mDataStallTxPerThr); 242 mWifiMetrics.setDataStallCcaLevelThr(mDataStallCcaLevelThr); 243 244 mTxTputSufficientLowThrKbps = DeviceConfig.getInt(NAMESPACE, 245 "tput_sufficient_low_thr_kbps", DEFAULT_TX_TPUT_SUFFICIENT_THR_LOW_KBPS); 246 mTxTputSufficientHighThrKbps = DeviceConfig.getInt(NAMESPACE, 247 "tput_sufficient_high_thr_kbps", DEFAULT_TX_TPUT_SUFFICIENT_THR_HIGH_KBPS); 248 mRxTputSufficientLowThrKbps = DeviceConfig.getInt(NAMESPACE, 249 "rx_tput_sufficient_low_thr_kbps", DEFAULT_RX_TPUT_SUFFICIENT_THR_LOW_KBPS); 250 mRxTputSufficientHighThrKbps = DeviceConfig.getInt(NAMESPACE, 251 "rx_tput_sufficient_high_thr_kbps", DEFAULT_RX_TPUT_SUFFICIENT_THR_HIGH_KBPS); 252 mTputSufficientRatioThrNum = DeviceConfig.getInt(NAMESPACE, 253 "tput_sufficient_ratio_thr_num", DEFAULT_TPUT_SUFFICIENT_RATIO_THR_NUM); 254 mTputSufficientRatioThrDen = DeviceConfig.getInt(NAMESPACE, 255 "tput_sufficient_ratio_thr_den", DEFAULT_TPUT_SUFFICIENT_RATIO_THR_DEN); 256 mTxPktPerSecondThr = DeviceConfig.getInt(NAMESPACE, 257 "tx_pkt_per_second_thr", DEFAULT_TX_PACKET_PER_SECOND_THR); 258 mRxPktPerSecondThr = DeviceConfig.getInt(NAMESPACE, 259 "rx_pkt_per_second_thr", DEFAULT_RX_PACKET_PER_SECOND_THR); 260 261 mConnectionFailureHighThrPercent = DeviceConfig.getInt(NAMESPACE, 262 "connection_failure_high_thr_percent", 263 DEFAULT_CONNECTION_FAILURE_HIGH_THR_PERCENT); 264 mConnectionFailureCountMin = DeviceConfig.getInt(NAMESPACE, 265 "connection_failure_count_min", 266 DEFAULT_CONNECTION_FAILURE_COUNT_MIN); 267 mConnectionFailureDisconnectionHighThrPercent = DeviceConfig.getInt(NAMESPACE, 268 "connection_failure_disconnection_high_thr_percent", 269 DEFAULT_CONNECTION_FAILURE_DISCONNECTION_HIGH_THR_PERCENT); 270 mConnectionFailureDisconnectionCountMin = DeviceConfig.getInt(NAMESPACE, 271 "connection_failure_disconnection_count_min", 272 DEFAULT_CONNECTION_FAILURE_DISCONNECTION_COUNT_MIN); 273 mAssocRejectionHighThrPercent = DeviceConfig.getInt(NAMESPACE, 274 "assoc_rejection_high_thr_percent", 275 DEFAULT_ASSOC_REJECTION_HIGH_THR_PERCENT); 276 mAssocRejectionCountMin = DeviceConfig.getInt(NAMESPACE, 277 "assoc_rejection_count_min", 278 DEFAULT_ASSOC_REJECTION_COUNT_MIN); 279 mAssocTimeoutHighThrPercent = DeviceConfig.getInt(NAMESPACE, 280 "assoc_timeout_high_thr_percent", 281 DEFAULT_ASSOC_TIMEOUT_HIGH_THR_PERCENT); 282 mAssocTimeoutCountMin = DeviceConfig.getInt(NAMESPACE, 283 "assoc_timeout_count_min", 284 DEFAULT_ASSOC_TIMEOUT_COUNT_MIN); 285 mAuthFailureHighThrPercent = DeviceConfig.getInt(NAMESPACE, 286 "auth_failure_high_thr_percent", 287 DEFAULT_AUTH_FAILURE_HIGH_THR_PERCENT); 288 mAuthFailureCountMin = DeviceConfig.getInt(NAMESPACE, 289 "auth_failure_count_min", 290 DEFAULT_AUTH_FAILURE_COUNT_MIN); 291 mShortConnectionNonlocalHighThrPercent = DeviceConfig.getInt(NAMESPACE, 292 "short_connection_nonlocal_high_thr_percent", 293 DEFAULT_SHORT_CONNECTION_NONLOCAL_HIGH_THR_PERCENT); 294 mShortConnectionNonlocalCountMin = DeviceConfig.getInt(NAMESPACE, 295 "short_connection_nonlocal_count_min", 296 DEFAULT_SHORT_CONNECTION_NONLOCAL_COUNT_MIN); 297 mDisconnectionNonlocalHighThrPercent = DeviceConfig.getInt(NAMESPACE, 298 "disconnection_nonlocal_high_thr_percent", 299 DEFAULT_DISCONNECTION_NONLOCAL_HIGH_THR_PERCENT); 300 mDisconnectionNonlocalCountMin = DeviceConfig.getInt(NAMESPACE, 301 "disconnection_nonlocal_count_min", 302 DEFAULT_DISCONNECTION_NONLOCAL_COUNT_MIN); 303 mHealthMonitorRatioThrNumerator = DeviceConfig.getInt(NAMESPACE, 304 "health_monitor_ratio_thr_numerator", 305 DEFAULT_HEALTH_MONITOR_RATIO_THR_NUMERATOR); 306 mHealthMonitorMinRssiThrDbm = DeviceConfig.getInt(NAMESPACE, 307 "health_monitor_min_rssi_thr_dbm", 308 DEFAULT_HEALTH_MONITOR_MIN_RSSI_THR_DBM); 309 310 mRandomizationFlakySsidHotlist = 311 getUnmodifiableSetQuoted("randomization_flaky_ssid_hotlist"); 312 mAggressiveMacRandomizationSsidAllowlist = 313 getUnmodifiableSetQuoted("aggressive_randomization_ssid_allowlist"); 314 mAggressiveMacRandomizationSsidBlocklist = 315 getUnmodifiableSetQuoted("aggressive_randomization_ssid_blocklist"); 316 317 mIsAbnormalConnectionFailureBugreportEnabled = DeviceConfig.getBoolean(NAMESPACE, 318 "abnormal_connection_failure_bugreport_enabled", false); 319 mIsAbnormalDisconnectionBugreportEnabled = DeviceConfig.getBoolean(NAMESPACE, 320 "abnormal_disconnection_bugreport_enabled", false); 321 mHealthMonitorMinNumConnectionAttempt = DeviceConfig.getInt(NAMESPACE, 322 "health_monitor_min_num_connection_attempt", 323 DEFAULT_HEALTH_MONITOR_MIN_NUM_CONNECTION_ATTEMPT); 324 mBugReportMinWindowMs = DeviceConfig.getInt(NAMESPACE, 325 "bug_report_min_window_ms", 326 DEFAULT_BUG_REPORT_MIN_WINDOW_MS); 327 mBugReportThresholdExtraRatio = DeviceConfig.getInt(NAMESPACE, 328 "report_bug_report_threshold_extra_ratio", 329 DEFAULT_BUG_REPORT_THRESHOLD_EXTRA_RATIO); 330 mIsOverlappingConnectionBugreportEnabled = DeviceConfig.getBoolean(NAMESPACE, 331 "overlapping_connection_bugreport_enabled", false); 332 mOverlappingConnectionDurationThresholdMs = DeviceConfig.getInt(NAMESPACE, 333 "overlapping_connection_duration_threshold_ms", 334 DEFAULT_OVERLAPPING_CONNECTION_DURATION_THRESHOLD_MS); 335 mTxLinkSpeedLowThresholdMbps = DeviceConfig.getInt(NAMESPACE, 336 "tx_link_speed_low_threshold_mbps", 337 DEFAULT_TX_LINK_SPEED_LOW_THRESHOLD_MBPS); 338 mRxLinkSpeedLowThresholdMbps = DeviceConfig.getInt(NAMESPACE, 339 "rx_link_speed_low_threshold_mbps", 340 DEFAULT_RX_LINK_SPEED_LOW_THRESHOLD_MBPS); 341 mWifiBatterySaverEnabled = DeviceConfig.getBoolean(NAMESPACE, "battery_saver_enabled", 342 false); 343 mHealthMonitorShortConnectionDurationThrMs = DeviceConfig.getInt(NAMESPACE, 344 "health_monitor_short_connection_duration_thr_ms", 345 DEFAULT_HEALTH_MONITOR_SHORT_CONNECTION_DURATION_THR_MS); 346 mAbnormalDisconnectionReasonCodeMask = DeviceConfig.getLong(NAMESPACE, 347 "abnormal_disconnection_reason_code_mask", 348 DEFAULT_ABNORMAL_DISCONNECTION_REASON_CODE_MASK); 349 mHealthMonitorRssiPollValidTimeMs = DeviceConfig.getInt(NAMESPACE, 350 "health_monitor_rssi_poll_valid_time_ms", 351 DEFAULT_HEALTH_MONITOR_RSSI_POLL_VALID_TIME_MS); 352 mNonstationaryScanRssiValidTimeMs = DeviceConfig.getInt(NAMESPACE, 353 "nonstationary_scan_rssi_valid_time_ms", 354 DEFAULT_NONSTATIONARY_SCAN_RSSI_VALID_TIME_MS); 355 mStationaryScanRssiValidTimeMs = DeviceConfig.getInt(NAMESPACE, 356 "stationary_scan_rssi_valid_time_ms", 357 DEFAULT_STATIONARY_SCAN_RSSI_VALID_TIME_MS); 358 mHealthMonitorFwAlertValidTimeMs = DeviceConfig.getInt(NAMESPACE, 359 "health_monitor_fw_alert_valid_time_ms", 360 DEFAULT_HEALTH_MONITOR_FW_ALERT_VALID_TIME_MS); 361 mWifiMetrics.setHealthMonitorRssiPollValidTimeMs(mHealthMonitorRssiPollValidTimeMs); 362 mMinConfirmationDurationSendLowScoreMs = DeviceConfig.getInt(NAMESPACE, 363 "min_confirmation_duration_send_low_score_ms", 364 DEFAULT_MIN_CONFIRMATION_DURATION_SEND_LOW_SCORE_MS); 365 mMinConfirmationDurationSendHighScoreMs = DeviceConfig.getInt(NAMESPACE, 366 "min_confirmation_duration_send_high_score_ms", 367 DEFAULT_MIN_CONFIRMATION_DURATION_SEND_HIGH_SCORE_MS); 368 mRssiThresholdNotSendLowScoreToCsDbm = DeviceConfig.getInt(NAMESPACE, 369 "rssi_threshold_not_send_low_score_to_cs_dbm", 370 DEFAULT_RSSI_THRESHOLD_NOT_SEND_LOW_SCORE_TO_CS_DBM); 371 mAllowEnhancedMacRandomizationOnOpenSsids = DeviceConfig.getBoolean(NAMESPACE, 372 "allow_enhanced_mac_randomization_on_open_ssids", false); 373 mTrafficStatsThresholdMaxKbyte = DeviceConfig.getInt(NAMESPACE, 374 "traffic_stats_threshold_max_kbyte", DEFAULT_TRAFFIC_STATS_THRESHOLD_MAX_KB); 375 mBandwidthEstimatorLargeTimeConstantSec = DeviceConfig.getInt(NAMESPACE, 376 "bandwidth_estimator_time_constant_large_sec", 377 DEFAULT_BANDWIDTH_ESTIMATOR_TIME_CONSTANT_LARGE_SEC); 378 379 } 380 getUnmodifiableSetQuoted(String key)381 private Set<String> getUnmodifiableSetQuoted(String key) { 382 String rawList = DeviceConfig.getString(NAMESPACE, key, ""); 383 Set<String> result = new ArraySet<>(); 384 String[] list = rawList.split(","); 385 for (String cur : list) { 386 if (cur.length() == 0) { 387 continue; 388 } 389 result.add("\"" + cur + "\""); 390 } 391 return Collections.unmodifiableSet(result); 392 } 393 394 /** 395 * Gets the feature flag for reporting abnormally long connections. 396 */ isAbnormalConnectionBugreportEnabled()397 public boolean isAbnormalConnectionBugreportEnabled() { 398 return mIsAbnormalConnectionBugreportEnabled; 399 } 400 401 /** 402 * Gets the threshold for classifying abnormally long connections. 403 */ getAbnormalConnectionDurationMs()404 public int getAbnormalConnectionDurationMs() { 405 return mAbnormalConnectionDurationMs; 406 } 407 408 /** 409 * Gets the duration of evaluating Wifi condition to trigger a data stall. 410 */ getDataStallDurationMs()411 public int getDataStallDurationMs() { 412 return mDataStallDurationMs; 413 } 414 415 /** 416 * Gets the threshold of Tx throughput below which to trigger a data stall. 417 */ getDataStallTxTputThrKbps()418 public int getDataStallTxTputThrKbps() { 419 return mDataStallTxTputThrKbps; 420 } 421 422 /** 423 * Gets the threshold of Rx throughput below which to trigger a data stall. 424 */ getDataStallRxTputThrKbps()425 public int getDataStallRxTputThrKbps() { 426 return mDataStallRxTputThrKbps; 427 } 428 429 /** 430 * Gets the threshold of Tx packet error rate above which to trigger a data stall. 431 */ getDataStallTxPerThr()432 public int getDataStallTxPerThr() { 433 return mDataStallTxPerThr; 434 } 435 436 /** 437 * Gets the threshold of CCA level above which to trigger a data stall. 438 */ getDataStallCcaLevelThr()439 public int getDataStallCcaLevelThr() { 440 return mDataStallCcaLevelThr; 441 } 442 443 /** 444 * Gets the low threshold of L2 throughput below which L2 throughput is always insufficient 445 */ getTxTputSufficientLowThrKbps()446 public int getTxTputSufficientLowThrKbps() { 447 return mTxTputSufficientLowThrKbps; 448 } 449 450 /** 451 * Gets the high threshold of L2 throughput above which L2 throughput is always sufficient 452 */ getTxTputSufficientHighThrKbps()453 public int getTxTputSufficientHighThrKbps() { 454 return mTxTputSufficientHighThrKbps; 455 } 456 457 /** 458 * Gets the low threshold of L2 throughput below which L2 Rx throughput is always insufficient 459 */ getRxTputSufficientLowThrKbps()460 public int getRxTputSufficientLowThrKbps() { 461 return mRxTputSufficientLowThrKbps; 462 } 463 464 /** 465 * Gets the high threshold of L2 throughput above which L2 Rx throughput is always sufficient 466 */ getRxTputSufficientHighThrKbps()467 public int getRxTputSufficientHighThrKbps() { 468 return mRxTputSufficientHighThrKbps; 469 } 470 471 /** 472 * Gets the numerator part of L2 throughput over L3 throughput ratio sufficiency threshold 473 * above which L2 throughput is sufficient 474 */ getTputSufficientRatioThrNum()475 public int getTputSufficientRatioThrNum() { 476 return mTputSufficientRatioThrNum; 477 } 478 479 /** 480 * Gets the denominator part of L2 throughput over L3 throughput ratio sufficiency threshold 481 * above which L2 throughput is sufficient 482 */ getTputSufficientRatioThrDen()483 public int getTputSufficientRatioThrDen() { 484 return mTputSufficientRatioThrDen; 485 } 486 487 /** 488 * Gets the threshold of Tx packet per second 489 * below which Tx throughput sufficiency check will always pass 490 */ getTxPktPerSecondThr()491 public int getTxPktPerSecondThr() { 492 return mTxPktPerSecondThr; 493 } 494 495 /** 496 * Gets the threshold of Rx packet per second 497 * below which Rx throughput sufficiency check will always pass 498 */ getRxPktPerSecondThr()499 public int getRxPktPerSecondThr() { 500 return mRxPktPerSecondThr; 501 } 502 503 /** 504 * Gets the high threshold of connection failure rate in percent 505 */ getConnectionFailureHighThrPercent()506 public int getConnectionFailureHighThrPercent() { 507 return mConnectionFailureHighThrPercent; 508 } 509 510 /** 511 * Gets connection-failure-due-to-disconnection min count 512 */ getConnectionFailureDisconnectionCountMin()513 public int getConnectionFailureDisconnectionCountMin() { 514 return mConnectionFailureDisconnectionCountMin; 515 } 516 517 /** 518 * Gets the high threshold of connection-failure-due-to-disconnection rate in percent 519 */ getConnectionFailureDisconnectionHighThrPercent()520 public int getConnectionFailureDisconnectionHighThrPercent() { 521 return mConnectionFailureDisconnectionHighThrPercent; 522 } 523 524 /** 525 * Gets connection failure min count 526 */ getConnectionFailureCountMin()527 public int getConnectionFailureCountMin() { 528 return mConnectionFailureCountMin; 529 } 530 531 /** 532 * Gets the high threshold of association rejection rate in percent 533 */ getAssocRejectionHighThrPercent()534 public int getAssocRejectionHighThrPercent() { 535 return mAssocRejectionHighThrPercent; 536 } 537 538 /** 539 * Gets association rejection min count 540 */ getAssocRejectionCountMin()541 public int getAssocRejectionCountMin() { 542 return mAssocRejectionCountMin; 543 } 544 545 /** 546 * Gets the high threshold of association timeout rate in percent 547 */ getAssocTimeoutHighThrPercent()548 public int getAssocTimeoutHighThrPercent() { 549 return mAssocTimeoutHighThrPercent; 550 } 551 552 /** 553 * Gets association timeout min count 554 */ getAssocTimeoutCountMin()555 public int getAssocTimeoutCountMin() { 556 return mAssocTimeoutCountMin; 557 } 558 559 560 /** 561 * Gets the high threshold of authentication failure rate in percent 562 */ getAuthFailureHighThrPercent()563 public int getAuthFailureHighThrPercent() { 564 return mAuthFailureHighThrPercent; 565 } 566 567 /** 568 * Gets authentication failure min count 569 */ getAuthFailureCountMin()570 public int getAuthFailureCountMin() { 571 return mAuthFailureCountMin; 572 } 573 574 /** 575 * Gets the high threshold of nonlocal short connection rate in percent 576 */ getShortConnectionNonlocalHighThrPercent()577 public int getShortConnectionNonlocalHighThrPercent() { 578 return mShortConnectionNonlocalHighThrPercent; 579 } 580 581 /** 582 * Gets nonlocal short connection min count 583 */ getShortConnectionNonlocalCountMin()584 public int getShortConnectionNonlocalCountMin() { 585 return mShortConnectionNonlocalCountMin; 586 } 587 588 /** 589 * Gets the high threshold of nonlocal disconnection rate in percent 590 */ getDisconnectionNonlocalHighThrPercent()591 public int getDisconnectionNonlocalHighThrPercent() { 592 return mDisconnectionNonlocalHighThrPercent; 593 } 594 595 /** 596 * Gets nonlocal disconnection min count 597 */ getDisconnectionNonlocalCountMin()598 public int getDisconnectionNonlocalCountMin() { 599 return mDisconnectionNonlocalCountMin; 600 } 601 602 /** 603 * Gets health monitor ratio threshold, numerator part 604 */ getHealthMonitorRatioThrNumerator()605 public int getHealthMonitorRatioThrNumerator() { 606 return mHealthMonitorRatioThrNumerator; 607 } 608 609 /** 610 * Gets health monitor min RSSI threshold in dBm 611 */ getHealthMonitorMinRssiThrDbm()612 public int getHealthMonitorMinRssiThrDbm() { 613 return mHealthMonitorMinRssiThrDbm; 614 } 615 616 /** 617 * Gets the Set of SSIDs in the flaky SSID hotlist. 618 */ getRandomizationFlakySsidHotlist()619 public Set<String> getRandomizationFlakySsidHotlist() { 620 return mRandomizationFlakySsidHotlist; 621 } 622 623 /** 624 * Gets the list of SSIDs for aggressive MAC randomization. 625 */ getAggressiveMacRandomizationSsidAllowlist()626 public Set<String> getAggressiveMacRandomizationSsidAllowlist() { 627 return mAggressiveMacRandomizationSsidAllowlist; 628 } 629 630 /** 631 * Gets the list of SSIDs that aggressive MAC randomization should not be used for. 632 */ getAggressiveMacRandomizationSsidBlocklist()633 public Set<String> getAggressiveMacRandomizationSsidBlocklist() { 634 return mAggressiveMacRandomizationSsidBlocklist; 635 } 636 /** 637 * Gets the feature flag for reporting abnormal connection failure. 638 */ isAbnormalConnectionFailureBugreportEnabled()639 public boolean isAbnormalConnectionFailureBugreportEnabled() { 640 return mIsAbnormalConnectionFailureBugreportEnabled; 641 } 642 643 /** 644 * Gets the feature flag for reporting abnormal disconnection. 645 */ isAbnormalDisconnectionBugreportEnabled()646 public boolean isAbnormalDisconnectionBugreportEnabled() { 647 return mIsAbnormalDisconnectionBugreportEnabled; 648 } 649 650 /** 651 * Gets health monitor min number of connection attempt threshold 652 */ getHealthMonitorMinNumConnectionAttempt()653 public int getHealthMonitorMinNumConnectionAttempt() { 654 return mHealthMonitorMinNumConnectionAttempt; 655 } 656 657 /** 658 * Gets minimum wait time between two bug report captures 659 */ getBugReportMinWindowMs()660 public int getBugReportMinWindowMs() { 661 return mBugReportMinWindowMs; 662 } 663 664 /** 665 * Gets the extra ratio of threshold to trigger bug report. 666 */ getBugReportThresholdExtraRatio()667 public int getBugReportThresholdExtraRatio() { 668 return mBugReportThresholdExtraRatio; 669 } 670 671 /** 672 * Gets the feature flag for reporting overlapping connection. 673 */ isOverlappingConnectionBugreportEnabled()674 public boolean isOverlappingConnectionBugreportEnabled() { 675 return mIsOverlappingConnectionBugreportEnabled; 676 } 677 678 /** 679 * Gets overlapping connection duration threshold in ms 680 */ getOverlappingConnectionDurationThresholdMs()681 public int getOverlappingConnectionDurationThresholdMs() { 682 return mOverlappingConnectionDurationThresholdMs; 683 } 684 685 /** 686 * Gets the threshold of link speed below which Tx link speed is ignored at low traffic 687 */ getTxLinkSpeedLowThresholdMbps()688 public int getTxLinkSpeedLowThresholdMbps() { 689 return mTxLinkSpeedLowThresholdMbps; 690 } 691 692 /** 693 * Gets the threshold of link speed below which Rx link speed is ignored at low traffic 694 */ getRxLinkSpeedLowThresholdMbps()695 public int getRxLinkSpeedLowThresholdMbps() { 696 return mRxLinkSpeedLowThresholdMbps; 697 } 698 699 /** 700 * Gets the feature flag for Wifi battery saver. 701 */ isWifiBatterySaverEnabled()702 public boolean isWifiBatterySaverEnabled() { 703 return mWifiBatterySaverEnabled; 704 } 705 706 /** 707 * Gets health monitor short connection duration threshold in ms 708 */ getHealthMonitorShortConnectionDurationThrMs()709 public int getHealthMonitorShortConnectionDurationThrMs() { 710 return mHealthMonitorShortConnectionDurationThrMs; 711 } 712 713 /** 714 * Gets abnormal disconnection reason code mask 715 */ getAbnormalDisconnectionReasonCodeMask()716 public long getAbnormalDisconnectionReasonCodeMask() { 717 return mAbnormalDisconnectionReasonCodeMask; 718 } 719 720 /** 721 * Gets health monitor RSSI poll valid time in ms 722 */ getHealthMonitorRssiPollValidTimeMs()723 public int getHealthMonitorRssiPollValidTimeMs() { 724 return mHealthMonitorRssiPollValidTimeMs; 725 } 726 727 /** 728 * Gets scan rssi valid time in ms when device is in non-stationary state 729 */ getNonstationaryScanRssiValidTimeMs()730 public int getNonstationaryScanRssiValidTimeMs() { 731 return mNonstationaryScanRssiValidTimeMs; 732 } 733 734 /** 735 * Gets scan rssi valid time in ms when device is in stationary state 736 */ getStationaryScanRssiValidTimeMs()737 public int getStationaryScanRssiValidTimeMs() { 738 return mStationaryScanRssiValidTimeMs; 739 } 740 741 /** 742 * Gets health monitor firmware alert valid time in ms, 743 * -1 disables firmware alert time check 744 */ getHealthMonitorFwAlertValidTimeMs()745 public int getHealthMonitorFwAlertValidTimeMs() { 746 return mHealthMonitorFwAlertValidTimeMs; 747 } 748 749 /** 750 * Gets the minimum confirmation duration for sending network score to connectivity service 751 * when score breaches low. 752 */ getMinConfirmationDurationSendLowScoreMs()753 public int getMinConfirmationDurationSendLowScoreMs() { 754 return mMinConfirmationDurationSendLowScoreMs; 755 } 756 757 /** 758 * Gets the minimum confirmation duration for sending network score to connectivity service 759 * when score breaches high. 760 */ getMinConfirmationDurationSendHighScoreMs()761 public int getMinConfirmationDurationSendHighScoreMs() { 762 return mMinConfirmationDurationSendHighScoreMs; 763 } 764 765 /** 766 * Gets the RSSI threshold above which low score is not sent to connectivity service when 767 * external scorer takes action. 768 */ getRssiThresholdNotSendLowScoreToCsDbm()769 public int getRssiThresholdNotSendLowScoreToCsDbm() { 770 return mRssiThresholdNotSendLowScoreToCsDbm; 771 } 772 773 /** 774 * Gets whether enhanced MAC randomization should be allowed on open networks. 775 */ allowEnhancedMacRandomizationOnOpenSsids()776 public boolean allowEnhancedMacRandomizationOnOpenSsids() { 777 return mAllowEnhancedMacRandomizationOnOpenSsids; 778 } 779 780 /** 781 * Gets traffic stats maximum threshold in KByte 782 */ getTrafficStatsThresholdMaxKbyte()783 public int getTrafficStatsThresholdMaxKbyte() { 784 return mTrafficStatsThresholdMaxKbyte; 785 } 786 787 /** 788 * Gets bandwidth estimator large time constant in second 789 */ getBandwidthEstimatorLargeTimeConstantSec()790 public int getBandwidthEstimatorLargeTimeConstantSec() { 791 return mBandwidthEstimatorLargeTimeConstantSec; 792 } 793 794 } 795