Merge "Fix issue #28400000: Settings memory UI still showing z-ram..." into nyc-dev

am: b3edcd78d2

* commit 'b3edcd78d25372a2a1e7520b63da1d5d38fbe59f':
  Fix issue #28400000: Settings memory UI still showing z-ram...

Change-Id: I1eda5e59bdd122dd35a8025b35b63b216ca9e60d
This commit is contained in:
Dianne Hackborn
2016-05-12 00:50:42 +00:00
committed by android-build-merger
2 changed files with 34 additions and 6 deletions

View File

@@ -676,6 +676,15 @@ public final class Debug
return getTotalSwappedOutPss(); return getTotalSwappedOutPss();
} }
/**
* Return true if the kernel is reporting pss swapped out... that is, if
* {@link #getSummaryTotalSwapPss()} will return non-0 values.
* @hide
*/
public boolean hasSwappedOutPss() {
return hasSwappedOutPss;
}
public int describeContents() { public int describeContents() {
return 0; return 0;
} }

View File

@@ -16,6 +16,7 @@
package com.android.internal.app.procstats; package com.android.internal.app.procstats;
import android.os.Debug;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import android.os.SystemClock; import android.os.SystemClock;
@@ -150,7 +151,7 @@ public final class ProcessStats implements Parcelable {
}; };
// Current version of the parcel format. // Current version of the parcel format.
private static final int PARCEL_VERSION = 19; private static final int PARCEL_VERSION = 20;
// In-memory Parcel magic number, used to detect attempts to unmarshall bad data // In-memory Parcel magic number, used to detect attempts to unmarshall bad data
private static final int MAGIC = 0x50535454; private static final int MAGIC = 0x50535454;
@@ -174,10 +175,9 @@ public final class ProcessStats implements Parcelable {
String mRuntime; String mRuntime;
boolean mRunning; boolean mRunning;
public final SparseMappingTable mTableData = new SparseMappingTable(); boolean mHasSwappedOutPss;
int[] mAddLongTable; public final SparseMappingTable mTableData = new SparseMappingTable();
int mAddLongTableSize;
public final long[] mSysMemUsageArgs = new long[SYS_MEM_USAGE_COUNT]; public final long[] mSysMemUsageArgs = new long[SYS_MEM_USAGE_COUNT];
public final SysMemUsageTable mSysMemUsage = new SysMemUsageTable(mTableData); public final SysMemUsageTable mSysMemUsage = new SysMemUsageTable(mTableData);
@@ -191,6 +191,13 @@ public final class ProcessStats implements Parcelable {
public ProcessStats(boolean running) { public ProcessStats(boolean running) {
mRunning = running; mRunning = running;
reset(); reset();
if (running) {
// If we are actively running, we need to determine whether the system is
// collecting swap pss data.
Debug.MemoryInfo info = new Debug.MemoryInfo();
Debug.getMemoryInfo(android.os.Process.myPid(), info);
mHasSwappedOutPss = info.hasSwappedOutPss();
}
} }
public ProcessStats(Parcel in) { public ProcessStats(Parcel in) {
@@ -281,6 +288,8 @@ public final class ProcessStats implements Parcelable {
} }
mTimePeriodEndRealtime += other.mTimePeriodEndRealtime - other.mTimePeriodStartRealtime; mTimePeriodEndRealtime += other.mTimePeriodEndRealtime - other.mTimePeriodStartRealtime;
mTimePeriodEndUptime += other.mTimePeriodEndUptime - other.mTimePeriodStartUptime; mTimePeriodEndUptime += other.mTimePeriodEndUptime - other.mTimePeriodStartUptime;
mHasSwappedOutPss |= other.mHasSwappedOutPss;
} }
public void addSysMemUsage(long cachedMem, long freeMem, long zramMem, long kernelMem, public void addSysMemUsage(long cachedMem, long freeMem, long zramMem, long kernelMem,
@@ -353,8 +362,8 @@ public final class ProcessStats implements Parcelable {
* (double)memTime; * (double)memTime;
data.sysMemFreeWeight += longs[idx+SYS_MEM_USAGE_FREE_AVERAGE] data.sysMemFreeWeight += longs[idx+SYS_MEM_USAGE_FREE_AVERAGE]
* (double)memTime; * (double)memTime;
data.sysMemZRamWeight += longs[idx+SYS_MEM_USAGE_ZRAM_AVERAGE] data.sysMemZRamWeight += longs[idx + SYS_MEM_USAGE_ZRAM_AVERAGE]
* (double)memTime; * (double) memTime;
data.sysMemKernelWeight += longs[idx+SYS_MEM_USAGE_KERNEL_AVERAGE] data.sysMemKernelWeight += longs[idx+SYS_MEM_USAGE_KERNEL_AVERAGE]
* (double)memTime; * (double)memTime;
data.sysMemNativeWeight += longs[idx+SYS_MEM_USAGE_NATIVE_AVERAGE] data.sysMemNativeWeight += longs[idx+SYS_MEM_USAGE_NATIVE_AVERAGE]
@@ -362,6 +371,7 @@ public final class ProcessStats implements Parcelable {
data.sysMemSamples += longs[idx+SYS_MEM_USAGE_SAMPLE_COUNT]; data.sysMemSamples += longs[idx+SYS_MEM_USAGE_SAMPLE_COUNT];
} }
} }
data.hasSwappedOutPss = mHasSwappedOutPss;
ArrayMap<String, SparseArray<ProcessState>> procMap = mProcesses.getMap(); ArrayMap<String, SparseArray<ProcessState>> procMap = mProcesses.getMap();
for (int iproc=0; iproc<procMap.size(); iproc++) { for (int iproc=0; iproc<procMap.size(); iproc++) {
SparseArray<ProcessState> uids = procMap.valueAt(iproc); SparseArray<ProcessState> uids = procMap.valueAt(iproc);
@@ -640,6 +650,7 @@ public final class ProcessStats implements Parcelable {
out.writeLong(mTimePeriodStartUptime); out.writeLong(mTimePeriodStartUptime);
out.writeLong(mTimePeriodEndUptime); out.writeLong(mTimePeriodEndUptime);
out.writeString(mRuntime); out.writeString(mRuntime);
out.writeInt(mHasSwappedOutPss ? 1 : 0);
out.writeInt(mFlags); out.writeInt(mFlags);
mTableData.writeToParcel(out); mTableData.writeToParcel(out);
@@ -798,6 +809,7 @@ public final class ProcessStats implements Parcelable {
mTimePeriodStartUptime = in.readLong(); mTimePeriodStartUptime = in.readLong();
mTimePeriodEndUptime = in.readLong(); mTimePeriodEndUptime = in.readLong();
mRuntime = in.readString(); mRuntime = in.readString();
mHasSwappedOutPss = in.readInt() != 0;
mFlags = in.readInt(); mFlags = in.readInt();
mTableData.readFromParcel(in); mTableData.readFromParcel(in);
readCompactedLongArray(in, version, mMemFactorDurations, mMemFactorDurations.length); readCompactedLongArray(in, version, mMemFactorDurations, mMemFactorDurations.length);
@@ -1344,6 +1356,9 @@ public final class ProcessStats implements Parcelable {
if (partial) { if (partial) {
pw.print(" (partial)"); pw.print(" (partial)");
} }
if (mHasSwappedOutPss) {
pw.print(" (swapped-out-pss)");
}
pw.print(' '); pw.print(' ');
pw.print(mRuntime); pw.print(mRuntime);
pw.println(); pw.println();
@@ -1429,6 +1444,9 @@ public final class ProcessStats implements Parcelable {
if (partial) { if (partial) {
pw.print(",partial"); pw.print(",partial");
} }
if (mHasSwappedOutPss) {
pw.print(",swapped-out-pss");
}
pw.println(); pw.println();
pw.print("config,"); pw.println(mRuntime); pw.print("config,"); pw.println(mRuntime);
for (int ip=0; ip<pkgMap.size(); ip++) { for (int ip=0; ip<pkgMap.size(); ip++) {
@@ -1616,6 +1634,7 @@ public final class ProcessStats implements Parcelable {
public double sysMemKernelWeight; public double sysMemKernelWeight;
public double sysMemNativeWeight; public double sysMemNativeWeight;
public int sysMemSamples; public int sysMemSamples;
public boolean hasSwappedOutPss;
} }
} }