From e0ec1f3ce4c2b3e23be611e43f50403cef11ecaa Mon Sep 17 00:00:00 2001 From: Ioannis Ilkos Date: Thu, 11 Jun 2020 14:56:13 +0100 Subject: [PATCH] Remove incorrect isAppUid check reading memory state The check misclassifies processes as apps (it only checks lower bound, whereas there's also an upper bound of 20000-1). At the same time it is redundant. It was originally introduced to quickly filter out processes that were known to AM, but nowadays we explicitly remove these from the set of processes to scan. Bug: 158470048 Test: manual test, android.cts.statsd.atom.UidAtomTests#testProcessMemorySnapshot, 'android.cts.statsd.atom.UidAtomTests#testProcessMemoryHighWaterMark Change-Id: Ie24107ccea31efae40277d8d46fa36f978f2481e --- .../server/stats/pull/StatsPullAtomService.java | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java b/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java index c2bae1a8962b2..ea79d543041b7 100644 --- a/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java +++ b/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java @@ -209,14 +209,6 @@ public class StatsPullAtomService extends SystemService { // Random seed stable for StatsPullAtomService life cycle - can be used for stable sampling private static final int RANDOM_SEED = new Random().nextInt(); - /** - * Lowest available uid for apps. - * - *

Used to quickly discard memory snapshots of the zygote forks from native process - * measurements. - */ - private static final int MIN_APP_UID = 10_000; - private static final int DIMENSION_KEY_SIZE_HARD_LIMIT = 800; private static final int DIMENSION_KEY_SIZE_SOFT_LIMIT = 500; private static final long APP_OPS_SAMPLING_INITIALIZATION_DELAY_MILLIS = 45000; @@ -1819,10 +1811,6 @@ public class StatsPullAtomService extends SystemService { return StatsManager.PULL_SUCCESS; } - private static boolean isAppUid(int uid) { - return uid >= MIN_APP_UID; - } - private void registerProcessMemoryHighWaterMark() { int tagId = FrameworkStatsLog.PROCESS_MEMORY_HIGH_WATER_MARK; mStatsManager.setPullAtomCallback( @@ -1859,7 +1847,7 @@ public class StatsPullAtomService extends SystemService { int size = processCmdlines.size(); for (int i = 0; i < size; ++i) { final MemorySnapshot snapshot = readMemorySnapshotFromProcfs(processCmdlines.keyAt(i)); - if (snapshot == null || isAppUid(snapshot.uid)) { + if (snapshot == null) { continue; } StatsEvent e = StatsEvent.newBuilder() @@ -1920,7 +1908,7 @@ public class StatsPullAtomService extends SystemService { for (int i = 0; i < size; ++i) { int pid = processCmdlines.keyAt(i); final MemorySnapshot snapshot = readMemorySnapshotFromProcfs(pid); - if (snapshot == null || isAppUid(snapshot.uid)) { + if (snapshot == null) { continue; } StatsEvent e = StatsEvent.newBuilder()