Add /proc/cpuinfo to RuntimeInfo.

Test: adb shell vintf
Bug: 37513906
Change-Id: I94617cb2ca0ae961ec56b2d22b663ecafbcbed48
diff --git a/RuntimeInfo-target.cpp b/RuntimeInfo-target.cpp
index 3b094c9..8f3d8b4 100644
--- a/RuntimeInfo-target.cpp
+++ b/RuntimeInfo-target.cpp
@@ -28,6 +28,10 @@
 #include <sys/utsname.h>
 #include <unistd.h>
 
+#include <fstream>
+#include <iostream>
+#include <sstream>
+
 #include <cutils/properties.h>
 #include <selinux/selinux.h>
 #include <zlib.h>
@@ -135,6 +139,14 @@
 
 status_t RuntimeInfoFetcher::fetchCpuInfo() {
     // TODO implement this; 32-bit and 64-bit has different format.
+    std::ifstream in{"/proc/cpuinfo"};
+    if (!in.is_open()) {
+        LOG(WARNING) << "Cannot read /proc/cpuinfo";
+        return UNKNOWN_ERROR;
+    }
+    std::stringstream sstream;
+    sstream << in.rdbuf();
+    mRuntimeInfo->mCpuInfo = sstream.str();
     return OK;
 }
 
diff --git a/RuntimeInfo.cpp b/RuntimeInfo.cpp
index 8d249d2..b3f4031 100644
--- a/RuntimeInfo.cpp
+++ b/RuntimeInfo.cpp
@@ -53,6 +53,10 @@
     return mKernelSepolicyVersion;
 }
 
+const std::string &RuntimeInfo::cpuInfo() const {
+    return mCpuInfo;
+}
+
 bool RuntimeInfo::checkCompatibility(const CompatibilityMatrix &mat,
             std::string *error) const {
     if (mat.mType != SchemaType::FRAMEWORK) {
diff --git a/include/vintf/RuntimeInfo.h b/include/vintf/RuntimeInfo.h
index 9359e1f..c7a9924 100644
--- a/include/vintf/RuntimeInfo.h
+++ b/include/vintf/RuntimeInfo.h
@@ -50,6 +50,9 @@
     // files under /vendor/etc/selinux/
     const std::vector<std::string> &sepolicyFilePaths() const;
 
+    // /proc/cpuinfo
+    const std::string &cpuInfo() const;
+
     // /sys/fs/selinux/policyvers
     size_t kernelSepolicyVersion() const;
 
@@ -83,6 +86,7 @@
     KernelVersion mKernelVersion;
 
     std::vector<std::string> mSepolicyFilePaths;
+    std::string mCpuInfo;
     Version mAvbBootVersion;
     Version mAvbInitVersion;
 
diff --git a/parse_string.cpp b/parse_string.cpp
index 8bf66c5..c37b39f 100644
--- a/parse_string.cpp
+++ b/parse_string.cpp
@@ -387,6 +387,8 @@
     for (const auto &file : ki.sepolicyFilePaths()) {
         oss << "    " << file << "\n";
     }
+    oss << "\ncpu info:\n";
+    oss << ki.cpuInfo();
     oss << "\n#CONFIG's loaded = " << ki.mKernelConfigs.size() << ";\n";
     for (const auto &pair : ki.mKernelConfigs) {
         oss << pair.first << "=" << pair.second << "\n";