From b742cdf2a0510661bdb07b121d67a0239d59c0d8 Mon Sep 17 00:00:00 2001 From: Vlad Popa Date: Wed, 26 Apr 2023 17:08:07 +0200 Subject: [PATCH] CSD: Load the ISoundDoseFactory dynamically Also removed the default implementation of the ISoundDoseFactory which only provides a dummy SoundDose object. It is better to fall back to the framework MEL. Test: manual, logs Bug: 272260521 Change-Id: I3b49c9ae4af7c4eafaef46de3fc90aa05bd819c4 --- audio/aidl/sounddose/default/Android.bp | 46 ----------------- .../sounddose/default/SoundDoseFactory.cpp | 49 ------------------- .../default/include/SoundDoseFactory.h | 38 -------------- .../all-versions/default/service/Android.bp | 3 -- .../android.hardware.audio.sounddose-aidl.xml | 7 --- .../all-versions/default/service/service.cpp | 18 ++----- 6 files changed, 4 insertions(+), 157 deletions(-) delete mode 100644 audio/aidl/sounddose/default/Android.bp delete mode 100644 audio/aidl/sounddose/default/SoundDoseFactory.cpp delete mode 100644 audio/aidl/sounddose/default/include/SoundDoseFactory.h delete mode 100644 audio/common/all-versions/default/service/android.hardware.audio.sounddose-aidl.xml diff --git a/audio/aidl/sounddose/default/Android.bp b/audio/aidl/sounddose/default/Android.bp deleted file mode 100644 index bd770fa5b5..0000000000 --- a/audio/aidl/sounddose/default/Android.bp +++ /dev/null @@ -1,46 +0,0 @@ -package { - // See: http://go/android-license-faq - // A large-scale-change added 'default_applicable_licenses' to import - // all of the 'license_kinds' from "hardware_interfaces_license" - // to get the below license kinds: - // SPDX-license-identifier-Apache-2.0 - default_applicable_licenses: ["hardware_interfaces_license"], -} - -cc_defaults { - name: "aidlsounddoseservice_defaults", - vendor: true, - header_libs: [ - "libsounddoseaidl_headers", - ], -} - -cc_library { - name: "libsounddoseserviceexampleimpl", - defaults: [ - "aidlsounddoseservice_defaults", - "latest_android_media_audio_common_types_ndk_shared", - "latest_android_hardware_audio_core_sounddose_ndk_shared", - "latest_android_hardware_audio_sounddose_ndk_shared", - ], - export_include_dirs: ["include"], - srcs: [ - "SoundDoseFactory.cpp", - ], - shared_libs: [ - "libaudioservicesounddoseimpl", - "libbase", - "libbinder_ndk", - ], - - visibility: [ - "//hardware/interfaces/audio/common/all-versions/default/service", - ], -} - -cc_library_headers { - name: "libsounddoseaidl_headers", - export_include_dirs: ["include"], - vendor_available: true, - host_supported: true, -} diff --git a/audio/aidl/sounddose/default/SoundDoseFactory.cpp b/audio/aidl/sounddose/default/SoundDoseFactory.cpp deleted file mode 100644 index 83a592b54e..0000000000 --- a/audio/aidl/sounddose/default/SoundDoseFactory.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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. - */ - -#define LOG_TAG "AHAL_SoundDoseFactory" - -#include "SoundDoseFactory.h" - -#include -#include - -namespace aidl::android::hardware::audio::sounddose { - -using ::aidl::android::hardware::audio::core::sounddose::SoundDose; - -ndk::ScopedAStatus SoundDoseFactory::getSoundDose(const std::string& in_module, - std::shared_ptr* _aidl_return) { - auto soundDoseIt = mSoundDoseBinderMap.find(in_module); - if (soundDoseIt != mSoundDoseBinderMap.end()) { - *_aidl_return = ISoundDose::fromBinder(soundDoseIt->second); - - LOG(DEBUG) << __func__ - << ": returning cached instance of ISoundDose: " << _aidl_return->get() - << " for module " << in_module; - return ndk::ScopedAStatus::ok(); - } - - auto soundDose = ndk::SharedRefBase::make(); - mSoundDoseBinderMap[in_module] = soundDose->asBinder(); - *_aidl_return = soundDose; - - LOG(DEBUG) << __func__ << ": returning new instance of ISoundDose: " << _aidl_return->get() - << " for module " << in_module; - return ndk::ScopedAStatus::ok(); -} - -} // namespace aidl::android::hardware::audio::sounddose diff --git a/audio/aidl/sounddose/default/include/SoundDoseFactory.h b/audio/aidl/sounddose/default/include/SoundDoseFactory.h deleted file mode 100644 index ced4291411..0000000000 --- a/audio/aidl/sounddose/default/include/SoundDoseFactory.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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 -#include -#include - -#include - -namespace aidl::android::hardware::audio::sounddose { - -using ::aidl::android::hardware::audio::core::sounddose::ISoundDose; - -class SoundDoseFactory : public BnSoundDoseFactory { - public: - ndk::ScopedAStatus getSoundDose(const std::string& module, - std::shared_ptr* _aidl_return) override; - - private: - std::unordered_map mSoundDoseBinderMap; -}; - -} // namespace aidl::android::hardware::audio::sounddose diff --git a/audio/common/all-versions/default/service/Android.bp b/audio/common/all-versions/default/service/Android.bp index 2fcfb235e7..d513062c25 100644 --- a/audio/common/all-versions/default/service/Android.bp +++ b/audio/common/all-versions/default/service/Android.bp @@ -38,13 +38,11 @@ cc_binary { name: "android.hardware.audio.service", init_rc: ["android.hardware.audio.service.rc"], - vintf_fragments: ["android.hardware.audio.sounddose-aidl.xml"], relative_install_path: "hw", vendor: true, defaults: [ "android_hardware_audio_config_defaults", - "latest_android_hardware_audio_sounddose_ndk_shared", ], srcs: ["service.cpp"], @@ -56,7 +54,6 @@ cc_binary { ], shared_libs: [ - "//hardware/interfaces/audio/aidl/sounddose/default:libsounddoseserviceexampleimpl", "libcutils", "libbinder", "libbinder_ndk", diff --git a/audio/common/all-versions/default/service/android.hardware.audio.sounddose-aidl.xml b/audio/common/all-versions/default/service/android.hardware.audio.sounddose-aidl.xml deleted file mode 100644 index a297bfbbe5..0000000000 --- a/audio/common/all-versions/default/service/android.hardware.audio.sounddose-aidl.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - android.hardware.audio.sounddose - 1 - ISoundDoseFactory/default - - diff --git a/audio/common/all-versions/default/service/service.cpp b/audio/common/all-versions/default/service/service.cpp index 7b5a932ff6..1557a9505d 100644 --- a/audio/common/all-versions/default/service/service.cpp +++ b/audio/common/all-versions/default/service/service.cpp @@ -20,10 +20,6 @@ #include #include -#include -#include -#include -#include #include #include #include @@ -37,8 +33,6 @@ using android::OK; using InterfacesList = std::vector; -using aidl::android::hardware::audio::sounddose::SoundDoseFactory; - /** Try to register the provided factories in the provided order. * If any registers successfully, do not register any other and return true. * If all fail, return false. @@ -144,6 +138,10 @@ int main(int /* argc */, char* /* argv */ []) { "android.hardware.bluetooth.audio-impl", "createIBluetoothAudioProviderFactory", }, + { + "android.hardware.audio.sounddose-vendor-impl", + "createISoundDoseFactory", + }, }; // clang-format on @@ -171,13 +169,5 @@ int main(int /* argc */, char* /* argv */ []) { } } - // Register ISoundDoseFactory interface as a workaround for using the audio AIDL HAL - auto soundDoseDefault = ndk::SharedRefBase::make(); - const std::string soundDoseDefaultName = - std::string() + SoundDoseFactory::descriptor + "/default"; - binder_status_t status = AServiceManager_addService(soundDoseDefault->asBinder().get(), - soundDoseDefaultName.c_str()); - CHECK_EQ(STATUS_OK, status); - joinRpcThreadpool(); }