Merge "Snap for 11871564 from e5ddaeeccb966b40f388f0e578e5959908be8a9f to sdk-release" into sdk-release
diff --git a/Android.bp b/Android.bp
index 8bd49c5..7550873 100644
--- a/Android.bp
+++ b/Android.bp
@@ -102,19 +102,18 @@
min_sdk_version: "S", // 31
}
-cc_library_shared {
- name: "libnativehelper",
+// This library contains code that is compatible with
+// both ART and JVM. All code specific to ART should go
+// inside libnativehelper directly.
+cc_library_static {
+ name: "libnativehelper_any_vm",
defaults: ["libnativehelper_defaults"],
- bootstrap: false,
host_supported: true,
srcs: [
"DlHelp.c",
"ExpandableString.c",
"JNIHelp.c",
- "JNIPlatformHelp.c",
- "JniConstants.c",
"JniInvocation.c",
- "file_descriptor_jni.c",
],
export_include_dirs: [
"header_only_include",
@@ -123,6 +122,32 @@
"include_platform",
"include_platform_header_only",
],
+ visibility: ["//frameworks/base/libs/nativehelper_jvm"],
+ stl: "none",
+ apex_available: [
+ "com.android.art",
+ "com.android.art.debug",
+ ],
+ min_sdk_version: "S", // 31
+ target: {
+ windows: {
+ enabled: true,
+ },
+ },
+}
+
+cc_library_shared {
+ name: "libnativehelper",
+ defaults: ["libnativehelper_defaults"],
+ bootstrap: false,
+ host_supported: true,
+ srcs: [
+ "JNIPlatformHelp.c",
+ "JniConstants.c",
+ "file_descriptor_jni.c",
+ ],
+ whole_static_libs: ["libnativehelper_any_vm"],
+ export_static_lib_headers: ["libnativehelper_any_vm"],
stl: "none",
stubs: {
symbol_file: "libnativehelper.map.txt",
diff --git a/include/nativehelper/JNIHelp.h b/include/nativehelper/JNIHelp.h
index 6538ddf..f34a110 100644
--- a/include/nativehelper/JNIHelp.h
+++ b/include/nativehelper/JNIHelp.h
@@ -96,7 +96,12 @@
}
[[maybe_unused]] static const char* platformStrError(int errnum, char* buf, size_t buflen) {
+#ifdef _WIN32
+ strerror_s(buf, buflen, errnum);
+ return buf;
+#else
return safe_strerror(strerror_r, errnum, buf, buflen);
+#endif
}
[[maybe_unused]] static jmethodID FindMethod(JNIEnv* env, const char* className,