Infer kernel level from GKI kernel release string

In addition to reading the kernel level from device manifest, also read
from uname(). If the values conflict, report an error. If only one of
the values exist, use it.

Fixes: 161317193
Test: libvintf_test
Test: vintf_object_test

Change-Id: I8da27d2373338f7c38af5c6dc4161bb7d59af2ea
diff --git a/RuntimeInfo-target.cpp b/RuntimeInfo-target.cpp
index c5e9d23..1137fd5 100644
--- a/RuntimeInfo-target.cpp
+++ b/RuntimeInfo-target.cpp
@@ -114,7 +114,7 @@
     return OK;
 }
 
-status_t RuntimeInfoFetcher::fetchVersion(RuntimeInfo::FetchFlags) {
+status_t RuntimeInfoFetcher::fetchVersion(RuntimeInfo::FetchFlags flags) {
     struct utsname buf;
     if (uname(&buf)) {
         return -errno;
@@ -127,7 +127,12 @@
 
     mRuntimeInfo->mIsMainline = mRuntimeInfo->mOsRelease.find(kMainline) != std::string::npos;
 
-    status_t err = parseKernelVersion();
+    status_t err = RuntimeInfo::parseGkiKernelRelease(flags, mRuntimeInfo->mOsRelease,
+                                                      &mRuntimeInfo->mKernel.mVersion,
+                                                      &mRuntimeInfo->mKernel.mLevel);
+    if (err == OK) return OK;
+
+    err = parseKernelVersion();
     if (err != OK) {
         LOG(ERROR) << "Could not parse kernel version from \""
                    << mRuntimeInfo->mOsRelease << "\"";
@@ -175,7 +180,7 @@
     using RF = RuntimeInfoFetcher;
     // clang-format off
     const static std::vector<FetchFunction> gFetchFunctions({
-        {F::CPU_VERSION,                 &RF::fetchVersion,            "/proc/version"},
+        {F::CPU_VERSION | F::KERNEL_FCM, &RF::fetchVersion,            "/proc/version"},
         {F::CONFIG_GZ,                   &RF::fetchKernelConfigs,      "/proc/config.gz"},
         {F::CPU_INFO,                    &RF::fetchCpuInfo,            "/proc/cpuinfo"},
         {F::POLICYVERS,                  &RF::fetchKernelSepolicyVers, "kernel sepolicy version"},