Wifi: Replace dual_band with 5GHz band support

As part of the support of the 6GHz band, the concept of dual-band
is no longer valid since we have more than 2 bands supported by
Android and can be checked on the device.
This commit replaces checks on dual-band support with an explicit
check on 5GHz band support.
This commit also reads the device support for 5GHz/6GHz bands through
the overlay configs, and removes the logic for reading it from the
vendor HAL.

Bug: 145936758
Bug: 139354972
Test: Manual
Change-Id: I9f0ad7c5ab57107c71b13f857994e874a34d9bdf
diff --git a/RROOverlaySampleApp/res/values/config.xml b/RROOverlaySampleApp/res/values/config.xml
index cf6ab94..08b0430 100644
--- a/RROOverlaySampleApp/res/values/config.xml
+++ b/RROOverlaySampleApp/res/values/config.xml
@@ -18,6 +18,6 @@
 -->
 <!-- Overrides the default value of the specified config values when this sample app is installed -->
 <resources>
-    <bool translatable="false" name="config_wifi_dual_band_support">true</bool>
+    <bool translatable="false" name="config_wifi5ghzSupport">true</bool>
     <bool translatable="false" name="config_wifi_connected_mac_randomization_supported">true</bool>
 </resources>
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index 43a2006..458f6d1 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -26,7 +26,6 @@
 import static android.net.wifi.WifiManager.WIFI_AP_STATE_ENABLED;
 import static android.net.wifi.WifiManager.WIFI_AP_STATE_ENABLING;
 import static android.net.wifi.WifiManager.WIFI_AP_STATE_FAILED;
-import static android.net.wifi.WifiManager.WIFI_FEATURE_INFRA_5G;
 
 import android.annotation.CheckResult;
 import android.annotation.NonNull;
@@ -1186,7 +1185,7 @@
             boolean is5Ghz = hasAutomotiveFeature(mContext)
                     && mContext.getResources().getBoolean(
                     R.bool.config_wifi_local_only_hotspot_5ghz)
-                    && is5GhzSupported();
+                    && is5GhzBandSupportedInternal();
 
             int band = is5Ghz ? WifiConfiguration.AP_BAND_5GHZ
                     : WifiConfiguration.AP_BAND_2GHZ;
@@ -2390,14 +2389,25 @@
     }
 
     @Override
-    public boolean isDualBandSupported() {
-        //TODO (b/123227116): pull it from the HAL
+    public boolean is5GHzBandSupported() {
         if (mVerboseLoggingEnabled) {
-            mLog.info("isDualBandSupported uid=%").c(Binder.getCallingUid()).flush();
+            mLog.info("is5GHzBandSupported uid=%").c(Binder.getCallingUid()).flush();
         }
 
-        return mContext.getResources().getBoolean(
-                R.bool.config_wifi_dual_band_support);
+        return is5GhzBandSupportedInternal();
+    }
+
+    private boolean is5GhzBandSupportedInternal() {
+        return mContext.getResources().getBoolean(R.bool.config_wifi5ghzSupport);
+    }
+
+    @Override
+    public boolean is6GHzBandSupported() {
+        if (mVerboseLoggingEnabled) {
+            mLog.info("is6GHzBandSupported uid=%").c(Binder.getCallingUid()).flush();
+        }
+
+        return mContext.getResources().getBoolean(R.bool.config_wifi6ghzSupport);
     }
 
     private int getMaxApInterfacesCount() {
@@ -3158,10 +3168,6 @@
                 mWifiTrafficPoller.removeCallback(callbackIdentifier));
     }
 
-    private boolean is5GhzSupported() {
-        return (getSupportedFeaturesInternal() & WIFI_FEATURE_INFRA_5G) == WIFI_FEATURE_INFRA_5G;
-    }
-
     private long getSupportedFeaturesInternal() {
         final AsyncChannel channel = mClientModeImplChannel;
         if (channel != null) {
diff --git a/service/java/com/android/server/wifi/WifiVendorHal.java b/service/java/com/android/server/wifi/WifiVendorHal.java
index 97dded6..c98121f 100644
--- a/service/java/com/android/server/wifi/WifiVendorHal.java
+++ b/service/java/com/android/server/wifi/WifiVendorHal.java
@@ -1142,9 +1142,6 @@
      * Translation table used by getSupportedFeatureSet for translating IWifiStaIface caps
      */
     private static final long[][] sStaFeatureCapabilityTranslation = {
-            {WifiManager.WIFI_FEATURE_INFRA_5G,
-                    IWifiStaIface.StaIfaceCapabilityMask.STA_5G
-            },
             {WifiManager.WIFI_FEATURE_PASSPOINT,
                     IWifiStaIface.StaIfaceCapabilityMask.HOTSPOT
             },
@@ -1180,9 +1177,6 @@
             },
             {WifiManager.WIFI_FEATURE_SCAN_RAND,
                     IWifiStaIface.StaIfaceCapabilityMask.SCAN_RAND
-            },
-            {WifiManager.WIFI_FEATURE_INFRA_6G,
-                    android.hardware.wifi.V1_4.IWifiStaIface.StaIfaceCapabilityMask.STA_6G
             }
     };
 
@@ -1232,21 +1226,12 @@
                     });
                 }
 
-                android.hardware.wifi.V1_4.IWifiStaIface ifaceV14 =
-                        getWifiStaIfaceForV1_4Mockable(ifaceName);
-                if (ifaceV14 != null) {
-                    ifaceV14.getCapabilities_1_4((status, capabilities) -> {
+                IWifiStaIface iface = getStaIface(ifaceName);
+                if (iface != null) {
+                    iface.getCapabilities((status, capabilities) -> {
                         if (!ok(status)) return;
                         feat.value |= wifiFeatureMaskFromStaCapabilities(capabilities);
                     });
-                } else {
-                    IWifiStaIface iface = getStaIface(ifaceName);
-                    if (iface != null) {
-                        iface.getCapabilities((status, capabilities) -> {
-                            if (!ok(status)) return;
-                            feat.value |= wifiFeatureMaskFromStaCapabilities(capabilities);
-                        });
-                    }
                 }
             }
             featureSet = feat.value;
@@ -2356,20 +2341,6 @@
         return android.hardware.wifi.V1_3.IWifiStaIface.castFrom(iface);
     }
 
-    /**
-     * Method to mock out the V1_4 IWifiStaIface retrieval in unit tests.
-     *
-     * @param ifaceName Name of the interface
-     * @return 1.4 IWifiStaIface object if the device is running the 1.4 wifi hal service, null
-     * otherwise.
-     */
-    protected android.hardware.wifi.V1_4.IWifiStaIface getWifiStaIfaceForV1_4Mockable(
-            @NonNull String ifaceName) {
-        IWifiStaIface iface = getStaIface(ifaceName);
-        if (iface == null) return null;
-        return android.hardware.wifi.V1_4.IWifiStaIface.castFrom(iface);
-    }
-
     protected android.hardware.wifi.V1_4.IWifiApIface getWifiApIfaceForV1_4Mockable(
             String ifaceName) {
         IWifiApIface iface = getApIface(ifaceName);
diff --git a/service/res/values/config.xml b/service/res/values/config.xml
index b7f6a70..b5354a1 100644
--- a/service/res/values/config.xml
+++ b/service/res/values/config.xml
@@ -21,8 +21,14 @@
      entries do not follow the convention, but all new entries should. -->
 
 <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-    <!-- Boolean indicating whether the wifi chipset has dual frequency band support -->
-    <bool translatable="false" name="config_wifi_dual_band_support">false</bool>
+    <!-- boolean indicating whether the WiFi chipset has 5GHz band support.
+         Note: This config is replacing the config_wifi_dual_band_support
+         since more bands may now be supported (such as 6GHz), the naming dual_band
+         is no longer indicative, and a separate config now exists for each band -->
+    <bool translatable="false" name ="config_wifi5ghzSupport">false</bool>
+
+    <!-- boolean indicating whether the WiFi chipset has 6GHz band support -->
+    <bool translatable="false" name ="config_wifi6ghzSupport">false</bool>
 
     <!-- Maximum number of concurrent WiFi interfaces in AP mode -->
     <integer translatable="false" name="config_wifi_max_ap_interfaces">1</integer>
diff --git a/service/res/values/overlayable.xml b/service/res/values/overlayable.xml
index 450aa17..16e987b 100644
--- a/service/res/values/overlayable.xml
+++ b/service/res/values/overlayable.xml
@@ -20,7 +20,8 @@
         <policy type="product|system|vendor">
 
           <!-- Params from config.xml that can be overlayed -->
-          <item type="bool" name="config_wifi_dual_band_support" />
+          <item type="bool" name="config_wifi5ghzSupport" />
+          <item type="bool" name="config_wifi6ghzSupport" />
           <item type="integer" name="config_wifi_max_ap_interfaces" />
           <item type="bool" name="config_wifi_convert_apband_5ghz_to_any" />
           <item type="bool" name="config_wifi_fast_bss_transition_enabled" />
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
index 0273211..f3cf19f 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
@@ -32,7 +32,6 @@
 import static android.net.wifi.WifiManager.WIFI_AP_STATE_DISABLING;
 import static android.net.wifi.WifiManager.WIFI_AP_STATE_ENABLED;
 import static android.net.wifi.WifiManager.WIFI_AP_STATE_FAILED;
-import static android.net.wifi.WifiManager.WIFI_FEATURE_INFRA_5G;
 import static android.net.wifi.WifiManager.WIFI_STATE_DISABLED;
 
 import static com.android.server.wifi.LocalOnlyHotspotRequestInfo.HOTSPOT_NO_ERROR;
@@ -1864,9 +1863,10 @@
         when(mResources.getBoolean(
                 eq(R.bool.config_wifi_local_only_hotspot_5ghz)))
                 .thenReturn(true);
+        when(mResources.getBoolean(
+                eq(R.bool.config_wifi5ghzSupport)))
+                .thenReturn(true);
         when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)).thenReturn(true);
-        when(mClientModeImpl.syncGetSupportedFeatures(any(AsyncChannel.class)))
-                .thenReturn((long) WIFI_FEATURE_INFRA_5G);
 
         verify(mAsyncChannel).connect(any(), mHandlerCaptor.capture(), any(Handler.class));
         final Handler handler = mHandlerCaptor.getValue();
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java b/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java
index 3d290e4..7405351 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java
@@ -157,8 +157,6 @@
     private android.hardware.wifi.V1_2.IWifiStaIface mIWifiStaIfaceV12;
     @Mock
     private android.hardware.wifi.V1_3.IWifiStaIface mIWifiStaIfaceV13;
-    @Mock
-    private android.hardware.wifi.V1_4.IWifiStaIface mIWifiStaIfaceV14;
     private IWifiStaIfaceEventCallback mIWifiStaIfaceEventCallback;
     private IWifiChipEventCallback mIWifiChipEventCallback;
     private android.hardware.wifi.V1_2.IWifiChipEventCallback mIWifiChipEventCallbackV12;
@@ -208,12 +206,6 @@
                 String ifaceName) {
             return null;
         }
-
-        @Override
-        protected android.hardware.wifi.V1_4.IWifiStaIface getWifiStaIfaceForV1_4Mockable(
-                String ifaceName) {
-            return null;
-        }
     }
 
     /**
@@ -256,12 +248,6 @@
                 String ifaceName) {
             return null;
         }
-
-        @Override
-        protected android.hardware.wifi.V1_4.IWifiStaIface getWifiStaIfaceForV1_4Mockable(
-                String ifaceName) {
-            return null;
-        }
     }
 
     /**
@@ -304,12 +290,6 @@
                 String ifaceName) {
             return mIWifiStaIfaceV13;
         }
-
-        @Override
-        protected android.hardware.wifi.V1_4.IWifiStaIface getWifiStaIfaceForV1_4Mockable(
-                String ifaceName) {
-            return null;
-        }
     }
 
     /**
@@ -352,12 +332,6 @@
                 String ifaceName) {
             return mIWifiStaIfaceV13;
         }
-
-        @Override
-        protected android.hardware.wifi.V1_4.IWifiStaIface getWifiStaIfaceForV1_4Mockable(
-                String ifaceName) {
-            return mIWifiStaIfaceV14;
-        }
     }
 
     /**
@@ -914,60 +888,6 @@
         assertEquals(expectedFeatureSet, mWifiVendorHal.getSupportedFeatureSet(TEST_IFACE_NAME));
     }
 
-    /**
-     * Test get supported features on HAL V1_4.
-     * Tests whether we coalesce information from different sources
-     * (IWifiStaIface, IWifiChip and HalDeviceManager) into the bitmask of supported features
-     * correctly.
-     */
-    @Test
-    public void testGetSupportedFeaturesV1_4() throws Exception {
-        mWifiVendorHal = new WifiVendorHalSpyV1_4(mHalDeviceManager, mHandler);
-        assertTrue(mWifiVendorHal.startVendorHalSta());
-
-        int staIfaceHidlCaps = (
-                IWifiStaIface.StaIfaceCapabilityMask.BACKGROUND_SCAN
-                        | IWifiStaIface.StaIfaceCapabilityMask.LINK_LAYER_STATS
-                        | android.hardware.wifi.V1_4.IWifiStaIface.StaIfaceCapabilityMask.STA_6G
-        );
-        int chipHidlCaps =
-                android.hardware.wifi.V1_1.IWifiChip.ChipCapabilityMask.SET_TX_POWER_LIMIT;
-        Set<Integer>  halDeviceManagerSupportedIfaces = new HashSet<Integer>() {{
-                add(IfaceType.STA);
-                add(IfaceType.P2P);
-            }};
-        long expectedFeatureSet = (
-                WifiManager.WIFI_FEATURE_SCANNER
-                        | WifiManager.WIFI_FEATURE_LINK_LAYER_STATS
-                        | WifiManager.WIFI_FEATURE_TX_POWER_LIMIT
-                        | WifiManager.WIFI_FEATURE_INFRA
-                        | WifiManager.WIFI_FEATURE_P2P
-                        | WifiManager.WIFI_FEATURE_INFRA_6G
-        );
-
-        doAnswer(new AnswerWithArguments() {
-            public void answer(
-                    android.hardware.wifi.V1_4.IWifiStaIface.getCapabilities_1_4Callback cb)
-                    throws RemoteException {
-                cb.onValues(mWifiStatusSuccess, staIfaceHidlCaps);
-            }
-        }).when(mIWifiStaIfaceV14).getCapabilities_1_4(
-                any(android.hardware.wifi.V1_4.IWifiStaIface.getCapabilities_1_4Callback.class));
-
-        doAnswer(new AnswerWithArguments() {
-            public void answer(android.hardware.wifi.V1_3.IWifiChip.getCapabilities_1_3Callback cb)
-                    throws RemoteException {
-                cb.onValues(mWifiStatusSuccess, chipHidlCaps);
-            }
-        }).when(mIWifiChipV13).getCapabilities_1_3(
-                any(android.hardware.wifi.V1_3.IWifiChip.getCapabilities_1_3Callback.class));
-
-        when(mHalDeviceManager.getSupportedIfaceTypes())
-                .thenReturn(halDeviceManagerSupportedIfaces);
-
-        assertEquals(expectedFeatureSet, mWifiVendorHal.getSupportedFeatureSet(TEST_IFACE_NAME));
-    }
-
    /**
      * Test |getFactoryMacAddress| gets called when the hal version is V1_3
      * @throws Exception