Audio HAL: More generalization for types imports

Complement imports of audio::CPP_VERSION with audio::common::CPP_VERSION
for core.

Import namespaces in VTS tests.

Remove "using namespace" from .cpp files where there
are already imports in the .h file.

Test: try moving types between audio/types.hal and common/types.hal.
Change-Id: I49c2e2466c8175f2516c2273f5c26d125afd4801
This commit is contained in:
Mikhail Naganov
2018-12-14 14:31:45 -08:00
parent 0c157d30f2
commit 00a44c0fc2
12 changed files with 28 additions and 88 deletions

View File

@@ -28,8 +28,6 @@ namespace common {
namespace CPP_VERSION {
namespace implementation {
using namespace ::android::hardware::audio::common::CPP_VERSION;
void HidlUtils::audioConfigFromHal(const audio_config_t& halConfig, AudioConfig* config) {
config->sampleRateHz = halConfig.sample_rate;
config->channelMask = EnumBitfield<AudioChannelMask>(halConfig.channel_mask);

View File

@@ -26,8 +26,6 @@ namespace audio {
namespace CPP_VERSION {
namespace implementation {
using namespace ::android::hardware::audio::common::CPP_VERSION;
std::string deviceAddressToHal(const DeviceAddress& address) {
// HAL assumes that the address is NUL-terminated.
char halAddress[AUDIO_DEVICE_MAX_ADDRESS_LEN];

View File

@@ -34,9 +34,6 @@ namespace audio {
namespace CPP_VERSION {
namespace implementation {
using namespace ::android::hardware::audio::common::CPP_VERSION;
using namespace ::android::hardware::audio::CPP_VERSION;
namespace {
class ReadThread : public Thread {

View File

@@ -34,8 +34,6 @@ namespace audio {
namespace CPP_VERSION {
namespace implementation {
using ::android::hardware::audio::common::CPP_VERSION::ThreadInfo;
namespace {
class WriteThread : public Thread {

View File

@@ -29,6 +29,7 @@ namespace audio {
namespace CPP_VERSION {
namespace implementation {
using namespace ::android::hardware::audio::common::CPP_VERSION;
using namespace ::android::hardware::audio::CPP_VERSION;
std::string deviceAddressToHal(const DeviceAddress& address);

View File

@@ -33,6 +33,7 @@ namespace implementation {
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using namespace ::android::hardware::audio::common::CPP_VERSION;
using namespace ::android::hardware::audio::CPP_VERSION;
class ParametersUtil {

View File

@@ -30,6 +30,7 @@ namespace audio {
namespace CPP_VERSION {
namespace implementation {
using namespace ::android::hardware::audio::common::CPP_VERSION;
using namespace ::android::hardware::audio::CPP_VERSION;
/** @return true if gain is between 0 and 1 included. */

View File

@@ -85,7 +85,7 @@ TEST_F(AudioPrimaryHidlTest, GetMicrophonesTest) {
ASSERT_OK(res);
hidl_vec<MicrophoneInfo> activeMicrophones;
Result readRes;
typedef MessageQueue<ReadParameters, kSynchronizedReadWrite> CommandMQ;
typedef MessageQueue<IStreamIn::ReadParameters, kSynchronizedReadWrite> CommandMQ;
typedef MessageQueue<uint8_t, kSynchronizedReadWrite> DataMQ;
std::unique_ptr<CommandMQ> commandMQ;
std::unique_ptr<DataMQ> dataMQ;
@@ -103,7 +103,7 @@ TEST_F(AudioPrimaryHidlTest, GetMicrophonesTest) {
}
}));
ASSERT_OK(readRes);
ReadParameters params;
IStreamIn::ReadParameters params;
params.command = IStreamIn::ReadCommand::READ;
ASSERT_TRUE(commandMQ != nullptr);
ASSERT_TRUE(commandMQ->isValid());

View File

@@ -84,40 +84,11 @@ using ::android::hardware::kSynchronizedReadWrite;
using ::android::hardware::MessageQueue;
using ::android::hardware::MQDescriptorSync;
using ::android::hardware::Return;
using ::android::hardware::audio::CPP_VERSION::AudioDrain;
using ::android::hardware::audio::CPP_VERSION::DeviceAddress;
using ::android::hardware::audio::CPP_VERSION::IDevice;
using ::android::hardware::audio::CPP_VERSION::IPrimaryDevice;
using TtyMode = ::android::hardware::audio::CPP_VERSION::IPrimaryDevice::TtyMode;
using ::android::hardware::audio::CPP_VERSION::IDevicesFactory;
using ::android::hardware::audio::CPP_VERSION::IStream;
using ::android::hardware::audio::CPP_VERSION::IStreamIn;
using ::android::hardware::audio::CPP_VERSION::MessageQueueFlagBits;
using ::android::hardware::audio::CPP_VERSION::TimeSpec;
using ReadParameters = ::android::hardware::audio::CPP_VERSION::IStreamIn::ReadParameters;
using ReadStatus = ::android::hardware::audio::CPP_VERSION::IStreamIn::ReadStatus;
using ::android::hardware::audio::common::CPP_VERSION::AudioChannelMask;
using ::android::hardware::audio::common::CPP_VERSION::AudioConfig;
using ::android::hardware::audio::common::CPP_VERSION::AudioDevice;
using ::android::hardware::audio::common::CPP_VERSION::AudioFormat;
using ::android::hardware::audio::common::CPP_VERSION::AudioHandleConsts;
using ::android::hardware::audio::common::CPP_VERSION::AudioHwSync;
using ::android::hardware::audio::common::CPP_VERSION::AudioInputFlag;
using ::android::hardware::audio::common::CPP_VERSION::AudioIoHandle;
using ::android::hardware::audio::common::CPP_VERSION::AudioMode;
using ::android::hardware::audio::common::CPP_VERSION::AudioOffloadInfo;
using ::android::hardware::audio::common::CPP_VERSION::AudioOutputFlag;
using ::android::hardware::audio::common::CPP_VERSION::AudioSource;
using ::android::hardware::audio::common::CPP_VERSION::ThreadInfo;
using ::android::hardware::audio::common::utils::mkEnumBitfield;
using ::android::hardware::audio::CPP_VERSION::IStreamOut;
using ::android::hardware::audio::CPP_VERSION::IStreamOutCallback;
using ::android::hardware::audio::CPP_VERSION::MmapBufferInfo;
using ::android::hardware::audio::CPP_VERSION::MmapPosition;
using ::android::hardware::audio::CPP_VERSION::ParameterValue;
using ::android::hardware::audio::CPP_VERSION::Result;
using namespace ::android::hardware::audio::common::CPP_VERSION;
using namespace ::android::hardware::audio::common::test::utility;
using namespace ::android::hardware::audio::CPP_VERSION;
// Typical accepted results from interface methods
static auto okOrNotSupported = {Result::OK, Result::NOT_SUPPORTED};
@@ -1374,12 +1345,13 @@ TEST_F(BoolAccessorPrimaryHidlTest, setGetBtScoWidebandEnabled) {
&IPrimaryDevice::getBtScoWidebandEnabled);
}
using TtyModeAccessorPrimaryHidlTest = AccessorPrimaryHidlTest<TtyMode>;
using TtyModeAccessorPrimaryHidlTest = AccessorPrimaryHidlTest<IPrimaryDevice::TtyMode>;
TEST_F(TtyModeAccessorPrimaryHidlTest, setGetTtyMode) {
doc::test("Query and set the TTY mode state");
testAccessors<OPTIONAL>("TTY mode", Initial{TtyMode::OFF},
{TtyMode::HCO, TtyMode::VCO, TtyMode::FULL},
&IPrimaryDevice::setTtyMode, &IPrimaryDevice::getTtyMode);
testAccessors<OPTIONAL>(
"TTY mode", Initial{IPrimaryDevice::TtyMode::OFF},
{IPrimaryDevice::TtyMode::HCO, IPrimaryDevice::TtyMode::VCO, IPrimaryDevice::TtyMode::FULL},
&IPrimaryDevice::setTtyMode, &IPrimaryDevice::getTtyMode);
}
TEST_F(BoolAccessorPrimaryHidlTest, setGetHac) {

View File

@@ -41,8 +41,6 @@ namespace CPP_VERSION {
namespace implementation {
using ::android::hardware::audio::common::CPP_VERSION::implementation::AudioChannelBitfield;
using namespace ::android::hardware::audio::common::CPP_VERSION;
using namespace ::android::hardware::audio::effect::CPP_VERSION;
namespace {

View File

@@ -43,18 +43,8 @@ using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::hardware::audio::common::CPP_VERSION::AudioDevice;
using ::android::hardware::audio::common::CPP_VERSION::AudioMode;
using ::android::hardware::audio::common::CPP_VERSION::AudioSource;
using ::android::hardware::audio::effect::CPP_VERSION::AudioBuffer;
using ::android::hardware::audio::effect::CPP_VERSION::EffectAuxChannelsConfig;
using ::android::hardware::audio::effect::CPP_VERSION::EffectConfig;
using ::android::hardware::audio::effect::CPP_VERSION::EffectDescriptor;
using ::android::hardware::audio::effect::CPP_VERSION::EffectOffloadParameter;
using ::android::hardware::audio::effect::CPP_VERSION::IEffect;
using ::android::hardware::audio::effect::CPP_VERSION::IEffectBufferProviderCallback;
using ::android::hardware::audio::effect::CPP_VERSION::IEqualizerEffect;
using ::android::hardware::audio::effect::CPP_VERSION::Result;
using namespace ::android::hardware::audio::common::CPP_VERSION;
using namespace ::android::hardware::audio::effect::CPP_VERSION;
struct EqualizerEffect : public IEqualizerEffect {
explicit EqualizerEffect(effect_handle_t handle);

View File

@@ -31,33 +31,19 @@
#include <VtsHalHidlTargetTestBase.h>
#include <VtsHalHidlTargetTestEnvBase.h>
using android::sp;
using android::hardware::hidl_handle;
using android::hardware::hidl_memory;
using android::hardware::hidl_string;
using android::hardware::hidl_vec;
using android::hardware::MQDescriptorSync;
using android::hardware::Return;
using android::hardware::Void;
using android::hardware::audio::common::CPP_VERSION::AudioDevice;
using android::hardware::audio::common::CPP_VERSION::AudioHandleConsts;
using android::hardware::audio::common::CPP_VERSION::AudioMode;
using android::hardware::audio::common::CPP_VERSION::AudioSource;
using android::hardware::audio::common::CPP_VERSION::Uuid;
using android::hardware::audio::common::utils::mkEnumBitfield;
using android::hardware::audio::effect::CPP_VERSION::AudioBuffer;
using android::hardware::audio::effect::CPP_VERSION::EffectAuxChannelsConfig;
using android::hardware::audio::effect::CPP_VERSION::EffectBufferConfig;
using android::hardware::audio::effect::CPP_VERSION::EffectConfig;
using android::hardware::audio::effect::CPP_VERSION::EffectDescriptor;
using android::hardware::audio::effect::CPP_VERSION::EffectOffloadParameter;
using android::hardware::audio::effect::CPP_VERSION::IEffect;
using android::hardware::audio::effect::CPP_VERSION::IEffectsFactory;
using android::hardware::audio::effect::CPP_VERSION::IEqualizerEffect;
using android::hardware::audio::effect::CPP_VERSION::ILoudnessEnhancerEffect;
using android::hardware::audio::effect::CPP_VERSION::Result;
using android::hidl::allocator::V1_0::IAllocator;
using android::hidl::memory::V1_0::IMemory;
using ::android::sp;
using ::android::hardware::hidl_handle;
using ::android::hardware::hidl_memory;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::MQDescriptorSync;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::hardware::audio::common::utils::mkEnumBitfield;
using ::android::hidl::allocator::V1_0::IAllocator;
using ::android::hidl::memory::V1_0::IMemory;
using namespace ::android::hardware::audio::common::CPP_VERSION;
using namespace ::android::hardware::audio::effect::CPP_VERSION;
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))
@@ -742,7 +728,7 @@ TEST_F(EqualizerAudioEffectHidlTest, GetSetAllProperties) {
"Verify that setting band levels and presets works via Get / "
"SetAllProperties for Equalizer effect");
using AllProperties =
android::hardware::audio::effect::CPP_VERSION::IEqualizerEffect::AllProperties;
::android::hardware::audio::effect::CPP_VERSION::IEqualizerEffect::AllProperties;
uint16_t numBands = 0;
getNumBands(&numBands);
ASSERT_GT(numBands, 0);