Loading core/java/com/android/internal/os/BatteryStatsImpl.java +13 −4 Original line number Diff line number Diff line Loading @@ -229,6 +229,15 @@ public class BatteryStatsImpl extends BatteryStats { @GuardedBy("this") public boolean mPerProcStateCpuTimesAvailable = true; /** * When per process state cpu times tracking is off, cpu times in KernelSingleUidTimeReader are * not updated. So, when the setting is turned on later, we would end up with huge cpu time * deltas. This flag tracks the case where tracking is turned on from off so that we won't * end up attributing the huge deltas to wrong buckets. */ @GuardedBy("this") private boolean mIsPerProcessStateCpuDataStale; /** * Uids for which per-procstate cpu times need to be updated. * Loading Loading @@ -402,7 +411,7 @@ public class BatteryStatsImpl extends BatteryStats { } // If the KernelSingleUidTimeReader has stale cpu times, then we shouldn't try to // compute deltas since it might result in mis-attributing cpu times to wrong states. if (mKernelSingleUidTimeReader.hasStaleData()) { if (mIsPerProcessStateCpuDataStale) { mPendingUids.clear(); return; } Loading Loading @@ -485,9 +494,9 @@ public class BatteryStatsImpl extends BatteryStats { mKernelUidCpuFreqTimeReader.getAllUidCpuFreqTimeMs(); // If the KernelSingleUidTimeReader has stale cpu times, then we shouldn't try to // compute deltas since it might result in mis-attributing cpu times to wrong states. if (mKernelSingleUidTimeReader.hasStaleData()) { if (mIsPerProcessStateCpuDataStale) { mKernelSingleUidTimeReader.setAllUidsCpuTimesMs(allUidCpuFreqTimesMs); mKernelSingleUidTimeReader.markDataAsStale(false); mIsPerProcessStateCpuDataStale = false; mPendingUids.clear(); return; } Loading Loading @@ -13430,7 +13439,7 @@ public class BatteryStatsImpl extends BatteryStats { private void updateTrackCpuTimesByProcStateLocked(boolean wasEnabled, boolean isEnabled) { TRACK_CPU_TIMES_BY_PROC_STATE = isEnabled; if (isEnabled && !wasEnabled) { mKernelSingleUidTimeReader.markDataAsStale(true); mIsPerProcessStateCpuDataStale = true; mExternalSync.scheduleCpuSyncDueToSettingChange(); mNumSingleUidCpuTimeReads = 0; core/java/com/android/internal/os/KernelSingleUidTimeReader.java +0 −14 Original line number Diff line number Diff line Loading @@ -53,8 +53,6 @@ public class KernelSingleUidTimeReader { private int mReadErrorCounter; @GuardedBy("this") private boolean mSingleUidCpuTimesAvailable = true; @GuardedBy("this") private boolean mHasStaleData; // We use the freq count obtained from /proc/uid_time_in_state to decide how many longs // to read from each /proc/uid/<uid>/time_in_state. On the first read, verify if this is // correct and if not, set {@link #mSingleUidCpuTimesAvailable} to false. This flag will Loading Loading @@ -196,18 +194,6 @@ public class KernelSingleUidTimeReader { return deltaTimesMs; } public void markDataAsStale(boolean hasStaleData) { synchronized (this) { mHasStaleData = hasStaleData; } } public boolean hasStaleData() { synchronized (this) { return mHasStaleData; } } public void setAllUidsCpuTimesMs(SparseArray<long[]> allUidsCpuTimesMs) { synchronized (this) { mLastUidCpuTimeMs.clear(); Loading Loading
core/java/com/android/internal/os/BatteryStatsImpl.java +13 −4 Original line number Diff line number Diff line Loading @@ -229,6 +229,15 @@ public class BatteryStatsImpl extends BatteryStats { @GuardedBy("this") public boolean mPerProcStateCpuTimesAvailable = true; /** * When per process state cpu times tracking is off, cpu times in KernelSingleUidTimeReader are * not updated. So, when the setting is turned on later, we would end up with huge cpu time * deltas. This flag tracks the case where tracking is turned on from off so that we won't * end up attributing the huge deltas to wrong buckets. */ @GuardedBy("this") private boolean mIsPerProcessStateCpuDataStale; /** * Uids for which per-procstate cpu times need to be updated. * Loading Loading @@ -402,7 +411,7 @@ public class BatteryStatsImpl extends BatteryStats { } // If the KernelSingleUidTimeReader has stale cpu times, then we shouldn't try to // compute deltas since it might result in mis-attributing cpu times to wrong states. if (mKernelSingleUidTimeReader.hasStaleData()) { if (mIsPerProcessStateCpuDataStale) { mPendingUids.clear(); return; } Loading Loading @@ -485,9 +494,9 @@ public class BatteryStatsImpl extends BatteryStats { mKernelUidCpuFreqTimeReader.getAllUidCpuFreqTimeMs(); // If the KernelSingleUidTimeReader has stale cpu times, then we shouldn't try to // compute deltas since it might result in mis-attributing cpu times to wrong states. if (mKernelSingleUidTimeReader.hasStaleData()) { if (mIsPerProcessStateCpuDataStale) { mKernelSingleUidTimeReader.setAllUidsCpuTimesMs(allUidCpuFreqTimesMs); mKernelSingleUidTimeReader.markDataAsStale(false); mIsPerProcessStateCpuDataStale = false; mPendingUids.clear(); return; } Loading Loading @@ -13430,7 +13439,7 @@ public class BatteryStatsImpl extends BatteryStats { private void updateTrackCpuTimesByProcStateLocked(boolean wasEnabled, boolean isEnabled) { TRACK_CPU_TIMES_BY_PROC_STATE = isEnabled; if (isEnabled && !wasEnabled) { mKernelSingleUidTimeReader.markDataAsStale(true); mIsPerProcessStateCpuDataStale = true; mExternalSync.scheduleCpuSyncDueToSettingChange(); mNumSingleUidCpuTimeReads = 0;
core/java/com/android/internal/os/KernelSingleUidTimeReader.java +0 −14 Original line number Diff line number Diff line Loading @@ -53,8 +53,6 @@ public class KernelSingleUidTimeReader { private int mReadErrorCounter; @GuardedBy("this") private boolean mSingleUidCpuTimesAvailable = true; @GuardedBy("this") private boolean mHasStaleData; // We use the freq count obtained from /proc/uid_time_in_state to decide how many longs // to read from each /proc/uid/<uid>/time_in_state. On the first read, verify if this is // correct and if not, set {@link #mSingleUidCpuTimesAvailable} to false. This flag will Loading Loading @@ -196,18 +194,6 @@ public class KernelSingleUidTimeReader { return deltaTimesMs; } public void markDataAsStale(boolean hasStaleData) { synchronized (this) { mHasStaleData = hasStaleData; } } public boolean hasStaleData() { synchronized (this) { return mHasStaleData; } } public void setAllUidsCpuTimesMs(SparseArray<long[]> allUidsCpuTimesMs) { synchronized (this) { mLastUidCpuTimeMs.clear(); Loading