Prevent early boot crash reading PowerProfile

The PowerProfile in BatteryStatsImpl may not be ready when
resetting stats early in the boot sequence.

Bug:29559031
Change-Id: I51bba762231a08804f1b68505bb1b0523476081d
This commit is contained in:
Adam Lesinski
2016-06-22 10:28:47 -07:00
parent f184789ae9
commit 1a76a62b8d

View File

@@ -8186,7 +8186,12 @@ public class BatteryStatsImpl extends BatteryStats {
for (int i=0; i<NUM_SCREEN_BRIGHTNESS_BINS; i++) {
mScreenBrightnessTimer[i].reset(false);
}
mEstimatedBatteryCapacity = (int) mPowerProfile.getBatteryCapacity();
if (mPowerProfile != null) {
mEstimatedBatteryCapacity = (int) mPowerProfile.getBatteryCapacity();
} else {
mEstimatedBatteryCapacity = -1;
}
mInteractiveTimer.reset(false);
mPowerSaveModeEnabledTimer.reset(false);
mLastIdleTimeStart = elapsedRealtimeMillis;