Merge "Check custom component names before aggregating BatteryUsageStats snapshots" into sc-qpr1-dev am: 0ef5152b17 am: 4ff921f559
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15872124 Change-Id: If46ae1934feff590ce5202a25765f5eac9bfea41
This commit is contained in:
@@ -29,6 +29,7 @@ import android.util.SparseArray;
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -234,8 +235,9 @@ public class BatteryUsageStatsProvider {
|
||||
final boolean includePowerModels = (query.getFlags()
|
||||
& BatteryUsageStatsQuery.FLAG_BATTERY_USAGE_STATS_INCLUDE_POWER_MODELS) != 0;
|
||||
|
||||
final String[] customEnergyConsumerNames = mStats.getCustomEnergyConsumerNames();
|
||||
final BatteryUsageStats.Builder builder = new BatteryUsageStats.Builder(
|
||||
mStats.getCustomEnergyConsumerNames(), includePowerModels);
|
||||
customEnergyConsumerNames, includePowerModels);
|
||||
if (mBatteryUsageStatsStore == null) {
|
||||
Log.e(TAG, "BatteryUsageStatsStore is unavailable");
|
||||
return builder.build();
|
||||
@@ -247,7 +249,14 @@ public class BatteryUsageStatsProvider {
|
||||
final BatteryUsageStats snapshot =
|
||||
mBatteryUsageStatsStore.loadBatteryUsageStats(timestamp);
|
||||
if (snapshot != null) {
|
||||
builder.add(snapshot);
|
||||
if (Arrays.equals(snapshot.getCustomPowerComponentNames(),
|
||||
customEnergyConsumerNames)) {
|
||||
builder.add(snapshot);
|
||||
} else {
|
||||
Log.w(TAG, "Ignoring older BatteryUsageStats snapshot, which has different "
|
||||
+ "custom power components: "
|
||||
+ Arrays.toString(snapshot.getCustomPowerComponentNames()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user