Fix null pointer from PowerUsageFeatureProvider

Some locations did not check if the returned value was null before
doing operations on them and could crash. This CL changes those
spots to take that into account.

Test: b/72463854 will add in follow up to unblock dogfood
Bug: 72350595
Change-Id: I0ace5c0ab4a8aa9fd5b09d41d6f986143246f059
This commit is contained in:
Salvador Martinez
2018-01-24 10:24:04 -08:00
parent 475fa50461
commit 250a79830c
2 changed files with 16 additions and 11 deletions

View File

@@ -55,6 +55,9 @@ public class DebugEstimatesLoader extends AsyncLoader<List<BatteryInfo>> {
stats, elapsedRealtimeUs, false);
Estimate estimate = powerUsageFeatureProvider.getEnhancedBatteryPrediction(context);
if (estimate == null) {
estimate = new Estimate(0, false);
}
BatteryInfo newInfo = BatteryInfo.getBatteryInfo(getContext(), batteryBroadcast, stats,
elapsedRealtimeUs, false,
BatteryUtils.convertMsToUs(estimate.estimateMillis),