If you want the full version of the kernel to be displayed in Android about the phone, this is a file for parsing: / Proc / version
Here is an excerpt from the Android source code that extracts the actual kernel version string:
private String getFormattedKernelVersion() {
String procVersionStr;
try {
procVersionStr = readLine(FILENAME_PROC_VERSION);
final String PROC_VERSION_REGEX =
"\\w+\\s+" +
"\\w+\\s+" +
"([^\\s]+)\\s+" +
"\\(([^\\s@]+(?:@[^\\s.]+)?)[^)]*\\)\\s+" +
"\\((?:[^(]*\\([^)]*\\))?[^)]*\\)\\s+" +
"([^\\s]+)\\s+" +
"(?:PREEMPT\\s+)?" +
"(.+)";
Pattern p = Pattern.compile(PROC_VERSION_REGEX);
Matcher m = p.matcher(procVersionStr);
if (!m.matches()) {
Log.e(LOG_TAG, "Regex did not match on /proc/version: " + procVersionStr);
return "Unavailable";
} else if (m.groupCount() < 4) {
Log.e(LOG_TAG, "Regex match on /proc/version only returned " + m.groupCount()
+ " groups");
return "Unavailable";
} else {
return (new StringBuilder(m.group(1)).append("\n").append(
m.group(2)).append(" ").append(m.group(3)).append("\n")
.append(m.group(4))).toString();
}
} catch (IOException e) {
Log.e(LOG_TAG,
"IO Exception when getting kernel version for Device Info screen",
e);
return "Unavailable";
}
}
source
share