Index: base/sys_info_android.cc |
diff --git a/base/sys_info_android.cc b/base/sys_info_android.cc |
index b84b557ec323ad5781fff8443c32f31d18d49046..d5bd3eed299d29e6094dc90cdf352924a8c8e10d 100644 |
--- a/base/sys_info_android.cc |
+++ b/base/sys_info_android.cc |
@@ -9,9 +9,34 @@ |
#include "base/logging.h" |
#include "base/string_number_conversions.h" |
#include "base/string_piece.h" |
+#include "base/stringprintf.h" |
namespace { |
+// Parse out the OS version numbers from the system properties. |
+void ParseOSVersionNumbers(const char* os_version_str, |
+ int *major_version, |
+ int *minor_version, |
+ int *bugfix_version) { |
+ if (strlen(os_version_str) > 0) { |
+ // Try to parse out the version numbers from the string. |
+ int num_read = sscanf(os_version_str, "%d.%d.%d", major_version, |
+ minor_version, bugfix_version); |
jar (doing other things)
2012/08/15 23:35:17
nit: better to wrap to paren when you can (and you
gone
2012/08/16 00:29:31
Ah, wasn't sure whether the style guide allowed it
|
+ |
+ if (num_read > 0) { |
+ // If we don't have a full set of version numbers, make the extras 0. |
+ if (num_read < 2) *minor_version = 0; |
+ if (num_read < 3) *bugfix_version = 0; |
+ return; |
+ } |
+ } |
+ |
+ // For some reason, we couldn't parse the version number string. |
+ *major_version = base::SysInfo::kDefaultAndroidMajorVersion; |
+ *minor_version = base::SysInfo::kDefaultAndroidMinorVersion; |
+ *bugfix_version = base::SysInfo::kDefaultAndroidBugfixVersion; |
+} |
+ |
int ParseHeapSize(const base::StringPiece& str) { |
const int64 KB = 1024; |
const int64 MB = 1024 * KB; |
@@ -51,6 +76,40 @@ int GetDalvikHeapSizeMB() { |
namespace base { |
+std::string SysInfo::GetAndroidBuildCodename() { |
+ char os_version_codename_str[PROP_VALUE_MAX]; |
+ __system_property_get("ro.build.version.codename", os_version_codename_str); |
+ return std::string(os_version_codename_str); |
+} |
+ |
+std::string SysInfo::GetAndroidBuildID() { |
+ char os_build_id_str[PROP_VALUE_MAX]; |
+ __system_property_get("ro.build.id", os_build_id_str); |
+ return std::string(os_build_id_str); |
+} |
+ |
+std::string SysInfo::GetDeviceName() { |
+ char device_model_str[PROP_VALUE_MAX]; |
+ __system_property_get("ro.product.model", device_model_str); |
+ return std::string(device_model_str); |
+} |
+ |
+void SysInfo::OperatingSystemVersionNumbers(int32* major_version, |
+ int32* minor_version, |
+ int32* bugfix_version) { |
+ // Read the version number string out from the properties. |
+ char os_version_str[PROP_VALUE_MAX]; |
+ __system_property_get("ro.build.version.release", os_version_str); |
+ |
+ // Parse out the numbers. |
+ int internal_major_version, internal_minor_version, internal_bugfix_version; |
jar (doing other things)
2012/08/15 23:35:17
What is the advantage of having these temporaries?
gone
2012/08/16 00:29:31
They're defined as int32s for all of the other pla
|
+ ParseOSVersionNumbers(os_version_str, &internal_major_version, |
+ &internal_minor_version, &internal_bugfix_version); |
+ *major_version = internal_major_version; |
+ *minor_version = internal_minor_version; |
+ *bugfix_version = internal_bugfix_version; |
+} |
+ |
int SysInfo::DalvikHeapSizeMB() { |
static int heap_size = GetDalvikHeapSizeMB(); |
return heap_size; |