From 0dc9dcca33ab9142548b44c02ae62a4578ea7321 Mon Sep 17 00:00:00 2001
From: Shunkai Yao <yaoshunkai@google.com>
Date: Tue, 10 Oct 2023 19:34:03 +0000
Subject: [PATCH] Update Spatialization and HeadTracking AIDL usage

Use latest_android AIDL interfaces to replace the one with version

Ignore-AOSP-First: Will cherry-pick to AOSP
Bug: 273373363
Bug: 293370815
Test: m -j32
Test: lunch panther-trunk_staging-userdebug; m
Test: Test Bluetooth Audio functionality on Panther
Change-Id: If37def1c3c9a2fe9192a4a039b282ba7cce17e8e
Merged-In: If37def1c3c9a2fe9192a4a039b282ba7cce17e8e
---
 android/app/Android.bp                       | 10 ++++++----
 system/audio_bluetooth_hw/Android.bp         |  8 +++++---
 system/audio_hal_interface/Android.bp        |  8 +++++---
 system/audio_hal_interface/fuzzer/Android.bp |  4 +++-
 system/btif/Android.bp                       | 18 +++++++++---------
 system/stack/Android.bp                      |  6 +++---
 system/stack/test/fuzzers/Android.bp         |  6 ++++--
 system/test/headless/Android.bp              |  2 +-
 system/test/suite/Android.bp                 |  6 +++---
 9 files changed, 39 insertions(+), 29 deletions(-)

diff --git a/android/app/Android.bp b/android/app/Android.bp
index 80b1450d510..52f1a26aa84 100644
--- a/android/app/Android.bp
+++ b/android/app/Android.bp
@@ -55,7 +55,12 @@ java_library {
 
 cc_library_shared {
     name: "libbluetooth_jni",
-    defaults: ["fluoride_defaults"],
+    defaults: [
+        "fluoride_defaults",
+        "latest_android_hardware_audio_common_ndk_static",
+        "latest_android_hardware_bluetooth_audio_ndk_static",
+        "latest_android_media_audio_common_types_ndk_static",
+    ],
     srcs: ["jni/**/*.cpp"],
     version_script: "libbluetooth_jni.map",
     header_libs: [
@@ -77,16 +82,13 @@ cc_library_shared {
     // is required to maintain FIPS compliance.
     stl: "libc++_static",
     static_libs: [
-        "android.hardware.audio.common-V2-ndk",
         "android.hardware.audio.common@5.0",
-        "android.hardware.bluetooth.audio-V3-ndk",
         "android.hardware.bluetooth.audio@2.0",
         "android.hardware.bluetooth.audio@2.1",
         "android.hardware.bluetooth@1.0",
         "android.hardware.bluetooth@1.1",
         "android.hardware.common-V2-ndk",
         "android.hardware.common.fmq-V1-ndk",
-        "android.media.audio.common.types-V2-ndk",
         "android.system.suspend-V1-ndk",
         "android.system.suspend.control-V1-ndk",
         "avrcp-target-service",
diff --git a/system/audio_bluetooth_hw/Android.bp b/system/audio_bluetooth_hw/Android.bp
index 67d286ec00b..01763dc2bde 100644
--- a/system/audio_bluetooth_hw/Android.bp
+++ b/system/audio_bluetooth_hw/Android.bp
@@ -20,7 +20,11 @@ cc_defaults {
 
 cc_library_shared {
     name: "audio.bluetooth.default",
-    defaults: ["audio_bluetooth_hw_defaults"],
+    defaults: [
+        "audio_bluetooth_hw_defaults",
+        "latest_android_hardware_audio_common_ndk_shared",
+        "latest_android_hardware_bluetooth_audio_ndk_shared",
+    ],
     relative_install_path: "hw",
     proprietary: true,
     srcs: [
@@ -32,8 +36,6 @@ cc_library_shared {
     ],
     header_libs: ["libhardware_headers"],
     shared_libs: [
-        "android.hardware.audio.common-V2-ndk",
-        "android.hardware.bluetooth.audio-V3-ndk",
         "libaudioutils",
         "libbase",
         "libbinder_ndk",
diff --git a/system/audio_hal_interface/Android.bp b/system/audio_hal_interface/Android.bp
index 47e7b4966ba..b44d635e47e 100644
--- a/system/audio_hal_interface/Android.bp
+++ b/system/audio_hal_interface/Android.bp
@@ -33,7 +33,7 @@ cc_library_static {
     target: {
         android: {
             shared_libs: [
-                "android.hardware.bluetooth.audio-V3-ndk",
+                "android.hardware.bluetooth.audio-V4-ndk",
                 "libbinder_ndk",
                 "libfmq",
             ],
@@ -79,7 +79,10 @@ cc_library_static {
 // Bluetooth Audio client interface library unit tests for target and host
 cc_test {
     name: "bluetooth-test-audio-hal-interface",
-    defaults: ["fluoride_defaults"],
+    defaults: [
+        "fluoride_defaults",
+        "latest_android_hardware_bluetooth_audio_ndk_shared",
+    ],
     include_dirs: [
         "packages/modules/Bluetooth/system",
         "packages/modules/Bluetooth/system/gd",
@@ -89,7 +92,6 @@ cc_test {
         "hidl/client_interface_hidl_unittest.cc",
     ],
     shared_libs: [
-        "android.hardware.bluetooth.audio-V3-ndk",
         "android.hardware.bluetooth.audio@2.0",
         "android.hardware.bluetooth.audio@2.1",
         "libbinder_ndk",
diff --git a/system/audio_hal_interface/fuzzer/Android.bp b/system/audio_hal_interface/fuzzer/Android.bp
index 3b7449e4083..a0b7b1d7276 100644
--- a/system/audio_hal_interface/fuzzer/Android.bp
+++ b/system/audio_hal_interface/fuzzer/Android.bp
@@ -29,9 +29,11 @@ cc_defaults {
         "avrcp_headers",
         "libbluetooth_headers",
     ],
+    defaults: [
+        "latest_android_hardware_bluetooth_audio_ndk_shared",
+    ],
     shared_libs: [
         "android.hardware.bluetooth.a2dp@1.0",
-        "android.hardware.bluetooth.audio-V3-ndk",
         "android.hardware.bluetooth.audio@2.0",
         "android.hardware.bluetooth.audio@2.1",
         "android.hardware.bluetooth@1.0",
diff --git a/system/btif/Android.bp b/system/btif/Android.bp
index 4aac9aa7d4e..56a8513af13 100644
--- a/system/btif/Android.bp
+++ b/system/btif/Android.bp
@@ -259,6 +259,9 @@ cc_test {
     defaults: [
         "bluetooth_gtest_x86_asan_workaround",
         "fluoride_defaults",
+        "latest_android_hardware_audio_common_ndk_static",
+        "latest_android_hardware_bluetooth_audio_ndk_static",
+        "latest_android_media_audio_common_types_ndk_static",
         "mts_defaults",
     ],
     test_suites: ["general-tests"],
@@ -282,14 +285,11 @@ cc_test {
         "server_configurable_flags",
     ],
     static_libs: [
-        "android.hardware.audio.common-V2-ndk",
         "android.hardware.bluetooth.a2dp@1.0",
-        "android.hardware.bluetooth.audio-V3-ndk",
         "android.hardware.bluetooth@1.0",
         "android.hardware.bluetooth@1.1",
         "android.hardware.common-V2-ndk",
         "android.hardware.common.fmq-V1-ndk",
-        "android.media.audio.common.types-V2-ndk",
         "android.system.suspend.control-V1-ndk",
         "libFraunhoferAAC",
         "libbluetooth-types",
@@ -541,6 +541,9 @@ cc_test {
     defaults: [
         "bluetooth_gtest_x86_asan_workaround",
         "fluoride_defaults",
+        "latest_android_hardware_audio_common_ndk_static",
+        "latest_android_hardware_bluetooth_audio_ndk_static",
+        "latest_android_media_audio_common_types_ndk_static",
         "mts_defaults",
     ],
     test_suites: ["general-tests"],
@@ -654,11 +657,8 @@ cc_test {
     target: {
         android: {
             static_libs: [
-                "android.hardware.audio.common-V2-ndk",
-                "android.hardware.bluetooth.audio-V3-ndk",
                 "android.hardware.common-V2-ndk",
                 "android.hardware.common.fmq-V1-ndk",
-                "android.media.audio.common.types-V2-ndk",
             ],
             shared_libs: [
                 "libbinder_ndk",
@@ -680,6 +680,9 @@ cc_test {
     defaults: [
         "bluetooth_gtest_x86_asan_workaround",
         "fluoride_defaults",
+        "latest_android_hardware_audio_common_ndk_static",
+        "latest_android_hardware_bluetooth_audio_ndk_static",
+        "latest_android_media_audio_common_types_ndk_static",
         "mts_defaults",
     ],
     test_suites: ["general-tests"],
@@ -792,11 +795,8 @@ cc_test {
     target: {
         android: {
             static_libs: [
-                "android.hardware.audio.common-V2-ndk",
-                "android.hardware.bluetooth.audio-V3-ndk",
                 "android.hardware.common-V2-ndk",
                 "android.hardware.common.fmq-V1-ndk",
-                "android.media.audio.common.types-V2-ndk",
             ],
             shared_libs: [
                 "libbinder_ndk",
diff --git a/system/stack/Android.bp b/system/stack/Android.bp
index 16edd7398f5..e9f5c0d5c31 100644
--- a/system/stack/Android.bp
+++ b/system/stack/Android.bp
@@ -672,6 +672,9 @@ cc_test {
     defaults: [
         "bluetooth_gtest_x86_asan_workaround",
         "fluoride_defaults",
+        "latest_android_hardware_audio_common_ndk_static",
+        "latest_android_hardware_bluetooth_audio_ndk_shared",
+        "latest_android_media_audio_common_types_ndk_static",
         "mts_defaults",
     ],
     test_suites: ["general-tests"],
@@ -706,14 +709,11 @@ cc_test {
         "server_configurable_flags",
     ],
     static_libs: [
-        "android.hardware.audio.common-V2-ndk",
         "android.hardware.bluetooth.a2dp@1.0",
-        "android.hardware.bluetooth.audio-V3-ndk",
         "android.hardware.bluetooth@1.0",
         "android.hardware.bluetooth@1.1",
         "android.hardware.common-V2-ndk",
         "android.hardware.common.fmq-V1-ndk",
-        "android.media.audio.common.types-V2-ndk",
         "android.system.suspend.control-V1-ndk",
         "libFraunhoferAAC",
         "libbluetooth-dumpsys",
diff --git a/system/stack/test/fuzzers/Android.bp b/system/stack/test/fuzzers/Android.bp
index ae570c5d87e..0ccc90faf42 100644
--- a/system/stack/test/fuzzers/Android.bp
+++ b/system/stack/test/fuzzers/Android.bp
@@ -9,7 +9,10 @@ package {
 
 cc_defaults {
     name: "libbt-stack_fuzz_defaults",
-    defaults: ["fluoride_defaults"],
+    defaults: [
+        "fluoride_defaults",
+        "latest_android_hardware_bluetooth_audio_ndk_shared",
+    ],
     include_dirs: [
         "packages/modules/Bluetooth/system/",
         "packages/modules/Bluetooth/system/gd/",
@@ -50,7 +53,6 @@ cc_defaults {
     ],
     shared_libs: [
         "android.hardware.bluetooth.a2dp@1.0",
-        "android.hardware.bluetooth.audio-V3-ndk",
         "android.hardware.bluetooth.audio@2.0",
         "android.hardware.bluetooth.audio@2.1",
         "android.hardware.bluetooth@1.0",
diff --git a/system/test/headless/Android.bp b/system/test/headless/Android.bp
index c56e047b455..3c67dd093a2 100644
--- a/system/test/headless/Android.bp
+++ b/system/test/headless/Android.bp
@@ -28,6 +28,7 @@ cc_binary {
     name: "bt_headless",
     defaults: [
         "fluoride_defaults",
+        "latest_android_hardware_bluetooth_audio_ndk_shared",
     ],
     cflags: [
         "-Wall",
@@ -110,7 +111,6 @@ cc_binary {
         "libz",
     ],
     shared_libs: [
-        "android.hardware.bluetooth.audio-V3-ndk",
         "android.hardware.bluetooth.audio@2.0",
         "android.hardware.bluetooth.audio@2.1",
         "android.hardware.bluetooth@1.0",
diff --git a/system/test/suite/Android.bp b/system/test/suite/Android.bp
index 695cee61e99..95bea9ff756 100644
--- a/system/test/suite/Android.bp
+++ b/system/test/suite/Android.bp
@@ -107,6 +107,9 @@ cc_test {
     test_suites: ["general-tests"],
     defaults: [
         "bluetooth_gtest_x86_asan_workaround",
+        "latest_android_hardware_audio_common_ndk_static",
+        "latest_android_hardware_bluetooth_audio_ndk_static",
+        "latest_android_media_audio_common_types_ndk_static",
         "mts_defaults",
         "net_test_defaults",
     ],
@@ -116,13 +119,10 @@ cc_test {
         "gatt/gatt_unittest.cc",
     ],
     static_libs: [
-        "android.hardware.audio.common-V2-ndk",
-        "android.hardware.bluetooth.audio-V3-ndk",
         "android.hardware.bluetooth@1.0",
         "android.hardware.bluetooth@1.1",
         "android.hardware.common-V2-ndk",
         "android.hardware.common.fmq-V1-ndk",
-        "android.media.audio.common.types-V2-ndk",
         "libbluetooth_gd",
         "libbt-btu-main-thread",
         "libbt-platform-protos-lite",
-- 
GitLab