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
Loading
Please register or sign in to comment