From e7f4f0297fe77fd76f944b9a3134534962833262 Mon Sep 17 00:00:00 2001 From: Adam Lesinski Date: Wed, 8 Jun 2016 14:19:09 -0700 Subject: [PATCH] Consume the first sample of KernelUidCpuTimeReader If the system_server crashes, when it starts back up it will assume that the entries in kernelUidCpuTimeReader are all fresh and we will end up double counting cpu time and power. Bug:29163081 Change-Id: I73e693199c170229af57efd610950e90263ac9bc --- core/java/com/android/internal/os/KernelUidCpuTimeReader.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/java/com/android/internal/os/KernelUidCpuTimeReader.java b/core/java/com/android/internal/os/KernelUidCpuTimeReader.java index 5d3043cc8a02..c828d11fd3d2 100644 --- a/core/java/com/android/internal/os/KernelUidCpuTimeReader.java +++ b/core/java/com/android/internal/os/KernelUidCpuTimeReader.java @@ -84,7 +84,8 @@ public class KernelUidCpuTimeReader { powerMaUs = 0; } - if (callback != null) { + // Only report if there is a callback and if this is not the first read. + if (callback != null && mLastTimeReadUs != 0) { long userTimeDeltaUs = userTimeUs; long systemTimeDeltaUs = systemTimeUs; long powerDeltaMaUs = powerMaUs; -- 2.11.0