Wi-Fi: Add 6GHz band support in Soft-AP UI advanced options
This changes adds support for following:
6GHz SAP: Add 6GHz band to the drop-down menu of Soft-AP band selection
switch to allow users to start Soft-Ap in 6GHz band. This option will not
be displayed if the device is not supporting 6GHz band.
This changes also removes wifi_ap_band_vendor_config_full and
wifi_ap_band_vendor_summary_full as now we are dynamically adding
SAP bands.
Change-Id: Id39a97d11624f5d8918aca4c1f7e8d88f5ef9f58
CRs-Fixed: 2569221
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index f54c5f1..aea398d 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -293,20 +293,6 @@
<item>@string/wifi_ap_choose_2G</item>
</string-array>
- <!-- Wi-Fi AP Vendor band settings. Either 2.4GHz, 5GHz or Both. -->
- <!-- Note that adding/removing/moving the items will need wifi settings code change. -->
- <string-array translatable="false" name="wifi_ap_band_vendor_config_full">
- <item>1</item>
- <item>3</item>
- <item>8</item>
- </string-array>
-
- <string-array translatable="false" name="wifi_ap_band_vendor_summary_full">
- <item>@string/wifi_ap_choose_2G</item>
- <item>@string/wifi_ap_prefer_5G</item>
- <item>@string/wifi_ap_choose_vendor_dual_band</item>
- </string-array>
-
<!-- Wi-Fi WPS setup for p2p connections. -->
<!-- Note that adding/removing/moving the items will need wifi settings code change. -->
<string-array name="wifi_p2p_wps_setup">
diff --git a/res/values/strings.xml b/res/values/strings.xml
index ebd34c8..7e0efec 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2034,10 +2034,14 @@
<string name="wifi_ap_choose_2G">2.4 GHz Band</string>
<!-- Label for the radio button to only choose wifi ap 5GHz band -->
<string name="wifi_ap_choose_5G">5.0 GHz Band</string>
+ <!-- Label for the radio button to only choose wifi ap 6GHz band -->
+ <string name="wifi_ap_choose_6G">6.0 GHz Band</string>
<!-- Label for the radio button to choose both wifi ap band (2.4GHz + 5GHz) -->
<string name="wifi_ap_choose_vendor_dual_band">Dual Band</string>
<!-- Label for the radio button to prefer 5GHz wifi ap band [CHAR LIMIT=80]-->
<string name="wifi_ap_prefer_5G">5.0 GHz Band preferred</string>
+ <!-- Label for the radio button to prefer 6GHz wifi ap band [CHAR LIMIT=80]-->
+ <string name="wifi_ap_prefer_6G">6.0 GHz Band preferred</string>
<!-- Label for adding to the list of selected bands when 2.4 GHz is selected -->
<string name="wifi_ap_2G">2.4 GHz</string>
<!-- Label for adding to the list of selected bands when 5.0 GHz is selected -->
diff --git a/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceController.java b/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceController.java
index 9b1fd76..1cf3f31 100644
--- a/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceController.java
+++ b/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceController.java
@@ -30,6 +30,8 @@
import com.android.settings.R;
import com.android.settings.core.FeatureFlags;
+import java.util.ArrayList;
+import java.util.Arrays;
public class WifiTetherApBandPreferenceController extends WifiTetherBasePreferenceController {
@@ -41,11 +43,13 @@
private int mBandIndex;
private int mSecurityType;
private boolean isVendorDualApSupported;
+ private final Context mContext;
public WifiTetherApBandPreferenceController(Context context,
OnTetherConfigUpdateListener listener) {
super(context, listener);
final SoftApConfiguration config = mWifiManager.getSoftApConfiguration();
+ mContext = context;
isVendorDualApSupported = context.getResources().getBoolean(
com.android.internal.R.bool.config_wifi_dual_sap_mode_enabled);
@@ -59,7 +63,7 @@
if (config == null) {
mBandIndex = SoftApConfiguration.BAND_2GHZ;
Log.d(TAG, "Updating band index to BAND_2GHZ because no config");
- } else if (is5GhzBandSupported()) {
+ } else if (is5GhzBandSupported() || is6GhzBandSupported()) {
mBandIndex = validateSelection(config);
Log.d(TAG, "Updating band index to " + mBandIndex);
} else {
@@ -74,7 +78,7 @@
preference.setEntries(mBandSummaries);
preference.setEntryValues(mBandEntries);
- if (!is5GhzBandSupported()) {
+ if (!is5GhzBandSupported() && !is6GhzBandSupported()) {
preference.setEnabled(false);
preference.setSummary(R.string.wifi_ap_choose_2G);
} else {
@@ -88,10 +92,11 @@
switch (mBandIndex) {
case SoftApConfiguration.BAND_2GHZ:
return mBandSummaries[0];
- case SoftApConfiguration.BAND_5GHZ:
- return mBandSummaries[1];
+ case SoftApConfiguration.BAND_5GHZ | SoftApConfiguration.BAND_2GHZ:
+ case SoftApConfiguration.BAND_6GHZ | SoftApConfiguration.BAND_2GHZ:
case SoftApConfiguration.BAND_DUAL:
- return mBandSummaries[2];
+ final ListPreference preference = (ListPreference) mPreference;
+ return mBandSummaries[preference.findIndexOfValue(String.valueOf(mBandIndex))];
default:
return mContext.getString(R.string.wifi_ap_prefer_5G);
}
@@ -128,11 +133,14 @@
// unsupported states:
// 1: BAND_5GHZ only - include 2GHZ since some of countries doesn't support 5G hotspot
// 2: no 5 GHZ support means we can't have BAND_5GHZ - default to 2GHZ
+ // 3: no 6 GHZ support means we can't have AP_BAND_6GHZ - default to 2GHZ
if (SoftApConfiguration.BAND_5GHZ == band) {
if (!is5GhzBandSupported()) {
return SoftApConfiguration.BAND_2GHZ;
}
return SoftApConfiguration.BAND_5GHZ | SoftApConfiguration.BAND_2GHZ;
+ } else if (!is6GhzBandSupported() && SoftApConfiguration.BAND_6GHZ == band) {
+ return SoftApConfiguration.BAND_2GHZ;
}
return band;
@@ -147,15 +155,29 @@
@VisibleForTesting
void updatePreferenceEntries() {
Resources res = mContext.getResources();
- int entriesRes = R.array.wifi_ap_band;
- int summariesRes = R.array.wifi_ap_band_summary;
- if (isVendorDualApSupported && mSecurityType != SoftApConfiguration.SECURITY_TYPE_OWE) {
- // change the list option if AP+AP is supproted and selected security type is not OWE
- entriesRes = R.array.wifi_ap_band_vendor_config_full;
- summariesRes = R.array.wifi_ap_band_vendor_summary_full;
+ ArrayList<String> bandEntries = new ArrayList<String>();
+ ArrayList<String> bandSummaries = new ArrayList<String>();
+ // Add 2GHz band
+ bandEntries.add(String.valueOf(SoftApConfiguration.BAND_2GHZ));
+ bandSummaries.add(mContext.getString(R.string.wifi_ap_choose_2G));
+ // Add 5GHz band
+ if (is5GhzBandSupported()) {
+ bandEntries.add(String.valueOf(SoftApConfiguration.BAND_5GHZ | SoftApConfiguration.BAND_2GHZ));
+ bandSummaries.add(mContext.getString(R.string.wifi_ap_prefer_5G));
}
- mBandEntries = res.getStringArray(entriesRes);
- mBandSummaries = res.getStringArray(summariesRes);
+ // Add 6GHz band
+ if (is6GhzBandSupported()) {
+ bandEntries.add(String.valueOf(SoftApConfiguration.BAND_6GHZ | SoftApConfiguration.BAND_2GHZ));
+ bandSummaries.add(mContext.getString(R.string.wifi_ap_prefer_6G));
+ }
+ // change the list option if AP+AP is supproted and selected security type is not OWE
+ if (isVendorDualApSupported && mSecurityType != SoftApConfiguration.SECURITY_TYPE_OWE &&
+ (is5GhzBandSupported())) {
+ bandEntries.add(String.valueOf(SoftApConfiguration.BAND_DUAL));
+ bandSummaries.add(mContext.getString(R.string.wifi_ap_choose_vendor_dual_band));
+ }
+ mBandEntries = bandEntries.toArray(new String[bandEntries.size()]);
+ mBandSummaries = bandSummaries.toArray(new String[bandSummaries.size()]);
}
private boolean is5GhzBandSupported() {
@@ -166,6 +188,14 @@
return true;
}
+ private boolean is6GhzBandSupported() {
+ final String countryCode = mWifiManager.getCountryCode();
+ if (!mWifiManager.is6GHzBandSupported() || countryCode == null) {
+ return false;
+ }
+ return true;
+ }
+
public int getBandIndex() {
return mBandIndex;
}