From 65a2ed67f80bae2dcd006d81681824ea2d8caac9 Mon Sep 17 00:00:00 2001
From: David Duarte <licorne@google.com>
Date: Fri, 12 May 2023 09:22:12 +0000
Subject: [PATCH] Move android.hardware.bluetooth.audio-V3-ndk to static_libs
 in tests

android.hardware.bluetooth.audio-V3-ndk.so is not present on the system
image if neither the APEX or the HAL bring it in.

Make the test able to work on system image without this library
by linking it statically.

Bug: 279502784
Fix: 267212763

Test: mma
Change-Id: I3ea3fc11d57b7c8149c87608d2149dbe306a5cb8
---
 system/btif/Android.bp       | 22 +++++++++++++++++++---
 system/stack/Android.bp      |  6 +++++-
 system/test/suite/Android.bp |  8 +++++---
 3 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/system/btif/Android.bp b/system/btif/Android.bp
index fb37c64289e..f1771f2759f 100644
--- a/system/btif/Android.bp
+++ b/system/btif/Android.bp
@@ -260,8 +260,13 @@ cc_test {
     ],
     static_libs: [
         "android.hardware.bluetooth.a2dp@1.0",
+        "android.hardware.audio.common-V1-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",
         "android.system.suspend.control-V1-ndk",
         "libFraunhoferAAC",
         "libbluetooth-types",
@@ -295,7 +300,6 @@ cc_test {
     target: {
         android: {
             shared_libs: [
-                "android.hardware.bluetooth.audio-V3-ndk",
                 "libPlatformProperties",
                 "libbinder_ndk",
             ],
@@ -558,8 +562,14 @@ cc_test {
     cflags: ["-DBUILDCFG"],
     target: {
         android: {
-            shared_libs: [
+            static_libs: [
+                "android.hardware.audio.common-V1-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",
             ],
         },
@@ -683,8 +693,14 @@ cc_test {
     cflags: ["-DBUILDCFG"],
     target: {
         android: {
-            shared_libs: [
+            static_libs: [
+                "android.hardware.audio.common-V1-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 ffc4902dab6..fb7eac267f0 100644
--- a/system/stack/Android.bp
+++ b/system/stack/Android.bp
@@ -312,7 +312,6 @@ cc_test {
         "test/stack_avrcp_test.cc",
     ],
     shared_libs: [
-        "android.hardware.bluetooth.audio-V3-ndk",
         "android.hardware.bluetooth.audio@2.0",
         "android.hardware.bluetooth.audio@2.1",
         "libPlatformProperties",
@@ -330,8 +329,13 @@ cc_test {
     ],
     static_libs: [
         "android.hardware.bluetooth.a2dp@1.0",
+        "android.hardware.audio.common-V1-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",
         "android.system.suspend.control-V1-ndk",
         "libFraunhoferAAC",
         "libbluetooth-dumpsys",
diff --git a/system/test/suite/Android.bp b/system/test/suite/Android.bp
index 4cb015234b7..f448ffc1e2d 100644
--- a/system/test/suite/Android.bp
+++ b/system/test/suite/Android.bp
@@ -119,12 +119,14 @@ cc_test {
         "gatt/gatt_unittest.cc",
     ],
     static_libs: [
+        "android.hardware.audio.common-V1-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",
         "libchrome",
         "libevent",
     ],
-    shared_libs: [
-        "android.hardware.bluetooth.audio-V3-ndk",
-    ],
 }
-- 
GitLab