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 dfcc14156bbdc857e8d1efea52ea498fafc44d24..12c76f38401611188ecec2bdd38c17018d6475c6 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 |
@@ -16,9 +16,13 @@ import org.chromium.base.SysUtils; |
import org.chromium.base.ThreadUtils; |
import java.io.FileNotFoundException; |
+import java.util.Arrays; |
import java.util.HashMap; |
+import java.util.HashSet; |
+import java.util.List; |
import java.util.Locale; |
import java.util.Map; |
+import java.util.Set; |
import javax.annotation.Nullable; |
@@ -190,6 +194,28 @@ public class Linker { |
// for testing by calling setMemoryDeviceConfig(). |
private static int sMemoryDeviceConfig = MEMORY_DEVICE_CONFIG_INIT; |
+ // List of devices for which we suppress the test for support for mapping |
+ // the APK file with executable permission. This test triggers a warning |
+ // on some devices. Devices must be listed in all uppercase only, on the |
+ // working assumption that no two distinct actual devices would have model |
+ // strings that differ only in character case. |
+ // |
+ // For more, see: |
+ // https://code.google.com/p/chromium/issues/detail?id=448084 |
+ private static final String[] MAP_CHECK_BLACKLIST = { |
+ "SCH-P709", "GT-I9158", "GT-I9152", "GT-I9150", "GT-I9200X", |
+ "SGH-M819N", "SCH-R960", "SPH-L600", "SGH-I527M", "SGH-I527", |
+ "SCH-P729", "SHV-E310L", "SHV-E310S", "SHV-E310K", "GT-I9208", |
+ "GT-I9205", "GT-I9200"}; |
+ |
+ // The blacklist is only used if the OS version code indicates that it |
+ // pre-dates an expiry version code. |
+ private static final int MAP_CHECK_BLACKLIST_EXPIRY = |
+ android.os.Build.VERSION_CODES.KITKAT; |
Andrew Hayden (chromium.org)
2015/01/23 14:59:51
I don't think you can use this on ICS, right? How
simonb (inactive)
2015/01/23 16:03:19
Compile-time constants should be okay. From:
htt
|
+ |
+ // Lookup set, lazy-initialized from the MAP_CHECK_BLACKLIST array. |
+ private static Set<String> sMapCheckBlacklist = null; |
+ |
// Becomes true after linker initialization. |
private static boolean sInitialized = false; |
@@ -846,13 +872,37 @@ public class Linker { |
public static boolean checkMapExecSupport(String apkFile) { |
assert apkFile != null; |
- // https://code.google.com/p/chromium/issues/detail?id=448084 |
- // Do not check if the device is Samsung Mega. |
+ // If the android build version is before a known good release, check |
+ // the blacklist for the build model. If the model is listed then |
+ // we 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. |
+ // |
+ // Uses a case-insensitive lookup to ensure nothing is missed. No two |
+ // devices will differ in model character case only. We ensure that the |
+ // blacklist is populated with uppercased device names. |
+ // |
+ // For more, see: |
+ // https://code.google.com/p/chromium/issues/detail?id=448084 |
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; |
+ final int version = android.os.Build.VERSION.SDK_INT; |
+ |
+ if (model != null && version < MAP_CHECK_BLACKLIST_EXPIRY) { |
+ synchronized (Linker.class) { |
+ // Initialize the blacklist lookup set before first use. |
+ if (sMapCheckBlacklist == null) { |
+ if (DEBUG) Log.i(TAG, "checkMapExecSupport: initializing blacklist"); |
+ final List<String> list = Arrays.asList(MAP_CHECK_BLACKLIST); |
+ sMapCheckBlacklist = new HashSet<String>(list); |
+ } |
+ } |
+ |
+ // Search the blacklist for the model reported by the OS. |
+ if (sMapCheckBlacklist.contains(model.toUpperCase())) { |
+ if (DEBUG) Log.i(TAG, "checkMapExecSupport: " + model |
+ + ": model is blacklisted, returning false"); |
+ return false; |
+ } |
} |
synchronized (Linker.class) { |