From 04994e322b88df30ce711c59f2a2975c2aae5612 Mon Sep 17 00:00:00 2001 From: Paul Kocialkowski Date: Tue, 24 Jun 2014 16:07:56 +0200 Subject: Proper CPU info parsing Signed-off-by: Paul Kocialkowski --- src/com/android/settings/DeviceInfoSettings.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/com/android/settings/DeviceInfoSettings.java b/src/com/android/settings/DeviceInfoSettings.java index 23fa672..91be9a4 100644 --- a/src/com/android/settings/DeviceInfoSettings.java +++ b/src/com/android/settings/DeviceInfoSettings.java @@ -416,15 +416,24 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment { private String getCPUInfo() { String result = null; + String line = null; + BufferedReader reader = null; try { /* The expected /proc/cpuinfo output is as follows: * Processor : ARMv7 Processor rev 2 (v7l) * BogoMIPS : 272.62 */ - String firstLine = readLine(FILENAME_PROC_CPUINFO); - if (firstLine != null) { - result = firstLine.split(":")[1].trim(); + + reader = new BufferedReader(new FileReader(FILENAME_PROC_CPUINFO), 256); + + try { + while ((line = reader.readLine()) != null) { + if (line.split(":")[0].trim().equals("model name") || line.split(":")[0].trim().equals("Processor")) + result = line.split(":")[1].trim(); + } + } finally { + reader.close(); } } catch (IOException e) {} -- cgit v1.1