Merge tag 'android-13.0.0_r35' into staging/lineage-20.0_merge-android-13.0.0_r35

Android 13.0.0 release 35

# -----BEGIN PGP SIGNATURE-----
#
# iF0EABECAB0WIQRDQNE1cO+UXoOBCWTorT+BmrEOeAUCZA9jygAKCRDorT+BmrEO
# eJy4AKCOmioLpogXXVOxUkFzzFfzeCAykwCggjUX8ytrl64rymJH30zs9y7ZTtU=
# =cwHu
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon Mar 13 19:56:26 2023 EET
# gpg:                using DSA key 4340D13570EF945E83810964E8AD3F819AB10E78
# gpg: Good signature from "The Android Open Source Project <initial-contribution@android.com>" [marginal]
# gpg: initial-contribution@android.com: Verified 1594 signatures in the past
#      16 months.  Encrypted 4 messages in the past 14 months.
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 4340 D135 70EF 945E 8381  0964 E8AD 3F81 9AB1 0E78

# By Steven Moreland
# Via Automerger Merge Worker (10) and others
* tag 'android-13.0.0_r35':
  libhidl: check ro.debuggable less

Change-Id: I39dd7059810ce6ff0b76fdae42e9a3d5ed906a16
diff --git a/libhidlmemory/Android.bp b/libhidlmemory/Android.bp
index fc5770c..537eb74 100644
--- a/libhidlmemory/Android.bp
+++ b/libhidlmemory/Android.bp
@@ -23,6 +23,7 @@
 
 cc_library {
     name: "libhidlmemory",
+    recovery_available: true,
     vendor_available: true,
     product_available: true,
     // Host support is needed for testing only
diff --git a/transport/HidlBinderSupport.cpp b/transport/HidlBinderSupport.cpp
index 8b36f1f..6e3038c 100644
--- a/transport/HidlBinderSupport.cpp
+++ b/transport/HidlBinderSupport.cpp
@@ -254,6 +254,10 @@
 
     if (sBnObj == nullptr) {
         auto func = details::getBnConstructorMap().get(descriptor, nullptr);
+        if (!func) {
+            // TODO(b/69122224): remove this static variable when prebuilts updated
+            func = details::gBnConstructorMap->get(descriptor, nullptr);
+        }
         LOG_ALWAYS_FATAL_IF(func == nullptr, "%s getBnConstructorMap returned null for %s",
                             __func__, descriptor.c_str());
 
diff --git a/transport/HidlPassthroughSupport.cpp b/transport/HidlPassthroughSupport.cpp
index e059b4d..6f30b7b 100644
--- a/transport/HidlPassthroughSupport.cpp
+++ b/transport/HidlPassthroughSupport.cpp
@@ -29,6 +29,10 @@
 
 static sp<IBase> tryWrap(const std::string& descriptor, sp<IBase> iface) {
     auto func = getBsConstructorMap().get(descriptor, nullptr);
+    if (!func) {
+        // TODO(b/69122224): remove this when prebuilts don't reference it
+        func = gBsConstructorMap->get(descriptor, nullptr);
+    }
     if (func) {
         return func(static_cast<void*>(iface.get()));
     }
diff --git a/transport/InternalStatic.h b/transport/InternalStatic.h
index a0d1c2d..666b2b6 100644
--- a/transport/InternalStatic.h
+++ b/transport/InternalStatic.h
@@ -28,6 +28,13 @@
 namespace details {
 
 // TODO(b/69122224): remove this once no prebuilts reference it
+// deprecated; use getBnConstructorMap instead.
+extern DoNotDestruct<BnConstructorMap> gBnConstructorMap;
+// TODO(b/69122224): remove this once no prebuilts reference it
+// deprecated; use getBsConstructorMap instead.
+extern DoNotDestruct<BsConstructorMap> gBsConstructorMap;
+
+// TODO(b/69122224): remove this once no prebuilts reference it
 extern DoNotDestruct<ConcurrentMap<wp<::android::hidl::base::V1_0::IBase>, SchedPrio>>
         gServicePrioMap;
 // TODO(b/69122224): remove this once no prebuilts reference it
diff --git a/transport/Static.cpp b/transport/Static.cpp
index fe7c0f0..240d196 100644
--- a/transport/Static.cpp
+++ b/transport/Static.cpp
@@ -27,6 +27,9 @@
 namespace hardware {
 namespace details {
 
+// Deprecated; kept for ABI compatibility. Use getBnConstructorMap.
+DoNotDestruct<BnConstructorMap> gBnConstructorMap{};
+
 DoNotDestruct<ConcurrentMap<const ::android::hidl::base::V1_0::IBase*,
                             wp<::android::hardware::BHwBinder>>>
         gBnMap{};
@@ -35,6 +38,11 @@
 DoNotDestruct<ConcurrentMap<wp<::android::hidl::base::V1_0::IBase>, SchedPrio>> gServicePrioMap{};
 DoNotDestruct<ConcurrentMap<wp<::android::hidl::base::V1_0::IBase>, bool>> gServiceSidMap{};
 
+// Deprecated; kept for ABI compatibility. Use getBsConstructorMap.
+DoNotDestruct<BsConstructorMap> gBsConstructorMap{};
+
+// For static executables, it is not guaranteed that gBnConstructorMap are initialized before
+// used in HAL definition libraries.
 BnConstructorMap& getBnConstructorMap() {
     static BnConstructorMap& map = *new BnConstructorMap();
     return map;