Index: base/android/java/src/org/chromium/base/library_loader/Linker.java |
diff --git a/base/android/java/src/org/chromium/base/library_loader/Linker.java b/base/android/java/src/org/chromium/base/library_loader/Linker.java |
index 2a3006ad174741b127dd62194b72abfbd2e21bf1..f42e04f8c7e23dc1f5d9c455cff20b96bee59fc2 100644 |
--- a/base/android/java/src/org/chromium/base/library_loader/Linker.java |
+++ b/base/android/java/src/org/chromium/base/library_loader/Linker.java |
@@ -136,7 +136,7 @@ import javax.annotation.Nullable; |
* |
* This behaviour is altered by the BROWSER_SHARED_RELRO_CONFIG configuration |
* variable below, which may force the browser to load the libraries at |
- * fixed addresses to. |
+ * fixed addresses too. |
* |
* - Once all libraries are loaded in the browser process, one can call |
* getSharedRelros() which returns a Bundle instance containing a map that |
@@ -221,6 +221,10 @@ public class Linker { |
// Becomes true once prepareLibraryLoad() has been called. |
private static boolean sPrepareLibraryLoadCalled = false; |
+ // One-way switch recording whether the device supports memory mapping |
+ // APK files with executable permissions. |
+ private static boolean sLoadFromApkSucceeded = false; |
+ |
picksi1
2014/10/10 10:52:17
Is this really a bool? Should this be an enum that
petrcermak
2014/10/10 14:20:14
As discussed, we will keep the boolean because we
|
// Used internally to initialize the linker's static data. Assume lock is held. |
private static void ensureInitializedLocked() { |
assert Thread.holdsLock(Linker.class); |
@@ -837,6 +841,35 @@ public class Linker { |
} |
/** |
+ * Test whether the device supports memory mapping APK files with executable |
+ * permissions. |
+ * |
+ * @param apkFile Filename of the APK. |
+ * @return true if supported. |
+ */ |
+ public static void testLoadFromApk(String apkFile) { |
+ synchronized (Linker.class) { |
+ ensureInitializedLocked(); |
+ if (sInBrowserProcess) { |
+ if (DEBUG) Log.i(TAG, "testLoadFromApk: " + apkFile); |
+ sLoadFromApkSucceeded = nativeTestLoadFromApk(apkFile); |
+ if (DEBUG) Log.i(TAG, "Memory mapping APK files with executable permissions " + |
+ (sLoadFromApkSucceeded ? "supported" : "NOT supported")); |
+ } |
+ } |
+ } |
+ |
+ /** |
+ * Returns whether the device supports memory mapping APK files with |
+ * executable permissions. |
+ * |
+ * @return true if supported. |
+ */ |
+ public static boolean loadFromApkSucceeded() { |
+ return sLoadFromApkSucceeded; |
rmcilroy
2014/10/10 10:27:05
Simon's CL moves from storing the result as a stat
petrcermak
2014/10/10 14:20:14
Done.
|
+ } |
picksi1
2014/10/10 10:52:17
return sAPKStatus == LOADING_SUCCESSFUL ? Or (my f
petrcermak
2014/10/10 14:20:14
As explained above, we stick with the boolean type
|
+ |
+ /** |
* Move activity from the native thread to the main UI thread. |
* Called from native code on its own thread. Posts a callback from |
* the UI thread back to native code. |
@@ -934,6 +967,16 @@ public class Linker { |
private static native long nativeGetRandomBaseLoadAddress(long sizeBytes); |
/** |
+ * Native method which tests whether the device supports memory mapping APK |
+ * files with executable permissions |
+ * |
+ * @param apkFile Filename of the APK. |
+ * @return true if supported. |
+ * |
+ */ |
+ private static native boolean nativeTestLoadFromApk(String apkFile); |
+ |
+ /** |
* Record information for a given library. |
* IMPORTANT: Native code knows about this class's fields, so |
* don't change them without modifying the corresponding C++ sources. |