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

Commit 66a9b2d7 authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android (Google) Code Review
Browse files

Merge "Fix issue #10903002: com.facebook.katana keeps itself in A Services" into klp-dev

parents be17a614 cbd9a52f
Loading
Loading
Loading
Loading
+75 −34
Original line number Diff line number Diff line
@@ -533,7 +533,8 @@ public final class ActivityThread {
    private native void dumpGraphicsInfo(FileDescriptor fd);

    private class ApplicationThread extends ApplicationThreadNative {
        private static final String HEAP_COLUMN = "%13s %8s %8s %8s %8s %8s %8s %8s %8s %8s";
        private static final String HEAP_FULL_COLUMN = "%13s %8s %8s %8s %8s %8s %8s %8s %8s %8s";
        private static final String HEAP_COLUMN = "%13s %8s %8s %8s %8s %8s %8s %8s";
        private static final String ONE_COUNT_COLUMN = "%21s %8d";
        private static final String TWO_COUNT_COLUMNS = "%21s %8d %21s %8d";
        private static final String DB_INFO_FORMAT = "  %8s %8s %14s %14s  %s";
@@ -892,18 +893,18 @@ public final class ActivityThread {

        @Override
        public void dumpMemInfo(FileDescriptor fd, Debug.MemoryInfo mem, boolean checkin,
                boolean dumpInfo, boolean dumpDalvik, String[] args) {
                boolean dumpFullInfo, boolean dumpDalvik, String[] args) {
            FileOutputStream fout = new FileOutputStream(fd);
            PrintWriter pw = new FastPrintWriter(fout);
            try {
                dumpMemInfo(pw, mem, checkin, dumpInfo, dumpDalvik);
                dumpMemInfo(pw, mem, checkin, dumpFullInfo, dumpDalvik);
            } finally {
                pw.flush();
            }
        }

        private void dumpMemInfo(PrintWriter pw, Debug.MemoryInfo memInfo, boolean checkin,
                boolean dumpInfo, boolean dumpDalvik) {
                boolean dumpFullInfo, boolean dumpDalvik) {
            long nativeMax = Debug.getNativeHeapSize() / 1024;
            long nativeAllocated = Debug.getNativeHeapAllocatedSize() / 1024;
            long nativeFree = Debug.getNativeHeapFreeSize() / 1024;
@@ -1036,20 +1037,37 @@ public final class ActivityThread {
            }

            // otherwise, show human-readable format
            printRow(pw, HEAP_COLUMN, "", "Pss", "Pss","Shared", "Private", "Shared", "Private",
                    "Heap", "Heap", "Heap");
            printRow(pw, HEAP_COLUMN, "", "Total", "Clean", "Dirty", "Dirty", "Clean", "Clean",
                    "Size", "Alloc", "Free");
            printRow(pw, HEAP_COLUMN, "", "------", "------", "------", "------", "------",
                    "------", "------", "------", "------");
            printRow(pw, HEAP_COLUMN, "Native Heap", memInfo.nativePss, memInfo.nativeSwappablePss,
                    memInfo.nativeSharedDirty,
            if (dumpFullInfo) {
                printRow(pw, HEAP_FULL_COLUMN, "", "Pss", "Pss", "Shared", "Private",
                        "Shared", "Private", "Heap", "Heap", "Heap");
                printRow(pw, HEAP_FULL_COLUMN, "", "Total", "Clean", "Dirty", "Dirty",
                        "Clean", "Clean", "Size", "Alloc", "Free");
                printRow(pw, HEAP_FULL_COLUMN, "", "------", "------", "------", "------",
                        "------", "------", "------", "------", "------");
                printRow(pw, HEAP_FULL_COLUMN, "Native Heap", memInfo.nativePss,
                        memInfo.nativeSwappablePss, memInfo.nativeSharedDirty,
                        memInfo.nativePrivateDirty, memInfo.nativeSharedClean,
                        memInfo.nativePrivateClean, nativeMax, nativeAllocated, nativeFree);
            printRow(pw, HEAP_COLUMN, "Dalvik Heap", memInfo.dalvikPss, memInfo.dalvikSwappablePss,
                    memInfo.dalvikSharedDirty,
                printRow(pw, HEAP_FULL_COLUMN, "Dalvik Heap", memInfo.dalvikPss,
                        memInfo.dalvikSwappablePss, memInfo.dalvikSharedDirty,
                        memInfo.dalvikPrivateDirty, memInfo.dalvikSharedClean,
                        memInfo.dalvikPrivateClean, dalvikMax, dalvikAllocated, dalvikFree);
            } else {
                printRow(pw, HEAP_COLUMN, "", "Pss", "Pss", "Private",
                        "Private", "Heap", "Heap", "Heap");
                printRow(pw, HEAP_COLUMN, "", "Total", "Clean", "Dirty",
                        "Clean", "Size", "Alloc", "Free");
                printRow(pw, HEAP_COLUMN, "", "------", "------", "------",
                        "------", "------", "------", "------");
                printRow(pw, HEAP_COLUMN, "Native Heap", memInfo.nativePss,
                        memInfo.nativeSwappablePss,
                        memInfo.nativePrivateDirty,
                        memInfo.nativePrivateClean, nativeMax, nativeAllocated, nativeFree);
                printRow(pw, HEAP_COLUMN, "Dalvik Heap", memInfo.dalvikPss,
                        memInfo.dalvikSwappablePss,
                        memInfo.dalvikPrivateDirty,
                        memInfo.dalvikPrivateClean, dalvikMax, dalvikAllocated, dalvikFree);
            }

            int otherPss = memInfo.otherPss;
            int otherSwappablePss = memInfo.otherSwappablePss;
@@ -1067,9 +1085,15 @@ public final class ActivityThread {
                final int myPrivateClean = memInfo.getOtherPrivateClean(i);
                if (myPss != 0 || mySharedDirty != 0 || myPrivateDirty != 0
                        || mySharedClean != 0 || myPrivateClean != 0) {
                    printRow(pw, HEAP_COLUMN, Debug.MemoryInfo.getOtherLabel(i),
                    if (dumpFullInfo) {
                        printRow(pw, HEAP_FULL_COLUMN, Debug.MemoryInfo.getOtherLabel(i),
                                myPss, mySwappablePss, mySharedDirty, myPrivateDirty,
                                mySharedClean, myPrivateClean, "", "", "");
                    } else {
                        printRow(pw, HEAP_COLUMN, Debug.MemoryInfo.getOtherLabel(i),
                                myPss, mySwappablePss, myPrivateDirty,
                                myPrivateClean, "", "", "");
                    }
                    otherPss -= myPss;
                    otherSwappablePss -= mySwappablePss;
                    otherSharedDirty -= mySharedDirty;
@@ -1079,16 +1103,27 @@ public final class ActivityThread {
                }
            }



            printRow(pw, HEAP_COLUMN, "Unknown", otherPss, otherSwappablePss, otherSharedDirty,
                    otherPrivateDirty, otherSharedClean, otherPrivateClean,"", "", "");
            printRow(pw, HEAP_COLUMN, "TOTAL", memInfo.getTotalPss(),
            if (dumpFullInfo) {
                printRow(pw, HEAP_FULL_COLUMN, "Unknown", otherPss, otherSwappablePss,
                        otherSharedDirty, otherPrivateDirty, otherSharedClean, otherPrivateClean,
                        "", "", "");
                printRow(pw, HEAP_FULL_COLUMN, "TOTAL", memInfo.getTotalPss(),
                        memInfo.getTotalSwappablePss(),
                        memInfo.getTotalSharedDirty(), memInfo.getTotalPrivateDirty(),
                        memInfo.getTotalSharedClean(), memInfo.getTotalPrivateClean(),
                        nativeMax+dalvikMax,
                        nativeAllocated+dalvikAllocated, nativeFree+dalvikFree);
            } else {
                printRow(pw, HEAP_COLUMN, "Unknown", otherPss, otherSwappablePss,
                        otherPrivateDirty, otherPrivateClean,
                        "", "", "");
                printRow(pw, HEAP_COLUMN, "TOTAL", memInfo.getTotalPss(),
                        memInfo.getTotalSwappablePss(),
                        memInfo.getTotalPrivateDirty(),
                        memInfo.getTotalPrivateClean(),
                        nativeMax+dalvikMax,
                        nativeAllocated+dalvikAllocated, nativeFree+dalvikFree);
            }

            if (dumpDalvik) {
                pw.println(" ");
@@ -1104,9 +1139,15 @@ public final class ActivityThread {
                    final int myPrivateClean = memInfo.getOtherPrivateClean(i);
                    if (myPss != 0 || mySharedDirty != 0 || myPrivateDirty != 0
                            || mySharedClean != 0 || myPrivateClean != 0) {
                        printRow(pw, HEAP_COLUMN, Debug.MemoryInfo.getOtherLabel(i),
                        if (dumpFullInfo) {
                            printRow(pw, HEAP_FULL_COLUMN, Debug.MemoryInfo.getOtherLabel(i),
                                    myPss, mySwappablePss, mySharedDirty, myPrivateDirty,
                                    mySharedClean, myPrivateClean, "", "", "");
                        } else {
                            printRow(pw, HEAP_COLUMN, Debug.MemoryInfo.getOtherLabel(i),
                                    myPss, mySwappablePss, myPrivateDirty,
                                    myPrivateClean, "", "", "");
                        }
                    }
                }
            }
+7 −1
Original line number Diff line number Diff line
@@ -1031,7 +1031,13 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo
    /** @hide */
    public static final int MEMINFO_SLAB = 5;
    /** @hide */
    public static final int MEMINFO_COUNT = 6;
    public static final int MEMINFO_SWAP_TOTAL = 6;
    /** @hide */
    public static final int MEMINFO_SWAP_FREE = 7;
    /** @hide */
    public static final int MEMINFO_ZRAM_TOTAL = 8;
    /** @hide */
    public static final int MEMINFO_COUNT = 9;

    /**
     * Retrieves /proc/meminfo.  outSizes is filled with fields
+42 −46
Original line number Diff line number Diff line
@@ -16,47 +16,11 @@

package com.android.internal.util;

import java.io.FileInputStream;

import android.os.Debug;
import android.os.StrictMode;

public class MemInfoReader {
    byte[] mBuffer = new byte[1024];

    private long mTotalSize;
    private long mFreeSize;
    private long mCachedSize;

    private boolean matchText(byte[] buffer, int index, String text) {
        int N = text.length();
        if ((index+N) >= buffer.length) {
            return false;
        }
        for (int i=0; i<N; i++) {
            if (buffer[index+i] != text.charAt(i)) {
                return false;
            }
        }
        return true;
    }

    private long extractMemValue(byte[] buffer, int index) {
        while (index < buffer.length && buffer[index] != '\n') {
            if (buffer[index] >= '0' && buffer[index] <= '9') {
                int start = index;
                index++;
                while (index < buffer.length && buffer[index] >= '0'
                    && buffer[index] <= '9') {
                    index++;
                }
                String str = new String(buffer, 0, start, index-start);
                return ((long)Integer.parseInt(str)) * 1024;
            }
            index++;
        }
        return 0;
    }
public final class MemInfoReader {
    final long[] mInfos = new long[Debug.MEMINFO_COUNT];

    public void readMemInfo() {
        // Permit disk reads here, as /proc/meminfo isn't really "on
@@ -64,25 +28,57 @@ public class MemInfoReader {
        // /proc/ and /sys/ files perhaps?
        StrictMode.ThreadPolicy savedPolicy = StrictMode.allowThreadDiskReads();
        try {
            long[] infos = new long[Debug.MEMINFO_COUNT];
            Debug.getMemInfo(infos);
            mTotalSize = infos[Debug.MEMINFO_TOTAL] * 1024;
            mFreeSize = infos[Debug.MEMINFO_FREE] * 1024;
            mCachedSize = infos[Debug.MEMINFO_CACHED] * 1024;
            Debug.getMemInfo(mInfos);
        } finally {
            StrictMode.setThreadPolicy(savedPolicy);
        }
    }

    public long getTotalSize() {
        return mTotalSize;
        return mInfos[Debug.MEMINFO_TOTAL] * 1024;
    }

    public long getFreeSize() {
        return mFreeSize;
        return mInfos[Debug.MEMINFO_FREE] * 1024;
    }

    public long getCachedSize() {
        return mCachedSize;
        return mInfos[Debug.MEMINFO_CACHED] * 1024;
    }

    public long getTotalSizeKb() {
        return mInfos[Debug.MEMINFO_TOTAL];
    }

    public long getFreeSizeKb() {
        return mInfos[Debug.MEMINFO_FREE];
    }

    public long getCachedSizeKb() {
        return mInfos[Debug.MEMINFO_CACHED];
    }

    public long getBuffersSizeKb() {
        return mInfos[Debug.MEMINFO_BUFFERS];
    }

    public long getShmemSizeKb() {
        return mInfos[Debug.MEMINFO_SHMEM];
    }

    public long getSlabSizeKb() {
        return mInfos[Debug.MEMINFO_SLAB];
    }

    public long getSwapTotalSizeKb() {
        return mInfos[Debug.MEMINFO_SWAP_TOTAL];
    }

    public long getSwapFreeSizeKb() {
        return mInfos[Debug.MEMINFO_SWAP_FREE];
    }

    public long getZramTotalSizeKb() {
        return mInfos[Debug.MEMINFO_ZRAM_TOTAL];
    }
}
+35 −5
Original line number Diff line number Diff line
@@ -516,6 +516,19 @@ static jlong android_os_Debug_getPss(JNIEnv *env, jobject clazz)
    return android_os_Debug_getPssPid(env, clazz, getpid(), NULL);
}

enum {
    MEMINFO_TOTAL,
    MEMINFO_FREE,
    MEMINFO_BUFFERS,
    MEMINFO_CACHED,
    MEMINFO_SHMEM,
    MEMINFO_SLAB,
    MEMINFO_SWAP_TOTAL,
    MEMINFO_SWAP_FREE,
    MEMINFO_ZRAM_TOTAL,
    MEMINFO_COUNT
};

static void android_os_Debug_getMemInfo(JNIEnv *env, jobject clazz, jlongArray out)
{
    char buffer[1024];
@@ -529,15 +542,15 @@ static void android_os_Debug_getMemInfo(JNIEnv *env, jobject clazz, jlongArray o
    int fd = open("/proc/meminfo", O_RDONLY);

    if (fd < 0) {
        printf("Unable to open /proc/meminfo: %s\n", strerror(errno));
        ALOGW("Unable to open /proc/meminfo: %s\n", strerror(errno));
        return;
    }

    const int len = read(fd, buffer, sizeof(buffer)-1);
    int len = read(fd, buffer, sizeof(buffer)-1);
    close(fd);

    if (len < 0) {
        printf("Empty /proc/meminfo");
        ALOGW("Empty /proc/meminfo");
        return;
    }
    buffer[len] = 0;
@@ -549,6 +562,8 @@ static void android_os_Debug_getMemInfo(JNIEnv *env, jobject clazz, jlongArray o
            "Cached:",
            "Shmem:",
            "Slab:",
            "SwapTotal:",
            "SwapFree:",
            NULL
    };
    static const int tagsLen[] = {
@@ -558,12 +573,14 @@ static void android_os_Debug_getMemInfo(JNIEnv *env, jobject clazz, jlongArray o
            7,
            6,
            5,
            10,
            9,
            0
    };
    long mem[] = { 0, 0, 0, 0, 0, 0 };
    long mem[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };

    char* p = buffer;
    while (*p && numFound < 6) {
    while (*p && numFound < 8) {
        int i = 0;
        while (tags[i]) {
            if (strncmp(p, tags[i], tagsLen[i]) == 0) {
@@ -587,7 +604,20 @@ static void android_os_Debug_getMemInfo(JNIEnv *env, jobject clazz, jlongArray o
        if (*p) p++;
    }

    fd = open("/sys/block/zram0/mem_used_total", O_RDONLY);
    if (fd >= 0) {
        len = read(fd, buffer, sizeof(buffer)-1);
        close(fd);
        if (len > 0) {
            buffer[len] = 0;
            mem[MEMINFO_ZRAM_TOTAL] = atoll(buffer);
        }
    }

    int maxNum = env->GetArrayLength(out);
    if (maxNum > MEMINFO_COUNT) {
        maxNum = MEMINFO_COUNT;
    }
    jlong* outArray = env->GetLongArrayElements(out, 0);
    if (outArray != NULL) {
        for (int i=0; i<maxNum && tags[i]; i++) {
+113 −24

File changed.

Preview size limit exceeded, changes collapsed.

Loading