Merge "Create vendor apex for cuttlefish audio and audio effect" into main am: fe55cba9bb

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2863478

Change-Id: Iefccf72b3d97cdbae66b643203682d6a6631fd00
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Deyao Ren 2024-01-17 21:46:41 +00:00 committed by Automerger Merge Worker
commit 66f0387a35
22 changed files with 163 additions and 38 deletions

View file

@ -115,8 +115,6 @@ cc_library {
cc_binary {
name: "android.hardware.audio.service-aidl.example",
relative_install_path: "hw",
init_rc: ["android.hardware.audio.service-aidl.example.rc"],
vintf_fragments: ["android.hardware.audio.service-aidl.xml"],
defaults: [
"aidlaudioservice_defaults",
"latest_android_hardware_audio_core_sounddose_ndk_shared",
@ -142,6 +140,7 @@ cc_binary {
"-Wthread-safety",
"-DBACKEND_NDK",
],
installable: false, //installed in apex com.android.hardware.audio
}
cc_test {
@ -235,10 +234,9 @@ filegroup {
cc_binary {
name: "android.hardware.audio.effect.service-aidl.example",
relative_install_path: "hw",
init_rc: ["android.hardware.audio.effect.service-aidl.example.rc"],
vintf_fragments: ["android.hardware.audio.effect.service-aidl.xml"],
defaults: ["aidlaudioeffectservice_defaults"],
shared_libs: [
"libapexsupport",
"libtinyxml2",
],
srcs: [
@ -246,6 +244,7 @@ cc_binary {
"EffectFactory.cpp",
"EffectMain.cpp",
],
installable: false, //installed in apex com.android.hardware.audio.effect
}
cc_library_headers {
@ -254,3 +253,22 @@ cc_library_headers {
vendor_available: true,
host_supported: true,
}
prebuilt_etc {
name: "android.hardware.audio.service-aidl.example.rc",
src: "android.hardware.audio.service-aidl.example.rc",
installable: false,
}
prebuilt_etc {
name: "android.hardware.audio.service-aidl.xml",
src: "android.hardware.audio.service-aidl.xml",
sub_dir: "vintf",
installable: false,
}
prebuilt_etc {
name: "audio_effects_config.xml",
src: "audio_effects_config.xml",
installable: false,
}

View file

@ -24,6 +24,10 @@
#include "effectFactory-impl/EffectConfig.h"
#ifdef __ANDROID_APEX__
#include <android/apexsupport.h>
#endif
using aidl::android::media::audio::common::AudioSource;
using aidl::android::media::audio::common::AudioStreamType;
using aidl::android::media::audio::common::AudioUuid;
@ -89,6 +93,24 @@ std::vector<std::reference_wrapper<const tinyxml2::XMLElement>> EffectConfig::ge
}
bool EffectConfig::resolveLibrary(const std::string& path, std::string* resolvedPath) {
if (__builtin_available(android AAPEXSUPPORT_API, *)) {
AApexInfo *apexInfo;
if (AApexInfo_create(&apexInfo) == AAPEXINFO_OK) {
std::string apexName(AApexInfo_getName(apexInfo));
AApexInfo_destroy(apexInfo);
std::string candidatePath("/apex/");
candidatePath.append(apexName).append(kEffectLibApexPath).append(path);
LOG(DEBUG) << __func__ << " effect lib path " << candidatePath;
if (access(candidatePath.c_str(), R_OK) == 0) {
*resolvedPath = std::move(candidatePath);
return true;
}
}
} else {
LOG(DEBUG) << __func__ << " libapexsupport is not supported";
}
// If audio effects libs are not in vendor apex, locate them in kEffectLibPath
for (auto* libraryDirectory : kEffectLibPath) {
std::string candidatePath = std::string(libraryDirectory) + '/' + path;
if (access(candidatePath.c_str(), R_OK) == 0) {

View file

@ -21,15 +21,39 @@
#include <android/binder_process.h>
#include <system/audio_config.h>
#ifdef __ANDROID_APEX__
#include <android/apexsupport.h>
#endif
/** Default name of effect configuration file. */
static const char* kDefaultConfigName = "audio_effects_config.xml";
static inline std::string config_file_path() {
if (__builtin_available(android AAPEXSUPPORT_API, *)) {
AApexInfo *apexInfo;
if (AApexInfo_create(&apexInfo) == AAPEXINFO_OK) {
std::string apexName(AApexInfo_getName(apexInfo));
AApexInfo_destroy(apexInfo);
std::string candidatePath("/apex/");
candidatePath.append(apexName).append("/etc/").append(kDefaultConfigName);
LOG(DEBUG) << __func__ << " effect lib path " << candidatePath;
if (access(candidatePath.c_str(), R_OK) == 0) {
return std::move(candidatePath);
}
}
} else {
LOG(DEBUG) << __func__ << " libapexsupport is not supported";
}
LOG(DEBUG) << __func__ << ": Unable to resolve config file path in APEX";
return android::audio_find_readable_configuration_file(kDefaultConfigName);
}
int main() {
// This is a debug implementation, always enable debug logging.
android::base::SetMinimumLogSeverity(::android::base::DEBUG);
ABinderProcess_setThreadPoolMaxThreadCount(0);
auto configFile = android::audio_find_readable_configuration_file(kDefaultConfigName);
auto configFile = config_file_path();
if (configFile == "") {
LOG(ERROR) << __func__ << ": config file " << kDefaultConfigName << " not found!";
return EXIT_FAILURE;

View file

@ -34,6 +34,6 @@ cc_library_shared {
],
relative_install_path: "soundfx",
visibility: [
"//hardware/interfaces/audio/aidl/default",
"//hardware/interfaces/audio/aidl/default:__subpackages__",
],
}

View file

@ -1,11 +0,0 @@
service vendor.audio-effect-hal-aidl /vendor/bin/hw/android.hardware.audio.effect.service-aidl.example
class hal
user audioserver
# media gid needed for /dev/fm (radio) and for /data/misc/media (tee)
group audio media
capabilities BLOCK_SUSPEND
# setting RLIMIT_RTPRIO allows binder RT priority inheritance
rlimit rtprio 10 10
ioprio rt 4
task_profiles ProcessCapacityHigh HighPerformance
onrestart restart audioserver

View file

@ -1,7 +0,0 @@
<manifest version="1.0" type="device">
<hal format="aidl">
<name>android.hardware.audio.effect</name>
<version>2</version>
<fqname>IFactory/default</fqname>
</hal>
</manifest>

View file

@ -1,4 +1,5 @@
service vendor.audio-hal-aidl /vendor/bin/hw/android.hardware.audio.service-aidl.example
service vendor.audio-hal-aidl /apex/com.android.hardware.audio/bin/hw/android.hardware.audio.service-aidl.example
class hal
user audioserver
# media gid needed for /dev/fm (radio) and for /data/misc/media (tee)
@ -9,3 +10,15 @@ service vendor.audio-hal-aidl /vendor/bin/hw/android.hardware.audio.service-aidl
ioprio rt 4
task_profiles ProcessCapacityHigh HighPerformance
onrestart restart audioserver
service vendor.audio-effect-hal-aidl /apex/com.android.hardware.audio/bin/hw/android.hardware.audio.effect.service-aidl.example
class hal
user audioserver
# media gid needed for /dev/fm (radio) and for /data/misc/media (tee)
group audio media
capabilities BLOCK_SUSPEND
# setting RLIMIT_RTPRIO allows binder RT priority inheritance
rlimit rtprio 10 10
ioprio rt 4
task_profiles ProcessCapacityHigh HighPerformance
onrestart restart audioserver

View file

@ -31,4 +31,9 @@
<fqname>IModule/usb</fqname>
</hal>
-->
<hal format="aidl">
<name>android.hardware.audio.effect</name>
<version>2</version>
<fqname>IFactory/default</fqname>
</hal>
</manifest>

View file

@ -0,0 +1,49 @@
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"],
}
apex {
name: "com.android.hardware.audio",
manifest: "manifest.json",
file_contexts: "file_contexts",
key: "com.android.hardware.key",
certificate: ":com.android.hardware.certificate",
updatable: false,
vendor: true,
binaries: [
"android.hardware.audio.service-aidl.example",
"android.hardware.audio.effect.service-aidl.example",
],
native_shared_libs: [
"libaecsw",
"libagc1sw",
"libagc2sw",
"libbassboostsw",
"libbundleaidl",
"libdownmixaidl",
"libdynamicsprocessingaidl",
"libenvreverbsw",
"libequalizersw",
"libextensioneffect",
"libhapticgeneratoraidl",
"libloudnessenhanceraidl",
"libnssw",
"libpreprocessingaidl",
"libpresetreverbsw",
"libreverbaidl",
"libvirtualizersw",
"libvisualizeraidl",
"libvolumesw",
],
prebuilts: [
"android.hardware.audio.service-aidl.example.rc",
"android.hardware.audio.service-aidl.xml",
"audio_effects_config.xml",
],
}

View file

@ -0,0 +1,4 @@
(/.*)? u:object_r:vendor_file:s0
/etc(/.*)? u:object_r:vendor_configs_file:s0
/bin/hw/android\.hardware\.audio\.service-aidl\.example u:object_r:hal_audio_default_exec:s0
/bin/hw/android\.hardware\.audio\.effect\.service-aidl\.example u:object_r:hal_audio_default_exec:s0

View file

@ -0,0 +1,4 @@
{
"name": "com.android.hardware.audio",
"version": 1
}

View file

@ -34,6 +34,6 @@ cc_library_shared {
],
relative_install_path: "soundfx",
visibility: [
"//hardware/interfaces/audio/aidl/default",
"//hardware/interfaces/audio/aidl/default:__subpackages__",
],
}

View file

@ -34,6 +34,6 @@ cc_library_shared {
],
relative_install_path: "soundfx",
visibility: [
"//hardware/interfaces/audio/aidl/default",
"//hardware/interfaces/audio/aidl/default:__subpackages__",
],
}

View file

@ -34,6 +34,6 @@ cc_library_shared {
],
relative_install_path: "soundfx",
visibility: [
"//hardware/interfaces/audio/aidl/default",
"//hardware/interfaces/audio/aidl/default:__subpackages__",
],
}

View file

@ -34,6 +34,6 @@ cc_library_shared {
],
relative_install_path: "soundfx",
visibility: [
"//hardware/interfaces/audio/aidl/default",
"//hardware/interfaces/audio/aidl/default:__subpackages__",
],
}

View file

@ -34,6 +34,6 @@ cc_library_shared {
],
relative_install_path: "soundfx",
visibility: [
"//hardware/interfaces/audio/aidl/default",
"//hardware/interfaces/audio/aidl/default:__subpackages__",
],
}

View file

@ -34,6 +34,6 @@ cc_library_shared {
],
relative_install_path: "soundfx",
visibility: [
"//hardware/interfaces/audio/aidl/default",
"//hardware/interfaces/audio/aidl/default:__subpackages__",
],
}

View file

@ -64,12 +64,16 @@ class EffectConfig {
const ProcessingLibrariesMap& getProcessingMap() const;
private:
static constexpr const char* kEffectLibPath[] =
#ifdef __LP64__
{"/odm/lib64/soundfx", "/vendor/lib64/soundfx", "/system/lib64/soundfx"};
#define SOUND_FX_PATH "/lib64/soundfx/"
#else
{"/odm/lib/soundfx", "/vendor/lib/soundfx", "/system/lib/soundfx"};
#define SOUND_FX_PATH "/lib/soundfx/"
#endif
static constexpr const char* kEffectLibPath[] =
{ "/odm" SOUND_FX_PATH, "/vendor" SOUND_FX_PATH, "/system" SOUND_FX_PATH };
static constexpr const char* kEffectLibApexPath = SOUND_FX_PATH;
#undef SOUND_FX_PATH
int mSkippedElements;
/* Parsed Libraries result */

View file

@ -34,6 +34,6 @@ cc_library_shared {
],
relative_install_path: "soundfx",
visibility: [
"//hardware/interfaces/audio/aidl/default",
"//hardware/interfaces/audio/aidl/default:__subpackages__",
],
}

View file

@ -34,6 +34,6 @@ cc_library_shared {
],
relative_install_path: "soundfx",
visibility: [
"//hardware/interfaces/audio/aidl/default",
"//hardware/interfaces/audio/aidl/default:__subpackages__",
],
}

View file

@ -34,6 +34,6 @@ cc_library_shared {
],
relative_install_path: "soundfx",
visibility: [
"//hardware/interfaces/audio/aidl/default",
"//hardware/interfaces/audio/aidl/default:__subpackages__",
],
}

View file

@ -34,6 +34,6 @@ cc_library_shared {
],
relative_install_path: "soundfx",
visibility: [
"//hardware/interfaces/audio/aidl/default",
"//hardware/interfaces/audio/aidl/default:__subpackages__",
],
}