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