Merge "Fix crash in BatteryUtils"

This commit is contained in:
TreeHugger Robot
2018-12-19 02:04:29 +00:00
committed by Android (Google) Code Review
2 changed files with 26 additions and 6 deletions

View File

@@ -449,12 +449,14 @@ public class BatteryUtils {
final BatteryStats stats = statsHelper.getStats();
BatteryInfo batteryInfo;
final Estimate estimate;
Estimate estimate = null;
// Get enhanced prediction if available
if (mPowerUsageFeatureProvider != null &&
mPowerUsageFeatureProvider.isEnhancedBatteryPredictionEnabled(mContext)) {
estimate = mPowerUsageFeatureProvider.getEnhancedBatteryPrediction(mContext);
} else {
}
if (estimate == null) {
estimate = new Estimate(
PowerUtil.convertUsToMs(stats.computeBatteryTimeRemaining(elapsedRealtimeUs)),
false /* isBasedOnUsage */,