Detect native bridge via system properties in NativeAllocationRegisteryTest

The uname-based detection for native bridge translation in
NativeAllocationRegisteryTest was brittle and needed to be updated for
each native bridge architecture. Using system properties is more robust
and does not require manual updating for new architectures, such as
RISC-V.

Test: cts-tradefed run cts -m CtsLibcoreTestCases \
-t libcore.libcore.util.NativeAllocationRegistryTest
(with and without native bridge)
Bug: 277619571

Change-Id: I14b972afe0bcb5e80ef8af8244fce9165565414a
diff --git a/luni/src/test/native/libcore_libcore_util_NativeAllocationRegistryTest.cpp b/luni/src/test/native/libcore_libcore_util_NativeAllocationRegistryTest.cpp
index b901189..572c69e 100644
--- a/luni/src/test/native/libcore_libcore_util_NativeAllocationRegistryTest.cpp
+++ b/luni/src/test/native/libcore_libcore_util_NativeAllocationRegistryTest.cpp
@@ -21,53 +21,22 @@
 #include <atomic>
 #include <string>
 
+#include <android-base/macros.h>
 #include <jni.h>
 #include <nativehelper/JNIHelp.h>
 #include <nativehelper/ScopedUtfChars.h>
 
-constexpr bool IsX86BuildArch() {
-#if defined(__i386__)
-  return true;
-#elif defined(__x86_64__)
-  return true;
-#else
-  return false;
+#if defined(__BIONIC__)
+#include <sys/system_properties.h>
 #endif
-}
-
-constexpr bool IsArmBuildArch() {
-#if defined(__arm__)
-  return true;
-#elif defined(__aarch64__)
-  return true;
-#else
-  return false;
-#endif
-}
 
 extern "C"
 jboolean Java_libcore_libcore_util_NativeAllocationRegistryTest_isNativeBridgedABI(JNIEnv*, jclass) {
-  FILE* fp = popen("uname -m", "re");
-  char buf[128];
-  memset(buf, '\0', sizeof(buf));
-  char* str = fgets(buf, sizeof(buf), fp);
-  pclose(fp);
-  if (!str) {
-    // Assume no native bridge if cannot do uname.
-    return static_cast<jboolean>(false);
-  }
-
-  std::string uname_string = buf;
-  bool is_native_bridged_abi;
-  if (IsX86BuildArch()) {
-    is_native_bridged_abi = uname_string.find("86") == std::string::npos;
-  } else if (IsArmBuildArch()) {
-    is_native_bridged_abi = uname_string.find("arm") == std::string::npos &&
-        uname_string.find("aarch64") == std::string::npos;
-  } else {
-    is_native_bridged_abi = false;
-  }
-  return static_cast<jboolean>(is_native_bridged_abi);
+#if defined(__BIONIC__)
+  return __system_property_find("ro.dalvik.vm.isa." ABI_STRING) != nullptr;
+#else
+  return false;
+#endif
 }
 
 std::atomic<uint64_t> gNumNativeBytesAllocated = 0;