WiFi: enable any combination of STA/AP/P2P/NAN interfaces.

The total number of interfaces is still limited to 2,
will be addressed in a separate change.

Bug: 36120314
Test: KitchenSink (see go/aae-dual-ap)
Test: b/120081854
Change-Id: I8962c5167fcbe55805fce320f639d37b4b902c5c
diff --git a/wifi/1.3/default/tests/hidl_struct_util_unit_tests.cpp b/wifi/1.3/default/tests/hidl_struct_util_unit_tests.cpp
index 790b7fa..dbf7bd6 100644
--- a/wifi/1.3/default/tests/hidl_struct_util_unit_tests.cpp
+++ b/wifi/1.3/default/tests/hidl_struct_util_unit_tests.cpp
@@ -222,7 +222,7 @@
               converted.iface.wmeVoPktStats.retries);
 
     EXPECT_EQ(legacy_stats.radios.size(), converted.radios.size());
-    for (int i = 0; i < legacy_stats.radios.size(); i++) {
+    for (size_t i = 0; i < legacy_stats.radios.size(); i++) {
         EXPECT_EQ(legacy_stats.radios[i].stats.on_time,
                   converted.radios[i].V1_0.onTimeInMs);
         EXPECT_EQ(legacy_stats.radios[i].stats.tx_time,
@@ -233,7 +233,7 @@
                   converted.radios[i].V1_0.onTimeInMsForScan);
         EXPECT_EQ(legacy_stats.radios[i].tx_time_per_levels.size(),
                   converted.radios[i].V1_0.txTimeInMsPerLevel.size());
-        for (int j = 0; j < legacy_stats.radios[i].tx_time_per_levels.size();
+        for (size_t j = 0; j < legacy_stats.radios[i].tx_time_per_levels.size();
              j++) {
             EXPECT_EQ(legacy_stats.radios[i].tx_time_per_levels[j],
                       converted.radios[i].V1_0.txTimeInMsPerLevel[j]);
@@ -250,21 +250,20 @@
                   converted.radios[i].onTimeInMsForHs20Scan);
         EXPECT_EQ(legacy_stats.radios[i].channel_stats.size(),
                   converted.radios[i].channelStats.size());
-        for (int k = 0; k < legacy_stats.radios[i].channel_stats.size(); k++) {
+        for (size_t k = 0; k < legacy_stats.radios[i].channel_stats.size();
+             k++) {
+            auto& legacy_channel_st = legacy_stats.radios[i].channel_stats[k];
             EXPECT_EQ(WifiChannelWidthInMhz::WIDTH_20,
                       converted.radios[i].channelStats[k].channel.width);
-            EXPECT_EQ(
-                legacy_stats.radios[i].channel_stats[k].channel.center_freq,
-                converted.radios[i].channelStats[k].channel.centerFreq);
-            EXPECT_EQ(
-                legacy_stats.radios[i].channel_stats[k].channel.center_freq0,
-                converted.radios[i].channelStats[k].channel.centerFreq0);
-            EXPECT_EQ(
-                legacy_stats.radios[i].channel_stats[k].channel.center_freq1,
-                converted.radios[i].channelStats[k].channel.centerFreq1);
-            EXPECT_EQ(legacy_stats.radios[i].channel_stats[k].cca_busy_time,
+            EXPECT_EQ(WifiChannelInMhz(legacy_channel_st.channel.center_freq),
+                      converted.radios[i].channelStats[k].channel.centerFreq);
+            EXPECT_EQ(WifiChannelInMhz(legacy_channel_st.channel.center_freq0),
+                      converted.radios[i].channelStats[k].channel.centerFreq0);
+            EXPECT_EQ(WifiChannelInMhz(legacy_channel_st.channel.center_freq1),
+                      converted.radios[i].channelStats[k].channel.centerFreq1);
+            EXPECT_EQ(legacy_channel_st.cca_busy_time,
                       converted.radios[i].channelStats[k].ccaBusyTimeInMs);
-            EXPECT_EQ(legacy_stats.radios[i].channel_stats[k].on_time,
+            EXPECT_EQ(legacy_channel_st.on_time,
                       converted.radios[i].channelStats[k].onTimeInMs);
         }
     }
diff --git a/wifi/1.3/default/tests/mock_wifi_feature_flags.h b/wifi/1.3/default/tests/mock_wifi_feature_flags.h
index 86c50a7..8b0baa4 100644
--- a/wifi/1.3/default/tests/mock_wifi_feature_flags.h
+++ b/wifi/1.3/default/tests/mock_wifi_feature_flags.h
@@ -18,6 +18,7 @@
 #define MOCK_WIFI_FEATURE_FLAGS_H_
 
 #include <gmock/gmock.h>
+#undef NAN  // This is weird, NAN is defined in bionic/libc/include/math.h:38
 
 #include "wifi_feature_flags.h"
 
@@ -32,9 +33,7 @@
    public:
     MockWifiFeatureFlags();
 
-    MOCK_METHOD0(isAwareSupported, bool());
-    MOCK_METHOD0(isDualInterfaceSupported, bool());
-    MOCK_METHOD0(isApDisabled, bool());
+    MOCK_METHOD0(getChipModes, std::vector<V1_0::IWifiChip::ChipMode>());
 };
 
 }  // namespace feature_flags
diff --git a/wifi/1.3/default/tests/runtests.sh b/wifi/1.3/default/tests/runtests.sh
index 6bce3ef..eefc697 100755
--- a/wifi/1.3/default/tests/runtests.sh
+++ b/wifi/1.3/default/tests/runtests.sh
@@ -23,4 +23,4 @@
 $ANDROID_BUILD_TOP/build/soong/soong_ui.bash --make-mode android.hardware.wifi@1.0-service-tests
 adb root
 adb sync data
-adb shell /data/nativetest64/vendor/android.hardware.wifi@1.0-service-tests/android.hardware.wifi@1.0-service-tests
+adb shell /data/nativetest64/android.hardware.wifi@1.0-service-tests/android.hardware.wifi@1.0-service-tests
diff --git a/wifi/1.3/default/tests/wifi_chip_unit_tests.cpp b/wifi/1.3/default/tests/wifi_chip_unit_tests.cpp
index 61060b5..32ba760 100644
--- a/wifi/1.3/default/tests/wifi_chip_unit_tests.cpp
+++ b/wifi/1.3/default/tests/wifi_chip_unit_tests.cpp
@@ -44,48 +44,77 @@
 class WifiChipTest : public Test {
    protected:
     void setupV1IfaceCombination() {
-        EXPECT_CALL(*feature_flags_, isAwareSupported())
-            .WillRepeatedly(testing::Return(false));
-        EXPECT_CALL(*feature_flags_, isDualInterfaceSupported())
-            .WillRepeatedly(testing::Return(false));
-        EXPECT_CALL(*feature_flags_, isApDisabled())
-            .WillRepeatedly(testing::Return(false));
+        // clang-format off
+        const hidl_vec<V1_0::IWifiChip::ChipIfaceCombination> combinationsSta = {
+            {{{{IfaceType::STA}, 1}, {{IfaceType::P2P}, 1}}}
+        };
+        const hidl_vec<V1_0::IWifiChip::ChipIfaceCombination> combinationsAp = {
+            {{{{IfaceType::AP}, 1}}}
+        };
+        const std::vector<V1_0::IWifiChip::ChipMode> modes = {
+            {feature_flags::chip_mode_ids::kV1Sta, combinationsSta},
+            {feature_flags::chip_mode_ids::kV1Ap, combinationsAp}
+        };
+        // clang-format on
+        EXPECT_CALL(*feature_flags_, getChipModes())
+            .WillRepeatedly(testing::Return(modes));
     }
 
     void setupV1_AwareIfaceCombination() {
-        EXPECT_CALL(*feature_flags_, isAwareSupported())
-            .WillRepeatedly(testing::Return(true));
-        EXPECT_CALL(*feature_flags_, isDualInterfaceSupported())
-            .WillRepeatedly(testing::Return(false));
-        EXPECT_CALL(*feature_flags_, isApDisabled())
-            .WillRepeatedly(testing::Return(false));
+        // clang-format off
+        const hidl_vec<V1_0::IWifiChip::ChipIfaceCombination> combinationsSta = {
+            {{{{IfaceType::STA}, 1}, {{IfaceType::P2P, IfaceType::NAN}, 1}}}
+        };
+        const hidl_vec<V1_0::IWifiChip::ChipIfaceCombination> combinationsAp = {
+            {{{{IfaceType::AP}, 1}}}
+        };
+        const std::vector<V1_0::IWifiChip::ChipMode> modes = {
+            {feature_flags::chip_mode_ids::kV1Sta, combinationsSta},
+            {feature_flags::chip_mode_ids::kV1Ap, combinationsAp}
+        };
+        // clang-format on
+        EXPECT_CALL(*feature_flags_, getChipModes())
+            .WillRepeatedly(testing::Return(modes));
     }
 
     void setupV1_AwareDisabledApIfaceCombination() {
-        EXPECT_CALL(*feature_flags_, isAwareSupported())
-            .WillRepeatedly(testing::Return(true));
-        EXPECT_CALL(*feature_flags_, isDualInterfaceSupported())
-            .WillRepeatedly(testing::Return(false));
-        EXPECT_CALL(*feature_flags_, isApDisabled())
-            .WillRepeatedly(testing::Return(true));
+        // clang-format off
+        const hidl_vec<V1_0::IWifiChip::ChipIfaceCombination> combinationsSta = {
+            {{{{IfaceType::STA}, 1}, {{IfaceType::P2P, IfaceType::NAN}, 1}}}
+        };
+        const std::vector<V1_0::IWifiChip::ChipMode> modes = {
+            {feature_flags::chip_mode_ids::kV1Sta, combinationsSta}
+        };
+        // clang-format on
+        EXPECT_CALL(*feature_flags_, getChipModes())
+            .WillRepeatedly(testing::Return(modes));
     }
 
     void setupV2_AwareIfaceCombination() {
-        EXPECT_CALL(*feature_flags_, isAwareSupported())
-            .WillRepeatedly(testing::Return(true));
-        EXPECT_CALL(*feature_flags_, isDualInterfaceSupported())
-            .WillRepeatedly(testing::Return(true));
-        EXPECT_CALL(*feature_flags_, isApDisabled())
-            .WillRepeatedly(testing::Return(false));
+        // clang-format off
+        const hidl_vec<V1_0::IWifiChip::ChipIfaceCombination> combinations = {
+            {{{{IfaceType::STA}, 1}, {{IfaceType::AP}, 1}}},
+            {{{{IfaceType::STA}, 1}, {{IfaceType::P2P, IfaceType::NAN}, 1}}}
+        };
+        const std::vector<V1_0::IWifiChip::ChipMode> modes = {
+            {feature_flags::chip_mode_ids::kV3, combinations}
+        };
+        // clang-format on
+        EXPECT_CALL(*feature_flags_, getChipModes())
+            .WillRepeatedly(testing::Return(modes));
     }
 
     void setupV2_AwareDisabledApIfaceCombination() {
-        EXPECT_CALL(*feature_flags_, isAwareSupported())
-            .WillRepeatedly(testing::Return(true));
-        EXPECT_CALL(*feature_flags_, isDualInterfaceSupported())
-            .WillRepeatedly(testing::Return(true));
-        EXPECT_CALL(*feature_flags_, isApDisabled())
-            .WillRepeatedly(testing::Return(true));
+        // clang-format off
+        const hidl_vec<V1_0::IWifiChip::ChipIfaceCombination> combinations = {
+            {{{{IfaceType::STA}, 1}, {{IfaceType::P2P, IfaceType::NAN}, 1}}}
+        };
+        const std::vector<V1_0::IWifiChip::ChipMode> modes = {
+            {feature_flags::chip_mode_ids::kV3, combinations}
+        };
+        // clang-format on
+        EXPECT_CALL(*feature_flags_, getChipModes())
+            .WillRepeatedly(testing::Return(modes));
     }
 
     void assertNumberOfModes(uint32_t num_modes) {