Loading services/core/java/com/android/server/am/LmkdStatsReporter.java +3 −3 Original line number Diff line number Diff line Loading @@ -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(); Loading @@ -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; Loading services/core/java/com/android/server/am/ProcessList.java +26 −1 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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"; Loading services/core/java/com/android/server/am/ProcessServiceRecord.java +10 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading
services/core/java/com/android/server/am/LmkdStatsReporter.java +3 −3 Original line number Diff line number Diff line Loading @@ -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(); Loading @@ -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; Loading
services/core/java/com/android/server/am/ProcessList.java +26 −1 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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"; Loading
services/core/java/com/android/server/am/ProcessServiceRecord.java +10 −0 Original line number Diff line number Diff line Loading @@ -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; Loading