Wifi: Add 6GHz bands to WifiBand

This commit adds 6GHz band to WifiBand and update the impacted
structures and methods in Wifi HAL.
Note that Background scar related HAL API will not be using the
new band, and will continue with the legacy set of bands.

Bug: 139354972
Test: Manual
Test: VTS test
Test: Unit test: ./hardware/interfaces/wifi/1.4/default/tests/runtests.sh
Change-Id: I54662251034806338ad64d4622ade259ca260a79
This commit is contained in:
Ahmed ElArabawy
2019-11-15 18:19:15 -08:00
parent 8cdfeb2c1f
commit fd809fcdfc
15 changed files with 320 additions and 53 deletions

View File

@@ -11,6 +11,7 @@ hidl_interface {
"IWifi.hal",
"IWifiApIface.hal",
"IWifiChip.hal",
"IWifiChipEventCallback.hal",
"IWifiRttController.hal",
"IWifiRttControllerEventCallback.hal",
"IWifiStaIface.hal",

View File

@@ -19,12 +19,29 @@ package android.hardware.wifi@1.4;
import @1.0::WifiStatus;
import @1.0::IWifiIface;
import @1.3::IWifiChip;
import IWifiChipEventCallback;
import IWifiRttController;
/**
* Interface that represents a chip that must be configured as a single unit.
*/
interface IWifiChip extends @1.3::IWifiChip {
/**
* Requests notifications of significant events on this chip. Multiple calls
* to this must register multiple callbacks each of which must receive all
* events.
*
* @param callback An instance of the |IWifiChipEventCallback| HIDL interface
* object.
* @return status WifiStatus of the operation.
* Possible status codes:
* |WifiStatusCode.SUCCESS|,
* |WifiStatusCode.ERROR_NOT_SUPPORTED|,
* |WifiStatusCode.ERROR_WIFI_CHIP_INVALID|
*/
registerEventCallback_1_4(IWifiChipEventCallback callback)
generates (WifiStatus status);
/**
* Create a RTTController instance.
*

View File

@@ -0,0 +1,65 @@
/*
* Copyright 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.hardware.wifi@1.4;
import @1.2::IWifiChipEventCallback;
import WifiBand;
/**
* Wifi chip event callbacks.
*/
interface IWifiChipEventCallback extends @1.2::IWifiChipEventCallback {
/**
* Struct describing the state of each hardware radio chain (hardware MAC)
* on the device.
*/
struct RadioModeInfo {
/**
* Identifier for this radio chain. This is vendor dependent & used
* only for debugging purposes.
*/
uint32_t radioId;
/**
* List of bands on which this radio chain is operating.
* Can be one of:
* a) WifiBand.BAND_24GHZ => 2.4Ghz.
* b) WifiBand.BAND_5GHZ => 5Ghz.
* c) WifiBand.BAND_24GHZ_5GHZ = 2.4Ghz + 5Ghz (Radio is time sharing
* across the 2 bands).
* d) WifiBand.BAND_6GHZ => 6Ghz.
* e) WifiBand.BAND_5GHZ_6GHZ => 5Ghz + 6Ghz (Radio is time sharing
* across the 2 bands).
* f) WifiBand.BAND_24GHZ_5GHZ_6GHZ => 2.4Ghz + 5Ghz + 6Ghz (Radio is
* time sharing across the 3 bands).
*/
WifiBand bandInfo;
/** List of interfaces on this radio chain (hardware MAC). */
vec<IfaceInfo> ifaceInfos;
};
/**
* Asynchronous callback indicating a radio mode change.
* Radio mode change could be a result of:
* a) Bringing up concurrent interfaces (For ex: STA + AP).
* b) Change in operating band of one of the concurrent interfaces (For ex:
* STA connection moved from 2.4G to 5G)
*
* @param radioModeInfos List of RadioModeInfo structures for each
* radio chain (hardware MAC) on the device.
*/
oneway onRadioModeChange_1_4(vec<RadioModeInfo> radioModeInfos);
};

View File

@@ -316,7 +316,7 @@ legacy_hal::wifi_latency_mode convertHidlLatencyModeToLegacy(
bool convertLegacyWifiMacInfoToHidl(
const legacy_hal::WifiMacInfo& legacy_mac_info,
V1_2::IWifiChipEventCallback::RadioModeInfo* hidl_radio_mode_info) {
IWifiChipEventCallback::RadioModeInfo* hidl_radio_mode_info) {
if (!hidl_radio_mode_info) {
return false;
}
@@ -325,8 +325,17 @@ bool convertLegacyWifiMacInfoToHidl(
hidl_radio_mode_info->radioId = legacy_mac_info.wlan_mac_id;
// Convert from bitmask of bands in the legacy HAL to enum value in
// the HIDL interface.
if (legacy_mac_info.mac_band & legacy_hal::WLAN_MAC_2_4_BAND &&
legacy_mac_info.mac_band & legacy_hal::WLAN_MAC_5_0_BAND) {
if (legacy_mac_info.mac_band & legacy_hal::WLAN_MAC_6_0_BAND &&
legacy_mac_info.mac_band & legacy_hal::WLAN_MAC_5_0_BAND &&
legacy_mac_info.mac_band & legacy_hal::WLAN_MAC_2_4_BAND) {
hidl_radio_mode_info->bandInfo = WifiBand::BAND_24GHZ_5GHZ_6GHZ;
} else if (legacy_mac_info.mac_band & legacy_hal::WLAN_MAC_6_0_BAND &&
legacy_mac_info.mac_band & legacy_hal::WLAN_MAC_5_0_BAND) {
hidl_radio_mode_info->bandInfo = WifiBand::BAND_5GHZ_6GHZ;
} else if (legacy_mac_info.mac_band & legacy_hal::WLAN_MAC_6_0_BAND) {
hidl_radio_mode_info->bandInfo = WifiBand::BAND_6GHZ;
} else if (legacy_mac_info.mac_band & legacy_hal::WLAN_MAC_2_4_BAND &&
legacy_mac_info.mac_band & legacy_hal::WLAN_MAC_5_0_BAND) {
hidl_radio_mode_info->bandInfo = WifiBand::BAND_24GHZ_5GHZ;
} else if (legacy_mac_info.mac_band & legacy_hal::WLAN_MAC_2_4_BAND) {
hidl_radio_mode_info->bandInfo = WifiBand::BAND_24GHZ;
@@ -348,15 +357,14 @@ bool convertLegacyWifiMacInfoToHidl(
bool convertLegacyWifiMacInfosToHidl(
const std::vector<legacy_hal::WifiMacInfo>& legacy_mac_infos,
std::vector<V1_2::IWifiChipEventCallback::RadioModeInfo>*
hidl_radio_mode_infos) {
std::vector<IWifiChipEventCallback::RadioModeInfo>* hidl_radio_mode_infos) {
if (!hidl_radio_mode_infos) {
return false;
}
*hidl_radio_mode_infos = {};
for (const auto& legacy_mac_info : legacy_mac_infos) {
V1_2::IWifiChipEventCallback::RadioModeInfo hidl_radio_mode_info;
IWifiChipEventCallback::RadioModeInfo hidl_radio_mode_info;
if (!convertLegacyWifiMacInfoToHidl(legacy_mac_info,
&hidl_radio_mode_info)) {
return false;
@@ -449,21 +457,21 @@ bool convertLegacyGscanCapabilitiesToHidl(
return true;
}
legacy_hal::wifi_band convertHidlWifiBandToLegacy(WifiBand band) {
legacy_hal::wifi_band convertHidlWifiBandToLegacy(V1_0::WifiBand band) {
switch (band) {
case WifiBand::BAND_UNSPECIFIED:
case V1_0::WifiBand::BAND_UNSPECIFIED:
return legacy_hal::WIFI_BAND_UNSPECIFIED;
case WifiBand::BAND_24GHZ:
case V1_0::WifiBand::BAND_24GHZ:
return legacy_hal::WIFI_BAND_BG;
case WifiBand::BAND_5GHZ:
case V1_0::WifiBand::BAND_5GHZ:
return legacy_hal::WIFI_BAND_A;
case WifiBand::BAND_5GHZ_DFS:
case V1_0::WifiBand::BAND_5GHZ_DFS:
return legacy_hal::WIFI_BAND_A_DFS;
case WifiBand::BAND_5GHZ_WITH_DFS:
case V1_0::WifiBand::BAND_5GHZ_WITH_DFS:
return legacy_hal::WIFI_BAND_A_WITH_DFS;
case WifiBand::BAND_24GHZ_5GHZ:
case V1_0::WifiBand::BAND_24GHZ_5GHZ:
return legacy_hal::WIFI_BAND_ABG;
case WifiBand::BAND_24GHZ_5GHZ_WITH_DFS:
case V1_0::WifiBand::BAND_24GHZ_5GHZ_WITH_DFS:
return legacy_hal::WIFI_BAND_ABG_WITH_DFS;
};
CHECK(false);

View File

@@ -21,10 +21,10 @@
#include <android/hardware/wifi/1.0/IWifiChip.h>
#include <android/hardware/wifi/1.0/types.h>
#include <android/hardware/wifi/1.2/IWifiChipEventCallback.h>
#include <android/hardware/wifi/1.2/types.h>
#include <android/hardware/wifi/1.3/IWifiChip.h>
#include <android/hardware/wifi/1.3/types.h>
#include <android/hardware/wifi/1.4/IWifiChipEventCallback.h>
#include <android/hardware/wifi/1.4/IWifiStaIface.h>
#include <android/hardware/wifi/1.4/types.h>
@@ -65,8 +65,7 @@ legacy_hal::wifi_power_scenario convertHidlTxPowerScenarioToLegacy_1_2(
V1_2::IWifiChip::TxPowerScenario hidl_scenario);
bool convertLegacyWifiMacInfosToHidl(
const std::vector<legacy_hal::WifiMacInfo>& legacy_mac_infos,
std::vector<V1_2::IWifiChipEventCallback::RadioModeInfo>*
hidl_radio_mode_infos);
std::vector<IWifiChipEventCallback::RadioModeInfo>* hidl_radio_mode_infos);
// STA iface conversion methods.
bool convertLegacyFeaturesToHidlStaCapabilities(
@@ -78,7 +77,7 @@ bool convertLegacyApfCapabilitiesToHidl(
bool convertLegacyGscanCapabilitiesToHidl(
const legacy_hal::wifi_gscan_capabilities& legacy_caps,
StaBackgroundScanCapabilities* hidl_caps);
legacy_hal::wifi_band convertHidlWifiBandToLegacy(WifiBand band);
legacy_hal::wifi_band convertHidlWifiBandToLegacy(V1_0::WifiBand band);
bool convertHidlGscanParamsToLegacy(
const StaBackgroundScanParameters& hidl_scan_params,
legacy_hal::wifi_scan_cmd_params* legacy_scan_params);

View File

@@ -55,8 +55,7 @@ TEST_F(HidlStructUtilTest, CanConvertLegacyWifiMacInfosToHidlWithOneMac) {
legacy_mac_info1.iface_infos.push_back(legacy_iface_info2);
legacy_mac_infos.push_back(legacy_mac_info1);
std::vector<V1_2::IWifiChipEventCallback::RadioModeInfo>
hidl_radio_mode_infos;
std::vector<IWifiChipEventCallback::RadioModeInfo> hidl_radio_mode_infos;
ASSERT_TRUE(hidl_struct_util::convertLegacyWifiMacInfosToHidl(
legacy_mac_infos, &hidl_radio_mode_infos));
@@ -90,20 +89,18 @@ TEST_F(HidlStructUtilTest, CanConvertLegacyWifiMacInfosToHidlWithTwoMac) {
legacy_mac_info2.iface_infos.push_back(legacy_iface_info2);
legacy_mac_infos.push_back(legacy_mac_info2);
std::vector<V1_2::IWifiChipEventCallback::RadioModeInfo>
hidl_radio_mode_infos;
std::vector<IWifiChipEventCallback::RadioModeInfo> hidl_radio_mode_infos;
ASSERT_TRUE(hidl_struct_util::convertLegacyWifiMacInfosToHidl(
legacy_mac_infos, &hidl_radio_mode_infos));
ASSERT_EQ(2u, hidl_radio_mode_infos.size());
// Find mac info 1.
const auto hidl_radio_mode_info1 =
std::find_if(hidl_radio_mode_infos.begin(), hidl_radio_mode_infos.end(),
[&legacy_mac_info1](
const V1_2::IWifiChipEventCallback::RadioModeInfo& x) {
return x.radioId == legacy_mac_info1.wlan_mac_id;
});
const auto hidl_radio_mode_info1 = std::find_if(
hidl_radio_mode_infos.begin(), hidl_radio_mode_infos.end(),
[&legacy_mac_info1](const IWifiChipEventCallback::RadioModeInfo& x) {
return x.radioId == legacy_mac_info1.wlan_mac_id;
});
ASSERT_NE(hidl_radio_mode_infos.end(), hidl_radio_mode_info1);
EXPECT_EQ(WifiBand::BAND_5GHZ, hidl_radio_mode_info1->bandInfo);
ASSERT_EQ(1u, hidl_radio_mode_info1->ifaceInfos.size());
@@ -113,12 +110,11 @@ TEST_F(HidlStructUtilTest, CanConvertLegacyWifiMacInfosToHidlWithTwoMac) {
hidl_iface_info1.channel);
// Find mac info 2.
const auto hidl_radio_mode_info2 =
std::find_if(hidl_radio_mode_infos.begin(), hidl_radio_mode_infos.end(),
[&legacy_mac_info2](
const V1_2::IWifiChipEventCallback::RadioModeInfo& x) {
return x.radioId == legacy_mac_info2.wlan_mac_id;
});
const auto hidl_radio_mode_info2 = std::find_if(
hidl_radio_mode_infos.begin(), hidl_radio_mode_infos.end(),
[&legacy_mac_info2](const IWifiChipEventCallback::RadioModeInfo& x) {
return x.radioId == legacy_mac_info2.wlan_mac_id;
});
ASSERT_NE(hidl_radio_mode_infos.end(), hidl_radio_mode_info2);
EXPECT_EQ(WifiBand::BAND_24GHZ, hidl_radio_mode_info2->bandInfo);
ASSERT_EQ(1u, hidl_radio_mode_info2->ifaceInfos.size());

View File

@@ -64,7 +64,7 @@ Return<void> WifiApIface::setCountryCode(const hidl_array<int8_t, 2>& code,
}
Return<void> WifiApIface::getValidFrequenciesForBand(
WifiBand band, getValidFrequenciesForBand_cb hidl_status_cb) {
V1_0::WifiBand band, getValidFrequenciesForBand_cb hidl_status_cb) {
return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
&WifiApIface::getValidFrequenciesForBandInternal,
hidl_status_cb, band);
@@ -100,7 +100,7 @@ WifiStatus WifiApIface::setCountryCodeInternal(
}
std::pair<WifiStatus, std::vector<WifiChannelInMhz>>
WifiApIface::getValidFrequenciesForBandInternal(WifiBand band) {
WifiApIface::getValidFrequenciesForBandInternal(V1_0::WifiBand band) {
static_assert(sizeof(WifiChannelInMhz) == sizeof(uint32_t),
"Size mismatch");
legacy_hal::wifi_error legacy_status;

View File

@@ -49,7 +49,8 @@ class WifiApIface : public V1_4::IWifiApIface {
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;
V1_0::WifiBand band,
getValidFrequenciesForBand_cb hidl_status_cb) override;
Return<void> setMacAddress(const hidl_array<uint8_t, 6>& mac,
setMacAddress_cb hidl_status_cb) override;
Return<void> getFactoryMacAddress(
@@ -61,7 +62,7 @@ class WifiApIface : public V1_4::IWifiApIface {
std::pair<WifiStatus, IfaceType> getTypeInternal();
WifiStatus setCountryCodeInternal(const std::array<int8_t, 2>& code);
std::pair<WifiStatus, std::vector<WifiChannelInMhz>>
getValidFrequenciesForBandInternal(WifiBand band);
getValidFrequenciesForBandInternal(V1_0::WifiBand band);
WifiStatus setMacAddressInternal(const std::array<uint8_t, 6>& mac);
std::pair<WifiStatus, std::array<uint8_t, 6>>
getFactoryMacAddressInternal();

View File

@@ -341,7 +341,7 @@ void WifiChip::invalidate() {
bool WifiChip::isValid() { return is_valid_; }
std::set<sp<V1_2::IWifiChipEventCallback>> WifiChip::getEventCallbacks() {
std::set<sp<IWifiChipEventCallback>> WifiChip::getEventCallbacks() {
return event_cb_handler_.getCallbacks();
}
@@ -628,6 +628,14 @@ Return<void> WifiChip::createRttController_1_4(
hidl_status_cb, bound_iface);
}
Return<void> WifiChip::registerEventCallback_1_4(
const sp<IWifiChipEventCallback>& event_callback,
registerEventCallback_cb hidl_status_cb) {
return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
&WifiChip::registerEventCallbackInternal_1_4,
hidl_status_cb, event_callback);
}
void WifiChip::invalidateAndRemoveAllIfaces() {
invalidateAndClearAll(ap_ifaces_);
invalidateAndClearAll(nan_ifaces_);
@@ -1125,11 +1133,9 @@ WifiStatus WifiChip::setLatencyModeInternal(LatencyMode mode) {
}
WifiStatus WifiChip::registerEventCallbackInternal_1_2(
const sp<V1_2::IWifiChipEventCallback>& event_callback) {
if (!event_cb_handler_.addCallback(event_callback)) {
return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN);
}
return createWifiStatus(WifiStatusCode::SUCCESS);
const sp<V1_2::IWifiChipEventCallback>& /* event_callback */) {
// Deprecated support for this callback.
return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED);
}
WifiStatus WifiChip::selectTxPowerScenarioInternal_1_2(
@@ -1179,6 +1185,14 @@ WifiChip::createRttControllerInternal_1_4(const sp<IWifiIface>& bound_iface) {
return {createWifiStatus(WifiStatusCode::SUCCESS), rtt};
}
WifiStatus WifiChip::registerEventCallbackInternal_1_4(
const sp<IWifiChipEventCallback>& event_callback) {
if (!event_cb_handler_.addCallback(event_callback)) {
return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN);
}
return createWifiStatus(WifiStatusCode::SUCCESS);
}
WifiStatus WifiChip::handleChipConfiguration(
/* NONNULL */ std::unique_lock<std::recursive_mutex>* lock,
ChipModeId mode_id) {
@@ -1281,7 +1295,7 @@ WifiStatus WifiChip::registerRadioModeChangeCallback() {
LOG(ERROR) << "Callback invoked on an invalid object";
return;
}
std::vector<V1_2::IWifiChipEventCallback::RadioModeInfo>
std::vector<IWifiChipEventCallback::RadioModeInfo>
hidl_radio_mode_infos;
if (!hidl_struct_util::convertLegacyWifiMacInfosToHidl(
mac_infos, &hidl_radio_mode_infos)) {
@@ -1289,9 +1303,9 @@ WifiStatus WifiChip::registerRadioModeChangeCallback() {
return;
}
for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
if (!callback->onRadioModeChange(hidl_radio_mode_infos)
if (!callback->onRadioModeChange_1_4(hidl_radio_mode_infos)
.isOk()) {
LOG(ERROR) << "Failed to invoke onRadioModeChange"
LOG(ERROR) << "Failed to invoke onRadioModeChange_1_4"
<< " callback on: " << toString(callback);
}
}

View File

@@ -71,7 +71,7 @@ class WifiChip : public V1_4::IWifiChip {
// marked valid before processing them.
void invalidate();
bool isValid();
std::set<sp<V1_2::IWifiChipEventCallback>> getEventCallbacks();
std::set<sp<IWifiChipEventCallback>> getEventCallbacks();
// HIDL methods exposed.
Return<void> getId(getId_cb hidl_status_cb) override;
@@ -156,6 +156,9 @@ class WifiChip : public V1_4::IWifiChip {
Return<void> createRttController_1_4(
const sp<IWifiIface>& bound_iface,
createRttController_1_4_cb hidl_status_cb) override;
Return<void> registerEventCallback_1_4(
const sp<IWifiChipEventCallback>& event_callback,
registerEventCallback_1_4_cb hidl_status_cb) override;
private:
void invalidateAndRemoveAllIfaces();
@@ -223,6 +226,9 @@ class WifiChip : public V1_4::IWifiChip {
std::pair<WifiStatus, uint32_t> getCapabilitiesInternal_1_3();
std::pair<WifiStatus, sp<IWifiRttController>>
createRttControllerInternal_1_4(const sp<IWifiIface>& bound_iface);
WifiStatus registerEventCallbackInternal_1_4(
const sp<IWifiChipEventCallback>& event_callback);
WifiStatus handleChipConfiguration(
std::unique_lock<std::recursive_mutex>* lock, ChipModeId mode_id);
WifiStatus registerDebugRingBufferCallback();
@@ -271,7 +277,7 @@ class WifiChip : public V1_4::IWifiChip {
// registration mechanism. Use this to check if we have already
// registered a callback.
bool debug_ring_buffer_cb_registered_;
hidl_callback_util::HidlCallbackHandler<V1_2::IWifiChipEventCallback>
hidl_callback_util::HidlCallbackHandler<IWifiChipEventCallback>
event_cb_handler_;
DISALLOW_COPY_AND_ASSIGN(WifiChip);

View File

@@ -113,7 +113,7 @@ Return<void> WifiStaIface::getBackgroundScanCapabilities(
}
Return<void> WifiStaIface::getValidFrequenciesForBand(
WifiBand band, getValidFrequenciesForBand_cb hidl_status_cb) {
V1_0::WifiBand band, getValidFrequenciesForBand_cb hidl_status_cb) {
return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
&WifiStaIface::getValidFrequenciesForBandInternal,
hidl_status_cb, band);
@@ -344,7 +344,7 @@ WifiStaIface::getBackgroundScanCapabilitiesInternal() {
}
std::pair<WifiStatus, std::vector<WifiChannelInMhz>>
WifiStaIface::getValidFrequenciesForBandInternal(WifiBand band) {
WifiStaIface::getValidFrequenciesForBandInternal(V1_0::WifiBand band) {
static_assert(sizeof(WifiChannelInMhz) == sizeof(uint32_t),
"Size mismatch");
legacy_hal::wifi_error legacy_status;

View File

@@ -63,7 +63,8 @@ class WifiStaIface : public V1_4::IWifiStaIface {
Return<void> getBackgroundScanCapabilities(
getBackgroundScanCapabilities_cb hidl_status_cb) override;
Return<void> getValidFrequenciesForBand(
WifiBand band, getValidFrequenciesForBand_cb hidl_status_cb) override;
V1_0::WifiBand band,
getValidFrequenciesForBand_cb hidl_status_cb) override;
Return<void> startBackgroundScan(
uint32_t cmd_id, const StaBackgroundScanParameters& params,
startBackgroundScan_cb hidl_status_cb) override;
@@ -130,7 +131,7 @@ class WifiStaIface : public V1_4::IWifiStaIface {
std::pair<WifiStatus, StaBackgroundScanCapabilities>
getBackgroundScanCapabilitiesInternal();
std::pair<WifiStatus, std::vector<WifiChannelInMhz>>
getValidFrequenciesForBandInternal(WifiBand band);
getValidFrequenciesForBandInternal(V1_0::WifiBand band);
WifiStatus startBackgroundScanInternal(
uint32_t cmd_id, const StaBackgroundScanParameters& params);
WifiStatus stopBackgroundScanInternal(uint32_t cmd_id);

View File

@@ -26,12 +26,35 @@ import @1.0::RttStatus;
import @1.0::RttType;
import @1.0::TimeSpanInPs;
import @1.0::TimeStampInUs;
import @1.0::WifiBand;
import @1.0::WifiChannelInfo;
import @1.0::WifiChannelWidthInMhz;
import @1.0::WifiInformationElement;
import @1.0::WifiRateNss;
import @1.0::WifiRatePreamble;
/**
* Wifi bands defined in 80211 spec.
*/
enum WifiBand : @1.0::WifiBand {
/**
* 6 GHz.
*/
BAND_6GHZ = 8,
/**
* 5 GHz no DFS + 6 GHz.
*/
BAND_5GHZ_6GHZ = 10,
/**
* 2.4 GHz + 5 GHz no DFS + 6 GHz.
*/
BAND_24GHZ_5GHZ_6GHZ = 11,
/**
* 2.4 GHz + 5 GHz with DFS + 6 GHz.
*/
BAND_24GHZ_5GHZ_WITH_DFS_6GHZ = 15
};
/**
* Wifi Rate Preamble
*/

View File

@@ -21,6 +21,7 @@ cc_test {
srcs: [
"VtsHalWifiV1_4TargetTest.cpp",
"wifi_ap_iface_hidl_test.cpp",
"wifi_chip_hidl_test.cpp"
],
static_libs: [
"VtsHalWifiV1_0TargetTestUtil",

View File

@@ -0,0 +1,135 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <VtsHalHidlTargetCallbackBase.h>
#include <android-base/logging.h>
#undef NAN // NAN is defined in bionic/libc/include/math.h:38
#include <android/hardware/wifi/1.4/IWifi.h>
#include <android/hardware/wifi/1.4/IWifiChip.h>
#include <android/hardware/wifi/1.4/IWifiChipEventCallback.h>
#include <gtest/gtest.h>
#include <hidl/GtestPrinter.h>
#include <hidl/ServiceManagement.h>
#include "wifi_hidl_call_util.h"
#include "wifi_hidl_test_utils.h"
using ::android::sp;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::hardware::wifi::V1_0::IfaceType;
using ::android::hardware::wifi::V1_0::WifiDebugRingBufferStatus;
using ::android::hardware::wifi::V1_0::WifiStatus;
using ::android::hardware::wifi::V1_0::WifiStatusCode;
using ::android::hardware::wifi::V1_4::IWifiChip;
using ::android::hardware::wifi::V1_4::IWifiChipEventCallback;
/**
* Fixture to use for all Wifi chip HIDL interface tests.
*/
class WifiChipHidlTest : public ::testing::TestWithParam<std::string> {
public:
virtual void SetUp() override {
wifi_chip_ = IWifiChip::castFrom(getWifiChip(GetInstanceName()));
ASSERT_NE(nullptr, wifi_chip_.get());
}
virtual void TearDown() override { stopWifi(GetInstanceName()); }
// A simple test implementation of WifiChipEventCallback.
class WifiChipEventCallback
: public ::testing::VtsHalHidlTargetCallbackBase<WifiChipHidlTest>,
public IWifiChipEventCallback {
public:
WifiChipEventCallback(){};
virtual ~WifiChipEventCallback() = default;
Return<void> onChipReconfigured(uint32_t modeId __unused) {
return Void();
};
Return<void> onChipReconfigureFailure(
const WifiStatus& status __unused) {
return Void();
};
Return<void> onIfaceAdded(IfaceType type __unused,
const hidl_string& name __unused) {
return Void();
};
Return<void> onIfaceRemoved(IfaceType type __unused,
const hidl_string& name __unused) {
return Void();
};
Return<void> onDebugRingBufferDataAvailable(
const WifiDebugRingBufferStatus& status __unused,
const hidl_vec<uint8_t>& data __unused) {
return Void();
};
Return<void> onDebugErrorAlert(int32_t errorCode __unused,
const hidl_vec<uint8_t>& debugData
__unused) {
return Void();
};
Return<void> onRadioModeChange(
const hidl_vec<::android::hardware::wifi::V1_2::
IWifiChipEventCallback::RadioModeInfo>&
radioModeInfos __unused) {
return Void();
};
Return<void> onRadioModeChange_1_4(
const hidl_vec<RadioModeInfo>& radioModeInfos __unused) {
return Void();
};
};
protected:
sp<IWifiChip> wifi_chip_;
private:
std::string GetInstanceName() { return GetParam(); }
};
/*
* registerEventCallback_1_4
* This test case tests the registerEventCallback_1_4() API which registers
* a call back function with the hal implementation
*
* Note: it is not feasible to test the invocation of the call back function
* since event is triggered internally in the HAL implementation, and can not be
* triggered from the test case
*/
TEST_P(WifiChipHidlTest, registerEventCallback_1_4) {
sp<WifiChipEventCallback> wifiChipEventCallback =
new WifiChipEventCallback();
const auto& status = HIDL_INVOKE(wifi_chip_, registerEventCallback_1_4,
wifiChipEventCallback);
if (status.code != WifiStatusCode::SUCCESS) {
EXPECT_EQ(WifiStatusCode::ERROR_NOT_SUPPORTED, status.code);
return;
}
}