diff options
| author | Tomasz Wasilczyk <twasilczyk@google.com> | 2018-11-15 11:52:57 -0800 |
|---|---|---|
| committer | Tomasz Wasilczyk <twasilczyk@google.com> | 2018-12-11 14:06:28 -0800 |
| commit | b424da787290b37b1406474900712f621cec6ad1 (patch) | |
| tree | a10aacf53ac0ada9d248e6da3e80920e160d21b7 /wifi | |
| parent | 315002043adfb811bbe65934052c3be5b7ebd123 (diff) | |
| download | android_hardware_interfaces-b424da787290b37b1406474900712f621cec6ad1.tar.gz android_hardware_interfaces-b424da787290b37b1406474900712f621cec6ad1.tar.bz2 android_hardware_interfaces-b424da787290b37b1406474900712f621cec6ad1.zip | |
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
Diffstat (limited to 'wifi')
| -rw-r--r-- | wifi/1.3/default/Android.mk | 4 | ||||
| -rw-r--r-- | wifi/1.3/default/tests/hidl_struct_util_unit_tests.cpp | 27 | ||||
| -rw-r--r-- | wifi/1.3/default/tests/mock_wifi_feature_flags.h | 5 | ||||
| -rwxr-xr-x | wifi/1.3/default/tests/runtests.sh | 2 | ||||
| -rw-r--r-- | wifi/1.3/default/tests/wifi_chip_unit_tests.cpp | 89 | ||||
| -rw-r--r-- | wifi/1.3/default/wifi_chip.cpp | 95 | ||||
| -rw-r--r-- | wifi/1.3/default/wifi_chip.h | 1 | ||||
| -rw-r--r-- | wifi/1.3/default/wifi_feature_flags.cpp | 147 | ||||
| -rw-r--r-- | wifi/1.3/default/wifi_feature_flags.h | 17 | ||||
| -rw-r--r-- | wifi/1.3/default/wifi_legacy_hal.cpp | 1 |
10 files changed, 223 insertions, 165 deletions
diff --git a/wifi/1.3/default/Android.mk b/wifi/1.3/default/Android.mk index e05d2f08e..8312c314a 100644 --- a/wifi/1.3/default/Android.mk +++ b/wifi/1.3/default/Android.mk @@ -21,6 +21,9 @@ LOCAL_MODULE := android.hardware.wifi@1.0-service-lib LOCAL_MODULE_RELATIVE_PATH := hw LOCAL_PROPRIETARY_MODULE := true LOCAL_CPPFLAGS := -Wall -Werror -Wextra +ifdef WIFI_HAL_INTERFACE_COMBINATIONS +LOCAL_CPPFLAGS += -DWIFI_HAL_INTERFACE_COMBINATIONS="$(WIFI_HAL_INTERFACE_COMBINATIONS)" +endif ifdef WIFI_HIDL_FEATURE_AWARE LOCAL_CPPFLAGS += -DWIFI_HIDL_FEATURE_AWARE endif @@ -100,6 +103,7 @@ include $(BUILD_EXECUTABLE) include $(CLEAR_VARS) LOCAL_MODULE := android.hardware.wifi@1.0-service-tests LOCAL_PROPRIETARY_MODULE := true +LOCAL_CPPFLAGS := -Wall -Werror -Wextra LOCAL_SRC_FILES := \ tests/hidl_struct_util_unit_tests.cpp \ tests/main.cpp \ 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 790b7fab0..dbf7bd611 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 @@ TEST_F(HidlStructUtilTest, canConvertLegacyLinkLayerStatsToHidl) { 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 @@ TEST_F(HidlStructUtilTest, canConvertLegacyLinkLayerStatsToHidl) { 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 @@ TEST_F(HidlStructUtilTest, canConvertLegacyLinkLayerStatsToHidl) { 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 86c50a72c..8b0baa41a 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 @@ class MockWifiFeatureFlags : public WifiFeatureFlags { 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 6bce3ef8c..eefc697b2 100755 --- a/wifi/1.3/default/tests/runtests.sh +++ b/wifi/1.3/default/tests/runtests.sh @@ -23,4 +23,4 @@ set -e $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 61060b537..32ba76034 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 @@ namespace implementation { 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) { diff --git a/wifi/1.3/default/wifi_chip.cpp b/wifi/1.3/default/wifi_chip.cpp index a80116ab8..dd6bd7c02 100644 --- a/wifi/1.3/default/wifi_chip.cpp +++ b/wifi/1.3/default/wifi_chip.cpp @@ -36,15 +36,6 @@ using android::hardware::wifi::V1_0::ChipModeId; using android::hardware::wifi::V1_0::IfaceType; using android::hardware::wifi::V1_0::IWifiChip; -constexpr ChipModeId kInvalidModeId = UINT32_MAX; -// These mode ID's should be unique (even across combo versions). Refer to -// handleChipConfiguration() for it's usage. -// Mode ID's for V1 -constexpr ChipModeId kV1StaChipModeId = 0; -constexpr ChipModeId kV1ApChipModeId = 1; -// Mode ID for V2 -constexpr ChipModeId kV2ChipModeId = 2; - constexpr char kCpioMagic[] = "070701"; constexpr size_t kMaxBufferSizeBytes = 1024 * 1024; constexpr uint32_t kMaxRingBufferFileAgeSeconds = 60 * 60; @@ -318,10 +309,9 @@ WifiChip::WifiChip( mode_controller_(mode_controller), feature_flags_(feature_flags), is_valid_(true), - current_mode_id_(kInvalidModeId), - debug_ring_buffer_cb_registered_(false) { - populateModes(); -} + current_mode_id_(feature_flags::chip_mode_ids::kInvalid), + modes_(feature_flags.lock()->getChipModes()), + debug_ring_buffer_cb_registered_(false) {} void WifiChip::invalidate() { if (!writeRingbufferFilesInternal()) { @@ -1118,9 +1108,9 @@ WifiStatus WifiChip::handleChipConfiguration( } // Firmware mode change not needed for V2 devices. bool success = true; - if (mode_id == kV1StaChipModeId) { + if (mode_id == feature_flags::chip_mode_ids::kV1Sta) { success = mode_controller_.lock()->changeFirmwareMode(IfaceType::STA); - } else if (mode_id == kV1ApChipModeId) { + } else if (mode_id == feature_flags::chip_mode_ids::kV1Ap) { success = mode_controller_.lock()->changeFirmwareMode(IfaceType::AP); } if (!success) { @@ -1212,81 +1202,6 @@ WifiStatus WifiChip::registerRadioModeChangeCallback() { return createWifiStatusFromLegacyError(legacy_status); } -void WifiChip::populateModes() { - // The chip combination supported for current devices is fixed. - // They can be one of the following based on device features: - // a) 2 separate modes of operation with 1 interface combination each: - // Mode 1 (STA mode): Will support 1 STA and 1 P2P or NAN(optional) - // concurrent iface operations. - // Mode 2 (AP mode): Will support 1 AP iface operation. - // - // b) 1 mode of operation with 2 interface combinations - // (conditional on isDualInterfaceSupported()): - // Interface Combination 1: Will support 1 STA and 1 P2P or NAN(optional) - // concurrent iface operations. - // Interface Combination 2: Will support 1 STA and 1 AP concurrent - // iface operations. - // If Aware is enabled (conditional on isAwareSupported()), the iface - // combination will be modified to support either P2P or NAN in place of - // just P2P. - if (feature_flags_.lock()->isDualInterfaceSupported()) { - // V2 Iface combinations for Mode Id = 2. - const IWifiChip::ChipIfaceCombinationLimit - chip_iface_combination_limit_1 = {{IfaceType::STA}, 1}; - const IWifiChip::ChipIfaceCombinationLimit - chip_iface_combination_limit_2 = {{IfaceType::AP}, 1}; - IWifiChip::ChipIfaceCombinationLimit chip_iface_combination_limit_3; - if (feature_flags_.lock()->isAwareSupported()) { - chip_iface_combination_limit_3 = {{IfaceType::P2P, IfaceType::NAN}, - 1}; - } else { - chip_iface_combination_limit_3 = {{IfaceType::P2P}, 1}; - } - const IWifiChip::ChipIfaceCombination chip_iface_combination_1 = { - {chip_iface_combination_limit_1, chip_iface_combination_limit_2}}; - const IWifiChip::ChipIfaceCombination chip_iface_combination_2 = { - {chip_iface_combination_limit_1, chip_iface_combination_limit_3}}; - if (feature_flags_.lock()->isApDisabled()) { - const IWifiChip::ChipMode chip_mode = {kV2ChipModeId, - {chip_iface_combination_2}}; - modes_ = {chip_mode}; - } else { - const IWifiChip::ChipMode chip_mode = { - kV2ChipModeId, - {chip_iface_combination_1, chip_iface_combination_2}}; - modes_ = {chip_mode}; - } - } else { - // V1 Iface combinations for Mode Id = 0. (STA Mode) - const IWifiChip::ChipIfaceCombinationLimit - sta_chip_iface_combination_limit_1 = {{IfaceType::STA}, 1}; - IWifiChip::ChipIfaceCombinationLimit sta_chip_iface_combination_limit_2; - if (feature_flags_.lock()->isAwareSupported()) { - sta_chip_iface_combination_limit_2 = { - {IfaceType::P2P, IfaceType::NAN}, 1}; - } else { - sta_chip_iface_combination_limit_2 = {{IfaceType::P2P}, 1}; - } - const IWifiChip::ChipIfaceCombination sta_chip_iface_combination = { - {sta_chip_iface_combination_limit_1, - sta_chip_iface_combination_limit_2}}; - const IWifiChip::ChipMode sta_chip_mode = { - kV1StaChipModeId, {sta_chip_iface_combination}}; - // Iface combinations for Mode Id = 1. (AP Mode) - const IWifiChip::ChipIfaceCombinationLimit - ap_chip_iface_combination_limit = {{IfaceType::AP}, 1}; - const IWifiChip::ChipIfaceCombination ap_chip_iface_combination = { - {ap_chip_iface_combination_limit}}; - const IWifiChip::ChipMode ap_chip_mode = {kV1ApChipModeId, - {ap_chip_iface_combination}}; - if (feature_flags_.lock()->isApDisabled()) { - modes_ = {sta_chip_mode}; - } else { - modes_ = {sta_chip_mode, ap_chip_mode}; - } - } -} - std::vector<IWifiChip::ChipIfaceCombination> WifiChip::getCurrentModeIfaceCombinations() { if (!isValidModeId(current_mode_id_)) { diff --git a/wifi/1.3/default/wifi_chip.h b/wifi/1.3/default/wifi_chip.h index 11200f9d3..669524030 100644 --- a/wifi/1.3/default/wifi_chip.h +++ b/wifi/1.3/default/wifi_chip.h @@ -215,7 +215,6 @@ class WifiChip : public V1_3::IWifiChip { WifiStatus registerDebugRingBufferCallback(); WifiStatus registerRadioModeChangeCallback(); - void populateModes(); std::vector<IWifiChip::ChipIfaceCombination> getCurrentModeIfaceCombinations(); std::map<IfaceType, size_t> getCurrentIfaceCombination(); diff --git a/wifi/1.3/default/wifi_feature_flags.cpp b/wifi/1.3/default/wifi_feature_flags.cpp index 8d48c3628..17b3bee01 100644 --- a/wifi/1.3/default/wifi_feature_flags.cpp +++ b/wifi/1.3/default/wifi_feature_flags.cpp @@ -16,25 +16,6 @@ #include "wifi_feature_flags.h" -namespace { -#ifdef WIFI_HIDL_FEATURE_AWARE -static const bool wifiHidlFeatureAware = true; -#else -static const bool wifiHidlFeatureAware = false; -#endif // WIFI_HIDL_FEATURE_AWARE -#ifdef WIFI_HIDL_FEATURE_DUAL_INTERFACE -static const bool wifiHidlFeatureDualInterface = true; -#else -static const bool wifiHidlFeatureDualInterface = false; -#endif // WIFI_HIDL_FEATURE_DUAL_INTERFACE -#ifdef WIFI_HIDL_FEATURE_DISABLE_AP -static const bool wifiHidlFeatureDisableAp = true; -#else -static const bool wifiHidlFeatureDisableAp = false; -#endif // WIFI_HIDL_FEATURE_DISABLE_AP - -} // namespace - namespace android { namespace hardware { namespace wifi { @@ -42,12 +23,132 @@ namespace V1_3 { namespace implementation { namespace feature_flags { +using V1_0::ChipModeId; +using V1_0::IfaceType; +using V1_0::IWifiChip; + +/* The chip may either have a single mode supporting any number of combinations, + * or a fixed dual-mode (so it involves firmware loading to switch between + * modes) setting. If there is a need to support more modes, it needs to be + * implemented manually in WiFi HAL (see changeFirmwareMode in + * WifiChip::handleChipConfiguration). + * + * Supported combinations are defined in device's makefile, for example: + * WIFI_HAL_INTERFACE_COMBINATIONS := {{{STA, AP}, 1}, {{P2P, NAN}, 1}}, + * WIFI_HAL_INTERFACE_COMBINATIONS += {{{STA}, 1}, {{AP}, 2}} + * What means: + * Interface combination 1: 1 STA or AP and 1 P2P or NAN concurrent iface + * operations. + * Interface combination 2: 1 STA and 2 AP concurrent iface operations. + * + * For backward compatibility, the following makefile flags can be used to + * generate combinations list: + * - WIFI_HIDL_FEATURE_DUAL_INTERFACE + * - WIFI_HIDL_FEATURE_DISABLE_AP + * - WIFI_HIDL_FEATURE_AWARE + * However, they are ignored if WIFI_HAL_INTERFACE_COMBINATIONS was provided. + * With WIFI_HIDL_FEATURE_DUAL_INTERFACE flag set, there is a single mode with + * two interface combinations: + * Interface Combination 1: Will support 1 STA and 1 P2P or NAN (optional) + * concurrent iface operations. + * Interface Combination 2: Will support 1 STA and 1 AP concurrent + * iface operations. + * + * The only dual-mode configuration supported is for alternating STA and AP + * mode, that may involve firmware reloading. In such case, there are 2 separate + * modes of operation with 1 interface combination each: + * Mode 1 (STA mode): Will support 1 STA and 1 P2P or NAN (optional) + * concurrent iface operations. + * Mode 2 (AP mode): Will support 1 AP iface operation. + * + * If Aware is enabled, the iface combination will be modified to support either + * P2P or NAN in place of just P2P. + */ +// clang-format off +#ifdef WIFI_HAL_INTERFACE_COMBINATIONS +constexpr ChipModeId kMainModeId = chip_mode_ids::kV3; +#elif defined(WIFI_HIDL_FEATURE_DUAL_INTERFACE) +// former V2 (fixed dual interface) setup expressed as V3 +constexpr ChipModeId kMainModeId = chip_mode_ids::kV3; +# ifdef WIFI_HIDL_FEATURE_DISABLE_AP +# ifdef WIFI_HIDL_FEATURE_AWARE +// 1 STA + 1 of (P2P or NAN) +# define WIFI_HAL_INTERFACE_COMBINATIONS {{{STA}, 1}, {{P2P, NAN}, 1}} +# else +// 1 STA + 1 P2P +# define WIFI_HAL_INTERFACE_COMBINATIONS {{{STA}, 1}, {{P2P}, 1}} +# endif +# else +# ifdef WIFI_HIDL_FEATURE_AWARE +// (1 STA + 1 AP) or (1 STA + 1 of (P2P or NAN)) +# define WIFI_HAL_INTERFACE_COMBINATIONS {{{STA}, 1}, {{AP}, 1}},\ + {{{STA}, 1}, {{P2P, NAN}, 1}} +# else +// (1 STA + 1 AP) or (1 STA + 1 P2P) +# define WIFI_HAL_INTERFACE_COMBINATIONS {{{STA}, 1}, {{AP}, 1}},\ + {{{STA}, 1}, {{P2P}, 1}} +# endif +# endif +#else +// V1 (fixed single interface, dual-mode chip) +constexpr ChipModeId kMainModeId = chip_mode_ids::kV1Sta; +# ifdef WIFI_HIDL_FEATURE_AWARE +// 1 STA + 1 of (P2P or NAN) +# define WIFI_HAL_INTERFACE_COMBINATIONS {{{STA}, 1}, {{P2P, NAN}, 1}} +# else +// 1 STA + 1 P2P +# define WIFI_HAL_INTERFACE_COMBINATIONS {{{STA}, 1}, {{P2P}, 1}} +# endif + +# ifndef WIFI_HIDL_FEATURE_DISABLE_AP +# define WIFI_HAL_INTERFACE_COMBINATIONS_AP {{{AP}, 1}} +# endif +#endif +// clang-format on + +/** + * Helper class to convert a collection of combination limits to a combination. + * + * The main point here is to simplify the syntax required by + * WIFI_HAL_INTERFACE_COMBINATIONS. + */ +struct ChipIfaceCombination + : public hidl_vec<IWifiChip::ChipIfaceCombinationLimit> { + ChipIfaceCombination( + const std::initializer_list<IWifiChip::ChipIfaceCombinationLimit> list) + : hidl_vec(list) {} + + operator IWifiChip::ChipIfaceCombination() const { return {*this}; } + + static hidl_vec<IWifiChip::ChipIfaceCombination> make_vec( + const std::initializer_list<ChipIfaceCombination> list) { + return hidl_vec<IWifiChip::ChipIfaceCombination>( // + std::begin(list), std::end(list)); + } +}; + +#define STA IfaceType::STA +#define AP IfaceType::AP +#define P2P IfaceType::P2P +#define NAN IfaceType::NAN +static const std::vector<IWifiChip::ChipMode> kChipModes{ + {kMainModeId, + ChipIfaceCombination::make_vec({WIFI_HAL_INTERFACE_COMBINATIONS})}, +#ifdef WIFI_HAL_INTERFACE_COMBINATIONS_AP + {chip_mode_ids::kV1Ap, + ChipIfaceCombination::make_vec({WIFI_HAL_INTERFACE_COMBINATIONS_AP})}, +#endif +}; +#undef STA +#undef AP +#undef P2P +#undef NAN + WifiFeatureFlags::WifiFeatureFlags() {} -bool WifiFeatureFlags::isAwareSupported() { return wifiHidlFeatureAware; } -bool WifiFeatureFlags::isDualInterfaceSupported() { - return wifiHidlFeatureDualInterface; + +std::vector<IWifiChip::ChipMode> WifiFeatureFlags::getChipModes() { + return kChipModes; } -bool WifiFeatureFlags::isApDisabled() { return wifiHidlFeatureDisableAp; } } // namespace feature_flags } // namespace implementation diff --git a/wifi/1.3/default/wifi_feature_flags.h b/wifi/1.3/default/wifi_feature_flags.h index ce74e236b..b99a4166b 100644 --- a/wifi/1.3/default/wifi_feature_flags.h +++ b/wifi/1.3/default/wifi_feature_flags.h @@ -17,6 +17,8 @@ #ifndef WIFI_FEATURE_FLAGS_H_ #define WIFI_FEATURE_FLAGS_H_ +#include <android/hardware/wifi/1.2/IWifiChip.h> + namespace android { namespace hardware { namespace wifi { @@ -24,14 +26,23 @@ namespace V1_3 { namespace implementation { namespace feature_flags { +namespace chip_mode_ids { +// These mode ID's should be unique (even across combo versions). Refer to +// handleChipConfiguration() for it's usage. +constexpr V1_0::ChipModeId kInvalid = UINT32_MAX; +// Mode ID's for V1 +constexpr V1_0::ChipModeId kV1Sta = 0; +constexpr V1_0::ChipModeId kV1Ap = 1; +// Mode ID for V3 +constexpr V1_0::ChipModeId kV3 = 3; +} // namespace chip_mode_ids + class WifiFeatureFlags { public: WifiFeatureFlags(); virtual ~WifiFeatureFlags() = default; - virtual bool isAwareSupported(); - virtual bool isDualInterfaceSupported(); - virtual bool isApDisabled(); + virtual std::vector<V1_0::IWifiChip::ChipMode> getChipModes(); }; } // namespace feature_flags diff --git a/wifi/1.3/default/wifi_legacy_hal.cpp b/wifi/1.3/default/wifi_legacy_hal.cpp index 84a2c0333..2b90f9200 100644 --- a/wifi/1.3/default/wifi_legacy_hal.cpp +++ b/wifi/1.3/default/wifi_legacy_hal.cpp @@ -551,6 +551,7 @@ wifi_error WifiLegacyHal::startGscan( on_results_user_callback(id, cached_scan_results); return; } + FALLTHROUGH_INTENDED; } // Fall through if failed. Failure to retrieve cached scan // results should trigger a background scan failure. |
