mirror of
https://github.com/Divested-Mobile/DivestOS-Build.git
synced 2024-12-24 15:09:34 -05:00
97 lines
3.3 KiB
Diff
97 lines
3.3 KiB
Diff
diff --git a/include/keymaster/keymaster_configuration.h b/include/keymaster/keymaster_configuration.h
|
|
index 97b7fa5..69738fd 100644
|
|
--- a/include/keymaster/keymaster_configuration.h
|
|
+++ b/include/keymaster/keymaster_configuration.h
|
|
@@ -40,12 +40,24 @@
|
|
uint32_t GetOsVersion(const char* version_string);
|
|
|
|
/**
|
|
+ * Retrieves and parses OS version information from build properties. Returns 0 if the string
|
|
+ * doesn't contain a numeric version number.
|
|
+ */
|
|
+uint32_t GetOsVersion();
|
|
+
|
|
+/**
|
|
* Parses OS patch level string, returning year and month in integer form. For example, "2016-03-25"
|
|
* will be returned as 201603. Returns 0 if the string doesn't contain a date in the form
|
|
* YYYY-MM-DD.
|
|
*/
|
|
uint32_t GetOsPatchlevel(const char* patchlevel_string);
|
|
|
|
+/**
|
|
+ * Retrieves and parses OS patch level from build properties. Returns 0 if the string doesn't
|
|
+ * contain a date in the form YYYY-MM-DD.
|
|
+ */
|
|
+uint32_t GetOsPatchlevel();
|
|
+
|
|
} // namespace keymaster
|
|
|
|
#endif // SYSTEM_KEYMASTER_KEYMASTER_CONFIGURATION_H_
|
|
diff --git a/keymaster_configuration.cpp b/keymaster_configuration.cpp
|
|
index 42df7d6..ac6d3c1 100644
|
|
--- a/keymaster_configuration.cpp
|
|
+++ b/keymaster_configuration.cpp
|
|
@@ -70,15 +70,7 @@
|
|
}
|
|
|
|
keymaster_error_t ConfigureDevice(keymaster2_device_t* dev) {
|
|
- char version_str[PROPERTY_VALUE_MAX];
|
|
- property_get(kPlatformVersionProp, version_str, "" /* default */);
|
|
- uint32_t version = GetOsVersion(version_str);
|
|
-
|
|
- char patchlevel_str[PROPERTY_VALUE_MAX];
|
|
- property_get(kPlatformPatchlevelProp, patchlevel_str, "" /* default */);
|
|
- uint32_t patchlevel = GetOsPatchlevel(patchlevel_str);
|
|
-
|
|
- return ConfigureDevice(dev, version, patchlevel);
|
|
+ return ConfigureDevice(dev, GetOsVersion(), GetOsPatchlevel());
|
|
}
|
|
|
|
uint32_t GetOsVersion(const char* version_str) {
|
|
@@ -89,8 +81,8 @@
|
|
}
|
|
|
|
regmatch_t matches[kPlatformVersionMatchCount];
|
|
- int not_match
|
|
- = regexec(®ex, version_str, kPlatformVersionMatchCount, matches, 0 /* flags */);
|
|
+ int not_match =
|
|
+ regexec(®ex, version_str, kPlatformVersionMatchCount, matches, 0 /* flags */);
|
|
regfree(®ex);
|
|
if (not_match) {
|
|
ALOGI("Platform version string does not match expected format. Using version 0.");
|
|
@@ -104,6 +96,12 @@
|
|
return (major * 100 + minor) * 100 + subminor;
|
|
}
|
|
|
|
+uint32_t GetOsVersion() {
|
|
+ char version_str[PROPERTY_VALUE_MAX];
|
|
+ property_get(kPlatformVersionProp, version_str, "" /* default */);
|
|
+ return GetOsVersion(version_str);
|
|
+}
|
|
+
|
|
uint32_t GetOsPatchlevel(const char* patchlevel_str) {
|
|
regex_t regex;
|
|
if (regcomp(®ex, kPlatformPatchlevelRegex, REG_EXTENDED) != 0) {
|
|
@@ -112,8 +110,8 @@
|
|
}
|
|
|
|
regmatch_t matches[kPlatformPatchlevelMatchCount];
|
|
- int not_match
|
|
- = regexec(®ex, patchlevel_str, kPlatformPatchlevelMatchCount, matches, 0 /* flags */);
|
|
+ int not_match =
|
|
+ regexec(®ex, patchlevel_str, kPlatformPatchlevelMatchCount, matches, 0 /* flags */);
|
|
regfree(®ex);
|
|
if (not_match) {
|
|
ALOGI("Platform patchlevel string does not match expected format. Using patchlevel 0");
|
|
@@ -130,4 +128,10 @@
|
|
return year * 100 + month;
|
|
}
|
|
|
|
+uint32_t GetOsPatchlevel() {
|
|
+ char patchlevel_str[PROPERTY_VALUE_MAX];
|
|
+ property_get(kPlatformPatchlevelProp, patchlevel_str, "" /* default */);
|
|
+ return GetOsPatchlevel(patchlevel_str);
|
|
+}
|
|
+
|
|
} // namespace keymaster
|