Index: base/android/linker/linker_jni.cc |
diff --git a/base/android/linker/linker_jni.cc b/base/android/linker/linker_jni.cc |
index a545c528ed336e44953138c9a51f8ad5647a1bf4..30aced19769acc594e2953c6933be08f2d0d7877 100644 |
--- a/base/android/linker/linker_jni.cc |
+++ b/base/android/linker/linker_jni.cc |
@@ -584,7 +584,7 @@ jlong GetRandomBaseLoadAddress(JNIEnv* env, jclass clazz, jlong bytes) { |
// |apkfile_name| is the filename of the APK. |
// Returns true if supported. |
jboolean CheckLibraryLoadFromApkSupport(JNIEnv* env, jclass clazz, |
- jstring apkfile_name) { |
+ jstring apkfile_name) { |
String apkfile_name_str(env, apkfile_name); |
const char* apkfile_name_c_str = apkfile_name_str.c_str(); |
@@ -613,6 +613,29 @@ jboolean CheckLibraryLoadFromApkSupport(JNIEnv* env, jclass clazz, |
return status; |
} |
+// Check whether a library is page aligned in the APK file. |
+// |
+// |env| is the current JNI environment handle. |
+// |clazz| is the static class handle which is not used here. |
+// |apkfile_name| is the filename of the APK. |
+// |library_name| is the library base name. |
+// Returns true if page aligned. |
+jboolean CheckLibraryAlignedInApk(JNIEnv* env, jclass clazz, |
+ jstring apkfile_name, jstring library_name) { |
+ String apkfile_name_str(env, apkfile_name); |
+ const char* apkfile_name_c_str = apkfile_name_str.c_str(); |
+ String library_name_str(env, library_name); |
+ const char* library_name_c_str = library_name_str.c_str(); |
+ |
+ LOG_INFO("%s: Checking if %s is page-aligned in %s\n", __FUNCTION__, |
+ library_name_c_str, apkfile_name_c_str); |
+ jboolean aligned = crazy_linker_check_library_aligned_in_zip_file( |
+ apkfile_name_c_str, library_name_c_str) == CRAZY_STATUS_SUCCESS; |
+ LOG_INFO("%s: %s\n", __FUNCTION__, aligned ? "Aligned" : "NOT aligned"); |
+ |
+ return aligned; |
+} |
+ |
const JNINativeMethod kNativeMethods[] = { |
{"nativeLoadLibrary", |
"(" |
@@ -668,7 +691,14 @@ const JNINativeMethod kNativeMethods[] = { |
"Ljava/lang/String;" |
")" |
"Z", |
- reinterpret_cast<void*>(&CheckLibraryLoadFromApkSupport)}, }; |
+ reinterpret_cast<void*>(&CheckLibraryLoadFromApkSupport)}, |
+ {"nativeCheckLibraryAlignedInApk", |
+ "(" |
+ "Ljava/lang/String;" |
+ "Ljava/lang/String;" |
+ ")" |
+ "Z", |
+ reinterpret_cast<void*>(&CheckLibraryAlignedInApk)}, }; |
} // namespace |