Commit 78efcc0f authored by simonb's avatar simonb Committed by Commit bot

Skip direct map from apk check for pre-KitKat Samsung.

If the android build version pre-dates KitKat and the device
manufacturer is Samsung, skip the check for mmap exec support.
This avoids triggering a warning on these devices.
The version check is included because these devices do not show
the warning on later OS builds.

BUG=448084
TBR=rmcilroy@chromium.org

Review URL: https://codereview.chromium.org/869593002

Cr-Commit-Position: refs/heads/master@{#314156}
parent 793d6e1f
...@@ -12,6 +12,8 @@ import org.chromium.base.CommandLine; ...@@ -12,6 +12,8 @@ import org.chromium.base.CommandLine;
import org.chromium.base.JNINamespace; import org.chromium.base.JNINamespace;
import org.chromium.base.TraceEvent; import org.chromium.base.TraceEvent;
import java.util.Locale;
import javax.annotation.Nullable; import javax.annotation.Nullable;
/** /**
...@@ -59,6 +61,13 @@ public class LibraryLoader { ...@@ -59,6 +61,13 @@ public class LibraryLoader {
// APK file with executable permissions. // APK file with executable permissions.
private static boolean sMapApkWithExecPermission = false; private static boolean sMapApkWithExecPermission = false;
// One-way switch to indicate whether we probe for memory mapping the APK
// file with executable permissions. We suppress the probe under some
// conditions.
// For more, see:
// https://code.google.com/p/chromium/issues/detail?id=448084
private static boolean sProbeMapApkWithExecPermission = true;
// One-way switch becomes true if the Chromium library was loaded from the // One-way switch becomes true if the Chromium library was loaded from the
// APK file directly. // APK file directly.
private static boolean sLibraryWasLoadedFromApk = false; private static boolean sLibraryWasLoadedFromApk = false;
...@@ -166,11 +175,30 @@ public class LibraryLoader { ...@@ -166,11 +175,30 @@ public class LibraryLoader {
String apkFilePath = null; String apkFilePath = null;
boolean useMapExecSupportFallback = false; boolean useMapExecSupportFallback = false;
// If the Android build version pre-dates KitKat and the device
// manufacturer is Samsung, skip the check for mmap exec support and
// return false. This avoids triggering a warning on these devices.
// The version check is included because these devices do not show
// the warning on later OS builds.
//
// For more, see:
// https://code.google.com/p/chromium/issues/detail?id=448084
final String manufacturer = android.os.Build.MANUFACTURER;
final int version = android.os.Build.VERSION.SDK_INT;
if (manufacturer != null
&& version < android.os.Build.VERSION_CODES.KITKAT
&& manufacturer.toLowerCase(Locale.ENGLISH).contains("samsung")) {
Log.w(TAG, "Suppressed load from APK support check on this device");
sProbeMapApkWithExecPermission = false;
}
// Check if the device supports memory mapping the APK file // Check if the device supports memory mapping the APK file
// with executable permissions. // with executable permissions.
if (context != null) { if (context != null) {
apkFilePath = context.getApplicationInfo().sourceDir; apkFilePath = context.getApplicationInfo().sourceDir;
sMapApkWithExecPermission = Linker.checkMapExecSupport(apkFilePath); if (sProbeMapApkWithExecPermission) {
sMapApkWithExecPermission = Linker.checkMapExecSupport(apkFilePath);
}
if (!sMapApkWithExecPermission && Linker.isInZipFile()) { if (!sMapApkWithExecPermission && Linker.isInZipFile()) {
Log.w(TAG, "the no map executable support fallback will be used because" Log.w(TAG, "the no map executable support fallback will be used because"
+ " memory mapping the APK file with executable permissions is" + " memory mapping the APK file with executable permissions is"
...@@ -378,6 +406,10 @@ public class LibraryLoader { ...@@ -378,6 +406,10 @@ public class LibraryLoader {
return LibraryLoadFromApkStatusCodes.UNKNOWN; return LibraryLoadFromApkStatusCodes.UNKNOWN;
} }
if (!sProbeMapApkWithExecPermission) {
return LibraryLoadFromApkStatusCodes.UNKNOWN;
}
return sMapApkWithExecPermission return sMapApkWithExecPermission
? LibraryLoadFromApkStatusCodes.SUPPORTED ? LibraryLoadFromApkStatusCodes.SUPPORTED
: LibraryLoadFromApkStatusCodes.NOT_SUPPORTED; : LibraryLoadFromApkStatusCodes.NOT_SUPPORTED;
......
...@@ -846,15 +846,6 @@ public class Linker { ...@@ -846,15 +846,6 @@ public class Linker {
public static boolean checkMapExecSupport(String apkFile) { public static boolean checkMapExecSupport(String apkFile) {
assert apkFile != null; assert apkFile != null;
// https://code.google.com/p/chromium/issues/detail?id=448084
// Do not check if the device is Samsung Mega.
final String model = android.os.Build.MODEL;
if (model != null && model.equals("GT-I9205")) {
if (DEBUG) Log.i(TAG, "checkMapExecSupport: model is '" + model
+ "', returning false");
return false;
}
synchronized (Linker.class) { synchronized (Linker.class) {
ensureInitializedLocked(); ensureInitializedLocked();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment