Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / base / android / java / src / org / chromium / base / SysUtils.java
index 1568861..a8fcdcb 100644 (file)
@@ -5,6 +5,7 @@
 package org.chromium.base;
 
 import android.os.Build;
+import android.os.StrictMode;
 import android.util.Log;
 
 import java.io.BufferedReader;
@@ -52,6 +53,8 @@ public class SysUtils {
         // complicated.
 
         Pattern pattern = Pattern.compile("^MemTotal:\\s+([0-9]+) kB$");
+        // Synchronously reading files in /proc in the UI thread is safe.
+        StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
         try {
             FileReader fileReader = new FileReader("/proc/meminfo");
             try {
@@ -85,6 +88,8 @@ public class SysUtils {
             }
         } catch (Exception e) {
             Log.w(TAG, "Cannot get total physical size from /proc/meminfo", e);
+        } finally {
+            StrictMode.setThreadPolicy(oldPolicy);
         }
 
         return 0;
@@ -101,13 +106,6 @@ public class SysUtils {
         return sLowEndDevice.booleanValue();
     }
 
-    /**
-     * @return Whether isLowEndDevice() has ever been called.
-     */
-    public static boolean isLowEndStateInitialized() {
-        return (sLowEndDevice != null);
-    }
-
     private static boolean detectLowEndDevice() {
         if (CommandLine.isInitialized()) {
             if (CommandLine.getInstance().hasSwitch(BaseSwitches.ENABLE_LOW_END_DEVICE_MODE)) {