Skip wifi AP tests, if AP feature is not supported am: 6eab68a9e6 am: 7d5727bf65 am: 1c2d61fa57 am: 5c5332f235

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2740896

Change-Id: I18bfb07e81754cd2c7f8bb2fbaed8fab300d4cf5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Nethaji B 2023-09-06 19:38:08 +00:00 committed by Automerger Merge Worker
commit 0e87a271ea
3 changed files with 33 additions and 0 deletions

View file

@ -89,6 +89,24 @@ bool configureChipToSupportIfaceTypeInternal(const sp<IWifiChip>& wifi_chip,
ChipModeId mode_id;
return configureChipToSupportIfaceTypeInternal(wifi_chip, type, &mode_id);
}
bool doesChipSupportIfaceTypeInternal(const sp<IWifiChip>& wifi_chip,
IfaceType type) {
ChipModeId mode_id;
if (!wifi_chip.get()) {
return false;
}
const auto& status_and_modes = HIDL_INVOKE(wifi_chip, getAvailableModes);
if (status_and_modes.first.code != WifiStatusCode::SUCCESS) {
return false;
}
if (!findAnyModeSupportingIfaceType(type, status_and_modes.second,
&mode_id)) {
return false;
}
return true;
}
} // namespace
sp<IWifi> getWifi(const std::string& instance_name) {
@ -205,6 +223,11 @@ bool configureChipToSupportIfaceType(const sp<IWifiChip>& wifi_chip,
configured_mode_id);
}
bool doesChipSupportIfaceType(const sp<IWifiChip>& wifi_chip,
IfaceType type) {
return doesChipSupportIfaceTypeInternal(wifi_chip, type);
}
void stopWifi(const std::string& instance_name) {
sp<IWifi> wifi = IWifi::getService(instance_name);
ASSERT_NE(wifi, nullptr);

View file

@ -49,6 +49,10 @@ bool configureChipToSupportIfaceType(
const android::sp<android::hardware::wifi::V1_0::IWifiChip>& wifi_chip,
android::hardware::wifi::V1_0::IfaceType type,
android::hardware::wifi::V1_0::ChipModeId* configured_mode_id);
// Check whether wifi chip supports given interface type mode
bool doesChipSupportIfaceType(
const android::sp<android::hardware::wifi::V1_0::IWifiChip>& wifi_chip,
android::hardware::wifi::V1_0::IfaceType type);
// Used to trigger IWifi.stop() at the end of every test.
void stopWifi(const std::string& instance_name);
uint32_t getChipCapabilitiesLatest(

View file

@ -58,12 +58,16 @@ class WifiApIfaceHidlTest : public ::testing::TestWithParam<std::string> {
"wifi_softap_bridged_ap_supported");
// Make sure to start with a clean state
stopWifi(GetInstanceName());
// Read AP mode capabilities from the wifi chip modes
sp<IWifiChip> wifi_chip_ = getWifiChip_1_5(GetInstanceName());
isApModeSupport_ = doesChipSupportIfaceType(wifi_chip_, IfaceType::AP);
}
virtual void TearDown() override { stopWifi(GetInstanceName()); }
protected:
bool isBridgedSupport_ = false;
bool isApModeSupport_ = false;
std::string GetInstanceName() { return GetParam(); }
};
@ -83,6 +87,7 @@ TEST_P(WifiApIfaceHidlTest, resetToFactoryMacAddressInBridgedModeTest) {
* resetToFactoryMacAddress in non-bridged mode
*/
TEST_P(WifiApIfaceHidlTest, resetToFactoryMacAddressTest) {
if (!isApModeSupport_) GTEST_SKIP() << "Missing AP support";
sp<IWifiApIface> wifi_ap_iface = getWifiApIface_1_5(GetInstanceName());
ASSERT_NE(nullptr, wifi_ap_iface.get());
const auto& status = HIDL_INVOKE(wifi_ap_iface, resetToFactoryMacAddress);
@ -93,6 +98,7 @@ TEST_P(WifiApIfaceHidlTest, resetToFactoryMacAddressTest) {
* getBridgedInstances in non-bridged mode
*/
TEST_P(WifiApIfaceHidlTest, getBridgedInstancesTest) {
if (!isApModeSupport_) GTEST_SKIP() << "Missing AP support";
sp<IWifiApIface> wifi_ap_iface = getWifiApIface_1_5(GetInstanceName());
ASSERT_NE(nullptr, wifi_ap_iface.get());
const auto& status_and_instances =