gsi: sysbta: Implement all existing audio HAL versions

This is needed because libaudiohal.so can only interact with one HAL
version at a time (loading only one of the libaudiohal@version.so
implementations), so only the interface that matches the stock HAL
version will be used. libaudiohal decides which version to use by
looking through the interfaces whose variant is `default` and picking
the highest versioned one, so our hal will not interfere in the process
(because we use `sysbta` as our variant).
This commit is contained in:
Peter Cai 2022-08-24 21:07:35 -04:00 committed by Pierre-Hugues Husson
parent 4f1e4824dc
commit 420f583758
4 changed files with 98 additions and 14 deletions

View File

@ -37,6 +37,52 @@ cc_defaults {
]
}
cc_library_shared {
name: "android.hardware.audio@2.0-impl-system",
defaults: ["android.hardware.audio-impl-system_default"],
shared_libs: [
"android.hardware.audio@2.0",
"android.hardware.audio@2.0-util",
"android.hardware.audio.common@2.0",
"android.hardware.audio.common@2.0-util",
],
cflags: [
"-DMAJOR_VERSION=2",
"-DMINOR_VERSION=0",
"-include common/all-versions/VersionMacro.h",
],
}
cc_library_shared {
name: "android.hardware.audio@4.0-impl-system",
defaults: ["android.hardware.audio-impl-system_default"],
shared_libs: [
"android.hardware.audio@4.0",
"android.hardware.audio@4.0-util",
"android.hardware.audio.common@4.0",
"android.hardware.audio.common@4.0-util",
],
cflags: [
"-DMAJOR_VERSION=4",
"-DMINOR_VERSION=0",
"-include common/all-versions/VersionMacro.h",
],
}
cc_library_shared {
name: "android.hardware.audio@5.0-impl-system",
defaults: ["android.hardware.audio-impl-system_default"],
shared_libs: [
"android.hardware.audio@5.0",
"android.hardware.audio@5.0-util",
"android.hardware.audio.common@5.0",
"android.hardware.audio.common@5.0-util",
],
cflags: [
"-DMAJOR_VERSION=5",
"-DMINOR_VERSION=0",
"-include common/all-versions/VersionMacro.h",
],
}
cc_library_shared {
name: "android.hardware.audio@6.0-impl-system",
defaults: ["android.hardware.audio-impl-system_default"],
@ -49,6 +95,43 @@ cc_library_shared {
cflags: [
"-DMAJOR_VERSION=6",
"-DMINOR_VERSION=0",
"-include common/all-versions/VersionMacro.h",
],
}
cc_library_shared {
name: "android.hardware.audio@7.0-impl-system",
defaults: ["android.hardware.audio-impl-system_default"],
shared_libs: [
"android.hardware.audio@7.0",
"android.hardware.audio@7.0-util",
"android.hardware.audio.common@7.0",
"android.hardware.audio.common@7.0-enums",
"android.hardware.audio.common@7.0-util",
"libbase",
],
cflags: [
"-DMAJOR_VERSION=7",
"-DMINOR_VERSION=0",
"-include common/all-versions/VersionMacro.h",
],
}
cc_library_shared {
name: "android.hardware.audio@7.1-impl-system",
defaults: ["android.hardware.audio-impl-system_default"],
shared_libs: [
"android.hardware.audio@7.0",
"android.hardware.audio@7.1",
"android.hardware.audio@7.1-util",
"android.hardware.audio.common@7.0",
"android.hardware.audio.common@7.1-enums",
"android.hardware.audio.common@7.1-util",
"libbase",
],
cflags: [
"-DMAJOR_VERSION=7",
"-DMINOR_VERSION=1",
"-DCOMMON_TYPES_MINOR_VERSION=0",
"-DCORE_TYPES_MINOR_VERSION=0",
"-include common/all-versions/VersionMacro.h",

View File

@ -30,6 +30,11 @@ cc_binary {
],
required: [
// Audio HAL impls
"android.hardware.audio@2.0-impl-system",
"android.hardware.audio@4.0-impl-system",
"android.hardware.audio@5.0-impl-system",
"android.hardware.audio@6.0-impl-system",
"android.hardware.audio@7.0-impl-system",
"android.hardware.audio@7.1-impl-system",
],
}

View File

@ -7,6 +7,11 @@
<hal>
<name>android.hardware.audio</name>
<transport>hwbinder</transport>
<fqname>@2.0::IDevicesFactory/sysbta</fqname>
<fqname>@4.0::IDevicesFactory/sysbta</fqname>
<fqname>@5.0::IDevicesFactory/sysbta</fqname>
<fqname>@6.0::IDevicesFactory/sysbta</fqname>
<fqname>@7.0::IDevicesFactory/sysbta</fqname>
<fqname>@7.1::IDevicesFactory/sysbta</fqname>
</hal>
</manifest>

View File

@ -23,24 +23,14 @@
#include <android/binder_process.h>
#include <utils/Log.h>
#include <hidl/HidlTransportSupport.h>
//#include <hidl/LegacySupport.h>
#include <hwbinder/ProcessState.h>
#include <binder/ProcessState.h>
//#include PATH(android/hardware/audio/FILE_VERSION/IDevicesFactory.h)
//#include <hardware/audio.h>
#include "BluetoothAudioProviderFactory.h"
//#include "DevicesFactory.h"
//using namespace android::hardware;
using ::aidl::android::hardware::bluetooth::audio::
BluetoothAudioProviderFactory;
//using ::android::hardware::audio::CPP_VERSION::implementation::DevicesFactory;
//using namespace ::android::hardware::audio::CPP_VERSION;
#if defined(__LP64__)
#define HAL_LIBRARY_PATH "/system/lib64/hw"
#else
@ -49,7 +39,12 @@ using ::aidl::android::hardware::bluetooth::audio::
void registerAudioInterfaces() {
const char *interface_libs[] = {
"android.hardware.audio@2.0-impl-system.so",
"android.hardware.audio@4.0-impl-system.so",
"android.hardware.audio@5.0-impl-system.so",
"android.hardware.audio@6.0-impl-system.so",
"android.hardware.audio@7.0-impl-system.so",
"android.hardware.audio@7.1-impl-system.so",
};
for (auto& lib : interface_libs) {
@ -89,10 +84,6 @@ int main() {
ALOGW_IF(aidl_status != STATUS_OK, "Could not register %s, status=%d",
instance_name.c_str(), aidl_status);
//::android::sp<IDevicesFactory> audio_factory = new DevicesFactory();
//::android::status_t hidl_status = audio_factory->registerAsService("sysbta");
//ALOGW_IF(hidl_status != STATUS_OK, "Could not register sysbta, status=%d", hidl_status);
// We must also implement audio HAL interfaces in order to serve audio.sysbta.default.so
// It must be served in the *same* process to access the same libbluetooth_audio_session
registerAudioInterfaces();