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
This commit is contained in:
Roshan Pius 2017-02-22 09:48:03 -08:00
parent e54bcaee0b
commit 7f4574d2a1
13 changed files with 142 additions and 107 deletions

View file

@ -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)
#

View file

@ -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<WifiChannelInMhz> frequencies);
};

View file

@ -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<WifiChannelInMhz> frequencies);
/**

View file

@ -82,9 +82,7 @@ class HidlCallbackHandler {
return true;
}
const std::set<android::sp<CallbackType>> getCallbacks() {
return cb_set_;
}
const std::set<android::sp<CallbackType>> getCallbacks() { return cb_set_; }
// Death notification for callbacks.
void onObjectDeath(uint64_t cookie) {

View file

@ -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);

View file

@ -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);

View file

@ -17,6 +17,7 @@
#include <android-base/logging.h>
#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<void> WifiApIface::setCountryCode(const hidl_array<int8_t, 2>& code,
code);
}
Return<void> 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<WifiStatus, std::string> WifiApIface::getNameInternal() {
return {createWifiStatus(WifiStatusCode::SUCCESS), ifname_};
}
@ -79,6 +89,16 @@ WifiStatus WifiApIface::setCountryCodeInternal(
return createWifiStatusFromLegacyError(legacy_status);
}
std::pair<WifiStatus, std::vector<WifiChannelInMhz>>
WifiApIface::getValidFrequenciesForBandInternal(WifiBand band) {
static_assert(sizeof(WifiChannelInMhz) == sizeof(uint32_t), "Size mismatch");
legacy_hal::wifi_error legacy_status;
std::vector<uint32_t> 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

View file

@ -44,12 +44,16 @@ class WifiApIface : public IWifiApIface {
Return<void> getType(getType_cb hidl_status_cb) override;
Return<void> setCountryCode(const hidl_array<int8_t, 2>& code,
setCountryCode_cb hidl_status_cb) override;
Return<void> getValidFrequenciesForBand(
WifiBand band, getValidFrequenciesForBand_cb hidl_status_cb) override;
private:
// Corresponding worker functions for the HIDL methods.
std::pair<WifiStatus, std::string> getNameInternal();
std::pair<WifiStatus, IfaceType> getTypeInternal();
WifiStatus setCountryCodeInternal(const std::array<int8_t, 2>& code);
std::pair<WifiStatus, std::vector<WifiChannelInMhz>>
getValidFrequenciesForBandInternal(WifiBand band);
std::string ifname_;
std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;

View file

@ -562,7 +562,7 @@ wifi_error WifiLegacyHal::stopGscan(wifi_request_id id) {
}
std::pair<wifi_error, std::vector<uint32_t>>
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<uint32_t> freqs;

View file

@ -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<wifi_error, std::vector<uint32_t>> getValidFrequenciesForGscan(
std::pair<wifi_error, std::vector<uint32_t>> getValidFrequenciesForBand(
wifi_band band);
// Link layer stats functions.
wifi_error enableLinkLayerStats(bool debug);

View file

@ -106,13 +106,11 @@ Return<void> WifiStaIface::getBackgroundScanCapabilities(
hidl_status_cb);
}
Return<void> WifiStaIface::getValidFrequenciesForBackgroundScan(
StaBackgroundScanBand band,
getValidFrequenciesForBackgroundScan_cb hidl_status_cb) {
return validateAndCall(
this,
Return<void> WifiStaIface::getValidFrequenciesForBand(
WifiBand band, getValidFrequenciesForBand_cb hidl_status_cb) {
return validateAndCall(this,
WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
&WifiStaIface::getValidFrequenciesForBackgroundScanInternal,
&WifiStaIface::getValidFrequenciesForBandInternal,
hidl_status_cb,
band);
}
@ -363,14 +361,13 @@ WifiStaIface::getBackgroundScanCapabilitiesInternal() {
}
std::pair<WifiStatus, std::vector<WifiChannelInMhz>>
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<uint32_t> 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};
}

View file

@ -57,9 +57,8 @@ class WifiStaIface : public IWifiStaIface {
installApfPacketFilter_cb hidl_status_cb) override;
Return<void> getBackgroundScanCapabilities(
getBackgroundScanCapabilities_cb hidl_status_cb) override;
Return<void> getValidFrequenciesForBackgroundScan(
StaBackgroundScanBand band,
getValidFrequenciesForBackgroundScan_cb hidl_status_cb) override;
Return<void> getValidFrequenciesForBand(
WifiBand band, getValidFrequenciesForBand_cb hidl_status_cb) override;
Return<void> startBackgroundScan(
uint32_t cmd_id,
const StaBackgroundScanParameters& params,
@ -119,7 +118,7 @@ class WifiStaIface : public IWifiStaIface {
std::pair<WifiStatus, StaBackgroundScanCapabilities>
getBackgroundScanCapabilitiesInternal();
std::pair<WifiStatus, std::vector<WifiChannelInMhz>>
getValidFrequenciesForBackgroundScanInternal(StaBackgroundScanBand band);
getValidFrequenciesForBandInternal(WifiBand band);
WifiStatus startBackgroundScanInternal(
uint32_t cmd_id, const StaBackgroundScanParameters& params);
WifiStatus stopBackgroundScanInternal(uint32_t cmd_id);

View file

@ -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<WifiChannelInMhz> frequencies;
/**