- add sources.
[platform/framework/web/crosswalk.git] / src / base / android / sys_utils.cc
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
3 // found in the LICENSE file.
4
5 #include "base/android/sys_utils.h"
6
7 #include "base/android/build_info.h"
8 #include "base/sys_info.h"
9 #include "jni/SysUtils_jni.h"
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 {
29 namespace android {
30
31 bool SysUtils::Register(JNIEnv* env) {
32   return RegisterNativesImpl(env);
33 }
34
35 bool SysUtils::IsLowEndDevice() {
36   return SysInfo::AmountOfPhysicalMemory() <= kLowEndMemoryThreshold &&
37       BuildInfo::GetInstance()->sdk_int() > kLowEndSdkIntThreshold;
38 }
39
40 SysUtils::SysUtils() { }
41
42 }  // namespace android
43 }  // namespace base