| Index: base/android/java/src/org/chromium/base/SysUtils.java
|
| diff --git a/base/android/java/src/org/chromium/base/SysUtils.java b/base/android/java/src/org/chromium/base/SysUtils.java
|
| index 74bac1055336b09d27a78d6dbc4a1ee0eb18578d..db3335d4bbbacc509f005bd00b2418e291d31764 100644
|
| --- a/base/android/java/src/org/chromium/base/SysUtils.java
|
| +++ b/base/android/java/src/org/chromium/base/SysUtils.java
|
| @@ -4,10 +4,6 @@
|
|
|
| package org.chromium.base;
|
|
|
| -import android.annotation.TargetApi;
|
| -import android.app.ActivityManager;
|
| -import android.content.Context;
|
| -import android.os.Build;
|
| import android.os.StrictMode;
|
| import android.util.Log;
|
|
|
| @@ -25,9 +21,6 @@ public class SysUtils {
|
| // A device reporting strictly more total memory in megabytes cannot be considered 'low-end'.
|
| private static final int ANDROID_LOW_MEMORY_DEVICE_THRESHOLD_MB = 512;
|
|
|
| - // Number of kilobytes in a megabyte.
|
| - private static final int KBS_IN_MB = 1024;
|
| -
|
| private static final String TAG = "SysUtils";
|
|
|
| private static Boolean sLowEndDevice;
|
| @@ -39,7 +32,7 @@ public class SysUtils {
|
| * @return Amount of physical memory in kilobytes, or 0 if there was
|
| * an error trying to access the information.
|
| */
|
| - private static int amountOfPhysicalMemoryMB() {
|
| + private static int amountOfPhysicalMemoryKB() {
|
| // Extract total memory RAM size by parsing /proc/meminfo, note that
|
| // this is exactly what the implementation of sysconf(_SC_PHYS_PAGES)
|
| // does. However, it can't be called because this method must be
|
| @@ -72,12 +65,12 @@ public class SysUtils {
|
|
|
| int totalMemoryKB = Integer.parseInt(m.group(1));
|
| // Sanity check.
|
| - if (totalMemoryKB <= KBS_IN_MB) {
|
| + if (totalMemoryKB <= 1024) {
|
| Log.w(TAG, "Invalid /proc/meminfo total size in kB: " + m.group(1));
|
| break;
|
| }
|
|
|
| - return totalMemoryKB / KBS_IN_MB;
|
| + return totalMemoryKB;
|
| }
|
|
|
| } finally {
|
| @@ -106,7 +99,6 @@ public class SysUtils {
|
| return sLowEndDevice.booleanValue();
|
| }
|
|
|
| - @TargetApi(Build.VERSION_CODES.KITKAT)
|
| private static boolean detectLowEndDevice() {
|
| assert CommandLine.isInitialized();
|
| if (CommandLine.getInstance().hasSwitch(BaseSwitches.ENABLE_LOW_END_DEVICE_MODE)) {
|
| @@ -116,23 +108,7 @@ public class SysUtils {
|
| return false;
|
| }
|
|
|
| - Context context = ApplicationStatus.getApplicationContext();
|
| - // Only KitKat and later devices have isLowRamDevice() call available.
|
| - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && context != null) {
|
| - ActivityManager activityManager = (ActivityManager)
|
| - context.getSystemService(Context.ACTIVITY_SERVICE);
|
| - if (activityManager.isLowRamDevice()) {
|
| - return true;
|
| - }
|
| - } else {
|
| - Log.e(TAG, "ApplicationContext is null in ApplicationStatus");
|
| - }
|
| -
|
| - int ramSizeMB = amountOfPhysicalMemoryMB();
|
| - if (ramSizeMB <= 0) {
|
| - return false;
|
| - }
|
| -
|
| - return ramSizeMB <= ANDROID_LOW_MEMORY_DEVICE_THRESHOLD_MB;
|
| + int ramSizeKB = amountOfPhysicalMemoryKB();
|
| + return (ramSizeKB > 0 && ramSizeKB / 1024 < ANDROID_LOW_MEMORY_DEVICE_THRESHOLD_MB);
|
| }
|
| }
|
|
|