| 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 <dlfcn.h> | 7 #include <dlfcn.h> |
| 8 #include <sys/system_properties.h> | 8 #include <sys/system_properties.h> |
| 9 | 9 |
| 10 #include "base/android/sys_utils.h" | 10 #include "base/android/sys_utils.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 result = base::SysInfo::AmountOfPhysicalMemoryMB() / 6; | 148 result = base::SysInfo::AmountOfPhysicalMemoryMB() / 6; |
| 149 } | 149 } |
| 150 result = std::min<int64>(std::max<int64>(16 * MB, result), 512 * MB) / MB; | 150 result = std::min<int64>(std::max<int64>(16 * MB, result), 512 * MB) / MB; |
| 151 return static_cast<int>(result); | 151 return static_cast<int>(result); |
| 152 } | 152 } |
| 153 | 153 |
| 154 } // anonymous namespace | 154 } // anonymous namespace |
| 155 | 155 |
| 156 namespace base { | 156 namespace base { |
| 157 | 157 |
| 158 std::string SysInfo::HardwareModelName() { |
| 159 char device_model_str[PROP_VALUE_MAX]; |
| 160 __system_property_get("ro.product.model", device_model_str); |
| 161 return std::string(device_model_str); |
| 162 } |
| 163 |
| 158 std::string SysInfo::OperatingSystemName() { | 164 std::string SysInfo::OperatingSystemName() { |
| 159 return "Android"; | 165 return "Android"; |
| 160 } | 166 } |
| 161 | 167 |
| 162 std::string SysInfo::GetAndroidBuildCodename() { | |
| 163 char os_version_codename_str[PROP_VALUE_MAX]; | |
| 164 __system_property_get("ro.build.version.codename", os_version_codename_str); | |
| 165 return std::string(os_version_codename_str); | |
| 166 } | |
| 167 | |
| 168 std::string SysInfo::GetAndroidBuildID() { | |
| 169 char os_build_id_str[PROP_VALUE_MAX]; | |
| 170 __system_property_get("ro.build.id", os_build_id_str); | |
| 171 return std::string(os_build_id_str); | |
| 172 } | |
| 173 | |
| 174 std::string SysInfo::GetDeviceName() { | |
| 175 char device_model_str[PROP_VALUE_MAX]; | |
| 176 __system_property_get("ro.product.model", device_model_str); | |
| 177 return std::string(device_model_str); | |
| 178 } | |
| 179 | |
| 180 std::string SysInfo::OperatingSystemVersion() { | 168 std::string SysInfo::OperatingSystemVersion() { |
| 181 int32 major, minor, bugfix; | 169 int32 major, minor, bugfix; |
| 182 OperatingSystemVersionNumbers(&major, &minor, &bugfix); | 170 OperatingSystemVersionNumbers(&major, &minor, &bugfix); |
| 183 return StringPrintf("%d.%d.%d", major, minor, bugfix); | 171 return StringPrintf("%d.%d.%d", major, minor, bugfix); |
| 184 } | 172 } |
| 185 | 173 |
| 186 void SysInfo::OperatingSystemVersionNumbers(int32* major_version, | 174 void SysInfo::OperatingSystemVersionNumbers(int32* major_version, |
| 187 int32* minor_version, | 175 int32* minor_version, |
| 188 int32* bugfix_version) { | 176 int32* bugfix_version) { |
| 189 // Read the version number string out from the properties. | 177 // Read the version number string out from the properties. |
| 190 char os_version_str[PROP_VALUE_MAX]; | 178 char os_version_str[PROP_VALUE_MAX]; |
| 191 __system_property_get("ro.build.version.release", os_version_str); | 179 __system_property_get("ro.build.version.release", os_version_str); |
| 192 | 180 |
| 193 // Parse out the numbers. | 181 // Parse out the numbers. |
| 194 ParseOSVersionNumbers(os_version_str, major_version, minor_version, | 182 ParseOSVersionNumbers(os_version_str, major_version, minor_version, |
| 195 bugfix_version); | 183 bugfix_version); |
| 196 } | 184 } |
| 197 | 185 |
| 186 std::string SysInfo::GetAndroidBuildCodename() { |
| 187 char os_version_codename_str[PROP_VALUE_MAX]; |
| 188 __system_property_get("ro.build.version.codename", os_version_codename_str); |
| 189 return std::string(os_version_codename_str); |
| 190 } |
| 191 |
| 192 std::string SysInfo::GetAndroidBuildID() { |
| 193 char os_build_id_str[PROP_VALUE_MAX]; |
| 194 __system_property_get("ro.build.id", os_build_id_str); |
| 195 return std::string(os_build_id_str); |
| 196 } |
| 197 |
| 198 int SysInfo::DalvikHeapSizeMB() { | 198 int SysInfo::DalvikHeapSizeMB() { |
| 199 static int heap_size = GetDalvikHeapSizeMB(); | 199 static int heap_size = GetDalvikHeapSizeMB(); |
| 200 return heap_size; | 200 return heap_size; |
| 201 } | 201 } |
| 202 | 202 |
| 203 int SysInfo::DalvikHeapGrowthLimitMB() { | 203 int SysInfo::DalvikHeapGrowthLimitMB() { |
| 204 static int heap_growth_limit = GetDalvikHeapGrowthLimitMB(); | 204 static int heap_growth_limit = GetDalvikHeapGrowthLimitMB(); |
| 205 return heap_growth_limit; | 205 return heap_growth_limit; |
| 206 } | 206 } |
| 207 | 207 |
| 208 static base::LazyInstance< | 208 static base::LazyInstance< |
| 209 base::internal::LazySysInfoValue<bool, | 209 base::internal::LazySysInfoValue<bool, |
| 210 android::SysUtils::IsLowEndDeviceFromJni> >::Leaky | 210 android::SysUtils::IsLowEndDeviceFromJni> >::Leaky |
| 211 g_lazy_low_end_device = LAZY_INSTANCE_INITIALIZER; | 211 g_lazy_low_end_device = LAZY_INSTANCE_INITIALIZER; |
| 212 | 212 |
| 213 bool SysInfo::IsLowEndDevice() { | 213 bool SysInfo::IsLowEndDevice() { |
| 214 return g_lazy_low_end_device.Get().value(); | 214 return g_lazy_low_end_device.Get().value(); |
| 215 } | 215 } |
| 216 | 216 |
| 217 | 217 |
| 218 } // namespace base | 218 } // namespace base |
| OLD | NEW |