Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/sys_info.h" | 5 #include "base/sys_info.h" |
| 6 | 6 |
| 7 #include <sys/system_properties.h> | 7 #include <sys/system_properties.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/stringprintf.h" | |
| 10 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/strings/string_piece.h" | 12 #include "base/strings/string_piece.h" |
| 12 | 13 |
| 13 namespace { | 14 namespace { |
| 14 | 15 |
| 15 // Default version of Android to fall back to when actual version numbers | 16 // Default version of Android to fall back to when actual version numbers |
| 16 // cannot be acquired. | 17 // cannot be acquired. |
| 17 // TODO(dfalcantara): Keep this reasonably up to date with the latest publicly | 18 // TODO(dfalcantara): Keep this reasonably up to date with the latest publicly |
| 18 // available version of Android. | 19 // available version of Android. |
| 19 static const int kDefaultAndroidMajorVersion = 4; | 20 static const int kDefaultAndroidMajorVersion = 4; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 __system_property_get("ro.build.id", os_build_id_str); | 128 __system_property_get("ro.build.id", os_build_id_str); |
| 128 return std::string(os_build_id_str); | 129 return std::string(os_build_id_str); |
| 129 } | 130 } |
| 130 | 131 |
| 131 std::string SysInfo::GetDeviceName() { | 132 std::string SysInfo::GetDeviceName() { |
| 132 char device_model_str[PROP_VALUE_MAX]; | 133 char device_model_str[PROP_VALUE_MAX]; |
| 133 __system_property_get("ro.product.model", device_model_str); | 134 __system_property_get("ro.product.model", device_model_str); |
| 134 return std::string(device_model_str); | 135 return std::string(device_model_str); |
| 135 } | 136 } |
| 136 | 137 |
| 138 std::string SysInfo::OperatingSystemVersion() { | |
| 139 int32 major, minor, bugfix; | |
| 140 OperatingSystemVersionNumbers(&major, &minor, &bugfix); | |
| 141 return base::StringPrintf("%d.%d.%d", major, minor, bugfix); | |
|
brettw
2013/05/06 22:56:24
Don't need "base::" here (you're already in base).
Zhenyao Mo
2013/05/06 23:07:07
Done.
| |
| 142 } | |
| 143 | |
| 137 void SysInfo::OperatingSystemVersionNumbers(int32* major_version, | 144 void SysInfo::OperatingSystemVersionNumbers(int32* major_version, |
| 138 int32* minor_version, | 145 int32* minor_version, |
| 139 int32* bugfix_version) { | 146 int32* bugfix_version) { |
| 140 // Read the version number string out from the properties. | 147 // Read the version number string out from the properties. |
| 141 char os_version_str[PROP_VALUE_MAX]; | 148 char os_version_str[PROP_VALUE_MAX]; |
| 142 __system_property_get("ro.build.version.release", os_version_str); | 149 __system_property_get("ro.build.version.release", os_version_str); |
| 143 | 150 |
| 144 // Parse out the numbers. | 151 // Parse out the numbers. |
| 145 ParseOSVersionNumbers(os_version_str, major_version, minor_version, | 152 ParseOSVersionNumbers(os_version_str, major_version, minor_version, |
| 146 bugfix_version); | 153 bugfix_version); |
| 147 } | 154 } |
| 148 | 155 |
| 149 int SysInfo::DalvikHeapSizeMB() { | 156 int SysInfo::DalvikHeapSizeMB() { |
| 150 static int heap_size = GetDalvikHeapSizeMB(); | 157 static int heap_size = GetDalvikHeapSizeMB(); |
| 151 return heap_size; | 158 return heap_size; |
| 152 } | 159 } |
| 153 | 160 |
| 154 int SysInfo::DalvikHeapGrowthLimitMB() { | 161 int SysInfo::DalvikHeapGrowthLimitMB() { |
| 155 static int heap_growth_limit = GetDalvikHeapGrowthLimitMB(); | 162 static int heap_growth_limit = GetDalvikHeapGrowthLimitMB(); |
| 156 return heap_growth_limit; | 163 return heap_growth_limit; |
| 157 } | 164 } |
| 158 | 165 |
| 159 | 166 |
| 160 } // namespace base | 167 } // namespace base |
| OLD | NEW |