From 8fc34c4a4dd6505f7e7571e434291c830025a4b6 Mon Sep 17 00:00:00 2001
From: William Escande <wescande@google.com>
Date: Mon, 13 Nov 2023 16:17:11 -0800
Subject: [PATCH] Sysprop: wrap usage because of Floss

Test: m Bluetooth | No-op change
Bug: 310741104
Change-Id: I95d113e90ba710d687722f846f52011950bf3f5d
---
 sysprop/Android.bp                            | 11 ++++++
 .../android_bluetooth_sysprop.h               | 35 +++++++++++++++++++
 system/BUILD.gn                               |  1 +
 system/bta/Android.bp                         | 12 +++----
 system/btif/Android.bp                        |  6 ++--
 system/profile/avrcp/Android.bp               |  2 +-
 system/stack/Android.bp                       |  8 ++---
 system/test/suite/Android.bp                  |  2 +-
 8 files changed, 62 insertions(+), 15 deletions(-)
 create mode 100644 sysprop/exported_include/android_bluetooth_sysprop.h

diff --git a/sysprop/Android.bp b/sysprop/Android.bp
index 4f848817f27..76750c9220d 100644
--- a/sysprop/Android.bp
+++ b/sysprop/Android.bp
@@ -20,3 +20,14 @@ sysprop_library {
     },
     apex_available: ["com.android.btservices"],
 }
+
+cc_library_static {
+    name: "libcom.android.sysprop.bluetooth.wrapped",
+    host_supported: true,
+    whole_static_libs: ["libcom.android.sysprop.bluetooth"],
+    export_include_dirs: ["exported_include"],
+    export_static_lib_headers: ["libcom.android.sysprop.bluetooth"],
+    visibility: ["//packages/modules/Bluetooth/system:__subpackages__"],
+    apex_available: ["com.android.btservices"],
+    min_sdk_version: "Tiramisu",
+}
diff --git a/sysprop/exported_include/android_bluetooth_sysprop.h b/sysprop/exported_include/android_bluetooth_sysprop.h
new file mode 100644
index 00000000000..3a3ccda8fe5
--- /dev/null
+++ b/sysprop/exported_include/android_bluetooth_sysprop.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2023 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
+
+#ifndef TARGET_FLOSS
+
+#include <a2dp.sysprop.h>
+#include <avrcp.sysprop.h>
+#include <ble.sysprop.h>
+#include <bta.sysprop.h>
+#include <hfp.sysprop.h>
+#include <pan.sysprop.h>
+
+#define GET_SYSPROP(namespace, prop, default) \
+  android::sysprop::bluetooth::namespace ::prop().value_or(default)
+
+#else
+
+#define GET_SYSPROP(namespace, prop, default) default
+
+#endif
diff --git a/system/BUILD.gn b/system/BUILD.gn
index a28ca64bd34..02b92d245b2 100644
--- a/system/BUILD.gn
+++ b/system/BUILD.gn
@@ -76,6 +76,7 @@ config("target_defaults") {
   include_dirs = [
     "//bt/system",
     "//bt/flags/exported_include",
+    "//bt/sysprop/exported_include",
     "//bt/system/linux_include",
     "//bt/system/types",
     "//bt/system/include",
diff --git a/system/bta/Android.bp b/system/bta/Android.bp
index 93f578c24bc..3439372f87b 100644
--- a/system/bta/Android.bp
+++ b/system/bta/Android.bp
@@ -139,7 +139,7 @@ cc_library_static {
         "libbt-bta-core",
         "libbt-platform-protos-lite",
         "libbt_shim_bridge",
-        "libcom.android.sysprop.bluetooth",
+        "libcom.android.sysprop.bluetooth.wrapped",
         "liblc3",
     ],
     shared_libs: [
@@ -202,7 +202,7 @@ cc_library_static {
         "lib-bt-packets",
         "libbt-platform-protos-lite",
         "libbt_shim_bridge",
-        "libcom.android.sysprop.bluetooth",
+        "libcom.android.sysprop.bluetooth.wrapped",
     ],
     apex_available: [
         "com.android.btservices",
@@ -280,7 +280,7 @@ cc_test {
         "libbtcore",
         "libbtdevice",
         "libchrome",
-        "libcom.android.sysprop.bluetooth",
+        "libcom.android.sysprop.bluetooth.wrapped",
         "libevent",
         "libgmock",
     ],
@@ -336,7 +336,7 @@ cc_test {
         "libbt_shim_ffi",
         "libbtcore",
         "libchrome",
-        "libcom.android.sysprop.bluetooth",
+        "libcom.android.sysprop.bluetooth.wrapped",
         "libgmock",
     ],
     cflags: ["-Wno-unused-parameter"],
@@ -429,7 +429,7 @@ cc_test {
         "libbtcore",
         "libbtdevice",
         "libchrome",
-        "libcom.android.sysprop.bluetooth",
+        "libcom.android.sysprop.bluetooth.wrapped",
         "libevent",
         "libgmock",
     ],
@@ -1203,7 +1203,7 @@ cc_test {
         "libbt_shim_bridge",
         "libbt_shim_ffi",
         "libchrome",
-        "libcom.android.sysprop.bluetooth",
+        "libcom.android.sysprop.bluetooth.wrapped",
         "libevent",
         "libgmock",
         "libosi",
diff --git a/system/btif/Android.bp b/system/btif/Android.bp
index 56277c4b259..41ff9822efe 100644
--- a/system/btif/Android.bp
+++ b/system/btif/Android.bp
@@ -521,7 +521,7 @@ cc_test {
         "libbt_shim_bridge",
         "libbt_shim_ffi",
         "libchrome",
-        "libcom.android.sysprop.bluetooth",
+        "libcom.android.sysprop.bluetooth.wrapped",
     ],
     cflags: [
         "-DBUILDCFG",
@@ -638,7 +638,7 @@ cc_test {
         "libbtif-core",
         "libc++fs",
         "libchrome",
-        "libcom.android.sysprop.bluetooth",
+        "libcom.android.sysprop.bluetooth.wrapped",
         "libevent",
         "libgmock",
         "libstatslog_bt",
@@ -775,7 +775,7 @@ cc_test {
         "libbtif-core",
         "libc++fs",
         "libchrome",
-        "libcom.android.sysprop.bluetooth",
+        "libcom.android.sysprop.bluetooth.wrapped",
         "libevent",
         "libgmock",
         "libstatslog_bt",
diff --git a/system/profile/avrcp/Android.bp b/system/profile/avrcp/Android.bp
index bd4380b4b89..34e3d1df48f 100644
--- a/system/profile/avrcp/Android.bp
+++ b/system/profile/avrcp/Android.bp
@@ -31,7 +31,7 @@ cc_library_static {
         "libosi",
     ],
     whole_static_libs: [
-        "libcom.android.sysprop.bluetooth",
+        "libcom.android.sysprop.bluetooth.wrapped",
     ],
     shared_libs: [
         "liblog",
diff --git a/system/stack/Android.bp b/system/stack/Android.bp
index 5f57faa8b7c..ea6114872f2 100644
--- a/system/stack/Android.bp
+++ b/system/stack/Android.bp
@@ -171,7 +171,7 @@ cc_library_static {
     whole_static_libs: [
         "libaptx_enc",
         "libaptxhd_enc",
-        "libcom.android.sysprop.bluetooth",
+        "libcom.android.sysprop.bluetooth.wrapped",
         "libldacBT_abr",
         "libldacBT_enc",
     ],
@@ -324,7 +324,7 @@ cc_library_static {
         "libbt-hci",
         "libbt-platform-protos-lite",
         "libbt_shim_bridge",
-        "libcom.android.sysprop.bluetooth",
+        "libcom.android.sysprop.bluetooth.wrapped",
     ],
     shared_libs: [
         "libPlatformProperties",
@@ -612,7 +612,7 @@ cc_fuzz {
     target: {
         android: {
             static_libs: [
-                "libcom.android.sysprop.bluetooth",
+                "libcom.android.sysprop.bluetooth.wrapped",
             ],
         },
     },
@@ -1548,7 +1548,7 @@ cc_test {
         "libbt_shim_ffi",
         "libbtdevice",
         "libchrome",
-        "libcom.android.sysprop.bluetooth",
+        "libcom.android.sysprop.bluetooth.wrapped",
         "libevent",
         "libgmock",
         "liblc3",
diff --git a/system/test/suite/Android.bp b/system/test/suite/Android.bp
index 1fd608b022c..1fb71fb269d 100644
--- a/system/test/suite/Android.bp
+++ b/system/test/suite/Android.bp
@@ -87,7 +87,7 @@ cc_defaults {
         "libbtif",
         "libbtif-core",
         "libc++fs",
-        "libcom.android.sysprop.bluetooth",
+        "libcom.android.sysprop.bluetooth.wrapped",
         "libflatbuffers-cpp",
         "libg722codec",
         "libgmock",
-- 
GitLab