diff options
author | Dianne Hackborn <hackbod@google.com> | 2013-06-26 23:16:47 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-06-26 23:16:48 +0000 |
commit | 49e9c44c4bf1e7ab52ffedc904cff86adea7e9ed (patch) | |
tree | 7e48935513da1f5b1cbb9ed4dd14a7b973f37fd4 | |
parent | 89dc02a9bed818cc6f5296c97eb504ccb010db42 (diff) | |
parent | b4e12494935697fa4ede006b37e6be889ef27109 (diff) | |
download | frameworks_base-49e9c44c4bf1e7ab52ffedc904cff86adea7e9ed.zip frameworks_base-49e9c44c4bf1e7ab52ffedc904cff86adea7e9ed.tar.gz frameworks_base-49e9c44c4bf1e7ab52ffedc904cff86adea7e9ed.tar.bz2 |
Merge "Add new ActivityManager.isLowRamDevice()."
-rw-r--r-- | api/current.txt | 1 | ||||
-rw-r--r-- | core/java/android/app/ActivityManager.java | 58 | ||||
-rw-r--r-- | core/res/res/values/config.xml | 11 | ||||
-rwxr-xr-x | core/res/res/values/symbols.xml | 2 | ||||
-rw-r--r-- | services/java/com/android/server/am/ProcessTracker.java | 2 | ||||
-rw-r--r-- | services/java/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 facaabe..187334d 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<android.app.ActivityManager.RunningServiceInfo> getRunningServices(int) throws java.lang.SecurityException; method public java.util.List<android.app.ActivityManager.RunningTaskInfo> 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 d65a6a2..780b522 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 4bd1c9b..d844076 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. --> <bool name="config_closeDialogWhenTouchOutside">true</bool> + <!-- Device configuration indicating this is a device with limited RAM, so heavier-weight + features should be turned off. --> + <bool name="config_lowRamDevice">false</bool> + + <!-- Device configuration indicating whether we should avoid using accelerated graphics + in certain places to reduce RAM footprint. This is ignored if config_lowRamDevice + is true (in that case this is assumed true as well). It can allow you to tune down + your device's memory use without going to the point of causing applications to turn + off features. --> + <bool name="config_avoidGfxAccel">false</bool> + <!-- The duration (in milliseconds) that the radio will scan for a signal when there's no network connection. If the scan doesn't timeout, use zero --> <integer name="config_radioScanningTimeout">0</integer> diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index a1166fc..38aa2a0 100755 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -243,6 +243,7 @@ <java-symbol type="bool" name="action_bar_embed_tabs" /> <java-symbol type="bool" name="action_bar_embed_tabs_pre_jb" /> <java-symbol type="bool" name="action_bar_expanded_action_views_exclusive" /> + <java-symbol type="bool" name="config_avoidGfxAccel" /> <java-symbol type="bool" name="config_allowActionMenuItemTextWithIcon" /> <java-symbol type="bool" name="config_bluetooth_address_validation" /> <java-symbol type="bool" name="config_bluetooth_sco_off_call" /> @@ -250,6 +251,7 @@ <java-symbol type="bool" name="config_duplicate_port_omadm_wappush" /> <java-symbol type="bool" name="config_enable_emergency_call_while_sim_locked" /> <java-symbol type="bool" name="config_enable_puk_unlock_screen" /> + <java-symbol type="bool" name="config_lowRamDevice" /> <java-symbol type="bool" name="config_mms_content_disposition_support" /> <java-symbol type="bool" name="config_showMenuShortcutsWhenKeyboardPresent" /> <java-symbol type="bool" name="config_sip_wifi_only" /> diff --git a/services/java/com/android/server/am/ProcessTracker.java b/services/java/com/android/server/am/ProcessTracker.java index c9db7e5..30470f1 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 25df50a..9e2e841 100644 --- a/services/java/com/android/server/content/SyncManager.java +++ b/services/java/com/android/server/content/SyncManager.java @@ -113,7 +113,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 = |