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

Commit 0ba11a6b authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes from topic "aosp-default-wrapper"

* changes:
  Minor fixes to TypeConverter tests
  Update code after moving UUID conversions to their own class
parents e3d0ba33 82700932
Loading
Loading
Loading
Loading
+4 −4
Original line number Original line Diff line number Diff line
@@ -25,9 +25,9 @@


#include "EffectBufferHalHidl.h"
#include "EffectBufferHalHidl.h"
#include "EffectHalHidl.h"
#include "EffectHalHidl.h"
#include "HidlUtils.h"
#include "UuidUtils.h"


using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils;
using ::android::hardware::audio::common::CPP_VERSION::implementation::UuidUtils;
using ::android::hardware::audio::common::utils::EnumBitfield;
using ::android::hardware::audio::common::utils::EnumBitfield;
using ::android::hardware::hidl_vec;
using ::android::hardware::hidl_vec;
using ::android::hardware::MQDescriptorSync;
using ::android::hardware::MQDescriptorSync;
@@ -58,8 +58,8 @@ EffectHalHidl::~EffectHalHidl() {
// static
// static
void EffectHalHidl::effectDescriptorToHal(
void EffectHalHidl::effectDescriptorToHal(
        const EffectDescriptor& descriptor, effect_descriptor_t* halDescriptor) {
        const EffectDescriptor& descriptor, effect_descriptor_t* halDescriptor) {
    HidlUtils::uuidToHal(descriptor.type, &halDescriptor->type);
    UuidUtils::uuidToHal(descriptor.type, &halDescriptor->type);
    HidlUtils::uuidToHal(descriptor.uuid, &halDescriptor->uuid);
    UuidUtils::uuidToHal(descriptor.uuid, &halDescriptor->uuid);
    halDescriptor->flags = static_cast<uint32_t>(descriptor.flags);
    halDescriptor->flags = static_cast<uint32_t>(descriptor.flags);
    halDescriptor->cpuLoad = descriptor.cpuLoad;
    halDescriptor->cpuLoad = descriptor.cpuLoad;
    halDescriptor->memoryUsage = descriptor.memoryUsage;
    halDescriptor->memoryUsage = descriptor.memoryUsage;
+4 −4
Original line number Original line Diff line number Diff line
@@ -23,9 +23,9 @@
#include "EffectBufferHalHidl.h"
#include "EffectBufferHalHidl.h"
#include "EffectHalHidl.h"
#include "EffectHalHidl.h"
#include "EffectsFactoryHalHidl.h"
#include "EffectsFactoryHalHidl.h"
#include "HidlUtils.h"
#include "UuidUtils.h"


using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils;
using ::android::hardware::audio::common::CPP_VERSION::implementation::UuidUtils;
using ::android::hardware::Return;
using ::android::hardware::Return;


namespace android {
namespace android {
@@ -85,7 +85,7 @@ status_t EffectsFactoryHalHidl::getDescriptor(
    // TODO: check for nullptr
    // TODO: check for nullptr
    if (mEffectsFactory == 0) return NO_INIT;
    if (mEffectsFactory == 0) return NO_INIT;
    Uuid hidlUuid;
    Uuid hidlUuid;
    HidlUtils::uuidFromHal(*pEffectUuid, &hidlUuid);
    UuidUtils::uuidFromHal(*pEffectUuid, &hidlUuid);
    Result retval = Result::NOT_INITIALIZED;
    Result retval = Result::NOT_INITIALIZED;
    Return<void> ret = mEffectsFactory->getDescriptor(hidlUuid,
    Return<void> ret = mEffectsFactory->getDescriptor(hidlUuid,
            [&](Result r, const EffectDescriptor& result) {
            [&](Result r, const EffectDescriptor& result) {
@@ -107,7 +107,7 @@ status_t EffectsFactoryHalHidl::createEffect(
        int32_t deviceId __unused, sp<EffectHalInterface> *effect) {
        int32_t deviceId __unused, sp<EffectHalInterface> *effect) {
    if (mEffectsFactory == 0) return NO_INIT;
    if (mEffectsFactory == 0) return NO_INIT;
    Uuid hidlUuid;
    Uuid hidlUuid;
    HidlUtils::uuidFromHal(*pEffectUuid, &hidlUuid);
    UuidUtils::uuidFromHal(*pEffectUuid, &hidlUuid);
    Result retval = Result::NOT_INITIALIZED;
    Result retval = Result::NOT_INITIALIZED;
    Return<void> ret;
    Return<void> ret;
#if MAJOR_VERSION >= 6
#if MAJOR_VERSION >= 6
+10 −5
Original line number Original line Diff line number Diff line
@@ -33,7 +33,8 @@ TEST(TypeConverter, ParseChannelMasks) {
    for (const auto enumVal : xsdc_enum_range<xsd::AudioChannelMask>{}) {
    for (const auto enumVal : xsdc_enum_range<xsd::AudioChannelMask>{}) {
        const std::string stringVal = toString(enumVal);
        const std::string stringVal = toString(enumVal);
        audio_channel_mask_t channelMask = channelMaskFromString(stringVal);
        audio_channel_mask_t channelMask = channelMaskFromString(stringVal);
        EXPECT_EQ(stringVal != "AUDIO_CHANNEL_NONE", audio_channel_mask_is_valid(channelMask))
        EXPECT_EQ(enumVal != xsd::AudioChannelMask::AUDIO_CHANNEL_NONE,
                audio_channel_mask_is_valid(channelMask))
                << "Validity of \"" << stringVal << "\" is not as expected";
                << "Validity of \"" << stringVal << "\" is not as expected";
    }
    }
}
}
@@ -67,7 +68,7 @@ TEST(TypeConverter, ParseInputOutputIndexChannelMask) {
            EXPECT_TRUE(ChannelIndexConverter::toString(channelMask, stringValBack))
            EXPECT_TRUE(ChannelIndexConverter::toString(channelMask, stringValBack))
                    << "Conversion of indexed channel mask " << channelMask << " failed";
                    << "Conversion of indexed channel mask " << channelMask << " failed";
            EXPECT_EQ(stringVal, stringValBack);
            EXPECT_EQ(stringVal, stringValBack);
        } else if (stringVal == "AUDIO_CHANNEL_NONE") {
        } else if (stringVal == toString(xsd::AudioChannelMask::AUDIO_CHANNEL_NONE)) {
            EXPECT_FALSE(InputChannelConverter::fromString(stringVal, channelMask))
            EXPECT_FALSE(InputChannelConverter::fromString(stringVal, channelMask))
                    << "Conversion of \"" << stringVal << "\" succeeded (as input channel mask)";
                    << "Conversion of \"" << stringVal << "\" succeeded (as input channel mask)";
            EXPECT_FALSE(OutputChannelConverter::fromString(stringVal, channelMask))
            EXPECT_FALSE(OutputChannelConverter::fromString(stringVal, channelMask))
@@ -86,6 +87,8 @@ TEST(TypeConverter, ParseInputOutputIndexChannelMask) {
            EXPECT_TRUE(ChannelIndexConverter::toString(channelMask, stringValBack))
            EXPECT_TRUE(ChannelIndexConverter::toString(channelMask, stringValBack))
                    << "Conversion of indexed channel mask " << channelMask << " failed";
                    << "Conversion of indexed channel mask " << channelMask << " failed";
            EXPECT_EQ(stringVal, stringValBack);
            EXPECT_EQ(stringVal, stringValBack);
        } else {
            FAIL() << "Unrecognized channel mask \"" << stringVal << "\"";
        }
        }
    }
    }
}
}
@@ -107,7 +110,7 @@ TEST(TypeConverter, ParseDevices) {
        std::string stringValBack;
        std::string stringValBack;
        EXPECT_TRUE(DeviceConverter::fromString(stringVal, device))
        EXPECT_TRUE(DeviceConverter::fromString(stringVal, device))
                << "Conversion of \"" << stringVal << "\" failed";
                << "Conversion of \"" << stringVal << "\" failed";
        if (stringVal != "AUDIO_DEVICE_NONE") {
        if (enumVal != xsd::AudioDevice::AUDIO_DEVICE_NONE) {
            EXPECT_TRUE(audio_is_input_device(device) || audio_is_output_device(device))
            EXPECT_TRUE(audio_is_input_device(device) || audio_is_output_device(device))
                    << "Device \"" << stringVal << "\" is neither input, nor output device";
                    << "Device \"" << stringVal << "\" is neither input, nor output device";
        } else {
        } else {
@@ -144,12 +147,14 @@ TEST(TypeConverter, ParseInOutDevices) {
            EXPECT_TRUE(OutputDeviceConverter::fromString(stringValBack, deviceBack))
            EXPECT_TRUE(OutputDeviceConverter::fromString(stringValBack, deviceBack))
                    << "Conversion of \"" << stringValBack << "\" failed";
                    << "Conversion of \"" << stringValBack << "\" failed";
            EXPECT_EQ(device, deviceBack);
            EXPECT_EQ(device, deviceBack);
        } else if (stringVal == "AUDIO_DEVICE_NONE") {
        } else if (stringVal == toString(xsd::AudioDevice::AUDIO_DEVICE_NONE)) {
            EXPECT_FALSE(InputDeviceConverter::fromString(stringVal, device))
            EXPECT_FALSE(InputDeviceConverter::fromString(stringVal, device))
                    << "Conversion of \"" << stringVal << "\" succeeded (as input device)";
                    << "Conversion of \"" << stringVal << "\" succeeded (as input device)";
            EXPECT_FALSE(OutputDeviceConverter::fromString(stringVal, device))
            EXPECT_FALSE(OutputDeviceConverter::fromString(stringVal, device))
                    << "Conversion of \"" << stringVal << "\" succeeded (as output device)";
                    << "Conversion of \"" << stringVal << "\" succeeded (as output device)";
            EXPECT_EQ(stringVal, toString(device));
            EXPECT_EQ(stringVal, toString(device));
        } else {
            FAIL() << "Unrecognized audio device \"" << stringVal << "\"";
        }
        }
    }
    }
}
}