Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(281)

Side by Side Diff: base/android/sys_utils.cc

Issue 59033008: android: Make org.chromium.base.SysUtils.isLowEndDevice() work without native code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Formatting Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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);
21 }
22
23 size_t SysUtils::AmountOfPhysicalMemoryKB() {
24 JNIEnv* env = AttachCurrentThread();
25 return static_cast<size_t>(Java_SysUtils_amountOfPhysicalMemoryKB(env));
38 } 26 }
39 27
40 SysUtils::SysUtils() { } 28 SysUtils::SysUtils() { }
41 29
42 } // namespace android 30 } // namespace android
43 } // namespace base 31 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698