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

Unified Diff: base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java

Issue 1137313003: Add use_apk_split parameter to java_apk.gypi / android_apk (gn) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@package_resources
Patch Set: Address style nits. Created 5 years, 7 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
« no previous file with comments | « base/android/java/src/org/chromium/base/PackageUtils.java ('k') | build/android/finalize_apk_action.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..504e53ad58198c82e6c1de52c2984aac2a1f17be 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,14 +4,19 @@
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.os.AsyncTask;
+import android.os.Build;
import android.os.SystemClock;
import android.util.Log;
import org.chromium.base.CalledByNative;
import org.chromium.base.CommandLine;
import org.chromium.base.JNINamespace;
+import org.chromium.base.PackageUtils;
import org.chromium.base.TraceEvent;
import org.chromium.base.VisibleForTesting;
import org.chromium.base.metrics.RecordHistogram;
@@ -250,7 +255,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 +369,31 @@ public class LibraryLoader {
}
}
+ // Returns whether the given split name is that of the ABI split.
+ private static boolean isAbiSplit(String splitName) {
+ // The split name for the ABI split is manually set in the build rules.
+ return splitName.startsWith("abi_");
+ }
+
+ // 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;
+ }
+ PackageInfo packageInfo = PackageUtils.getOwnPackageInfo(context);
+ if (packageInfo.splitNames != null) {
+ for (int i = 0; i < packageInfo.splitNames.length; ++i) {
+ if (isAbiSplit(packageInfo.splitNames[i])) {
+ 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) {
« no previous file with comments | « base/android/java/src/org/chromium/base/PackageUtils.java ('k') | build/android/finalize_apk_action.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698