Index: base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java |
diff --git a/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java b/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java |
index 9dc686572d0bb4a5f85b2b74c8fa5d012c6fb480..21fa8296a6b69aaf487ebc075e31b0168e4c05a9 100644 |
--- a/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java |
+++ b/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java |
@@ -4,8 +4,14 @@ |
package org.chromium.base.library_loader; |
+import android.annotation.TargetApi; |
import android.content.Context; |
+import android.content.pm.ApplicationInfo; |
+import android.content.pm.PackageInfo; |
+import android.content.pm.PackageManager; |
+import android.content.pm.PackageManager.NameNotFoundException; |
import android.os.AsyncTask; |
+import android.os.Build; |
import android.os.SystemClock; |
import android.util.Log; |
@@ -250,7 +256,7 @@ public class LibraryLoader { |
// Check if the device supports memory mapping the APK file |
// with executable permissions. |
if (context != null) { |
- apkFilePath = context.getApplicationInfo().sourceDir; |
+ apkFilePath = getLibraryApkPath(context); |
if (mProbeMapApkWithExecPermission) { |
mMapApkWithExecPermission = Linker.checkMapExecSupport(apkFilePath); |
} |
@@ -364,6 +370,31 @@ public class LibraryLoader { |
} |
} |
+ // Returns the path to the .apk that holds the native libraries. |
+ // This is either the main .apk, or the abi split apk. |
+ @TargetApi(Build.VERSION_CODES.LOLLIPOP) |
+ private static String getLibraryApkPath(Context context) { |
+ ApplicationInfo appInfo = context.getApplicationInfo(); |
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { |
+ return appInfo.sourceDir; |
+ } |
+ PackageManager manager = context.getPackageManager(); |
+ PackageInfo packageInfo = null; |
+ try { |
+ packageInfo = manager.getPackageInfo(context.getPackageName(), 0); |
+ } catch (NameNotFoundException e) { |
+ // Should never happen. |
+ } |
+ if (packageInfo.splitNames != null) { |
+ for (int i = 0; i < packageInfo.splitNames.length; ++i) { |
+ if (packageInfo.splitNames[i].startsWith("abi_")) { |
cjhopman
2015/05/16 01:31:10
Is the abi_ prefix something enforced by android?
agrieve
2015/05/16 02:21:40
We name it in our build rules. What would you sugg
cjhopman
2015/05/16 02:29:07
Oh, I just don't like it when our code makes hard
agrieve
2015/05/17 02:06:10
Thanks for spelling it out. Brand new to the codeb
|
+ return appInfo.splitSourceDirs[i]; |
+ } |
+ } |
+ } |
+ return appInfo.sourceDir; |
+ } |
+ |
// Load a native shared library with the Chromium linker. If the zip file |
// path is not null, the library is loaded directly from the zip file. |
private void loadLibrary(@Nullable String zipFilePath, String libFilePath) { |