Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ef0a402f authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Fix issue #28400000: Settings memory UI still showing z-ram...

...but probably shouldn't.

Keep track of whether zram is being included in per-process pss and,
if so, don't add it on separately.

Change-Id: Ic945fc3deca8412272bb6019fe1be4b878cb763a
parent ccb85eb4
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -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;
        }
        }
+25 −6
Original line number Original line Diff line number Diff line
@@ -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,
@@ -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;
    }
    }


}
}