powerstats: Add null checks to clients of power stats api

Bug: 182092453
Test: Presubmit
Change-Id: Iaa59fb6cb01c6ac41aba15b206ea98dcc796bee4
This commit is contained in:
Benjamin Schwartz
2021-03-08 10:06:29 -08:00
parent 4e92407479
commit 4b6fa6106b

View File

@@ -111,6 +111,8 @@ public class ProtoStreamUtils {
static class StateResidencyResultUtils {
public static void adjustTimeSinceBootToEpoch(StateResidencyResult[] stateResidencyResult,
long startWallTime) {
if (stateResidencyResult == null) return;
for (int i = 0; i < stateResidencyResult.length; i++) {
final int stateLength = stateResidencyResult[i].stateResidencyData.length;
for (int j = 0; j < stateLength; j++) {
@@ -320,6 +322,8 @@ public class ProtoStreamUtils {
static class EnergyMeasurementUtils {
public static void adjustTimeSinceBootToEpoch(EnergyMeasurement[] energyMeasurement,
long startWallTime) {
if (energyMeasurement == null) return;
for (int i = 0; i < energyMeasurement.length; i++) {
energyMeasurement[i].timestampMs += startWallTime;
}
@@ -539,6 +543,8 @@ public class ProtoStreamUtils {
static class EnergyConsumerResultUtils {
public static void adjustTimeSinceBootToEpoch(EnergyConsumerResult[] energyConsumerResult,
long startWallTime) {
if (energyConsumerResult == null) return;
for (int i = 0; i < energyConsumerResult.length; i++) {
energyConsumerResult[i].timestampMs += startWallTime;
}