• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 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 android.annotation.Nullable;
20 import android.net.wifi.WifiConfiguration;
21 import android.net.wifi.WifiContext;
22 import android.net.wifi.WifiManager;
23 import android.net.wifi.util.WifiResourceCache;
24 import android.util.ArraySet;
25 import android.util.Log;
26 import android.util.SparseArray;
27 
28 import androidx.annotation.Keep;
29 
30 import com.android.internal.annotations.VisibleForTesting;
31 import com.android.modules.utils.build.SdkLevel;
32 import com.android.server.wifi.WifiBlocklistMonitor.CarrierSpecificEapFailureConfig;
33 import com.android.wifi.resources.R;
34 
35 import java.io.FileDescriptor;
36 import java.io.PrintWriter;
37 import java.util.Arrays;
38 import java.util.HashMap;
39 import java.util.List;
40 import java.util.Map;
41 import java.util.Set;
42 import java.util.concurrent.atomic.AtomicBoolean;
43 import java.util.concurrent.atomic.AtomicInteger;
44 
45 import javax.annotation.concurrent.ThreadSafe;
46 
47 
48 /** Global wifi service in-memory state that is not persisted. */
49 @ThreadSafe
50 public class WifiGlobals {
51 
52     private static final String TAG = "WifiGlobals";
53     private final WifiContext mContext;
54     private final WifiResourceCache mWifiResourceCache;
55 
56     private final AtomicInteger mPollRssiIntervalMillis = new AtomicInteger(-1);
57     private final AtomicInteger mPollRssiShortIntervalMillis = new AtomicInteger();
58     private final AtomicInteger mPollRssiLongIntervalMillis = new AtomicInteger();
59     private boolean mIsPollRssiIntervalOverridden = false;
60     private final AtomicBoolean mIpReachabilityDisconnectEnabled = new AtomicBoolean(true);
61     private final AtomicBoolean mIsBluetoothConnected = new AtomicBoolean(false);
62     // Set default to false to check if the value will be overridden by WifiSettingConfigStore.
63     private final AtomicBoolean mIsWepAllowed = new AtomicBoolean(false);
64     private final AtomicBoolean mIsD2dStaConcurrencySupported = new AtomicBoolean(false);
65     private final AtomicInteger mSendDhcpHostnameRestriction = new AtomicInteger();
66     private boolean mIsWpa3SaeUpgradeOffloadEnabled;
67     private boolean mIsWpa3SaeH2eSupported;
68     private boolean mDisableFirmwareRoamingInIdleMode = false;
69     private final Map<String, List<String>> mCountryCodeToAfcServers;
70     // This is set by WifiManager#setVerboseLoggingEnabled(int).
71     private int mVerboseLoggingLevel = WifiManager.VERBOSE_LOGGING_LEVEL_DISABLED;
72     private boolean mIsUsingExternalScorer = false;
73     private Set<String> mMacRandomizationUnsupportedSsidPrefixes = new ArraySet<>();
74 
75     private SparseArray<SparseArray<CarrierSpecificEapFailureConfig>>
76             mCarrierSpecificEapFailureConfigMapPerCarrierId = new SparseArray<>();
77 
78 
WifiGlobals(WifiContext context)79     public WifiGlobals(WifiContext context) {
80         mContext = context;
81         mWifiResourceCache = context.getResourceCache();
82         mIsWpa3SaeUpgradeOffloadEnabled = mWifiResourceCache
83                 .getBoolean(R.bool.config_wifiSaeUpgradeOffloadEnabled);
84         mPollRssiIntervalMillis.set(mWifiResourceCache.getInteger(
85                 R.integer.config_wifiPollRssiIntervalMilliseconds));
86         mPollRssiShortIntervalMillis.set(mWifiResourceCache.getInteger(
87                 R.integer.config_wifiPollRssiIntervalMilliseconds));
88         mPollRssiLongIntervalMillis.set(mWifiResourceCache.getInteger(
89                 R.integer.config_wifiPollRssiLongIntervalMilliseconds));
90         mIsWpa3SaeH2eSupported = mWifiResourceCache
91                 .getBoolean(R.bool.config_wifiSaeH2eSupported);
92         Set<String> unsupportedSsidPrefixes = new ArraySet<>(mWifiResourceCache.getStringArray(
93                 R.array.config_wifiForceDisableMacRandomizationSsidPrefixList));
94         mCountryCodeToAfcServers = getCountryCodeToAfcServersMap();
95         if (!unsupportedSsidPrefixes.isEmpty()) {
96             for (String ssid : unsupportedSsidPrefixes) {
97                 String cleanedSsid = ssid.length() > 1 && (ssid.charAt(0) == '"')
98                         && (ssid.charAt(ssid.length() - 1) == '"')
99                         ? ssid.substring(0, ssid.length() - 1) : ssid;
100                 mMacRandomizationUnsupportedSsidPrefixes.add(cleanedSsid);
101             }
102         }
103         loadCarrierSpecificEapFailureConfigMap();
104     }
105 
106     /**
107      * Gets the CarrierSpecificEapFailureConfig applicable for the carrierId and eapFailureReason.
108      * @param carrierId the carrier ID
109      * @param eapFailureReason EAP failure reason
110      * @return The applicable CarrierSpecificEapFailureConfig, or null if there's no data for this
111      * particular combination of carrierId and eapFailureReason.
112      */
getCarrierSpecificEapFailureConfig( int carrierId, int eapFailureReason)113     public @Nullable CarrierSpecificEapFailureConfig getCarrierSpecificEapFailureConfig(
114             int carrierId, int eapFailureReason) {
115         if (!mCarrierSpecificEapFailureConfigMapPerCarrierId.contains(carrierId)) {
116             return null;
117         }
118         return mCarrierSpecificEapFailureConfigMapPerCarrierId.get(carrierId).get(eapFailureReason);
119     }
120 
121     /**
122      * Utility method for unit testing.
123      */
getCarrierSpecificEapFailureConfigMapSize()124     public @VisibleForTesting int getCarrierSpecificEapFailureConfigMapSize() {
125         return mCarrierSpecificEapFailureConfigMapPerCarrierId.size();
126     }
127 
loadCarrierSpecificEapFailureConfigMap()128     private void loadCarrierSpecificEapFailureConfigMap() {
129         String[] eapFailureOverrides = mWifiResourceCache.getStringArray(
130                 R.array.config_wifiEapFailureConfig);
131         if (eapFailureOverrides == null) {
132             return;
133         }
134         for (String line : eapFailureOverrides) {
135             if (line == null) {
136                 continue;
137             }
138             String[] items = line.split(",");
139             if (items.length != 5) {
140                 // error case. Should have exactly 5 items.
141                 Log.e(TAG, "Failed to parse eapFailureOverrides line=" + line);
142                 continue;
143             }
144             try {
145                 int carrierId = Integer.parseInt(items[0].trim());
146                 int eapFailureCode = Integer.parseInt(items[1].trim());
147                 int displayDialogue = Integer.parseInt(items[2].trim());
148                 int disableThreshold = Integer.parseInt(items[3].trim());
149                 int disableDurationMinutes = Integer.parseInt(items[4].trim());
150                 if (!mCarrierSpecificEapFailureConfigMapPerCarrierId.contains(carrierId)) {
151                     mCarrierSpecificEapFailureConfigMapPerCarrierId.put(carrierId,
152                             new SparseArray<>());
153                 }
154                 SparseArray<CarrierSpecificEapFailureConfig> perEapFailureMap =
155                         mCarrierSpecificEapFailureConfigMapPerCarrierId.get(carrierId);
156                 perEapFailureMap.put(eapFailureCode, new CarrierSpecificEapFailureConfig(
157                         disableThreshold, disableDurationMinutes * 60 * 1000, displayDialogue > 0));
158             } catch (Exception e) {
159                 // failure to parse. Something is wrong with the config.
160                 Log.e(TAG, "Parsing eapFailureOverrides line=" + line
161                         + ". Exception occurred:" + e);
162             }
163         }
164     }
165 
getCountryCodeToAfcServersMap()166     private Map<String, List<String>> getCountryCodeToAfcServersMap() {
167         Map<String, List<String>> countryCodeToAfcServers = new HashMap<>();
168         String[] countryCodeToAfcServersFromConfig = mWifiResourceCache.getStringArray(
169                 R.array.config_wifiAfcServerUrlsForCountry);
170 
171         if (countryCodeToAfcServersFromConfig == null) {
172             return countryCodeToAfcServers;
173         }
174 
175         // each entry should be of the form: countryCode,url1,url2...
176         for (String entry : countryCodeToAfcServersFromConfig) {
177             String[] countryAndUrls = entry.split(",");
178 
179             // if no servers are specified for a country, then continue to the next entry
180             if (countryAndUrls.length < 2) {
181                 continue;
182             }
183             countryCodeToAfcServers.put(countryAndUrls[0], Arrays.asList(Arrays.copyOfRange(
184                     countryAndUrls, 1, countryAndUrls.length)));
185         }
186         return countryCodeToAfcServers;
187     }
188 
getMacRandomizationUnsupportedSsidPrefixes()189     public Set<String> getMacRandomizationUnsupportedSsidPrefixes() {
190         return mMacRandomizationUnsupportedSsidPrefixes;
191     }
192 
193     /** Get the interval between RSSI polls, in milliseconds. */
194     @Keep
getPollRssiIntervalMillis()195     public int getPollRssiIntervalMillis() {
196         return mPollRssiIntervalMillis.get();
197     }
198 
199     /** Set the interval between RSSI polls, in milliseconds. */
setPollRssiIntervalMillis(int newPollIntervalMillis)200     public void setPollRssiIntervalMillis(int newPollIntervalMillis) {
201         mPollRssiIntervalMillis.set(newPollIntervalMillis);
202     }
203 
204     /** Returns whether CMD_IP_REACHABILITY_LOST events should trigger disconnects. */
getIpReachabilityDisconnectEnabled()205     public boolean getIpReachabilityDisconnectEnabled() {
206         return mIpReachabilityDisconnectEnabled.get();
207     }
208 
209     /**
210      * Returns a list of AFC server URLs for a country, or null if AFC is not available in that
211      * country.
212      */
getAfcServerUrlsForCountry(String countryCode)213     public @Nullable List<String> getAfcServerUrlsForCountry(String countryCode) {
214         return mCountryCodeToAfcServers.get(countryCode);
215     }
216 
217     /**
218      * Returns whether this device supports AFC.
219      */
isAfcSupportedOnDevice()220     public boolean isAfcSupportedOnDevice() {
221         return mWifiResourceCache.getBoolean(R.bool.config_wifiAfcSupported)
222                 && mWifiResourceCache.getBoolean(R.bool.config_wifiSoftap6ghzSupported)
223                 && mWifiResourceCache.getBoolean(R.bool.config_wifi6ghzSupport);
224     }
225 
226     /** Sets whether CMD_IP_REACHABILITY_LOST events should trigger disconnects. */
227     @Keep
setIpReachabilityDisconnectEnabled(boolean enabled)228     public void setIpReachabilityDisconnectEnabled(boolean enabled) {
229         mIpReachabilityDisconnectEnabled.set(enabled);
230     }
231 
232     /** Set whether bluetooth is enabled. */
setBluetoothEnabled(boolean isEnabled)233     public void setBluetoothEnabled(boolean isEnabled) {
234         // If BT was connected and then turned off, there is no CONNECTION_STATE_CHANGE message.
235         // So set mIsBluetoothConnected to false if we get a bluetooth disable while connected.
236         // But otherwise, Bluetooth being turned on doesn't mean that we're connected.
237         if (!isEnabled) {
238             mIsBluetoothConnected.set(false);
239         }
240     }
241 
242     /** Set whether bluetooth is connected. */
setBluetoothConnected(boolean isConnected)243     public void setBluetoothConnected(boolean isConnected) {
244         mIsBluetoothConnected.set(isConnected);
245     }
246 
247     /** Get whether bluetooth is connected */
isBluetoothConnected()248     public boolean isBluetoothConnected() {
249         return mIsBluetoothConnected.get();
250     }
251 
252     /**
253      * Helper method to check if Connected MAC Randomization is supported - onDown events are
254      * skipped if this feature is enabled (b/72459123).
255      *
256      * @return boolean true if Connected MAC randomization is supported, false otherwise
257      */
isConnectedMacRandomizationEnabled()258     public boolean isConnectedMacRandomizationEnabled() {
259         return mWifiResourceCache.getBoolean(
260                 R.bool.config_wifi_connected_mac_randomization_supported);
261     }
262 
263     /**
264      * Helper method to check if WEP networks are deprecated.
265      *
266      * @return boolean true if WEP networks are deprecated, false otherwise.
267      */
isWepDeprecated()268     public boolean isWepDeprecated() {
269         return mWifiResourceCache.getBoolean(R.bool.config_wifiWepDeprecated)
270                 || (mWifiResourceCache.getBoolean(R.bool.config_wifiWepAllowedControlSupported)
271                 && !mIsWepAllowed.get());
272     }
273 
274     /**
275      * Helper method to check if WEP networks are supported.
276      *
277      * @return boolean true if WEP networks are supported, false otherwise.
278      */
isWepSupported()279     public boolean isWepSupported() {
280         return !mWifiResourceCache.getBoolean(R.bool.config_wifiWepDeprecated
281         );
282     }
283 
284     /**
285      * Helper method to check if WPA-Personal networks are deprecated.
286      *
287      * @return boolean true if WPA-Personal networks are deprecated, false otherwise.
288      */
isWpaPersonalDeprecated()289     public boolean isWpaPersonalDeprecated() {
290         return mWifiResourceCache
291                 .getBoolean(R.bool.config_wifiWpaPersonalDeprecated);
292     }
293 
294     /**
295      * Helper method to check whether this device should disable firmware roaming in idle mode.
296      * @return if the device should disable firmware roaming in idle mode.
297      */
isDisableFirmwareRoamingInIdleMode()298     public boolean isDisableFirmwareRoamingInIdleMode() {
299         return mWifiResourceCache
300                 .getBoolean(R.bool.config_wifiDisableFirmwareRoamingInIdleMode);
301     }
302 
303     /**
304      * Get the configuration for whether Multi-internet are allowed to
305      * connect simultaneously to both 5GHz high and 5GHz low.
306      */
isSupportMultiInternetDual5G()307     public boolean isSupportMultiInternetDual5G() {
308         return mWifiResourceCache.getBoolean(
309                 R.bool.config_wifiAllowMultiInternetConnectDual5GFrequency);
310     }
311 
312     /**
313      * Get number of repeated NUD failures needed to disable a network.
314      */
getRepeatedNudFailuresThreshold()315     public int getRepeatedNudFailuresThreshold() {
316         return mWifiResourceCache
317                 .getInteger(R.integer.config_wifiDisableReasonRepeatedNudFailuresThreshold);
318     }
319 
320     /**
321      * Get the time window in millis to count for repeated NUD failures.
322      */
getRepeatedNudFailuresWindowMs()323     public int getRepeatedNudFailuresWindowMs() {
324         return mWifiResourceCache
325                 .getInteger(R.integer.config_wifiDisableReasonRepeatedNudFailuresWindowMs);
326     }
327 
328     /**
329      * Helper method to check if the device may not connect to the configuration
330      * due to deprecated security type
331      */
isDeprecatedSecurityTypeNetwork(@ullable WifiConfiguration config)332     public boolean isDeprecatedSecurityTypeNetwork(@Nullable WifiConfiguration config) {
333         if (config == null) {
334             return false;
335         }
336         if (isWepDeprecated() && config.isSecurityType(WifiConfiguration.SECURITY_TYPE_WEP)) {
337             return true;
338         }
339         if (isWpaPersonalDeprecated() && config.isWpaPersonalOnlyConfiguration()) {
340             return true;
341         }
342         return false;
343     }
344 
345     /**
346      * Help method to check if WPA3 SAE auto-upgrade is enabled.
347      *
348      * @return boolean true if auto-upgrade is enabled, false otherwise.
349      */
isWpa3SaeUpgradeEnabled()350     public boolean isWpa3SaeUpgradeEnabled() {
351         return mWifiResourceCache
352                 .getBoolean(R.bool.config_wifiSaeUpgradeEnabled);
353     }
354 
355     /**
356      * Help method to check if WPA3 SAE auto-upgrade offload is enabled.
357      *
358      * @return boolean true if auto-upgrade offload is enabled, false otherwise.
359      */
isWpa3SaeUpgradeOffloadEnabled()360     public boolean isWpa3SaeUpgradeOffloadEnabled() {
361         return mIsWpa3SaeUpgradeOffloadEnabled;
362     }
363 
364     /**
365      * Helper method to enable WPA3 SAE auto-upgrade offload based on the device capability for
366      * CROSS-AKM support.
367      */
setWpa3SaeUpgradeOffloadEnabled()368     public void setWpa3SaeUpgradeOffloadEnabled() {
369         Log.d(TAG, "Device supports CROSS-AKM feature - Enable WPA3 SAE auto-upgrade offload");
370         mIsWpa3SaeUpgradeOffloadEnabled = true;
371     }
372 
373 
374     /**
375      * Help method to check if OWE auto-upgrade is enabled.
376      *
377      * @return boolean true if auto-upgrade is enabled, false otherwise.
378      */
isOweUpgradeEnabled()379     public boolean isOweUpgradeEnabled() {
380         // OWE auto-upgrade is supported on S or newer releases.
381         return SdkLevel.isAtLeastS() && mWifiResourceCache
382                 .getBoolean(R.bool.config_wifiOweUpgradeEnabled);
383     }
384 
385     /**
386      * Help method to check if the setting to flush ANQP cache when Wi-Fi is toggled off.
387      *
388      * @return boolean true to flush ANQP cache on Wi-Fi toggle off event, false otherwise.
389      */
flushAnqpCacheOnWifiToggleOffEvent()390     public boolean flushAnqpCacheOnWifiToggleOffEvent() {
391         return mWifiResourceCache
392                 .getBoolean(R.bool.config_wifiFlushAnqpCacheOnWifiToggleOffEvent);
393     }
394 
395     /*
396      * Help method to check if WPA3 SAE Hash-to-Element is supported on this device.
397      *
398      * @return boolean true if supported;otherwise false.
399      */
isWpa3SaeH2eSupported()400     public boolean isWpa3SaeH2eSupported() {
401         return mIsWpa3SaeH2eSupported;
402     }
403 
404     /**
405      * Helper method to enable WPA3 SAE Hash-to-Element support based on the supplicant aidl
406      * version.
407      */
enableWpa3SaeH2eSupport()408     public void enableWpa3SaeH2eSupport() {
409         mIsWpa3SaeH2eSupported = true;
410     }
411 
412     /**
413      * Record the verbose logging level
414      */
setVerboseLoggingLevel(int level)415     public void setVerboseLoggingLevel(int level) {
416         mVerboseLoggingLevel = level;
417     }
418 
419     /** Return the currently set verbose logging level. */
getVerboseLoggingLevel()420     public int getVerboseLoggingLevel() {
421         return mVerboseLoggingLevel;
422     }
423 
424     /** Check if show key verbose logging mode is enabled. */
getShowKeyVerboseLoggingModeEnabled()425     public boolean getShowKeyVerboseLoggingModeEnabled() {
426         return mVerboseLoggingLevel == WifiManager.VERBOSE_LOGGING_LEVEL_ENABLED_SHOW_KEY;
427     }
428 
429     /** Set whether the external scorer is being used **/
setUsingExternalScorer(boolean isUsingExternalScorer)430     public void setUsingExternalScorer(boolean isUsingExternalScorer) {
431         mIsUsingExternalScorer = isUsingExternalScorer;
432     }
433 
434     /** Get whether the external scorer is being used **/
isUsingExternalScorer()435     public boolean isUsingExternalScorer() {
436         return mIsUsingExternalScorer;
437     }
438 
439     /** Get the prefix of the default wifi p2p device name. */
getWifiP2pDeviceNamePrefix()440     public String getWifiP2pDeviceNamePrefix() {
441         return mWifiResourceCache
442                 .getString(R.string.config_wifiP2pDeviceNamePrefix);
443     }
444 
445     /** Get the number of the default wifi p2p device name postfix digit. */
getWifiP2pDeviceNamePostfixNumDigits()446     public int getWifiP2pDeviceNamePostfixNumDigits() {
447         return mWifiResourceCache
448                 .getInteger(R.integer.config_wifiP2pDeviceNamePostfixNumDigits);
449     }
450 
451     /** Get the number of log records to maintain. */
getClientModeImplNumLogRecs()452     public int getClientModeImplNumLogRecs() {
453         return  mWifiResourceCache.getInteger(R.integer.config_wifiClientModeImplNumLogRecs);
454     }
455 
456     /** Get whether to use the saved factory MAC address when available **/
isSaveFactoryMacToConfigStoreEnabled()457     public boolean isSaveFactoryMacToConfigStoreEnabled() {
458         return mWifiResourceCache
459                 .getBoolean(R.bool.config_wifiSaveFactoryMacToWifiConfigStore);
460     }
461 
462     /** Get the low score threshold to do scan for MBB when external scorer is not used. **/
getWifiLowConnectedScoreThresholdToTriggerScanForMbb()463     public int getWifiLowConnectedScoreThresholdToTriggerScanForMbb() {
464         return mWifiResourceCache.getInteger(
465                 R.integer.config_wifiLowConnectedScoreThresholdToTriggerScanForMbb);
466     }
467 
468     /** Get the minimum period between the extra scans triggered for MBB when score is low **/
getWifiLowConnectedScoreScanPeriodSeconds()469     public int getWifiLowConnectedScoreScanPeriodSeconds() {
470         return mWifiResourceCache.getInteger(
471                 R.integer.config_wifiLowConnectedScoreScanPeriodSeconds);
472     }
473 
474     /** Get whether or not insecure enterprise configuration is allowed. */
isInsecureEnterpriseConfigurationAllowed()475     public boolean isInsecureEnterpriseConfigurationAllowed() {
476         return mWifiResourceCache.getBoolean(
477                 R.bool.config_wifiAllowInsecureEnterpriseConfigurationsForSettingsAndSUW);
478     }
479 
480     /** Get whether or not P2P MAC randomization is supported */
isP2pMacRandomizationSupported()481     public boolean isP2pMacRandomizationSupported() {
482         return mWifiResourceCache.getBoolean(
483                 R.bool.config_wifi_p2p_mac_randomization_supported);
484     }
485 
486     /** Get the regular (short) interval between RSSI polls, in milliseconds. */
getPollRssiShortIntervalMillis()487     public int getPollRssiShortIntervalMillis() {
488         return mPollRssiShortIntervalMillis.get();
489     }
490 
491     /** Set the regular (short) interval between RSSI polls, in milliseconds. */
setPollRssiShortIntervalMillis(int newPollIntervalMillis)492     public void setPollRssiShortIntervalMillis(int newPollIntervalMillis) {
493         mPollRssiShortIntervalMillis.set(newPollIntervalMillis);
494     }
495 
496     /**
497      * Get the long interval between RSSI polls, in milliseconds. The long interval is to
498      * reduce power consumption of the polls. This value should be greater than the regular
499      * interval.
500      */
getPollRssiLongIntervalMillis()501     public int getPollRssiLongIntervalMillis() {
502         return mPollRssiLongIntervalMillis.get();
503     }
504 
505     /**
506      * Set the long interval between RSSI polls, in milliseconds. The long interval is to
507      * reduce power consumption of the polls. This value should be greater than the regular
508      * interval.
509      */
setPollRssiLongIntervalMillis(int newPollIntervalMillis)510     public void setPollRssiLongIntervalMillis(int newPollIntervalMillis) {
511         mPollRssiLongIntervalMillis.set(newPollIntervalMillis);
512     }
513 
514     /**
515      * Get the RSSI threshold for client mode RSSI monitor, in dBm. If the device is stationary
516      * and current RSSI >= Threshold + Hysteresis value, set long interval and enable RSSI
517      * monitoring using the RSSI threshold. If device is non-stationary or current RSSI <=
518      * Threshold, set regular interval and disable RSSI monitoring.
519      */
getClientRssiMonitorThresholdDbm()520     public int getClientRssiMonitorThresholdDbm() {
521         return mWifiResourceCache.getInteger(
522                 R.integer.config_wifiClientRssiMonitorThresholdDbm);
523     }
524 
525     /**
526      * Get the hysteresis value in dB for the client mode RSSI monitor threshold. It can avoid
527      * frequent switch between regular and long polling intervals.
528      */
getClientRssiMonitorHysteresisDb()529     public int getClientRssiMonitorHysteresisDb() {
530         return mWifiResourceCache.getInteger(
531                 R.integer.config_wifiClientRssiMonitorHysteresisDb);
532     }
533 
534     /**
535      * Get whether adjusting the RSSI polling interval between regular and long intervals
536      * is enabled.
537      */
isAdjustPollRssiIntervalEnabled()538     public boolean isAdjustPollRssiIntervalEnabled() {
539         return mWifiResourceCache.getBoolean(
540                 R.bool.config_wifiAdjustPollRssiIntervalEnabled);
541     }
542 
543     /** Set whether the RSSI polling interval is overridden to a fixed value **/
setPollRssiIntervalOverridden(boolean isPollRssiIntervalOverridden)544     public void setPollRssiIntervalOverridden(boolean isPollRssiIntervalOverridden) {
545         mIsPollRssiIntervalOverridden = isPollRssiIntervalOverridden;
546     }
547 
548     /** Get whether the RSSI polling interval is overridden to a fixed value **/
isPollRssiIntervalOverridden()549     public boolean isPollRssiIntervalOverridden() {
550         return mIsPollRssiIntervalOverridden;
551     }
552 
553     /**
554      * Get whether hot-plugging an interface will trigger a restart of the wifi stack.
555      */
isWifiInterfaceAddedSelfRecoveryEnabled()556     public boolean isWifiInterfaceAddedSelfRecoveryEnabled() {
557         return  mWifiResourceCache.getBoolean(
558                 R.bool.config_wifiInterfaceAddedSelfRecoveryEnabled);
559     }
560 
561     /**
562      * Get whether background scan is supported.
563      */
isBackgroundScanSupported()564     public boolean isBackgroundScanSupported() {
565         return mWifiResourceCache
566                 .getBoolean(R.bool.config_wifi_background_scan_support
567                 );
568     };
569 
570     /**
571      * Get whether software pno is enabled.
572      */
isSwPnoEnabled()573     public boolean isSwPnoEnabled() {
574         return mWifiResourceCache
575                 .getBoolean(R.bool.config_wifiSwPnoEnabled);
576     };
577 
578     /**
579      * Get whether to temporarily disable a unwanted network that has low RSSI.
580      */
disableUnwantedNetworkOnLowRssi()581     public boolean disableUnwantedNetworkOnLowRssi() {
582         return mWifiResourceCache.getBoolean(
583                 R.bool.config_wifiDisableUnwantedNetworkOnLowRssi);
584     }
585 
586     /**
587      * Get whether to disable NUD disconnects for WAPI configurations in a specific CC.
588      */
disableNudDisconnectsForWapiInSpecificCc()589     public boolean disableNudDisconnectsForWapiInSpecificCc() {
590         return mWifiResourceCache.getBoolean(
591                 R.bool.config_wifiDisableNudDisconnectsForWapiInSpecificCc);
592     }
593 
594     /**
595      * Get the threshold to use for blocking a network due to NETWORK_NOT_FOUND_EVENT failure.
596      */
getNetworkNotFoundEventThreshold()597     public int getNetworkNotFoundEventThreshold() {
598         return mWifiResourceCache.getInteger(
599                 R.integer.config_wifiNetworkNotFoundEventThreshold);
600     }
601 
602     /**
603      * Set whether wep network is allowed by user.
604      */
setWepAllowed(boolean isAllowed)605     public void setWepAllowed(boolean isAllowed) {
606         mIsWepAllowed.set(isAllowed);
607     }
608 
609     /**
610      * Get whether or not wep network is allowed by user.
611      */
isWepAllowed()612     public boolean isWepAllowed() {
613         return mIsWepAllowed.get();
614     }
615 
616     /**
617      * Set whether the device supports device-to-device + STA concurrency.
618      */
setD2dStaConcurrencySupported(boolean isSupported)619     public void setD2dStaConcurrencySupported(boolean isSupported) {
620         mIsD2dStaConcurrencySupported.set(isSupported);
621     }
622 
623     /**
624      * Returns whether the device supports device-to-device when infra STA is disabled.
625      */
isD2dSupportedWhenInfraStaDisabled()626     public boolean isD2dSupportedWhenInfraStaDisabled() {
627         return mWifiResourceCache
628                 .getBoolean(R.bool.config_wifiD2dAllowedControlSupportedWhenInfraStaDisabled)
629                 && !mIsD2dStaConcurrencySupported.get();
630     }
631 
isNetworkSelectionSetTargetBssid()632     public boolean isNetworkSelectionSetTargetBssid() {
633         return mWifiResourceCache.getBoolean(R.bool.config_wifiNetworkSelectionSetTargetBssid);
634     }
635 
636     /**
637      * Set the global dhcp hostname restriction.
638      */
setSendDhcpHostnameRestriction( @ifiManager.SendDhcpHostnameRestriction int restriction)639     public void setSendDhcpHostnameRestriction(
640             @WifiManager.SendDhcpHostnameRestriction int restriction) {
641         mSendDhcpHostnameRestriction.set(restriction);
642     }
643 
644     /**
645      * Get the global dhcp hostname restriction.
646      */
647     @WifiManager.SendDhcpHostnameRestriction
getSendDhcpHostnameRestriction()648     public int getSendDhcpHostnameRestriction() {
649         return mSendDhcpHostnameRestriction.get();
650     }
651 
652     /**
653      * Get the maximum Wifi temporary disable duration.
654      */
getWifiConfigMaxDisableDurationMs()655     public long getWifiConfigMaxDisableDurationMs() {
656         return mWifiResourceCache
657                 .getInteger(R.integer.config_wifiDisableTemporaryMaximumDurationMs);
658     }
659 
660     /**
661      * Returns whether device support Wi-Fi 7 multi-link device Soft Ap.
662      */
isMLDApSupported()663     public boolean isMLDApSupported() {
664         int numberOfMLDSupported = mWifiResourceCache
665                 .getInteger(R.integer.config_wifiSoftApMaxNumberMLDSupported);
666         return numberOfMLDSupported != 0;
667     }
668 
669     /** Dump method for debugging */
dump(FileDescriptor fd, PrintWriter pw, String[] args)670     public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
671         pw.println("Dump of WifiGlobals");
672         pw.println("mPollRssiIntervalMillis=" + mPollRssiIntervalMillis.get());
673         pw.println("mIsPollRssiIntervalOverridden=" + mIsPollRssiIntervalOverridden);
674         pw.println("mPollRssiShortIntervalMillis=" + mPollRssiShortIntervalMillis.get());
675         pw.println("mPollRssiLongIntervalMillis=" + mPollRssiLongIntervalMillis.get());
676         pw.println("mIpReachabilityDisconnectEnabled=" + mIpReachabilityDisconnectEnabled.get());
677         pw.println("mIsBluetoothConnected=" + mIsBluetoothConnected.get());
678         pw.println("mIsWpa3SaeUpgradeOffloadEnabled=" + mIsWpa3SaeUpgradeOffloadEnabled);
679         pw.println("mIsUsingExternalScorer="
680                 + mIsUsingExternalScorer);
681         pw.println("mIsWepAllowed=" + mIsWepAllowed.get());
682         pw.println("mDisableFirmwareRoamingInIdleMode=" + mDisableFirmwareRoamingInIdleMode);
683         pw.println("IsD2dSupportedWhenInfraStaDisabled="
684                 + isD2dSupportedWhenInfraStaDisabled());
685         pw.println("mIsWpa3SaeH2eSupported=" + mIsWpa3SaeH2eSupported);
686         for (int i = 0; i < mCarrierSpecificEapFailureConfigMapPerCarrierId.size(); i++) {
687             int carrierId = mCarrierSpecificEapFailureConfigMapPerCarrierId.keyAt(i);
688             SparseArray<CarrierSpecificEapFailureConfig> perFailureMap =
689                     mCarrierSpecificEapFailureConfigMapPerCarrierId.valueAt(i);
690             for (int j = 0; j < perFailureMap.size(); j++) {
691                 int eapFailureCode = perFailureMap.keyAt(j);
692                 pw.println("carrierId=" + carrierId
693                         + ", eapFailureCode=" + eapFailureCode
694                         + ", displayNotification=" + perFailureMap.valueAt(j).displayNotification
695                         + ", threshold=" + perFailureMap.valueAt(j).threshold
696                         + ", durationMs=" + perFailureMap.valueAt(j).durationMs);
697             }
698         }
699         pw.println("mSendDhcpHostnameRestriction=" + mSendDhcpHostnameRestriction.get());
700     }
701 }
702