From b4e12494935697fa4ede006b37e6be889ef27109 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Wed, 26 Jun 2013 15:08:19 -0700 Subject: Add new ActivityManager.isLowRamDevice(). This and the old isHighEndGfx() is set up through a device configuration, rather than trying to compute it automatically. Change-Id: Ibc95c05791023a7ae6c88555b75bb61f2b613991 --- api/current.txt | 1 + core/java/android/app/ActivityManager.java | 58 ++++++++-------------- core/res/res/values/config.xml | 11 ++++ core/res/res/values/symbols.xml | 2 + .../java/com/android/server/am/ProcessTracker.java | 2 +- .../com/android/server/content/SyncManager.java | 2 +- 6 files changed, 36 insertions(+), 40 deletions(-) diff --git a/api/current.txt b/api/current.txt index 8d11dd011e32..6ca774a35a72 100644 --- a/api/current.txt +++ b/api/current.txt @@ -2904,6 +2904,7 @@ package android.app { method public android.app.PendingIntent getRunningServiceControlPanel(android.content.ComponentName) throws java.lang.SecurityException; method public java.util.List getRunningServices(int) throws java.lang.SecurityException; method public java.util.List getRunningTasks(int) throws java.lang.SecurityException; + method public boolean isLowRamDevice(); method public static boolean isRunningInTestHarness(); method public static boolean isUserAMonkey(); method public void killBackgroundProcesses(java.lang.String); diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java index d65a6a2426f9..780b5223adb6 100644 --- a/core/java/android/app/ActivityManager.java +++ b/core/java/android/app/ActivityManager.java @@ -16,6 +16,7 @@ package android.app; +import android.R; import android.os.BatteryStats; import android.os.IBinder; import com.android.internal.app.IUsageStats; @@ -377,51 +378,32 @@ public class ActivityManager { String vmHeapSize = SystemProperties.get("dalvik.vm.heapsize", "16m"); return Integer.parseInt(vmHeapSize.substring(0, vmHeapSize.length()-1)); } - + /** - * Used by persistent processes to determine if they are running on a - * higher-end device so should be okay using hardware drawing acceleration - * (which tends to consume a lot more RAM). - * @hide + * Returns true if this is a low-RAM device. Exactly whether a device is low-RAM + * is ultimately up to the device configuration, but currently it generally means + * something in the class of a 512MB device with about a 800x480 or less screen. + * This is mostly intended to be used by apps to determine whether they should turn + * off certain features that require more RAM. */ - static public boolean isHighEndGfx() { - MemInfoReader reader = new MemInfoReader(); - reader.readMemInfo(); - if (reader.getTotalSize() >= (512*1024*1024)) { - // If the device has at least 512MB RAM available to the kernel, - // we can afford the overhead of graphics acceleration. - return true; - } - - Display display = DisplayManagerGlobal.getInstance().getRealDisplay( - Display.DEFAULT_DISPLAY); - Point p = new Point(); - display.getRealSize(p); - int pixels = p.x * p.y; - if (pixels >= (1024*600)) { - // If this is a sufficiently large screen, then there are enough - // pixels on it that we'd really like to use hw drawing. - return true; - } - return false; + public boolean isLowRamDevice() { + return isLowRamDeviceStatic(); + } + + /** @hide */ + public static boolean isLowRamDeviceStatic() { + return Resources.getSystem().getBoolean(com.android.internal.R.bool.config_lowRamDevice); } /** - * Use to decide whether the running device can be considered a "large - * RAM" device. Exactly what memory limit large RAM is will vary, but - * it essentially means there is plenty of RAM to have lots of background - * processes running under decent loads. + * Used by persistent processes to determine if they are running on a + * higher-end device so should be okay using hardware drawing acceleration + * (which tends to consume a lot more RAM). * @hide */ - static public boolean isLargeRAM() { - MemInfoReader reader = new MemInfoReader(); - reader.readMemInfo(); - if (reader.getTotalSize() >= (640*1024*1024)) { - // Currently 640MB RAM available to the kernel is the point at - // which we have plenty of RAM to spare. - return true; - } - return false; + static public boolean isHighEndGfx() { + return !isLowRamDeviceStatic() && + !Resources.getSystem().getBoolean(com.android.internal.R.bool.config_avoidGfxAccel); } /** diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 4bd1c9bc8ef5..d844076c69c3 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -123,6 +123,17 @@ of them. This should not normally be modified. --> true + + false + + + false + 0 diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 7f39364b5848..fd8e76e38cc6 100755 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -239,6 +239,7 @@ + @@ -246,6 +247,7 @@ + diff --git a/services/java/com/android/server/am/ProcessTracker.java b/services/java/com/android/server/am/ProcessTracker.java index c9db7e55f234..30470f1b69c6 100644 --- a/services/java/com/android/server/am/ProcessTracker.java +++ b/services/java/com/android/server/am/ProcessTracker.java @@ -850,7 +850,7 @@ public final class ProcessTracker { pw.print(prefix); pw.print("PSS ("); pw.print(proc.mPssTableSize); - pw.println(" entrues):"); + pw.println(" entries):"); printedHeader = true; } pw.print(prefix); diff --git a/services/java/com/android/server/content/SyncManager.java b/services/java/com/android/server/content/SyncManager.java index 2b37c0e1a317..058d253e9d8e 100644 --- a/services/java/com/android/server/content/SyncManager.java +++ b/services/java/com/android/server/content/SyncManager.java @@ -112,7 +112,7 @@ public class SyncManager { private static final long MAX_TIME_PER_SYNC; static { - final boolean isLargeRAM = ActivityManager.isLargeRAM(); + final boolean isLargeRAM = !ActivityManager.isLowRamDeviceStatic(); int defaultMaxInitSyncs = isLargeRAM ? 5 : 2; int defaultMaxRegularSyncs = isLargeRAM ? 2 : 1; MAX_SIMULTANEOUS_INITIALIZATION_SYNCS = -- cgit v1.2.3-59-g8ed1b