Bug 943073 - Consolidate GeckoAppShell.isHighMemoryDevice and HardwareUtils.isLowMemoryPlatform. r=mcomella

This commit is contained in:
Richard Newman
2013-11-27 21:17:13 -08:00
parent cc937b1808
commit 99e18a9262
3 changed files with 78 additions and 121 deletions

View File

@@ -126,6 +126,9 @@ public class GeckoAppShell
static private final HashMap<String, String>
mAlertCookies = new HashMap<String, String>();
// See also HardwareUtils.LOW_MEMORY_THRESHOLD_MB.
static private final int HIGH_MEMORY_DEVICE_THRESHOLD_MB = 768;
/* Keep in sync with constants found here:
http://mxr.mozilla.org/mozilla-central/source/uriloader/base/nsIWebProgressListener.idl
*/
@@ -1378,29 +1381,7 @@ public class GeckoAppShell
}
private static boolean isHighMemoryDevice() {
BufferedReader br = null;
FileReader fr = null;
try {
fr = new FileReader("/proc/meminfo");
if (fr == null)
return false;
br = new BufferedReader(fr);
String line = br.readLine();
while (line != null && !line.startsWith("MemTotal")) {
line = br.readLine();
}
String[] tokens = line.split("\\s+");
if (tokens.length >= 2 && Long.parseLong(tokens[1]) >= 786432 /* 768MB in kb*/) {
return true;
}
} catch (Exception ex) {
} finally {
try {
if (fr != null)
fr.close();
} catch (IOException ioe) {}
}
return false;
return HardwareUtils.getMemSize() > HIGH_MEMORY_DEVICE_THRESHOLD_MB;
}
/**