Merge changes from topic "ddr_size_api" am: c12a383385 am: a4ed6716da
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2193505 Change-Id: I872060fbb5e3d4ba311ed83c7be539e9925e573c Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -4415,6 +4415,7 @@ package android.app {
|
|||||||
method public void readFromParcel(android.os.Parcel);
|
method public void readFromParcel(android.os.Parcel);
|
||||||
method public void writeToParcel(android.os.Parcel, int);
|
method public void writeToParcel(android.os.Parcel, int);
|
||||||
field @NonNull public static final android.os.Parcelable.Creator<android.app.ActivityManager.MemoryInfo> CREATOR;
|
field @NonNull public static final android.os.Parcelable.Creator<android.app.ActivityManager.MemoryInfo> CREATOR;
|
||||||
|
field public long advertisedMem;
|
||||||
field public long availMem;
|
field public long availMem;
|
||||||
field public boolean lowMemory;
|
field public boolean lowMemory;
|
||||||
field public long threshold;
|
field public long threshold;
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import android.annotation.IntRange;
|
|||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.annotation.RequiresPermission;
|
import android.annotation.RequiresPermission;
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.annotation.SystemApi;
|
import android.annotation.SystemApi;
|
||||||
import android.annotation.SystemService;
|
import android.annotation.SystemService;
|
||||||
import android.annotation.TestApi;
|
import android.annotation.TestApi;
|
||||||
@@ -2812,6 +2813,15 @@ public class ActivityManager {
|
|||||||
* {@link ActivityManager#getMemoryInfo}.
|
* {@link ActivityManager#getMemoryInfo}.
|
||||||
*/
|
*/
|
||||||
public static class MemoryInfo implements Parcelable {
|
public static class MemoryInfo implements Parcelable {
|
||||||
|
/**
|
||||||
|
* The advertised memory of the system, as the end user would encounter in a retail display
|
||||||
|
* environment. This value might be different from {@code totalMem}. This could be due to
|
||||||
|
* many reasons. For example, the ODM could reserve part of the memory for the Trusted
|
||||||
|
* Execution Environment (TEE) which the kernel doesn't have access or knowledge about it.
|
||||||
|
*/
|
||||||
|
@SuppressLint("MutableBareField")
|
||||||
|
public long advertisedMem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The available memory on the system. This number should not
|
* The available memory on the system. This number should not
|
||||||
* be considered absolute: due to the nature of the kernel, a significant
|
* be considered absolute: due to the nature of the kernel, a significant
|
||||||
@@ -2861,6 +2871,7 @@ public class ActivityManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
|
dest.writeLong(advertisedMem);
|
||||||
dest.writeLong(availMem);
|
dest.writeLong(availMem);
|
||||||
dest.writeLong(totalMem);
|
dest.writeLong(totalMem);
|
||||||
dest.writeLong(threshold);
|
dest.writeLong(threshold);
|
||||||
@@ -2872,6 +2883,7 @@ public class ActivityManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void readFromParcel(Parcel source) {
|
public void readFromParcel(Parcel source) {
|
||||||
|
advertisedMem = source.readLong();
|
||||||
availMem = source.readLong();
|
availMem = source.readLong();
|
||||||
totalMem = source.readLong();
|
totalMem = source.readLong();
|
||||||
threshold = source.readLong();
|
threshold = source.readLong();
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import android.annotation.TestApi;
|
|||||||
import android.annotation.UptimeMillisLong;
|
import android.annotation.UptimeMillisLong;
|
||||||
import android.compat.annotation.UnsupportedAppUsage;
|
import android.compat.annotation.UnsupportedAppUsage;
|
||||||
import android.os.Build.VERSION_CODES;
|
import android.os.Build.VERSION_CODES;
|
||||||
|
import android.sysprop.MemoryProperties;
|
||||||
import android.system.ErrnoException;
|
import android.system.ErrnoException;
|
||||||
import android.system.Os;
|
import android.system.Os;
|
||||||
import android.system.OsConstants;
|
import android.system.OsConstants;
|
||||||
@@ -1336,6 +1337,24 @@ public class Process {
|
|||||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
|
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
|
||||||
public static final native void sendSignalQuiet(int pid, int signal);
|
public static final native void sendSignalQuiet(int pid, int signal);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The advertised memory of the system, as the end user would encounter in a retail
|
||||||
|
* display environment. If the advertised memory is not defined, it returns
|
||||||
|
* {@code getTotalMemory()} rounded.
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static final long getAdvertisedMem() {
|
||||||
|
String formatSize = MemoryProperties.memory_ddr_size().orElse("0KB");
|
||||||
|
long memSize = FileUtils.parseSize(formatSize);
|
||||||
|
|
||||||
|
if (memSize == Long.MIN_VALUE) {
|
||||||
|
return FileUtils.roundStorageSize(getTotalMemory());
|
||||||
|
}
|
||||||
|
|
||||||
|
return memSize;
|
||||||
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@UnsupportedAppUsage
|
@UnsupportedAppUsage
|
||||||
public static final native long getFreeMemory();
|
public static final native long getFreeMemory();
|
||||||
|
|||||||
@@ -72,4 +72,7 @@ public class ProcessTest extends TestCase {
|
|||||||
assertEquals(-1, Process.getThreadGroupLeader(BAD_PID));
|
assertEquals(-1, Process.getThreadGroupLeader(BAD_PID));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testGetAdvertisedMem() {
|
||||||
|
assertTrue(Process.getTotalMemory() <= Process.getAdvertisedMem());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import static android.os.MessageQueue.OnFileDescriptorEventListener.EVENT_INPUT;
|
|||||||
import static android.os.Process.SYSTEM_UID;
|
import static android.os.Process.SYSTEM_UID;
|
||||||
import static android.os.Process.THREAD_PRIORITY_BACKGROUND;
|
import static android.os.Process.THREAD_PRIORITY_BACKGROUND;
|
||||||
import static android.os.Process.ZYGOTE_POLICY_FLAG_EMPTY;
|
import static android.os.Process.ZYGOTE_POLICY_FLAG_EMPTY;
|
||||||
|
import static android.os.Process.getAdvertisedMem;
|
||||||
import static android.os.Process.getFreeMemory;
|
import static android.os.Process.getFreeMemory;
|
||||||
import static android.os.Process.getTotalMemory;
|
import static android.os.Process.getTotalMemory;
|
||||||
import static android.os.Process.killProcessQuiet;
|
import static android.os.Process.killProcessQuiet;
|
||||||
@@ -1524,6 +1525,7 @@ public final class ProcessList {
|
|||||||
void getMemoryInfo(ActivityManager.MemoryInfo outInfo) {
|
void getMemoryInfo(ActivityManager.MemoryInfo outInfo) {
|
||||||
final long homeAppMem = getMemLevel(HOME_APP_ADJ);
|
final long homeAppMem = getMemLevel(HOME_APP_ADJ);
|
||||||
final long cachedAppMem = getMemLevel(CACHED_APP_MIN_ADJ);
|
final long cachedAppMem = getMemLevel(CACHED_APP_MIN_ADJ);
|
||||||
|
outInfo.advertisedMem = getAdvertisedMem();
|
||||||
outInfo.availMem = getFreeMemory();
|
outInfo.availMem = getFreeMemory();
|
||||||
outInfo.totalMem = getTotalMemory();
|
outInfo.totalMem = getTotalMemory();
|
||||||
outInfo.threshold = homeAppMem;
|
outInfo.threshold = homeAppMem;
|
||||||
|
|||||||
Reference in New Issue
Block a user