Index: base/android/linker/linker_jni.cc |
diff --git a/base/android/linker/linker_jni.cc b/base/android/linker/linker_jni.cc |
index 30aced19769acc594e2953c6933be08f2d0d7877..2b5a07dd203947dd52c33e9aff82ccf20053c2c2 100644 |
--- a/base/android/linker/linker_jni.cc |
+++ b/base/android/linker/linker_jni.cc |
@@ -576,6 +576,28 @@ jlong GetRandomBaseLoadAddress(JNIEnv* env, jclass clazz, jlong bytes) { |
return static_cast<jlong>(reinterpret_cast<uintptr_t>(address)); |
} |
+// Get the full path of a library in the zip file |
+// (lib/<abi>/crazy.<lib_name>). |
+// |
+// |env| is the current JNI environment handle. |
+// |clazz| is the static class handle which is not used here. |
+// |lib_name| is the library base name. |
+// Returns the full path (or empty string on failure). |
+jstring GetLibraryFilePathInZipFile(JNIEnv* env, |
+ jclass clazz, |
+ jstring lib_name) { |
+ String lib_name_str(env, lib_name); |
+ const char* lib_name_c_str = lib_name_str.c_str(); |
+ char buffer[kMaxFilePathLengthInZip + 1]; |
+ if (crazy_library_file_path_in_zip_file( |
+ lib_name_c_str, buffer, sizeof(buffer)) == CRAZY_STATUS_FAILURE) { |
+ LOG_ERROR("%s: Failed to get full filename for library '%s'", |
+ __FUNCTION__, lib_name_c_str); |
+ buffer[0] = '\0'; |
+ } |
+ return env->NewStringUTF(buffer); |
+} |
+ |
// Check whether the device supports loading a library directly from the APK |
// file. |
// |
@@ -686,19 +708,25 @@ const JNINativeMethod kNativeMethods[] = { |
")" |
"J", |
reinterpret_cast<void*>(&GetRandomBaseLoadAddress)}, |
- {"nativeCheckLibraryLoadFromApkSupport", |
- "(" |
- "Ljava/lang/String;" |
- ")" |
- "Z", |
- reinterpret_cast<void*>(&CheckLibraryLoadFromApkSupport)}, |
- {"nativeCheckLibraryAlignedInApk", |
- "(" |
- "Ljava/lang/String;" |
- "Ljava/lang/String;" |
- ")" |
- "Z", |
- reinterpret_cast<void*>(&CheckLibraryAlignedInApk)}, }; |
+ {"nativeGetLibraryFilePathInZipFile", |
+ "(" |
+ "Ljava/lang/String;" |
+ ")" |
+ "Ljava/lang/String;", |
+ reinterpret_cast<void*>(&GetLibraryFilePathInZipFile)}, |
+ {"nativeCheckLibraryLoadFromApkSupport", |
+ "(" |
+ "Ljava/lang/String;" |
+ ")" |
+ "Z", |
+ reinterpret_cast<void*>(&CheckLibraryLoadFromApkSupport)}, |
+ {"nativeCheckLibraryAlignedInApk", |
+ "(" |
+ "Ljava/lang/String;" |
+ "Ljava/lang/String;" |
+ ")" |
+ "Z", |
+ reinterpret_cast<void*>(&CheckLibraryAlignedInApk)}, }; |
} // namespace |