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..0ca99ba55e545c95564bdd7f872dceac069c2ed6 100644 |
--- a/base/android/linker/linker_jni.cc |
+++ b/base/android/linker/linker_jni.cc |
@@ -576,6 +576,33 @@ jlong GetRandomBaseLoadAddress(JNIEnv* env, jclass clazz, jlong bytes) { |
return static_cast<jlong>(reinterpret_cast<uintptr_t>(address)); |
} |
+// Maximum filename length of a file in a zip file. |
+// Note(petrcermak): The same constant is defined in |
+// crazy_linker_library_list.cpp. |
+const size_t kMaxFilenameInZip = 256; |
rmcilroy
2014/10/29 17:20:44
Could we just export this in crazy_linker.h instea
petrcermak
2014/10/30 19:55:07
Done. I moved the constant to crazy_linker.h so cr
|
+ |
+// Get the full filename 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 filename (or empty string on failure). |
+jstring GetLibraryFilenameInZipFile(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[kMaxFilenameInZip + 1]; |
+ if (CRAZY_STATUS_SUCCESS != crazy_library_filename_in_zip_file( |
+ lib_name_c_str, buffer, sizeof(buffer))) { |
picksi1
2014/10/30 10:48:08
Are the backwards <constant>!=<variable> part of t
petrcermak
2014/10/30 19:55:07
Done.
|
+ 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 +713,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)}, }; |
+ {"nativeGetLibraryFilenameInZipFile", |
+ "(" |
+ "Ljava/lang/String;" |
+ ")" |
+ "Ljava/lang/String;", |
+ reinterpret_cast<void*>(&GetLibraryFilenameInZipFile)}, |
+ {"nativeCheckLibraryLoadFromApkSupport", |
+ "(" |
+ "Ljava/lang/String;" |
+ ")" |
+ "Z", |
+ reinterpret_cast<void*>(&CheckLibraryLoadFromApkSupport)}, |
+ {"nativeCheckLibraryAlignedInApk", |
+ "(" |
+ "Ljava/lang/String;" |
+ "Ljava/lang/String;" |
+ ")" |
+ "Z", |
+ reinterpret_cast<void*>(&CheckLibraryAlignedInApk)}, }; |
} // namespace |