Skip to content
Commit 5bb1ec89 authored by Adam Bookatz's avatar Adam Bookatz
Browse files

BatteryStats custom buckets: don't revive dead Uids

It is possible for old uids to be reported to BatteryStats
in updateCustomMeasuredEnergyDataLocked().
This can happen, e.g., if a uid was uninstalled between
successive custom energy updates, so that the uid did use non-zero
energy but BatteryStats doesn't care anymore since the uid is gone.
If this happens,
we don't want to recreate any removed Uid objects, so we need
to be careful to only consider Uids that aren't removed.

In practice, this method will only be called after the CPU update,
which means that BatteryStats should already know about all active
uids (assuming they used CPU). Therefore, there shouldn't be any
unknown uids actively using custom energy buckets at this point.
We therefore simply ignore any unknown uids (just log them), on
the assumption that they refer to removed uids or stopped users.

Test: atest BatteryStatsTests
Bug: 180030409
Change-Id: If4fee7a1d11b148ca16d464d6ce4720c5a251130
parent 0088eefa
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment