Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4b6fa610 authored by Benjamin Schwartz's avatar Benjamin Schwartz
Browse files

powerstats: Add null checks to clients of power stats api

Bug: 182092453
Test: Presubmit
Change-Id: Iaa59fb6cb01c6ac41aba15b206ea98dcc796bee4
parent 4e924074
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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;
            }