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

Commit 4a9a0c3c authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Set number of foreground services in statsd atom LmkKillOccurred." into...

Merge "Set number of foreground services in statsd atom LmkKillOccurred." into tm-qpr-dev am: fb793ddc

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19641514



Change-Id: I341020ac1322dffdef9435a2494f488ec22b946e
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 116a0cc7 fb793ddc
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -50,7 +50,8 @@ public final class LmkdStatsReporter {
     * Logs the event when LMKD kills a process to reduce memory pressure.
     * Code: LMK_KILL_OCCURRED = 51
     */
    public static void logKillOccurred(DataInputStream inputData) {
    public static void logKillOccurred(DataInputStream inputData, int totalForegroundServices,
            int procsWithForegroundServices) {
        try {
            final long pgFault = inputData.readLong();
            final long pgMajFault = inputData.readLong();
@@ -67,11 +68,10 @@ public final class LmkdStatsReporter {
            final int thrashing = inputData.readInt();
            final int maxThrashing = inputData.readInt();
            final String procName = inputData.readUTF();

            FrameworkStatsLog.write(FrameworkStatsLog.LMK_KILL_OCCURRED, uid, procName, oomScore,
                    pgFault, pgMajFault, rssInBytes, cacheInBytes, swapInBytes, processStartTimeNS,
                    minOomScore, freeMemKb, freeSwapKb, mapKillReason(killReason), thrashing,
                    maxThrashing);
                    maxThrashing, totalForegroundServices, procsWithForegroundServices);
        } catch (IOException e) {
            Slog.e(TAG, "Invalid buffer data. Failed to log LMK_KILL_OCCURRED");
            return;
+26 −1
Original line number Diff line number Diff line
@@ -814,7 +814,12 @@ public final class ProcessList {
                                                < LmkdStatsReporter.KILL_OCCURRED_MSG_SIZE) {
                                            return false;
                                        }
                                        LmkdStatsReporter.logKillOccurred(inputData);
                                        Pair<Integer, Integer> temp = getNumForegroundServices();
                                        final int totalForegroundServices = temp.first;
                                        final int procsWithForegroundServices = temp.second;
                                        LmkdStatsReporter.logKillOccurred(inputData,
                                                totalForegroundServices,
                                                procsWithForegroundServices);
                                        return true;
                                    case LMK_STATE_CHANGED:
                                        if (receivedLen
@@ -5123,6 +5128,26 @@ public final class ProcessList {
        }
    }

    /**
     * Get the number of foreground services in all processes and number of processes that have
     * foreground service within.
     */
    Pair<Integer, Integer> getNumForegroundServices() {
        int numForegroundServices = 0;
        int procs = 0;
        synchronized (mService) {
            for (int i = 0, size = mLruProcesses.size(); i < size; i++) {
                ProcessRecord pr = mLruProcesses.get(i);
                int numFgs = pr.mServices.getNumForegroundServices();
                if (numFgs > 0) {
                    numForegroundServices += numFgs;
                    procs++;
                }
            }
        }
        return new Pair<>(numForegroundServices, procs);
    }

    private final class ImperceptibleKillRunner extends IUidObserver.Stub {
        private static final String EXTRA_PID = "pid";
        private static final String EXTRA_UID = "uid";
+10 −0
Original line number Diff line number Diff line
@@ -180,6 +180,16 @@ final class ProcessServiceRecord {
        mRepFgServiceTypes = foregroundServiceTypes;
    }

    int getNumForegroundServices() {
        int count = 0;
        for (int i = 0, serviceCount = mServices.size(); i < serviceCount; i++) {
            if (mServices.valueAt(i).isForeground) {
                count++;
            }
        }
        return count;
    }

    void updateHasTopStartedAlmostPerceptibleServices() {
        mHasTopStartedAlmostPerceptibleServices = false;
        mLastTopStartedAlmostPerceptibleBindRequestUptimeMs = 0;