vintf: KernelInfo -> RuntimeInfo.
There are more runtime information to report to the
OTA server besides kernel information (like avb.meta-version).
Renaming this class to reflect this.
Test: mma
Test: libvintf_test
Change-Id: Ie5863508bdac7a1a378c00528c8fd9853c6c50aa
diff --git a/Android.bp b/Android.bp
index 5f5443f..a85dc26 100644
--- a/Android.bp
+++ b/Android.bp
@@ -34,7 +34,7 @@
"parse_xml.cpp",
"CompatibilityMatrix.cpp",
"KernelConfigTypedValue.cpp",
- "KernelInfo.cpp",
+ "RuntimeInfo.cpp",
"ManifestHal.cpp",
"MatrixHal.cpp",
"MatrixKernel.cpp",
diff --git a/KernelInfo.cpp b/RuntimeInfo.cpp
similarity index 78%
rename from KernelInfo.cpp
rename to RuntimeInfo.cpp
index b3370a4..1c93ee0 100644
--- a/KernelInfo.cpp
+++ b/RuntimeInfo.cpp
@@ -17,7 +17,7 @@
#define LOG_TAG "libvintf"
-#include "KernelInfo.h"
+#include "RuntimeInfo.h"
#include "CompatibilityMatrix.h"
#include "parse_string.h"
@@ -51,8 +51,8 @@
s->erase(r.base(), s->end());
}
-struct KernelInfoFetcher {
- KernelInfoFetcher(KernelInfo *ki) : mKernelInfo(ki) { }
+struct RuntimeInfoFetcher {
+ RuntimeInfoFetcher(RuntimeInfo *ki) : mRuntimeInfo(ki) { }
status_t fetchAllInformation();
private:
void streamConfig(const char *buf, size_t len);
@@ -63,12 +63,12 @@
status_t fetchKernelSepolicyVers();
status_t fetchSepolicyFiles();
status_t parseKernelVersion();
- KernelInfo *mKernelInfo;
+ RuntimeInfo *mRuntimeInfo;
std::string mRemaining;
};
// decompress /proc/config.gz and read its contents.
-status_t KernelInfoFetcher::fetchKernelConfigs() {
+status_t RuntimeInfoFetcher::fetchKernelConfigs() {
gzFile f = gzopen(PROC_CONFIG, "rb");
if (f == NULL) {
LOG(ERROR) << "Could not open /proc/config.gz: " << errno;
@@ -95,7 +95,7 @@
return err;
}
-void KernelInfoFetcher::parseConfig(std::string *s) {
+void RuntimeInfoFetcher::parseConfig(std::string *s) {
removeTrailingComments(s);
trim(s);
if (s->empty()) {
@@ -108,13 +108,13 @@
}
std::string key = s->substr(0, equalPos);
std::string value = s->substr(equalPos + 1);
- if (!mKernelInfo->mKernelConfigs.emplace(std::move(key), std::move(value)).second) {
+ if (!mRuntimeInfo->mKernelConfigs.emplace(std::move(key), std::move(value)).second) {
LOG(WARNING) << "Duplicated key in /proc/config.gz: " << s->substr(0, equalPos);
return;
}
}
-void KernelInfoFetcher::streamConfig(const char *buf, size_t len) {
+void RuntimeInfoFetcher::streamConfig(const char *buf, size_t len) {
const char *begin = buf;
const char *end = buf;
const char *stop = buf + len;
@@ -130,63 +130,63 @@
mRemaining.insert(mRemaining.size(), begin, end - begin);
}
-status_t KernelInfoFetcher::fetchCpuInfo() {
+status_t RuntimeInfoFetcher::fetchCpuInfo() {
// TODO implement this; 32-bit and 64-bit has different format.
return OK;
}
-status_t KernelInfoFetcher::fetchKernelSepolicyVers() {
+status_t RuntimeInfoFetcher::fetchKernelSepolicyVers() {
int pv = security_policyvers();
if (pv < 0) {
return pv;
}
- mKernelInfo->mKernelSepolicyVersion = pv;
+ mRuntimeInfo->mKernelSepolicyVersion = pv;
return OK;
}
-status_t KernelInfoFetcher::fetchVersion() {
+status_t RuntimeInfoFetcher::fetchVersion() {
struct utsname buf;
if (uname(&buf)) {
return -errno;
}
- mKernelInfo->mOsName = buf.sysname;
- mKernelInfo->mNodeName = buf.nodename;
- mKernelInfo->mOsRelease = buf.release;
- mKernelInfo->mOsVersion = buf.version;
- mKernelInfo->mHardwareId = buf.machine;
+ mRuntimeInfo->mOsName = buf.sysname;
+ mRuntimeInfo->mNodeName = buf.nodename;
+ mRuntimeInfo->mOsRelease = buf.release;
+ mRuntimeInfo->mOsVersion = buf.version;
+ mRuntimeInfo->mHardwareId = buf.machine;
status_t err = parseKernelVersion();
if (err != OK) {
LOG(ERROR) << "Could not parse kernel version from \""
- << mKernelInfo->mOsRelease << "\"";
+ << mRuntimeInfo->mOsRelease << "\"";
}
return err;
}
-status_t KernelInfoFetcher::parseKernelVersion() {
- auto pos = mKernelInfo->mOsRelease.find('.');
+status_t RuntimeInfoFetcher::parseKernelVersion() {
+ auto pos = mRuntimeInfo->mOsRelease.find('.');
if (pos == std::string::npos) {
return UNKNOWN_ERROR;
}
- pos = mKernelInfo->mOsRelease.find('.', pos + 1);
+ pos = mRuntimeInfo->mOsRelease.find('.', pos + 1);
if (pos == std::string::npos) {
return UNKNOWN_ERROR;
}
- pos = mKernelInfo->mOsRelease.find_first_not_of("0123456789", pos + 1);
+ pos = mRuntimeInfo->mOsRelease.find_first_not_of("0123456789", pos + 1);
// no need to check pos == std::string::npos, because substr will handle this
- if (!parse(mKernelInfo->mOsRelease.substr(0, pos), &mKernelInfo->mKernelVersion)) {
+ if (!parse(mRuntimeInfo->mOsRelease.substr(0, pos), &mRuntimeInfo->mKernelVersion)) {
return UNKNOWN_ERROR;
}
return OK;
}
// Grab sepolicy files.
-status_t KernelInfoFetcher::fetchSepolicyFiles() {
+status_t RuntimeInfoFetcher::fetchSepolicyFiles() {
// TODO implement this
return OK;
}
-status_t KernelInfoFetcher::fetchAllInformation() {
+status_t RuntimeInfoFetcher::fetchAllInformation() {
status_t err;
if ((err = fetchVersion()) != OK) {
return err;
@@ -207,31 +207,31 @@
}
-const std::string &KernelInfo::osName() const {
+const std::string &RuntimeInfo::osName() const {
return mOsName;
}
-const std::string &KernelInfo::nodeName() const {
+const std::string &RuntimeInfo::nodeName() const {
return mNodeName;
}
-const std::string &KernelInfo::osRelease() const {
+const std::string &RuntimeInfo::osRelease() const {
return mOsRelease;
}
-const std::string &KernelInfo::osVersion() const {
+const std::string &RuntimeInfo::osVersion() const {
return mOsVersion;
}
-const std::string &KernelInfo::hardwareId() const {
+const std::string &RuntimeInfo::hardwareId() const {
return mHardwareId;
}
-size_t KernelInfo::kernelSepolicyVersion() const {
+size_t RuntimeInfo::kernelSepolicyVersion() const {
return mKernelSepolicyVersion;
}
-void KernelInfo::clear() {
+void RuntimeInfo::clear() {
mKernelConfigs.clear();
mOsName.clear();
mNodeName.clear();
@@ -240,7 +240,7 @@
mHardwareId.clear();
}
-bool KernelInfo::checkCompatibility(const CompatibilityMatrix &mat,
+bool RuntimeInfo::checkCompatibility(const CompatibilityMatrix &mat,
std::string *error) const {
if (kernelSepolicyVersion() != mat.getSepolicy().kernelSepolicyVersion()) {
if (error != nullptr) {
@@ -284,14 +284,14 @@
return true;
}
-const KernelInfo *KernelInfo::Get() {
- static KernelInfo ki{};
- static KernelInfo *kip = nullptr;
+const RuntimeInfo *RuntimeInfo::Get() {
+ static RuntimeInfo ki{};
+ static RuntimeInfo *kip = nullptr;
static std::mutex mutex{};
std::lock_guard<std::mutex> lock(mutex);
if (kip == nullptr) {
- if (KernelInfoFetcher(&ki).fetchAllInformation() == OK) {
+ if (RuntimeInfoFetcher(&ki).fetchAllInformation() == OK) {
kip = &ki;
} else {
ki.clear();
diff --git a/include/vintf/KernelInfo.h b/include/vintf/RuntimeInfo.h
similarity index 92%
rename from include/vintf/KernelInfo.h
rename to include/vintf/RuntimeInfo.h
index 3647ca1..64bbb59 100644
--- a/include/vintf/KernelInfo.h
+++ b/include/vintf/RuntimeInfo.h
@@ -30,14 +30,14 @@
struct CompatibilityMatrix;
// Kernel Info sent to OTA server
-struct KernelInfo {
+struct RuntimeInfo {
- KernelInfo() {}
+ RuntimeInfo() {}
// Get the object that contains all kernel information. If any error,
// nullptr is returned.
// Note: this is not thread-safe.
- static const KernelInfo *Get();
+ static const RuntimeInfo *Get();
// /proc/version
// utsname.sysname
@@ -60,9 +60,9 @@
private:
- friend struct KernelInfoFetcher;
+ friend struct RuntimeInfoFetcher;
friend struct LibVintfTest;
- friend std::string dump(const KernelInfo &ki);
+ friend std::string dump(const RuntimeInfo &ki);
void clear();
diff --git a/include/vintf/parse_string.h b/include/vintf/parse_string.h
index 738097e..3cd5232 100644
--- a/include/vintf/parse_string.h
+++ b/include/vintf/parse_string.h
@@ -22,7 +22,7 @@
#include <string>
#include "CompatibilityMatrix.h"
-#include "KernelInfo.h"
+#include "RuntimeInfo.h"
#include "VendorManifest.h"
namespace android {
@@ -77,7 +77,7 @@
// the XML string.
std::string dump(const VendorManifest &vm);
-std::string dump(const KernelInfo &ki);
+std::string dump(const RuntimeInfo &ki);
} // namespace vintf
} // namespace android
diff --git a/main.cpp b/main.cpp
index 2dd8633..29d74fc 100644
--- a/main.cpp
+++ b/main.cpp
@@ -17,7 +17,7 @@
#include <iostream>
#include <vintf/parse_xml.h>
#include <vintf/parse_string.h>
-#include <vintf/KernelInfo.h>
+#include <vintf/RuntimeInfo.h>
#include <vintf/VendorManifest.h>
int main(int, char **) {
@@ -28,7 +28,7 @@
std::cout << gVendorManifestConverter(*vm);
std::cout << std::endl;
- const KernelInfo *ki = KernelInfo::Get();
+ const RuntimeInfo *ki = RuntimeInfo::Get();
if (ki != nullptr)
std::cout << dump(*ki);
std::cout << std::endl;
diff --git a/parse_string.cpp b/parse_string.cpp
index b75d576..75d48e2 100644
--- a/parse_string.cpp
+++ b/parse_string.cpp
@@ -360,7 +360,7 @@
return oss.str();
}
-std::string dump(const KernelInfo &ki) {
+std::string dump(const RuntimeInfo &ki) {
std::ostringstream oss;
oss << "kernel = "
diff --git a/test/main.cpp b/test/main.cpp
index 911f0b0..cfaa0fc 100644
--- a/test/main.cpp
+++ b/test/main.cpp
@@ -19,7 +19,7 @@
#include <vintf/parse_string.h>
#include <vintf/parse_xml.h>
#include <vintf/CompatibilityMatrix.h>
-#include <vintf/KernelInfo.h>
+#include <vintf/RuntimeInfo.h>
#include <vintf/VendorManifest.h>
#include <android-base/logging.h>
@@ -75,8 +75,8 @@
return vm;
}
- KernelInfo testKernelInfo() {
- KernelInfo info;
+ RuntimeInfo testRuntimeInfo() {
+ RuntimeInfo info;
info.mOsName = "Linux";
info.mNodeName = "localhost";
info.mOsRelease = "3.18.31-g936f9a479d0f";
@@ -328,8 +328,8 @@
}
}
-TEST_F(LibVintfTest, KernelInfo) {
- KernelInfo ki = testKernelInfo();
+TEST_F(LibVintfTest, RuntimeInfo) {
+ RuntimeInfo ki = testRuntimeInfo();
using KernelConfigs = std::vector<KernelConfig>;
const KernelConfigs configs {
KernelConfig{"CONFIG_64BIT", Tristate::YES},