OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/android/sys_utils.h" | 5 #include "base/android/sys_utils.h" |
6 | 6 |
7 #include "base/android/build_info.h" | 7 #include "base/android/build_info.h" |
8 #include "base/sys_info.h" | 8 #include "base/sys_info.h" |
9 #include "jni/SysUtils_jni.h" | 9 #include "jni/SysUtils_jni.h" |
10 | 10 |
11 // Any device that reports a physical RAM size less than this, in megabytes | |
12 // is considered 'low-end'. IMPORTANT: Read the LinkerLowMemoryThresholdTest | |
13 // comments in build/android/pylib/linker/test_case.py before modifying this | |
14 // value. | |
15 #define ANDROID_LOW_MEMORY_DEVICE_THRESHOLD_MB 512 | |
16 | |
17 const int64 kLowEndMemoryThreshold = | |
18 1024 * 1024 * ANDROID_LOW_MEMORY_DEVICE_THRESHOLD_MB; | |
19 | |
20 // Only support low end device changes on builds greater than JB MR2. | |
21 const int kLowEndSdkIntThreshold = 18; | |
22 | |
23 // Defined and called by JNI | |
24 static jboolean IsLowEndDevice(JNIEnv* env, jclass clazz) { | |
25 return base::android::SysUtils::IsLowEndDevice(); | |
26 } | |
27 | |
28 namespace base { | 11 namespace base { |
29 namespace android { | 12 namespace android { |
30 | 13 |
31 bool SysUtils::Register(JNIEnv* env) { | 14 bool SysUtils::Register(JNIEnv* env) { |
32 return RegisterNativesImpl(env); | 15 return RegisterNativesImpl(env); |
33 } | 16 } |
34 | 17 |
35 bool SysUtils::IsLowEndDevice() { | 18 bool SysUtils::IsLowEndDevice() { |
36 return SysInfo::AmountOfPhysicalMemory() <= kLowEndMemoryThreshold && | 19 JNIEnv* env = AttachCurrentThread(); |
37 BuildInfo::GetInstance()->sdk_int() > kLowEndSdkIntThreshold; | 20 return Java_SysUtils_isLowEndDevice(env); |
38 } | 21 } |
39 | 22 |
bulach
2013/11/06 12:16:39
you may want to expose "AmountOfPhyiscalMemoryForT
| |
40 SysUtils::SysUtils() { } | 23 SysUtils::SysUtils() { } |
41 | 24 |
42 } // namespace android | 25 } // namespace android |
43 } // namespace base | 26 } // namespace base |
OLD | NEW |