mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
Merge "Effect Aidl: make EffectFactoryHelper methods static only" into main
This commit is contained in:
@@ -36,21 +36,6 @@ using aidl::android::media::audio::common::AudioUuid;
|
|||||||
|
|
||||||
class EffectFactoryHelper {
|
class EffectFactoryHelper {
|
||||||
public:
|
public:
|
||||||
explicit EffectFactoryHelper(const std::string& name) : mServiceName(name) {}
|
|
||||||
|
|
||||||
void ConnectToFactoryService() {
|
|
||||||
mEffectFactory = IFactory::fromBinder(binderUtil.connectToService(mServiceName));
|
|
||||||
ASSERT_NE(mEffectFactory, nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RestartFactoryService() {
|
|
||||||
ASSERT_NE(mEffectFactory, nullptr);
|
|
||||||
mEffectFactory = IFactory::fromBinder(binderUtil.restartService());
|
|
||||||
ASSERT_NE(mEffectFactory, nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<IFactory> GetFactory() const { return mEffectFactory; }
|
|
||||||
|
|
||||||
static std::vector<std::pair<std::shared_ptr<IFactory>, Descriptor>> getAllEffectDescriptors(
|
static std::vector<std::pair<std::shared_ptr<IFactory>, Descriptor>> getAllEffectDescriptors(
|
||||||
std::string serviceName, std::optional<AudioUuid> type = std::nullopt) {
|
std::string serviceName, std::optional<AudioUuid> type = std::nullopt) {
|
||||||
AudioHalBinderServiceUtil util;
|
AudioHalBinderServiceUtil util;
|
||||||
@@ -84,9 +69,4 @@ class EffectFactoryHelper {
|
|||||||
return EffectFactoryHelper::getHalVersion(factory) >=
|
return EffectFactoryHelper::getHalVersion(factory) >=
|
||||||
aidl::android::hardware::audio::effect::kReopenSupportedVersion;
|
aidl::android::hardware::audio::effect::kReopenSupportedVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
std::shared_ptr<IFactory> mEffectFactory;
|
|
||||||
std::string mServiceName;
|
|
||||||
AudioHalBinderServiceUtil binderUtil;
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -56,10 +56,7 @@ using android::hardware::audio::common::testing::detail::TestExecutionTracer;
|
|||||||
/// Effect factory testing.
|
/// Effect factory testing.
|
||||||
class EffectFactoryTest : public testing::TestWithParam<std::string> {
|
class EffectFactoryTest : public testing::TestWithParam<std::string> {
|
||||||
public:
|
public:
|
||||||
void SetUp() override {
|
void SetUp() override { connectAndGetFactory(); }
|
||||||
mFactoryHelper = std::make_unique<EffectFactoryHelper>(GetParam());
|
|
||||||
connectAndGetFactory();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TearDown() override {
|
void TearDown() override {
|
||||||
for (auto& effect : mEffects) {
|
for (auto& effect : mEffects) {
|
||||||
@@ -68,13 +65,14 @@ class EffectFactoryTest : public testing::TestWithParam<std::string> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<EffectFactoryHelper> mFactoryHelper;
|
std::string kServiceName = GetParam();
|
||||||
std::shared_ptr<IFactory> mEffectFactory;
|
std::shared_ptr<IFactory> mEffectFactory;
|
||||||
std::vector<std::shared_ptr<IEffect>> mEffects;
|
std::vector<std::shared_ptr<IEffect>> mEffects;
|
||||||
const Descriptor::Identity kNullId = {.uuid = getEffectUuidNull()};
|
const Descriptor::Identity kNullId = {.uuid = getEffectUuidNull()};
|
||||||
const Descriptor::Identity kZeroId = {.uuid = getEffectUuidZero()};
|
const Descriptor::Identity kZeroId = {.uuid = getEffectUuidZero()};
|
||||||
const Descriptor kNullDesc = {.common.id = kNullId};
|
const Descriptor kNullDesc = {.common.id = kNullId};
|
||||||
const Descriptor kZeroDesc = {.common.id = kZeroId};
|
const Descriptor kZeroDesc = {.common.id = kZeroId};
|
||||||
|
AudioHalBinderServiceUtil mBinderUtil;
|
||||||
|
|
||||||
template <typename Functor>
|
template <typename Functor>
|
||||||
void ForEachId(const std::vector<Descriptor::Identity> ids, Functor functor) {
|
void ForEachId(const std::vector<Descriptor::Identity> ids, Functor functor) {
|
||||||
@@ -117,8 +115,7 @@ class EffectFactoryTest : public testing::TestWithParam<std::string> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
void connectAndGetFactory() {
|
void connectAndGetFactory() {
|
||||||
ASSERT_NO_FATAL_FAILURE(mFactoryHelper->ConnectToFactoryService());
|
mEffectFactory = IFactory::fromBinder(mBinderUtil.connectToService(kServiceName));
|
||||||
mEffectFactory = mFactoryHelper->GetFactory();
|
|
||||||
ASSERT_NE(mEffectFactory, nullptr);
|
ASSERT_NE(mEffectFactory, nullptr);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -128,7 +125,9 @@ TEST_P(EffectFactoryTest, SetupAndTearDown) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(EffectFactoryTest, CanBeRestarted) {
|
TEST_P(EffectFactoryTest, CanBeRestarted) {
|
||||||
ASSERT_NO_FATAL_FAILURE(mFactoryHelper->RestartFactoryService());
|
ASSERT_NE(mEffectFactory, nullptr);
|
||||||
|
mEffectFactory = IFactory::fromBinder(mBinderUtil.restartService());
|
||||||
|
ASSERT_NE(mEffectFactory, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -250,7 +249,8 @@ TEST_P(EffectFactoryTest, CreateDestroyWithRestart) {
|
|||||||
EXPECT_NE(descs.size(), 0UL);
|
EXPECT_NE(descs.size(), 0UL);
|
||||||
creatAndDestroyDescs(descs);
|
creatAndDestroyDescs(descs);
|
||||||
|
|
||||||
mFactoryHelper->RestartFactoryService();
|
mEffectFactory = IFactory::fromBinder(mBinderUtil.restartService());
|
||||||
|
ASSERT_NE(mEffectFactory, nullptr);
|
||||||
|
|
||||||
connectAndGetFactory();
|
connectAndGetFactory();
|
||||||
creatAndDestroyDescs(descs);
|
creatAndDestroyDescs(descs);
|
||||||
@@ -263,7 +263,8 @@ TEST_P(EffectFactoryTest, EffectInvalidAfterRestart) {
|
|||||||
EXPECT_NE(descs.size(), 0UL);
|
EXPECT_NE(descs.size(), 0UL);
|
||||||
std::vector<std::shared_ptr<IEffect>> effects = createWithDescs(descs);
|
std::vector<std::shared_ptr<IEffect>> effects = createWithDescs(descs);
|
||||||
|
|
||||||
ASSERT_NO_FATAL_FAILURE(mFactoryHelper->RestartFactoryService());
|
mEffectFactory = IFactory::fromBinder(mBinderUtil.restartService());
|
||||||
|
ASSERT_NE(mEffectFactory, nullptr);
|
||||||
|
|
||||||
connectAndGetFactory();
|
connectAndGetFactory();
|
||||||
destroyEffects(effects, EX_ILLEGAL_ARGUMENT);
|
destroyEffects(effects, EX_ILLEGAL_ARGUMENT);
|
||||||
|
|||||||
Reference in New Issue
Block a user