From 7f4574d2a1764df195ad9c16f149a73b93b825d3 Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Wed, 22 Feb 2017 09:48:03 -0800 Subject: [PATCH] wifi: Duplicate getValidChannelsForBand in AP iface This functionality is needed even for AP iface. So, duplicate this method. Changes in the CL: 1. Add getValidChannelsForBand() in IWifiApIface. 2. Rename StaBackgroundScanBan to WifiBand to make it a more generic name. 3. Change the existing method name in IWifiStaIface to match with the one in IWifiApIface. While there, Fix indentation in hidl_callback_util.h Bug: 35663149 Test: Compiles Change-Id: Iaeb6c323e13eedf2f98de92fea77e327c76ffa5b --- wifi/1.0/Android.mk | 76 +++++++++++++-------------- wifi/1.0/IWifiApIface.hal | 17 ++++++ wifi/1.0/IWifiStaIface.hal | 3 +- wifi/1.0/default/hidl_callback_util.h | 8 ++- wifi/1.0/default/hidl_struct_util.cpp | 16 +++--- wifi/1.0/default/hidl_struct_util.h | 2 +- wifi/1.0/default/wifi_ap_iface.cpp | 20 +++++++ wifi/1.0/default/wifi_ap_iface.h | 4 ++ wifi/1.0/default/wifi_legacy_hal.cpp | 2 +- wifi/1.0/default/wifi_legacy_hal.h | 2 +- wifi/1.0/default/wifi_sta_iface.cpp | 23 ++++---- wifi/1.0/default/wifi_sta_iface.h | 7 ++- wifi/1.0/types.hal | 69 ++++++++++++------------ 13 files changed, 142 insertions(+), 107 deletions(-) diff --git a/wifi/1.0/Android.mk b/wifi/1.0/Android.mk index 4476b14ec5..fa6ef6c18f 100644 --- a/wifi/1.0/Android.mk +++ b/wifi/1.0/Android.mk @@ -795,25 +795,6 @@ $(GEN): $(LOCAL_PATH)/types.hal $(transform-generated-source) LOCAL_GENERATED_SOURCES += $(GEN) -# -# Build types.hal (StaBackgroundScanBand) -# -GEN := $(intermediates)/android/hardware/wifi/V1_0/StaBackgroundScanBand.java -$(GEN): $(HIDL) -$(GEN): PRIVATE_HIDL := $(HIDL) -$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal -$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) -$(GEN): PRIVATE_CUSTOM_TOOL = \ - $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ - -Ljava \ - -randroid.hardware:hardware/interfaces \ - -randroid.hidl:system/libhidl/transport \ - android.hardware.wifi@1.0::types.StaBackgroundScanBand - -$(GEN): $(LOCAL_PATH)/types.hal - $(transform-generated-source) -LOCAL_GENERATED_SOURCES += $(GEN) - # # Build types.hal (StaBackgroundScanBucketEventReportSchemeMask) # @@ -1080,6 +1061,25 @@ $(GEN): $(LOCAL_PATH)/types.hal $(transform-generated-source) LOCAL_GENERATED_SOURCES += $(GEN) +# +# Build types.hal (WifiBand) +# +GEN := $(intermediates)/android/hardware/wifi/V1_0/WifiBand.java +$(GEN): $(HIDL) +$(GEN): PRIVATE_HIDL := $(HIDL) +$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal +$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) +$(GEN): PRIVATE_CUSTOM_TOOL = \ + $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ + -Ljava \ + -randroid.hardware:hardware/interfaces \ + -randroid.hidl:system/libhidl/transport \ + android.hardware.wifi@1.0::types.WifiBand + +$(GEN): $(LOCAL_PATH)/types.hal + $(transform-generated-source) +LOCAL_GENERATED_SOURCES += $(GEN) + # # Build types.hal (WifiChannelInfo) # @@ -2598,25 +2598,6 @@ $(GEN): $(LOCAL_PATH)/types.hal $(transform-generated-source) LOCAL_GENERATED_SOURCES += $(GEN) -# -# Build types.hal (StaBackgroundScanBand) -# -GEN := $(intermediates)/android/hardware/wifi/V1_0/StaBackgroundScanBand.java -$(GEN): $(HIDL) -$(GEN): PRIVATE_HIDL := $(HIDL) -$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal -$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) -$(GEN): PRIVATE_CUSTOM_TOOL = \ - $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ - -Ljava \ - -randroid.hardware:hardware/interfaces \ - -randroid.hidl:system/libhidl/transport \ - android.hardware.wifi@1.0::types.StaBackgroundScanBand - -$(GEN): $(LOCAL_PATH)/types.hal - $(transform-generated-source) -LOCAL_GENERATED_SOURCES += $(GEN) - # # Build types.hal (StaBackgroundScanBucketEventReportSchemeMask) # @@ -2883,6 +2864,25 @@ $(GEN): $(LOCAL_PATH)/types.hal $(transform-generated-source) LOCAL_GENERATED_SOURCES += $(GEN) +# +# Build types.hal (WifiBand) +# +GEN := $(intermediates)/android/hardware/wifi/V1_0/WifiBand.java +$(GEN): $(HIDL) +$(GEN): PRIVATE_HIDL := $(HIDL) +$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal +$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) +$(GEN): PRIVATE_CUSTOM_TOOL = \ + $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ + -Ljava \ + -randroid.hardware:hardware/interfaces \ + -randroid.hidl:system/libhidl/transport \ + android.hardware.wifi@1.0::types.WifiBand + +$(GEN): $(LOCAL_PATH)/types.hal + $(transform-generated-source) +LOCAL_GENERATED_SOURCES += $(GEN) + # # Build types.hal (WifiChannelInfo) # diff --git a/wifi/1.0/IWifiApIface.hal b/wifi/1.0/IWifiApIface.hal index aeca2cd44b..1f6ee7c040 100644 --- a/wifi/1.0/IWifiApIface.hal +++ b/wifi/1.0/IWifiApIface.hal @@ -33,4 +33,21 @@ interface IWifiApIface extends IWifiIface { * |WifiStatusCode.FAILURE_IFACE_INVALID| */ setCountryCode(int8_t[2] code) generates (WifiStatus status); + + /** + * Used to query the list of valid frequencies (depending on country code set) + * for the provided band. + * + * @param band Band for which the frequency list is being generated. + * @return status WifiStatus of the operation. + * Possible status codes: + * |WifiStatusCode.SUCCESS|, + * |WifiStatusCode.ERROR_WIFI_IFACE_INVALID|, + * |WifiStatusCode.ERROR_NOT_SUPPORTED|, + * |WifiStatusCode.ERROR_NOT_AVAILABLE|, + * |WifiStatusCode.ERROR_UNKNOWN| + * @return frequencies vector of valid frequencies for the provided band. + */ + getValidFrequenciesForBand(WifiBand band) + generates (WifiStatus status, vec frequencies); }; diff --git a/wifi/1.0/IWifiStaIface.hal b/wifi/1.0/IWifiStaIface.hal index 96dc54a51e..43c312659e 100644 --- a/wifi/1.0/IWifiStaIface.hal +++ b/wifi/1.0/IWifiStaIface.hal @@ -180,7 +180,6 @@ interface IWifiStaIface extends IWifiIface { * for the provided band. These channels may be specifed in the * |BackgroundScanBucketParameters.frequenciesInMhz| for a background scan * request. - * Must fail if |StaIfaceCapabilityMask.BACKGROUND_SCAN| is not set. * * @param band Band for which the frequency list is being generated. * @return status WifiStatus of the operation. @@ -192,7 +191,7 @@ interface IWifiStaIface extends IWifiIface { * |WifiStatusCode.ERROR_UNKNOWN| * @return frequencies vector of valid frequencies for the provided band. */ - getValidFrequenciesForBackgroundScan(StaBackgroundScanBand band) + getValidFrequenciesForBand(WifiBand band) generates (WifiStatus status, vec frequencies); /** diff --git a/wifi/1.0/default/hidl_callback_util.h b/wifi/1.0/default/hidl_callback_util.h index a1c681987f..7136279503 100644 --- a/wifi/1.0/default/hidl_callback_util.h +++ b/wifi/1.0/default/hidl_callback_util.h @@ -82,14 +82,12 @@ class HidlCallbackHandler { return true; } - const std::set> getCallbacks() { - return cb_set_; - } + const std::set> getCallbacks() { return cb_set_; } // Death notification for callbacks. void onObjectDeath(uint64_t cookie) { - CallbackType *cb = reinterpret_cast(cookie); - const auto& iter = cb_set_.find(cb); + CallbackType* cb = reinterpret_cast(cookie); + const auto& iter = cb_set_.find(cb); if (iter == cb_set_.end()) { LOG(ERROR) << "Unknown callback death notification received"; return; diff --git a/wifi/1.0/default/hidl_struct_util.cpp b/wifi/1.0/default/hidl_struct_util.cpp index 7dbc8ebbed..c7b8c41315 100644 --- a/wifi/1.0/default/hidl_struct_util.cpp +++ b/wifi/1.0/default/hidl_struct_util.cpp @@ -306,21 +306,21 @@ bool convertLegacyGscanCapabilitiesToHidl( return true; } -legacy_hal::wifi_band convertHidlGscanBandToLegacy(StaBackgroundScanBand band) { +legacy_hal::wifi_band convertHidlWifiBandToLegacy(WifiBand band) { switch (band) { - case StaBackgroundScanBand::BAND_UNSPECIFIED: + case WifiBand::BAND_UNSPECIFIED: return legacy_hal::WIFI_BAND_UNSPECIFIED; - case StaBackgroundScanBand::BAND_24GHZ: + case WifiBand::BAND_24GHZ: return legacy_hal::WIFI_BAND_BG; - case StaBackgroundScanBand::BAND_5GHZ: + case WifiBand::BAND_5GHZ: return legacy_hal::WIFI_BAND_A; - case StaBackgroundScanBand::BAND_5GHZ_DFS: + case WifiBand::BAND_5GHZ_DFS: return legacy_hal::WIFI_BAND_A_DFS; - case StaBackgroundScanBand::BAND_5GHZ_WITH_DFS: + case WifiBand::BAND_5GHZ_WITH_DFS: return legacy_hal::WIFI_BAND_A_WITH_DFS; - case StaBackgroundScanBand::BAND_24GHZ_5GHZ: + case WifiBand::BAND_24GHZ_5GHZ: return legacy_hal::WIFI_BAND_ABG; - case StaBackgroundScanBand::BAND_24GHZ_5GHZ_WITH_DFS: + case WifiBand::BAND_24GHZ_5GHZ_WITH_DFS: return legacy_hal::WIFI_BAND_ABG_WITH_DFS; }; CHECK(false); diff --git a/wifi/1.0/default/hidl_struct_util.h b/wifi/1.0/default/hidl_struct_util.h index 490dcae3dc..41e97b3590 100644 --- a/wifi/1.0/default/hidl_struct_util.h +++ b/wifi/1.0/default/hidl_struct_util.h @@ -60,7 +60,7 @@ bool convertLegacyApfCapabilitiesToHidl( bool convertLegacyGscanCapabilitiesToHidl( const legacy_hal::wifi_gscan_capabilities& legacy_caps, StaBackgroundScanCapabilities* hidl_caps); -legacy_hal::wifi_band convertHidlGscanBandToLegacy(StaBackgroundScanBand band); +legacy_hal::wifi_band convertHidlWifiBandToLegacy(WifiBand band); bool convertHidlGscanParamsToLegacy( const StaBackgroundScanParameters& hidl_scan_params, legacy_hal::wifi_scan_cmd_params* legacy_scan_params); diff --git a/wifi/1.0/default/wifi_ap_iface.cpp b/wifi/1.0/default/wifi_ap_iface.cpp index 1a8b31db0a..e2beec2c62 100644 --- a/wifi/1.0/default/wifi_ap_iface.cpp +++ b/wifi/1.0/default/wifi_ap_iface.cpp @@ -17,6 +17,7 @@ #include #include "hidl_return_util.h" +#include "hidl_struct_util.h" #include "wifi_ap_iface.h" #include "wifi_status_util.h" @@ -64,6 +65,15 @@ Return WifiApIface::setCountryCode(const hidl_array& code, code); } +Return WifiApIface::getValidFrequenciesForBand( + WifiBand band, getValidFrequenciesForBand_cb hidl_status_cb) { + return validateAndCall(this, + WifiStatusCode::ERROR_WIFI_IFACE_INVALID, + &WifiApIface::getValidFrequenciesForBandInternal, + hidl_status_cb, + band); +} + std::pair WifiApIface::getNameInternal() { return {createWifiStatus(WifiStatusCode::SUCCESS), ifname_}; } @@ -79,6 +89,16 @@ WifiStatus WifiApIface::setCountryCodeInternal( return createWifiStatusFromLegacyError(legacy_status); } +std::pair> +WifiApIface::getValidFrequenciesForBandInternal(WifiBand band) { + static_assert(sizeof(WifiChannelInMhz) == sizeof(uint32_t), "Size mismatch"); + legacy_hal::wifi_error legacy_status; + std::vector valid_frequencies; + std::tie(legacy_status, valid_frequencies) = + legacy_hal_.lock()->getValidFrequenciesForBand( + hidl_struct_util::convertHidlWifiBandToLegacy(band)); + return {createWifiStatusFromLegacyError(legacy_status), valid_frequencies}; +} } // namespace implementation } // namespace V1_0 } // namespace wifi diff --git a/wifi/1.0/default/wifi_ap_iface.h b/wifi/1.0/default/wifi_ap_iface.h index 23d6435ea8..efc168a08a 100644 --- a/wifi/1.0/default/wifi_ap_iface.h +++ b/wifi/1.0/default/wifi_ap_iface.h @@ -44,12 +44,16 @@ class WifiApIface : public IWifiApIface { Return getType(getType_cb hidl_status_cb) override; Return setCountryCode(const hidl_array& code, setCountryCode_cb hidl_status_cb) override; + Return getValidFrequenciesForBand( + WifiBand band, getValidFrequenciesForBand_cb hidl_status_cb) override; private: // Corresponding worker functions for the HIDL methods. std::pair getNameInternal(); std::pair getTypeInternal(); WifiStatus setCountryCodeInternal(const std::array& code); + std::pair> + getValidFrequenciesForBandInternal(WifiBand band); std::string ifname_; std::weak_ptr legacy_hal_; diff --git a/wifi/1.0/default/wifi_legacy_hal.cpp b/wifi/1.0/default/wifi_legacy_hal.cpp index 7d58254aca..7390b65db9 100644 --- a/wifi/1.0/default/wifi_legacy_hal.cpp +++ b/wifi/1.0/default/wifi_legacy_hal.cpp @@ -562,7 +562,7 @@ wifi_error WifiLegacyHal::stopGscan(wifi_request_id id) { } std::pair> -WifiLegacyHal::getValidFrequenciesForGscan(wifi_band band) { +WifiLegacyHal::getValidFrequenciesForBand(wifi_band band) { static_assert(sizeof(uint32_t) >= sizeof(wifi_channel), "Wifi Channel cannot be represented in output"); std::vector freqs; diff --git a/wifi/1.0/default/wifi_legacy_hal.h b/wifi/1.0/default/wifi_legacy_hal.h index ed020b0389..c8fd5bdf58 100644 --- a/wifi/1.0/default/wifi_legacy_hal.h +++ b/wifi/1.0/default/wifi_legacy_hal.h @@ -175,7 +175,7 @@ class WifiLegacyHal { const on_gscan_results_callback& on_results_callback, const on_gscan_full_result_callback& on_full_result_callback); wifi_error stopGscan(wifi_request_id id); - std::pair> getValidFrequenciesForGscan( + std::pair> getValidFrequenciesForBand( wifi_band band); // Link layer stats functions. wifi_error enableLinkLayerStats(bool debug); diff --git a/wifi/1.0/default/wifi_sta_iface.cpp b/wifi/1.0/default/wifi_sta_iface.cpp index 55c9cf7062..0c8410269c 100644 --- a/wifi/1.0/default/wifi_sta_iface.cpp +++ b/wifi/1.0/default/wifi_sta_iface.cpp @@ -106,15 +106,13 @@ Return WifiStaIface::getBackgroundScanCapabilities( hidl_status_cb); } -Return WifiStaIface::getValidFrequenciesForBackgroundScan( - StaBackgroundScanBand band, - getValidFrequenciesForBackgroundScan_cb hidl_status_cb) { - return validateAndCall( - this, - WifiStatusCode::ERROR_WIFI_IFACE_INVALID, - &WifiStaIface::getValidFrequenciesForBackgroundScanInternal, - hidl_status_cb, - band); +Return WifiStaIface::getValidFrequenciesForBand( + WifiBand band, getValidFrequenciesForBand_cb hidl_status_cb) { + return validateAndCall(this, + WifiStatusCode::ERROR_WIFI_IFACE_INVALID, + &WifiStaIface::getValidFrequenciesForBandInternal, + hidl_status_cb, + band); } Return WifiStaIface::startBackgroundScan( @@ -363,14 +361,13 @@ WifiStaIface::getBackgroundScanCapabilitiesInternal() { } std::pair> -WifiStaIface::getValidFrequenciesForBackgroundScanInternal( - StaBackgroundScanBand band) { +WifiStaIface::getValidFrequenciesForBandInternal(WifiBand band) { static_assert(sizeof(WifiChannelInMhz) == sizeof(uint32_t), "Size mismatch"); legacy_hal::wifi_error legacy_status; std::vector valid_frequencies; std::tie(legacy_status, valid_frequencies) = - legacy_hal_.lock()->getValidFrequenciesForGscan( - hidl_struct_util::convertHidlGscanBandToLegacy(band)); + legacy_hal_.lock()->getValidFrequenciesForBand( + hidl_struct_util::convertHidlWifiBandToLegacy(band)); return {createWifiStatusFromLegacyError(legacy_status), valid_frequencies}; } diff --git a/wifi/1.0/default/wifi_sta_iface.h b/wifi/1.0/default/wifi_sta_iface.h index 5f0ffe9a2c..08faa2f1bb 100644 --- a/wifi/1.0/default/wifi_sta_iface.h +++ b/wifi/1.0/default/wifi_sta_iface.h @@ -57,9 +57,8 @@ class WifiStaIface : public IWifiStaIface { installApfPacketFilter_cb hidl_status_cb) override; Return getBackgroundScanCapabilities( getBackgroundScanCapabilities_cb hidl_status_cb) override; - Return getValidFrequenciesForBackgroundScan( - StaBackgroundScanBand band, - getValidFrequenciesForBackgroundScan_cb hidl_status_cb) override; + Return getValidFrequenciesForBand( + WifiBand band, getValidFrequenciesForBand_cb hidl_status_cb) override; Return startBackgroundScan( uint32_t cmd_id, const StaBackgroundScanParameters& params, @@ -119,7 +118,7 @@ class WifiStaIface : public IWifiStaIface { std::pair getBackgroundScanCapabilitiesInternal(); std::pair> - getValidFrequenciesForBackgroundScanInternal(StaBackgroundScanBand band); + getValidFrequenciesForBandInternal(WifiBand band); WifiStatus startBackgroundScanInternal( uint32_t cmd_id, const StaBackgroundScanParameters& params); WifiStatus stopBackgroundScanInternal(uint32_t cmd_id); diff --git a/wifi/1.0/types.hal b/wifi/1.0/types.hal index 30e8943f60..92164a1265 100644 --- a/wifi/1.0/types.hal +++ b/wifi/1.0/types.hal @@ -209,6 +209,37 @@ struct WifiRateInfo { uint32_t bitRateInKbps; }; +/** + * Wifi bands defined in 80211 spec. + */ +enum WifiBand : uint32_t { + BAND_UNSPECIFIED = 0, + /** + * 2.4 GHz. + */ + BAND_24GHZ = 1, + /** + * 5 GHz without DFS. + */ + BAND_5GHZ = 2, + /** + * 5 GHz DFS only. + */ + BAND_5GHZ_DFS = 4, + /** + * 5 GHz with DFS. + */ + BAND_5GHZ_WITH_DFS = 6, + /** + * 2.4 GHz + 5 GHz; no DFS. + */ + BAND_24GHZ_5GHZ = 3, + /** + * 2.4 GHz + 5 GHz with DFS + */ + BAND_24GHZ_5GHZ_WITH_DFS = 7 +}; + /** * STA specific types. * TODO(b/32159498): Move to a separate sta_types.hal. @@ -250,37 +281,6 @@ struct StaBackgroundScanCapabilities { int32_t maxReportingThreshold; }; -/** - * Bands that can be specified in Background scan requests. - */ -enum StaBackgroundScanBand : uint32_t { - BAND_UNSPECIFIED = 0, - /** - * 2.4 GHz. - */ - BAND_24GHZ = 1, - /** - * 5 GHz without DFS. - */ - BAND_5GHZ = 2, - /** - * 5 GHz DFS only. - */ - BAND_5GHZ_DFS = 4, - /** - * 5 GHz with DFS. - */ - BAND_5GHZ_WITH_DFS = 6, - /** - * 2.4 GHz + 5 GHz; no DFS. - */ - BAND_24GHZ_5GHZ = 3, - /** - * 2.4 GHz + 5 GHz with DFS - */ - BAND_24GHZ_5GHZ_WITH_DFS = 7 -}; - /** * Mask of event reporting schemes that can be specified in background scan * requests. @@ -311,12 +311,13 @@ enum StaBackgroundScanBucketEventReportSchemeMask : uint32_t { */ struct StaBackgroundScanBucketParameters { /** - * Bands to scan or 0 if frequencies list must be used instead. + * Bands to scan or |BAND_UNSPECIFIED| if frequencies list must be used + * instead. */ - StaBackgroundScanBand band; + WifiBand band; /** * Channel frequencies (in Mhz) to scan if |band| is set to - * |UNSPECIFIED|. + * |BAND_UNSPECIFIED|. */ vec frequencies; /**