Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 40fde0bc authored by Mikhail Naganov's avatar Mikhail Naganov
Browse files

Audio HAL V7.1: Update VTS

Mechanical updates from global greps. Updated test code
to use new methods from V7.1.

Added missing checks for null pointers in
PcmOnlyConfig...StreamTest::releasePatchIfNeeded for V7.

Bug: 214426419
Test: atest VtsHalAudioV7_1TargetTest
Change-Id: Id3a99993bf2ee0c87d44f668d759f7c10db9a435
parent 7d01538e
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -23,14 +23,14 @@
#include <system/audio.h>

using namespace android;
using namespace ::android::hardware::audio::common::CPP_VERSION;
using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils;
using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION;
using ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION::implementation::HidlUtils;

// Not generated automatically because DeviceAddress contains
// an union.
//
// operator== must be defined in the same namespace as the data type.
namespace android::hardware::audio::common::CPP_VERSION {
namespace android::hardware::audio::common::COMMON_TYPES_CPP_VERSION {

inline bool operator==(const DeviceAddress& lhs, const DeviceAddress& rhs) {
    if (lhs.device != rhs.device) return false;
@@ -49,7 +49,7 @@ inline bool operator==(const DeviceAddress& lhs, const DeviceAddress& rhs) {
    return lhs.busAddress == rhs.busAddress;
}

}  // namespace android::hardware::audio::common::CPP_VERSION
}  // namespace android::hardware::audio::common::COMMON_TYPES_CPP_VERSION

static void ConvertDeviceAddress(const DeviceAddress& device) {
    audio_devices_t halDeviceType;
+2 −2
Original line number Diff line number Diff line
@@ -29,8 +29,8 @@

using namespace android;
using ::android::hardware::hidl_vec;
using namespace ::android::hardware::audio::common::CPP_VERSION;
using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils;
using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION;
using ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION::implementation::HidlUtils;
namespace xsd {
using namespace ::android::audio::policy::configuration::V7_0;
}
+1 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@
#include <xsdc/XsdcSupport.h>

using namespace android;
using namespace ::android::hardware::audio::common::CPP_VERSION;
using namespace ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION;
using namespace ::android::hardware::audio::CPP_VERSION;
using ::android::hardware::hidl_vec;
using ::android::hardware::audio::CPP_VERSION::implementation::CoreUtils;
+6 −4
Original line number Diff line number Diff line
@@ -14,16 +14,18 @@
 * limitations under the License.
 */

// clang-format off
#include PATH(android/hardware/audio/FILE_VERSION/IStream.h)
#include PATH(android/hardware/audio/FILE_VERSION/types.h)
#include PATH(android/hardware/audio/common/FILE_VERSION/types.h)
#include PATH(android/hardware/audio/CORE_TYPES_FILE_VERSION/types.h)
#include PATH(android/hardware/audio/common/COMMON_TYPES_FILE_VERSION/types.h)
// clang-format on
#include <hidl/HidlSupport.h>

using ::android::hardware::hidl_handle;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::audio::common::CPP_VERSION::AudioChannelMask;
using ::android::hardware::audio::common::CPP_VERSION::AudioFormat;
using ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION::AudioChannelMask;
using ::android::hardware::audio::common::COMMON_TYPES_CPP_VERSION::AudioFormat;
using ::android::hardware::audio::CPP_VERSION::IStream;
using ::android::hardware::audio::CPP_VERSION::ParameterValue;
using ::android::hardware::audio::CPP_VERSION::Result;
+34 −13
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
#include "AudioPrimaryHidlHalTest.h"

#if MAJOR_VERSION >= 7
#include <android_audio_policy_configuration_V7_0.h>
#include PATH(APM_XSD_H_FILENAME)
#include <xsdc/XsdcSupport.h>

using android::xsdc_enum_range;
@@ -28,17 +28,37 @@ TEST_P(AudioHidlTest, OpenPrimaryDeviceUsingGetDevice) {
    if (getDeviceName() != DeviceManager::kPrimaryDevice) {
        GTEST_SKIP() << "No primary device on this factory";  // returns
    }
    EXPECT_TRUE(
            DeviceManager::getInstance().reset(getFactoryName(), DeviceManager::kPrimaryDevice));

    {  // Scope for device SPs
        sp<IDevice> baseDevice =
                DeviceManager::getInstance().get(getFactoryName(), DeviceManager::kPrimaryDevice);
    // Must use IDevicesFactory directly because DeviceManager always uses
    // the latest interfaces version and corresponding methods for opening
    // them. However, in minor package uprevs IPrimaryDevice does not inherit
    // IDevice from the same package and thus IDevice can not be upcasted
    // (see the interfaces in V7.1).
    auto factory = DevicesFactoryManager::getInstance().get(getFactoryName());
    ASSERT_TRUE(factory != nullptr);
    sp<::android::hardware::audio::CORE_TYPES_CPP_VERSION::IDevice> baseDevice;
    Result result;
    auto ret = factory->openDevice(DeviceManager::kPrimaryDevice, returnIn(result, baseDevice));
    ASSERT_TRUE(ret.isOk()) << ret.description();
    ASSERT_EQ(Result::OK, result);
    ASSERT_TRUE(baseDevice != nullptr);
        Return<sp<IPrimaryDevice>> primaryDevice = IPrimaryDevice::castFrom(baseDevice);
    {
        Return<sp<::android::hardware::audio::CORE_TYPES_CPP_VERSION::IPrimaryDevice>>
                primaryDevice = ::android::hardware::audio::CORE_TYPES_CPP_VERSION::IPrimaryDevice::
                        castFrom(baseDevice);
        EXPECT_TRUE(primaryDevice.isOk());
        EXPECT_TRUE(sp<IPrimaryDevice>(primaryDevice) != nullptr);
        EXPECT_TRUE(sp<::android::hardware::audio::CORE_TYPES_CPP_VERSION::IPrimaryDevice>(
                            primaryDevice) != nullptr);
    }
    EXPECT_TRUE(
            DeviceManager::getInstance().reset(getFactoryName(), DeviceManager::kPrimaryDevice));
#if MAJOR_VERSION < 6
    baseDevice.clear();
    DeviceManager::waitForInstanceDestruction();
#else
    auto closeRet = baseDevice->close();
    EXPECT_TRUE(closeRet.isOk());
#endif
}

//////////////////////////////////////////////////////////////////////////////
@@ -183,7 +203,7 @@ TEST_IO_STREAM(SetDevices, "Check that the stream can be rerouted to SPEAKER or
               areAudioPatchesSupported() ? doc::partialTest("Audio patches are supported")
                                          : testSetDevices(stream.get(), address))

static void checkGetHwAVSync(IDevice* device) {
static void checkGetHwAVSync(::android::hardware::audio::CPP_VERSION::IDevice* device) {
    Result res;
    AudioHwSync sync;
    ASSERT_OK(device->getHwAvSync(returnIn(res, sync)));
@@ -215,7 +235,7 @@ TEST_P(InputStreamTest, updateSinkMetadata) {
    ASSERT_OK(stream->updateSinkMetadata(initMetadata));

#elif MAJOR_VERSION >= 7
    xsdc_enum_range<android::audio::policy::configuration::V7_0::AudioSource> range;
    xsdc_enum_range<android::audio::policy::configuration::CPP_VERSION::AudioSource> range;
    // Test all possible track configuration
    for (auto source : range) {
        for (float volume : {0.0, 0.5, 1.0}) {
@@ -272,8 +292,9 @@ TEST_P(OutputStreamTest, updateSourceMetadata) {
    // Restore initial
    ASSERT_OK(stream->updateSourceMetadata(initMetadata));
#elif MAJOR_VERSION >= 7
    xsdc_enum_range<android::audio::policy::configuration::V7_0::AudioUsage> usageRange;
    xsdc_enum_range<android::audio::policy::configuration::V7_0::AudioContentType> contentRange;
    xsdc_enum_range<android::audio::policy::configuration::CPP_VERSION::AudioUsage> usageRange;
    xsdc_enum_range<android::audio::policy::configuration::CPP_VERSION::AudioContentType>
            contentRange;
    // Test all possible track configuration
    for (auto usage : usageRange) {
        for (auto content : contentRange) {
Loading