Permalink
Browse files

Add processor info in device info screen (1/2)

Change-Id: I4df9ab67616898e922271deea7646d32f64ae96b
  • Loading branch information...
KreAch3R authored and xlxfoxxlx committed Sep 17, 2016
1 parent 3f24778 commit 78fd0c0bfa7aeea49414ecd1663eb1505adcd6e4
Showing with 34 additions and 0 deletions.
  1. +34 −0 packages/SettingsLib/src/com/android/settingslib/DeviceInfoUtils.java
@@ -47,6 +47,7 @@
private static final String FILENAME_PROC_VERSION = "/proc/version";
private static final String FILENAME_MSV = "/sys/board_properties/soc/msv";
private static final String FILENAME_PROC_CPUINFO = "/proc/cpuinfo";
/**
* Reads a line from the specified file.
@@ -236,4 +237,37 @@ public static String getFormattedPhoneNumbers(Context context,
return sb.toString();
}
/**
* Returns the Hardware value in /proc/cpuinfo, else returns "Unknown".
* @return a string that describes the processor
*/
public static String getDeviceProcessorInfo() {
// Hardware : XYZ
final String PROC_HARDWARE_REGEX = "Hardware\\s*:\\s*(.*)\\(.*$"; /* hardware string */
try {
BufferedReader reader = new BufferedReader(new FileReader(FILENAME_PROC_CPUINFO));
String cpuinfo;
try {
while (null != (cpuinfo = reader.readLine())) {
if (cpuinfo.startsWith("Hardware")) {
Matcher m = Pattern.compile(PROC_HARDWARE_REGEX).matcher(cpuinfo);
if (m.matches()) {
return m.group(1);
}
}
}
return "Unknown";
} finally {
reader.close();
}
} catch (IOException e) {
Log.e(TAG,
"IO Exception when getting cpuinfo for Device Info screen",
e);
return "Unknown";
}
}
}

0 comments on commit 78fd0c0

Please sign in to comment.