diff options
author | Dianne Hackborn <hackbod@google.com> | 2009-10-08 17:55:49 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2009-10-08 18:43:47 -0700 |
commit | 2c6c5e6e49795e6e24cd089c9018377d837ba931 (patch) | |
tree | 4ab3596388a0022d13328fd1aed3eefc94f5b118 /core/java/android | |
parent | d10d02f53ec00bfa9eb9f5accf6454e4a4bbb6a6 (diff) | |
download | frameworks_base-2c6c5e6e49795e6e24cd089c9018377d837ba931.zip frameworks_base-2c6c5e6e49795e6e24cd089c9018377d837ba931.tar.gz frameworks_base-2c6c5e6e49795e6e24cd089c9018377d837ba931.tar.bz2 |
Fix issue #2176944: Need API so browser, others can determine memory size of device
Change-Id: I65d91cdb70df91b67fe84297dd6a94d26a785131
Diffstat (limited to 'core/java/android')
-rw-r--r-- | core/java/android/app/ActivityManager.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java index be89ee6..d709deb 100644 --- a/core/java/android/app/ActivityManager.java +++ b/core/java/android/app/ActivityManager.java @@ -27,6 +27,7 @@ import android.os.RemoteException; import android.os.Handler; import android.os.Parcel; import android.os.Parcelable; +import android.os.SystemProperties; import android.text.TextUtils; import java.util.List; @@ -47,6 +48,26 @@ public class ActivityManager { } /** + * Return the approximate per-application memory class of the current + * device. This gives you an idea of how hard a memory limit you should + * impose on your application to let the overall system work best. The + * returned value is in megabytes; the baseline Android memory class is + * 16 (which happens to be the Java heap limit of those devices); some + * device with more memory may return 24 or even higher numbers. + */ + public int getMemoryClass() { + return staticGetMemoryClass(); + } + + /** @hide */ + static public int staticGetMemoryClass() { + // Really brain dead right now -- just take this from the configured + // vm heap size, and assume it is in megabytes and thus ends with "m". + String vmHeapSize = SystemProperties.get("dalvik.vm.heapsize", "16m"); + return Integer.parseInt(vmHeapSize.substring(0, vmHeapSize.length()-1)); + } + + /** * Information you can retrieve about tasks that the user has most recently * started or visited. */ |