Snap for 8570526 from b6c56c54561204cef723ca45ffb92a70dcd7d5b1 to mainline-media-swcodec-release

Change-Id: Ic70d558823634d701379f545f49e05dd7ca20988
diff --git a/Android.bp b/Android.bp
index 9fd039e..91ac351 100644
--- a/Android.bp
+++ b/Android.bp
@@ -53,6 +53,7 @@
         "//apex_available:platform",
         "//apex_available:anyapex",
     ],
+    ramdisk_available: true,
     // recovery_available currently required for libchrome (https://r.android.com/799940).
     recovery_available: true,
     visibility: ["//visibility:public"],
@@ -196,13 +197,12 @@
         "//cts:__subpackages__",
         "//external/perfetto:__subpackages__",
         "//frameworks/base/packages/Connectivity/tests/integration:__pkg__",
+        "//frameworks/base/packages/ConnectivityT:__subpackages__", // TODO: remove after code move
         "//frameworks/base/packages/Tethering:__subpackages__",
         "//frameworks/libs/net/common/native/bpfmapjni",
         "//frameworks/libs/net/common/native/bpfutiljni",
         "//libcore:__subpackages__",
-        "//packages/modules/Connectivity/service",
-        "//packages/modules/Connectivity/tests:__subpackages__",
-        "//packages/modules/Connectivity/Tethering:__subpackages__",
+        "//packages/modules/Connectivity:__subpackages__",
         "//packages/modules/ExtServices:__subpackages__",
         "//packages/modules/NetworkStack:__subpackages__",
         ":__subpackages__",
diff --git a/JniInvocation.c b/JniInvocation.c
index 9cfb084..7effddb 100644
--- a/JniInvocation.c
+++ b/JniInvocation.c
@@ -23,14 +23,25 @@
 #include <sys/system_properties.h>
 #endif
 
+#include <errno.h>
 #include <jni.h>
 #include <stdbool.h>
 #include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
 
 #include "DlHelp.h"
 
 // Name the default library providing the JNI Invocation API.
 static const char* kDefaultJniInvocationLibrary = "libart.so";
+static const char* kDebugJniInvocationLibrary = "libartd.so";
+#if defined(__LP64__)
+#define LIB_DIR "lib64"
+#else
+#define LIB_DIR "lib"
+#endif
+static const char* kDebugJniInvocationLibraryPath = "/apex/com.android.art/" LIB_DIR "/libartd.so";
 
 struct JniInvocationImpl {
   // Name of library providing JNI_ method implementations.
@@ -118,10 +129,21 @@
     if (library != NULL) {
       return library;
     }
+
+    // If the debug library is installed, use it.
+    // TODO(b/216099383): Do this in the test harness instead.
+    struct stat st;
+    if (stat(kDebugJniInvocationLibraryPath, &st) == 0) {
+      return kDebugJniInvocationLibrary;
+    } else if (errno != ENOENT) {
+      ALOGW("Failed to stat %s: %s", kDebugJniInvocationLibraryPath, strerror(errno));
+    }
+
     // Choose the system_preferred_library (if provided).
     if (system_preferred_library != NULL) {
       return system_preferred_library;
     }
+
   }
   return kDefaultJniInvocationLibrary;
 }
diff --git a/tests/Android.bp b/tests/Android.bp
index caf8131..99ec108 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -61,7 +61,7 @@
 cc_test {
     name: "libnativehelper_tests",
     defaults: ["libnativehelper_test_defaults"],
-    test_suites: ["device-tests"],
+    test_suites: ["general-tests"],
     srcs: [
         "scoped_local_frame_test.cpp",
         "scoped_local_ref_test.cpp",
@@ -75,7 +75,7 @@
 cc_test {
     name: "libnativehelper_lazy_tests",
     defaults: ["libnativehelper_test_defaults"],
-    test_suites: ["device-tests"],
+    test_suites: ["general-tests"],
     srcs: ["libnativehelper_lazy_test.cpp"],
     shared_libs: ["liblog"],
     static_libs: ["libnativehelper_lazy"],
diff --git a/tests_mts/Android.bp b/tests_mts/Android.bp
index 6496983..9483a62 100644
--- a/tests_mts/Android.bp
+++ b/tests_mts/Android.bp
@@ -34,7 +34,7 @@
     sdk_version: "test_current",
     srcs: ["src/com/android/art/libnativehelper/JniHelpTest.java"],
     test_suites: [
-        "device-tests",
+        "general-tests",
         "mts",
     ],
 }