From ded8305cb712b1b65b4c8b247886681f519395f2 Mon Sep 17 00:00:00 2001 From: Rafal Slawik Date: Fri, 28 Feb 2020 13:20:13 +0000 Subject: [PATCH] Register IonHeapSize puller only if supported IonHeapSize atom can be created only if kernel exposes a sysfs node with the information, otherwise 0 is returned. Register the puller conditionally only if the sysfs node is present. This avoids the overhead of creating the atom and simplifies the server-side configuration. Bug: 15044292 Test: atest UidAtomTests#testIonHeapSize_enabled Test: atest UidAtomTests#testIonHeapSize_disabled Change-Id: Idcbd2564d5fa087dd0a936ab55f02271741c1462 --- .../com/android/server/stats/pull/StatsPullAtomService.java | 3 +++ 1 file changed, 3 insertions(+) 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 e426574fb9b7d..9c4391cf8ac3c 100644 --- a/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java +++ b/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java @@ -1468,6 +1468,9 @@ public class StatsPullAtomService extends SystemService { } private void registerIonHeapSize() { + if (!new File("/sys/kernel/ion/total_heaps_kb").exists()) { + return; + } int tagId = FrameworkStatsLog.ION_HEAP_SIZE; mStatsManager.registerPullAtomCallback( tagId,