Merge "Fixed VEHICLE_CURB_WEIGHT property" into tm-qpr-dev
diff --git a/audio/common/all-versions/default/7.0/HidlUtils.cpp b/audio/common/all-versions/default/7.0/HidlUtils.cpp
index 0fd2947..f89c898 100644
--- a/audio/common/all-versions/default/7.0/HidlUtils.cpp
+++ b/audio/common/all-versions/default/7.0/HidlUtils.cpp
@@ -898,7 +898,7 @@
for (const auto& transport : transports) {
switch (transport.audioCapability.getDiscriminator()) {
case AudioTransport::AudioCapability::hidl_discriminator::profile:
- if (halPort->num_audio_profiles > AUDIO_PORT_MAX_AUDIO_PROFILES) {
+ if (halPort->num_audio_profiles >= AUDIO_PORT_MAX_AUDIO_PROFILES) {
ALOGE("%s, too many audio profiles", __func__);
result = BAD_VALUE;
break;
@@ -914,7 +914,8 @@
result);
break;
case AudioTransport::AudioCapability::hidl_discriminator::edid:
- if (halPort->num_extra_audio_descriptors > AUDIO_PORT_MAX_EXTRA_AUDIO_DESCRIPTORS) {
+ if (halPort->num_extra_audio_descriptors >=
+ AUDIO_PORT_MAX_EXTRA_AUDIO_DESCRIPTORS) {
ALOGE("%s, too many extra audio descriptors", __func__);
result = BAD_VALUE;
break;
diff --git a/audio/common/all-versions/default/tests/hidlutils_tests.cpp b/audio/common/all-versions/default/tests/hidlutils_tests.cpp
index ec16b02..e6e2280 100644
--- a/audio/common/all-versions/default/tests/hidlutils_tests.cpp
+++ b/audio/common/all-versions/default/tests/hidlutils_tests.cpp
@@ -954,6 +954,18 @@
EXPECT_TRUE(audio_port_configs_are_equal(&halConfig, &halConfigBack));
}
+static AudioProfile generateValidAudioProfile() {
+ AudioProfile profile;
+ profile.format = toString(xsd::AudioFormat::AUDIO_FORMAT_PCM_16_BIT);
+ profile.sampleRates.resize(2);
+ profile.sampleRates[0] = 44100;
+ profile.sampleRates[1] = 48000;
+ profile.channelMasks.resize(2);
+ profile.channelMasks[0] = toString(xsd::AudioChannelMask::AUDIO_CHANNEL_OUT_MONO);
+ profile.channelMasks[1] = toString(xsd::AudioChannelMask::AUDIO_CHANNEL_OUT_STEREO);
+ return profile;
+}
+
TEST(HidlUtils, ConvertInvalidAudioTransports) {
hidl_vec<AudioTransport> invalid;
struct audio_port_v7 halInvalid = {};
@@ -973,20 +985,32 @@
invalid[0].audioCapability.edid(hidl_vec<uint8_t>(EXTRA_AUDIO_DESCRIPTOR_SIZE + 1));
invalid[1].encapsulationType = "random string";
EXPECT_EQ(BAD_VALUE, HidlUtils::audioTransportsToHal(invalid, &halInvalid));
+
+ // The size of audio profile must not be greater than the maximum value.
+ invalid.resize(0);
+ invalid.resize(AUDIO_PORT_MAX_AUDIO_PROFILES + 1);
+ for (size_t i = 0; i < invalid.size(); ++i) {
+ invalid[i].audioCapability.profile(generateValidAudioProfile());
+ invalid[i].encapsulationType =
+ toString(xsd::AudioEncapsulationType::AUDIO_ENCAPSULATION_TYPE_NONE);
+ }
+ EXPECT_EQ(BAD_VALUE, HidlUtils::audioTransportsToHal(invalid, &halInvalid));
+
+ // The size of extra audio descriptors must not be greater than the maximum value.
+ invalid.resize(0);
+ invalid.resize(AUDIO_PORT_MAX_EXTRA_AUDIO_DESCRIPTORS + 1);
+ for (size_t i = 0; i < invalid.size(); ++i) {
+ invalid[i].audioCapability.edid({0x11, 0x06, 0x01});
+ invalid[i].encapsulationType =
+ toString(xsd::AudioEncapsulationType::AUDIO_ENCAPSULATION_TYPE_IEC61937);
+ }
+ EXPECT_EQ(BAD_VALUE, HidlUtils::audioTransportsToHal(invalid, &halInvalid));
}
TEST(HidlUtils, ConvertAudioTransports) {
hidl_vec<AudioTransport> transports;
transports.resize(2);
- AudioProfile profile;
- profile.format = toString(xsd::AudioFormat::AUDIO_FORMAT_PCM_16_BIT);
- profile.sampleRates.resize(2);
- profile.sampleRates[0] = 44100;
- profile.sampleRates[1] = 48000;
- profile.channelMasks.resize(2);
- profile.channelMasks[0] = toString(xsd::AudioChannelMask::AUDIO_CHANNEL_OUT_MONO);
- profile.channelMasks[1] = toString(xsd::AudioChannelMask::AUDIO_CHANNEL_OUT_STEREO);
- transports[0].audioCapability.profile(profile);
+ transports[0].audioCapability.profile(generateValidAudioProfile());
hidl_vec<uint8_t> shortAudioDescriptor({0x11, 0x06, 0x01});
transports[0].encapsulationType =
toString(xsd::AudioEncapsulationType::AUDIO_ENCAPSULATION_TYPE_NONE);
diff --git a/audio/effect/all-versions/default/Effect.cpp b/audio/effect/all-versions/default/Effect.cpp
index 3baafc9..def3a3f 100644
--- a/audio/effect/all-versions/default/Effect.cpp
+++ b/audio/effect/all-versions/default/Effect.cpp
@@ -238,12 +238,27 @@
}
// static
-std::vector<uint8_t> Effect::parameterToHal(uint32_t paramSize, const void* paramData,
- uint32_t valueSize, const void** valueData) {
+bool Effect::parameterToHal(uint32_t paramSize, const void* paramData, uint32_t valueSize,
+ const void** valueData, std::vector<uint8_t>* halParamBuffer) {
+ constexpr size_t kMaxSize = EFFECT_PARAM_SIZE_MAX - sizeof(effect_param_t);
+ if (paramSize > kMaxSize) {
+ ALOGE("%s: Parameter size is too big: %" PRIu32, __func__, paramSize);
+ return false;
+ }
size_t valueOffsetFromData = alignedSizeIn<uint32_t>(paramSize) * sizeof(uint32_t);
+ if (valueOffsetFromData > kMaxSize) {
+ ALOGE("%s: Aligned parameter size is too big: %zu", __func__, valueOffsetFromData);
+ return false;
+ }
+ if (valueSize > kMaxSize - valueOffsetFromData) {
+ ALOGE("%s: Value size is too big: %" PRIu32 ", max size is %zu", __func__, valueSize,
+ kMaxSize - valueOffsetFromData);
+ android_errorWriteLog(0x534e4554, "237291425");
+ return false;
+ }
size_t halParamBufferSize = sizeof(effect_param_t) + valueOffsetFromData + valueSize;
- std::vector<uint8_t> halParamBuffer(halParamBufferSize, 0);
- effect_param_t* halParam = reinterpret_cast<effect_param_t*>(&halParamBuffer[0]);
+ halParamBuffer->resize(halParamBufferSize, 0);
+ effect_param_t* halParam = reinterpret_cast<effect_param_t*>(halParamBuffer->data());
halParam->psize = paramSize;
halParam->vsize = valueSize;
memcpy(halParam->data, paramData, paramSize);
@@ -256,7 +271,7 @@
*valueData = halParam->data + valueOffsetFromData;
}
}
- return halParamBuffer;
+ return true;
}
Result Effect::analyzeCommandStatus(const char* commandName, const char* context, status_t status) {
@@ -314,11 +329,15 @@
GetParameterSuccessCallback onSuccess) {
// As it is unknown what method HAL uses for copying the provided parameter data,
// it is safer to make sure that input and output buffers do not overlap.
- std::vector<uint8_t> halCmdBuffer =
- parameterToHal(paramSize, paramData, requestValueSize, nullptr);
+ std::vector<uint8_t> halCmdBuffer;
+ if (!parameterToHal(paramSize, paramData, requestValueSize, nullptr, &halCmdBuffer)) {
+ return Result::INVALID_ARGUMENTS;
+ }
const void* valueData = nullptr;
- std::vector<uint8_t> halParamBuffer =
- parameterToHal(paramSize, paramData, replyValueSize, &valueData);
+ std::vector<uint8_t> halParamBuffer;
+ if (!parameterToHal(paramSize, paramData, replyValueSize, &valueData, &halParamBuffer)) {
+ return Result::INVALID_ARGUMENTS;
+ }
uint32_t halParamBufferSize = halParamBuffer.size();
return sendCommandReturningStatusAndData(
@@ -472,8 +491,10 @@
Result Effect::setParameterImpl(uint32_t paramSize, const void* paramData, uint32_t valueSize,
const void* valueData) {
- std::vector<uint8_t> halParamBuffer =
- parameterToHal(paramSize, paramData, valueSize, &valueData);
+ std::vector<uint8_t> halParamBuffer;
+ if (!parameterToHal(paramSize, paramData, valueSize, &valueData, &halParamBuffer)) {
+ return Result::INVALID_ARGUMENTS;
+ }
return sendCommandReturningStatus(EFFECT_CMD_SET_PARAM, "SET_PARAM", halParamBuffer.size(),
&halParamBuffer[0]);
}
diff --git a/audio/effect/all-versions/default/Effect.h b/audio/effect/all-versions/default/Effect.h
index 011544d..f0b65df 100644
--- a/audio/effect/all-versions/default/Effect.h
+++ b/audio/effect/all-versions/default/Effect.h
@@ -211,8 +211,8 @@
channel_config_t* halConfig);
static void effectOffloadParamToHal(const EffectOffloadParameter& offload,
effect_offload_param_t* halOffload);
- static std::vector<uint8_t> parameterToHal(uint32_t paramSize, const void* paramData,
- uint32_t valueSize, const void** valueData);
+ static bool parameterToHal(uint32_t paramSize, const void* paramData, uint32_t valueSize,
+ const void** valueData, std::vector<uint8_t>* halParamBuffer);
Result analyzeCommandStatus(const char* commandName, const char* context, status_t status);
void getConfigImpl(int commandCode, const char* commandName, GetConfigCallback cb);
diff --git a/audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp b/audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp
index e59423f..ffa4c56 100644
--- a/audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp
+++ b/audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp
@@ -623,6 +623,23 @@
EXPECT_TRUE(ret.isOk());
}
+TEST_P(AudioEffectHidlTest, GetParameterInvalidMaxReplySize) {
+ description("Verify that GetParameter caps the maximum reply size");
+ // Use a non-empty parameter to avoid being rejected by any earlier checks.
+ hidl_vec<uint8_t> parameter;
+ parameter.resize(16);
+ // Use very large size to ensure that the service does not crash. Since parameters
+ // are specific to each effect, and some effects may not have parameters at all,
+ // simply checking the return value would not reveal an issue of using an uncapped value.
+ const uint32_t veryLargeReplySize = std::numeric_limits<uint32_t>::max() - 100;
+ Result retval = Result::OK;
+ Return<void> ret =
+ effect->getParameter(parameter, veryLargeReplySize,
+ [&](Result r, const hidl_vec<uint8_t>&) { retval = r; });
+ EXPECT_TRUE(ret.isOk());
+ EXPECT_EQ(Result::INVALID_ARGUMENTS, retval);
+}
+
TEST_P(AudioEffectHidlTest, GetSupportedConfigsForFeature) {
description("Verify that GetSupportedConfigsForFeature does not crash");
Return<void> ret = effect->getSupportedConfigsForFeature(
diff --git a/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h b/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h
index d29813d..9d7294e 100644
--- a/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h
+++ b/automotive/vehicle/aidl/impl/default_config/include/DefaultConfig.h
@@ -481,6 +481,15 @@
{.config =
{
+ .prop = toInt(
+ VehicleProperty::FUEL_CONSUMPTION_UNITS_DISTANCE_OVER_VOLUME),
+ .access = VehiclePropertyAccess::READ_WRITE,
+ .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
+ },
+ .initialValue = {.int32Values = {1}}},
+
+ {.config =
+ {
.prop = toInt(VehicleProperty::HW_KEY_INPUT),
.access = VehiclePropertyAccess::READ,
.changeMode = VehiclePropertyChangeMode::ON_CHANGE,
diff --git a/bluetooth/audio/aidl/default/LeAudioOffloadAudioProvider.cpp b/bluetooth/audio/aidl/default/LeAudioOffloadAudioProvider.cpp
index 0e22e44..7f610ef 100644
--- a/bluetooth/audio/aidl/default/LeAudioOffloadAudioProvider.cpp
+++ b/bluetooth/audio/aidl/default/LeAudioOffloadAudioProvider.cpp
@@ -55,21 +55,20 @@
const std::shared_ptr<IBluetoothAudioPort>& host_if,
const AudioConfiguration& audio_config,
const std::vector<LatencyMode>& latency_modes, DataMQDesc* _aidl_return) {
- if (audio_config.getTag() != AudioConfiguration::leAudioConfig) {
+ if (session_type_ ==
+ SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH) {
+ if (audio_config.getTag() != AudioConfiguration::leAudioBroadcastConfig) {
+ LOG(WARNING) << __func__ << " - Invalid Audio Configuration="
+ << audio_config.toString();
+ *_aidl_return = DataMQDesc();
+ return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
+ }
+ } else if (audio_config.getTag() != AudioConfiguration::leAudioConfig) {
LOG(WARNING) << __func__ << " - Invalid Audio Configuration="
<< audio_config.toString();
*_aidl_return = DataMQDesc();
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
- const auto& le_audio_config =
- audio_config.get<AudioConfiguration::leAudioConfig>();
- if (!BluetoothAudioCodecs::IsOffloadLeAudioConfigurationValid(
- session_type_, le_audio_config)) {
- LOG(WARNING) << __func__ << " - Unsupported LC3 Offloaded Configuration="
- << le_audio_config.toString();
- *_aidl_return = DataMQDesc();
- return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
- }
return BluetoothAudioProvider::startSession(
host_if, audio_config, latency_modes, _aidl_return);
diff --git a/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp b/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp
index b858f50..d5e85b8 100644
--- a/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp
+++ b/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp
@@ -321,19 +321,6 @@
return false;
}
-bool BluetoothAudioCodecs::IsOffloadLeAudioConfigurationValid(
- const SessionType& session_type, const LeAudioConfiguration&) {
- if (session_type !=
- SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH &&
- session_type !=
- SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH &&
- session_type !=
- SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH) {
- return false;
- }
- return true;
-}
-
std::vector<PcmCapabilities>
BluetoothAudioCodecs::GetSoftwarePcmCapabilities() {
return {kDefaultSoftwarePcmCapabilities};
diff --git a/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.h b/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.h
index ed0598b..e3d657b 100644
--- a/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.h
+++ b/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.h
@@ -44,9 +44,6 @@
static bool IsOffloadCodecConfigurationValid(
const SessionType& session_type, const CodecConfiguration& codec_config);
- static bool IsOffloadLeAudioConfigurationValid(
- const SessionType& session_type, const LeAudioConfiguration&);
-
static std::vector<LeAudioCodecCapabilitiesSetting>
GetLeAudioOffloadCodecCapabilities(const SessionType& session_type);
diff --git a/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp b/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp
index 3214bf2..292d352 100644
--- a/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp
+++ b/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp
@@ -111,7 +111,9 @@
if (session_type_ !=
SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH &&
session_type_ !=
- SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH) {
+ SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH &&
+ session_type_ !=
+ SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH) {
return;
}
std::lock_guard<std::recursive_mutex> guard(mutex_);
@@ -274,11 +276,14 @@
bool is_offload_a2dp_session =
(session_type_ == SessionType::A2DP_HARDWARE_OFFLOAD_ENCODING_DATAPATH ||
session_type_ == SessionType::A2DP_HARDWARE_OFFLOAD_DECODING_DATAPATH);
- bool is_offload_le_audio_session =
+ bool is_offload_le_audio_unicast_session =
(session_type_ ==
SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH ||
session_type_ ==
SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH);
+ bool is_offload_le_audio_broadcast_session =
+ (session_type_ ==
+ SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH);
auto audio_config_tag = audio_config.getTag();
bool is_software_audio_config =
(is_software_session &&
@@ -286,11 +291,15 @@
bool is_a2dp_offload_audio_config =
(is_offload_a2dp_session &&
audio_config_tag == AudioConfiguration::a2dpConfig);
- bool is_le_audio_offload_audio_config =
- (is_offload_le_audio_session &&
+ bool is_le_audio_offload_unicast_audio_config =
+ (is_offload_le_audio_unicast_session &&
audio_config_tag == AudioConfiguration::leAudioConfig);
+ bool is_le_audio_offload_broadcast_audio_config =
+ (is_offload_le_audio_broadcast_session &&
+ audio_config_tag == AudioConfiguration::leAudioBroadcastConfig);
if (!is_software_audio_config && !is_a2dp_offload_audio_config &&
- !is_le_audio_offload_audio_config) {
+ !is_le_audio_offload_unicast_audio_config &&
+ !is_le_audio_offload_broadcast_audio_config) {
return false;
}
audio_config_ = std::make_unique<AudioConfiguration>(audio_config);
diff --git a/wifi/1.4/vts/functional/Android.bp b/wifi/1.4/vts/functional/Android.bp
index f86869b..cac8c0b 100644
--- a/wifi/1.4/vts/functional/Android.bp
+++ b/wifi/1.4/vts/functional/Android.bp
@@ -44,6 +44,27 @@
],
}
+cc_library_static {
+ name: "VtsHalWifiV1_4TargetTestUtil",
+ defaults: ["VtsHalTargetTestDefaults"],
+ srcs: [
+ "wifi_hidl_test_utils_1_4.cpp",
+ ],
+ export_include_dirs: [
+ ".",
+ ],
+ shared_libs: [
+ "libnativehelper",
+ ],
+ static_libs: [
+ "VtsHalWifiV1_0TargetTestUtil",
+ "android.hardware.wifi@1.0",
+ "android.hardware.wifi@1.3",
+ "android.hardware.wifi@1.4",
+ "libwifi-system-iface",
+ ],
+}
+
// SoftAP-specific tests, similar to VtsHalWifiApV1_0TargetTest.
cc_test {
name: "VtsHalWifiApV1_4TargetTest",
diff --git a/wifi/1.4/vts/functional/wifi_hidl_test_utils_1_4.cpp b/wifi/1.4/vts/functional/wifi_hidl_test_utils_1_4.cpp
new file mode 100644
index 0000000..02e8320
--- /dev/null
+++ b/wifi/1.4/vts/functional/wifi_hidl_test_utils_1_4.cpp
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2022 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/IWifiApIface.h>
+#include <android/hardware/wifi/1.4/IWifiChip.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::ChipModeId;
+using ::android::hardware::wifi::V1_0::IfaceType;
+using ::android::hardware::wifi::V1_4::IWifiApIface;
+using ::android::hardware::wifi::V1_4::IWifiChip;
+
+sp<IWifiChip> getWifiChip_1_4(const std::string& instance_name) {
+ return IWifiChip::castFrom(getWifiChip(instance_name));
+}
+
+sp<IWifiApIface> getWifiApIface_1_4(const std::string& instance_name) {
+ LOG(INFO) << "getWifiApIface_1_4";
+ ChipModeId mode_id;
+ sp<IWifiChip> wifi_chip_ = getWifiChip_1_4(instance_name);
+ configureChipToSupportIfaceType(wifi_chip_, IfaceType::AP, &mode_id);
+ const auto& status_and_iface = HIDL_INVOKE(wifi_chip_, createApIface);
+ LOG(INFO) << "getWifiApIface_1_4 done to status_and_iface";
+ return IWifiApIface::castFrom(status_and_iface.second);
+}
diff --git a/wifi/1.4/vts/functional/wifi_hidl_test_utils_1_4.h b/wifi/1.4/vts/functional/wifi_hidl_test_utils_1_4.h
new file mode 100644
index 0000000..a2c5815
--- /dev/null
+++ b/wifi/1.4/vts/functional/wifi_hidl_test_utils_1_4.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+#pragma once
+
+#include <android/hardware/wifi/1.4/IWifi.h>
+#include <android/hardware/wifi/1.4/IWifiApIface.h>
+#include <android/hardware/wifi/1.4/IWifiChip.h>
+
+#include <getopt.h>
+
+#include <VtsHalHidlTargetTestEnvBase.h>
+// Helper functions to obtain references to the various HIDL interface objects.
+// Note: We only have a single instance of each of these objects currently.
+// These helper functions should be modified to return vectors if we support
+// multiple instances.
+android::sp<android::hardware::wifi::V1_4::IWifiChip> getWifiChip_1_4(
+ const std::string& instance_name);
+android::sp<android::hardware::wifi::V1_4::IWifiApIface> getWifiApIface_1_4(
+ const std::string& instance_name);
diff --git a/wifi/hostapd/1.2/vts/functional/Android.bp b/wifi/hostapd/1.2/vts/functional/Android.bp
index 9609da5..26edab5 100644
--- a/wifi/hostapd/1.2/vts/functional/Android.bp
+++ b/wifi/hostapd/1.2/vts/functional/Android.bp
@@ -31,12 +31,17 @@
],
static_libs: [
"VtsHalWifiV1_0TargetTestUtil",
+ "VtsHalWifiV1_4TargetTestUtil",
"VtsHalWifiHostapdV1_0TargetTestUtil",
"android.hardware.wifi.hostapd@1.0",
"android.hardware.wifi.hostapd@1.1",
"android.hardware.wifi.hostapd@1.2",
"android.hardware.wifi.hostapd@1.3",
"android.hardware.wifi@1.0",
+ "android.hardware.wifi@1.1",
+ "android.hardware.wifi@1.2",
+ "android.hardware.wifi@1.3",
+ "android.hardware.wifi@1.4",
"libgmock",
"libwifi-system",
"libwifi-system-iface",
diff --git a/wifi/hostapd/1.2/vts/functional/hostapd_hidl_test.cpp b/wifi/hostapd/1.2/vts/functional/hostapd_hidl_test.cpp
index c40c582..2fade4d 100644
--- a/wifi/hostapd/1.2/vts/functional/hostapd_hidl_test.cpp
+++ b/wifi/hostapd/1.2/vts/functional/hostapd_hidl_test.cpp
@@ -29,6 +29,7 @@
#include "hostapd_hidl_call_util.h"
#include "hostapd_hidl_test_utils.h"
+#include "wifi_hidl_test_utils_1_4.h"
using ::android::sp;
using ::android::hardware::hidl_string;
@@ -39,6 +40,9 @@
using ::android::hardware::wifi::hostapd::V1_2::Ieee80211ReasonCode;
using ::android::hardware::wifi::hostapd::V1_2::IHostapd;
using ::android::hardware::wifi::V1_0::IWifi;
+using ::android::hardware::wifi::V1_0::WifiStatusCode;
+using ::android::hardware::wifi::V1_4::IWifiApIface;
+using ::android::hardware::wifi::V1_4::IWifiChip;
namespace {
constexpr unsigned char kNwSsid[] = {'t', 'e', 's', 't', '1',
@@ -81,23 +85,25 @@
protected:
bool isWpa3SaeSupport_ = false;
bool isAcsSupport_ = false;
- std::string getPrimaryWlanIfaceName() {
- std::array<char, PROPERTY_VALUE_MAX> buffer;
- auto res = property_get("ro.vendor.wifi.sap.interface", buffer.data(),
- nullptr);
- if (res > 0) return buffer.data();
- property_get("wifi.interface", buffer.data(), "wlan0");
- return buffer.data();
+
+ std::string setupApIfaceIfNeededAndGetName() {
+ sp<IWifiApIface> wifi_ap_iface;
+ wifi_ap_iface = getWifiApIface_1_4(wifi_instance_name_);
+ EXPECT_NE(nullptr, wifi_ap_iface.get());
+
+ const auto& status_and_name = HIDL_INVOKE(wifi_ap_iface, getName);
+ EXPECT_EQ(WifiStatusCode::SUCCESS, status_and_name.first.code);
+ return status_and_name.second;
}
- IHostapd::IfaceParams getIfaceParamsWithoutAcs() {
+ IHostapd::IfaceParams getIfaceParamsWithoutAcs(std::string iface_name) {
::android::hardware::wifi::hostapd::V1_0::IHostapd::IfaceParams
iface_params;
::android::hardware::wifi::hostapd::V1_1::IHostapd::IfaceParams
iface_params_1_1;
IHostapd::IfaceParams iface_params_1_2;
- iface_params.ifaceName = getPrimaryWlanIfaceName();
+ iface_params.ifaceName = iface_name;
iface_params.hwModeParams.enable80211N = true;
iface_params.hwModeParams.enable80211AC = false;
iface_params.channelParams.enableAcs = false;
@@ -114,9 +120,9 @@
return iface_params_1_2;
}
- IHostapd::IfaceParams getIfaceParamsWithAcs() {
+ IHostapd::IfaceParams getIfaceParamsWithAcs(std::string iface_name) {
// First get the settings for WithoutAcs and then make changes
- IHostapd::IfaceParams iface_params_1_2 = getIfaceParamsWithoutAcs();
+ IHostapd::IfaceParams iface_params_1_2 = getIfaceParamsWithoutAcs(iface_name);
iface_params_1_2.V1_1.V1_0.channelParams.enableAcs = true;
iface_params_1_2.V1_1.V1_0.channelParams.acsShouldExcludeDfs = true;
iface_params_1_2.V1_1.V1_0.channelParams.channel = 0;
@@ -126,8 +132,8 @@
return iface_params_1_2;
}
- IHostapd::IfaceParams getIfaceParamsWithAcsAndFreqRange() {
- IHostapd::IfaceParams iface_params_1_2 = getIfaceParamsWithAcs();
+ IHostapd::IfaceParams getIfaceParamsWithAcsAndFreqRange(std::string iface_name) {
+ IHostapd::IfaceParams iface_params_1_2 = getIfaceParamsWithAcs(iface_name);
::android::hardware::wifi::hostapd::V1_2::IHostapd::AcsFrequencyRange
acsFrequencyRange;
acsFrequencyRange.start = 2412;
@@ -141,9 +147,8 @@
return iface_params_1_2;
}
- IHostapd::IfaceParams getIfaceParamsWithAcsAndInvalidFreqRange() {
- IHostapd::IfaceParams iface_params_1_2 =
- getIfaceParamsWithAcsAndFreqRange();
+ IHostapd::IfaceParams getIfaceParamsWithAcsAndInvalidFreqRange(std::string iface_name) {
+ IHostapd::IfaceParams iface_params_1_2 = getIfaceParamsWithAcsAndFreqRange(iface_name);
iface_params_1_2.channelParams.acsChannelFreqRangesMhz[0].start = 222;
iface_params_1_2.channelParams.acsChannelFreqRangesMhz[0].end = 999;
return iface_params_1_2;
@@ -205,8 +210,8 @@
return nw_params_1_2;
}
- IHostapd::IfaceParams getIfaceParamsWithInvalidChannel() {
- IHostapd::IfaceParams iface_params_1_2 = getIfaceParamsWithoutAcs();
+ IHostapd::IfaceParams getIfaceParamsWithInvalidChannel(std::string iface_name) {
+ IHostapd::IfaceParams iface_params_1_2 = getIfaceParamsWithoutAcs(iface_name);
iface_params_1_2.V1_1.V1_0.channelParams.channel = kIfaceInvalidChannel;
return iface_params_1_2;
}
@@ -231,8 +236,9 @@
if (!isAcsSupport_) GTEST_SKIP() << "Missing ACS support";
if (is_1_3(hostapd_))
GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3";
- auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2,
- getIfaceParamsWithAcs(), getPskNwParams());
+ std::string ifname = setupApIfaceIfNeededAndGetName();
+ auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2, getIfaceParamsWithAcs(ifname),
+ getPskNwParams());
EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code);
}
@@ -244,9 +250,9 @@
if (!isAcsSupport_) GTEST_SKIP() << "Missing ACS support";
if (is_1_3(hostapd_))
GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3";
- auto status =
- HIDL_INVOKE(hostapd_, addAccessPoint_1_2,
- getIfaceParamsWithAcsAndFreqRange(), getPskNwParams());
+ std::string ifname = setupApIfaceIfNeededAndGetName();
+ auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2,
+ getIfaceParamsWithAcsAndFreqRange(ifname), getPskNwParams());
EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code);
}
@@ -258,9 +264,9 @@
if (!isAcsSupport_) GTEST_SKIP() << "Missing ACS support";
if (is_1_3(hostapd_))
GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3";
+ std::string ifname = setupApIfaceIfNeededAndGetName();
auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2,
- getIfaceParamsWithAcsAndInvalidFreqRange(),
- getPskNwParams());
+ getIfaceParamsWithAcsAndInvalidFreqRange(ifname), getPskNwParams());
EXPECT_NE(HostapdStatusCode::SUCCESS, status.code);
}
@@ -272,8 +278,9 @@
if (!isAcsSupport_) GTEST_SKIP() << "Missing ACS support";
if (is_1_3(hostapd_))
GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3";
- auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2,
- getIfaceParamsWithAcs(), getOpenNwParams());
+ std::string ifname = setupApIfaceIfNeededAndGetName();
+ auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2, getIfaceParamsWithAcs(ifname),
+ getOpenNwParams());
EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code);
}
@@ -284,8 +291,9 @@
TEST_P(HostapdHidlTest, AddPskAccessPointWithoutAcs) {
if (is_1_3(hostapd_))
GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3";
- auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2,
- getIfaceParamsWithoutAcs(), getPskNwParams());
+ std::string ifname = setupApIfaceIfNeededAndGetName();
+ auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2, getIfaceParamsWithoutAcs(ifname),
+ getPskNwParams());
EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code);
}
@@ -296,8 +304,9 @@
TEST_P(HostapdHidlTest, AddOpenAccessPointWithoutAcs) {
if (is_1_3(hostapd_))
GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3";
- auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2,
- getIfaceParamsWithoutAcs(), getOpenNwParams());
+ std::string ifname = setupApIfaceIfNeededAndGetName();
+ auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2, getIfaceParamsWithoutAcs(ifname),
+ getOpenNwParams());
EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code);
}
@@ -309,9 +318,9 @@
if (!isWpa3SaeSupport_) GTEST_SKIP() << "Missing SAE support";
if (is_1_3(hostapd_))
GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3";
- auto status =
- HIDL_INVOKE(hostapd_, addAccessPoint_1_2, getIfaceParamsWithoutAcs(),
- getSaeTransitionNwParams());
+ std::string ifname = setupApIfaceIfNeededAndGetName();
+ auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2, getIfaceParamsWithoutAcs(ifname),
+ getSaeTransitionNwParams());
EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code);
}
@@ -323,8 +332,9 @@
if (!isWpa3SaeSupport_) GTEST_SKIP() << "Missing SAE support";
if (is_1_3(hostapd_))
GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3";
- auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2,
- getIfaceParamsWithoutAcs(), getSaeNwParams());
+ std::string ifname = setupApIfaceIfNeededAndGetName();
+ auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2, getIfaceParamsWithoutAcs(ifname),
+ getSaeNwParams());
EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code);
}
@@ -336,11 +346,11 @@
if (!isAcsSupport_) GTEST_SKIP() << "Missing ACS support";
if (is_1_3(hostapd_))
GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3";
- auto status_1_2 = HIDL_INVOKE(hostapd_, addAccessPoint_1_2,
- getIfaceParamsWithAcs(), getPskNwParams());
+ std::string ifname = setupApIfaceIfNeededAndGetName();
+ auto status_1_2 = HIDL_INVOKE(hostapd_, addAccessPoint_1_2, getIfaceParamsWithAcs(ifname),
+ getPskNwParams());
EXPECT_EQ(HostapdStatusCode::SUCCESS, status_1_2.code);
- auto status =
- HIDL_INVOKE(hostapd_, removeAccessPoint, getPrimaryWlanIfaceName());
+ auto status = HIDL_INVOKE(hostapd_, removeAccessPoint, ifname);
EXPECT_EQ(
android::hardware::wifi::hostapd::V1_0::HostapdStatusCode::SUCCESS,
status.code);
@@ -353,11 +363,11 @@
TEST_P(HostapdHidlTest, RemoveAccessPointWithoutAcs) {
if (is_1_3(hostapd_))
GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3";
- auto status_1_2 = HIDL_INVOKE(hostapd_, addAccessPoint_1_2,
- getIfaceParamsWithoutAcs(), getPskNwParams());
+ std::string ifname = setupApIfaceIfNeededAndGetName();
+ auto status_1_2 = HIDL_INVOKE(hostapd_, addAccessPoint_1_2, getIfaceParamsWithoutAcs(ifname),
+ getPskNwParams());
EXPECT_EQ(HostapdStatusCode::SUCCESS, status_1_2.code);
- auto status =
- HIDL_INVOKE(hostapd_, removeAccessPoint, getPrimaryWlanIfaceName());
+ auto status = HIDL_INVOKE(hostapd_, removeAccessPoint, ifname);
EXPECT_EQ(
android::hardware::wifi::hostapd::V1_0::HostapdStatusCode::SUCCESS,
status.code);
@@ -370,9 +380,9 @@
TEST_P(HostapdHidlTest, AddPskAccessPointWithInvalidChannel) {
if (is_1_3(hostapd_))
GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3";
- auto status =
- HIDL_INVOKE(hostapd_, addAccessPoint_1_2,
- getIfaceParamsWithInvalidChannel(), getPskNwParams());
+ std::string ifname = setupApIfaceIfNeededAndGetName();
+ auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2,
+ getIfaceParamsWithInvalidChannel(ifname), getPskNwParams());
EXPECT_NE(HostapdStatusCode::SUCCESS, status.code);
}
@@ -383,9 +393,9 @@
TEST_P(HostapdHidlTest, AddInvalidPskAccessPointWithoutAcs) {
if (is_1_3(hostapd_))
GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3";
- auto status =
- HIDL_INVOKE(hostapd_, addAccessPoint_1_2, getIfaceParamsWithoutAcs(),
- getInvalidPskNwParams());
+ std::string ifname = setupApIfaceIfNeededAndGetName();
+ auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2, getIfaceParamsWithoutAcs(ifname),
+ getInvalidPskNwParams());
EXPECT_NE(HostapdStatusCode::SUCCESS, status.code);
}
@@ -397,9 +407,9 @@
if (!isWpa3SaeSupport_) GTEST_SKIP() << "Missing SAE support";
if (is_1_3(hostapd_))
GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3";
- auto status =
- HIDL_INVOKE(hostapd_, addAccessPoint_1_2, getIfaceParamsWithoutAcs(),
- getInvalidSaeTransitionNwParams());
+ std::string ifname = setupApIfaceIfNeededAndGetName();
+ auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2, getIfaceParamsWithoutAcs(ifname),
+ getInvalidSaeTransitionNwParams());
EXPECT_NE(HostapdStatusCode::SUCCESS, status.code);
}
@@ -411,9 +421,9 @@
if (!isWpa3SaeSupport_) GTEST_SKIP() << "Missing SAE support";
if (is_1_3(hostapd_))
GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3";
- auto status =
- HIDL_INVOKE(hostapd_, addAccessPoint_1_2, getIfaceParamsWithoutAcs(),
- getInvalidSaeNwParams());
+ std::string ifname = setupApIfaceIfNeededAndGetName();
+ auto status = HIDL_INVOKE(hostapd_, addAccessPoint_1_2, getIfaceParamsWithoutAcs(ifname),
+ getInvalidSaeNwParams());
EXPECT_NE(HostapdStatusCode::SUCCESS, status.code);
}
@@ -422,9 +432,9 @@
* when hotspot interface doesn't init..
*/
TEST_P(HostapdHidlTest, DisconnectClientWhenIfaceNotAvailable) {
- auto status =
- HIDL_INVOKE(hostapd_, forceClientDisconnect, getPrimaryWlanIfaceName(),
- kTestZeroMacAddr, kTestDisconnectReasonCode);
+ std::string ifname = setupApIfaceIfNeededAndGetName();
+ auto status = HIDL_INVOKE(hostapd_, forceClientDisconnect, ifname, kTestZeroMacAddr,
+ kTestDisconnectReasonCode);
EXPECT_EQ(HostapdStatusCode::FAILURE_IFACE_UNKNOWN, status.code);
}
@@ -435,14 +445,13 @@
TEST_P(HostapdHidlTest, DisconnectClientWhenIfacAvailable) {
if (is_1_3(hostapd_))
GTEST_SKIP() << "Ignore addAccessPoint_1_2 on hostapd 1_3";
- auto status_1_2 =
- HIDL_INVOKE(hostapd_, addAccessPoint_1_2, getIfaceParamsWithoutAcs(),
- getOpenNwParams());
+ std::string ifname = setupApIfaceIfNeededAndGetName();
+ auto status_1_2 = HIDL_INVOKE(hostapd_, addAccessPoint_1_2, getIfaceParamsWithoutAcs(ifname),
+ getOpenNwParams());
EXPECT_EQ(HostapdStatusCode::SUCCESS, status_1_2.code);
- status_1_2 =
- HIDL_INVOKE(hostapd_, forceClientDisconnect, getPrimaryWlanIfaceName(),
- kTestZeroMacAddr, kTestDisconnectReasonCode);
+ status_1_2 = HIDL_INVOKE(hostapd_, forceClientDisconnect, ifname, kTestZeroMacAddr,
+ kTestDisconnectReasonCode);
EXPECT_EQ(HostapdStatusCode::FAILURE_CLIENT_UNKNOWN, status_1_2.code);
}