Fix crash in BatteryUtils
When enhanced estimation is enabled, it may still have malfunction when getting data from it. This CL handles this case and fall back to default estimation. Change-Id: Id8d75b07316afa8a73a302b49dc7f8e8b77d4fa4 Fixes: 121213171 Test: RunSettingsRoboTests
This commit is contained in:
@@ -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 */,
|
||||
|
Reference in New Issue
Block a user