Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(415)

Unified Diff: base/android/linker/linker_jni.cc

Issue 684163002: Library loading fallback. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
+
+// 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))) {
+ 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

Powered by Google App Engine
This is Rietveld 408576698