Merge commit '2c6c5e6e49795e6e24cd089c9018377d837ba931' into eclair-mr2 * commit '2c6c5e6e49795e6e24cd089c9018377d837ba931': Fix issue #2176944: Need API so browser, others can determine memory size of device
This commit is contained in:
@@ -17299,6 +17299,17 @@
|
|||||||
visibility="public"
|
visibility="public"
|
||||||
>
|
>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="getMemoryClass"
|
||||||
|
return="int"
|
||||||
|
abstract="false"
|
||||||
|
native="false"
|
||||||
|
synchronized="false"
|
||||||
|
static="false"
|
||||||
|
final="false"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</method>
|
||||||
<method name="getMemoryInfo"
|
<method name="getMemoryInfo"
|
||||||
return="void"
|
return="void"
|
||||||
abstract="false"
|
abstract="false"
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import android.os.RemoteException;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
import android.os.SystemProperties;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -46,6 +47,26 @@ public class ActivityManager {
|
|||||||
mHandler = handler;
|
mHandler = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
* Information you can retrieve about tasks that the user has most recently
|
||||||
* started or visited.
|
* started or visited.
|
||||||
|
|||||||
@@ -1436,6 +1436,8 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
|
|||||||
mSimpleProcessManagement = true;
|
mSimpleProcessManagement = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log.i(TAG, "Memory class: " + ActivityManager.staticGetMemoryClass());
|
||||||
|
|
||||||
MY_PID = Process.myPid();
|
MY_PID = Process.myPid();
|
||||||
|
|
||||||
File dataDir = Environment.getDataDirectory();
|
File dataDir = Environment.getDataDirectory();
|
||||||
|
|||||||
Reference in New Issue
Block a user