Merge "Fix null pointer from PowerUsageFeatureProvider"
This commit is contained in:
committed by
Android (Google) Code Review
commit
345a3cb61d
@@ -171,19 +171,21 @@ public class BatteryInfo {
|
|||||||
if (discharging && provider != null
|
if (discharging && provider != null
|
||||||
&& provider.isEnhancedBatteryPredictionEnabled(context)) {
|
&& provider.isEnhancedBatteryPredictionEnabled(context)) {
|
||||||
Estimate estimate = provider.getEnhancedBatteryPrediction(context);
|
Estimate estimate = provider.getEnhancedBatteryPrediction(context);
|
||||||
BatteryUtils.logRuntime(LOG_TAG, "time for enhanced BatteryInfo", startTime);
|
if(estimate != null) {
|
||||||
|
BatteryUtils
|
||||||
|
.logRuntime(LOG_TAG, "time for enhanced BatteryInfo", startTime);
|
||||||
return BatteryInfo.getBatteryInfo(context, batteryBroadcast, stats,
|
return BatteryInfo.getBatteryInfo(context, batteryBroadcast, stats,
|
||||||
elapsedRealtimeUs, shortString,
|
elapsedRealtimeUs, shortString,
|
||||||
BatteryUtils.convertMsToUs(estimate.estimateMillis),
|
BatteryUtils.convertMsToUs(estimate.estimateMillis),
|
||||||
estimate.isBasedOnUsage);
|
estimate.isBasedOnUsage);
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
long prediction = discharging
|
long prediction = discharging
|
||||||
? stats.computeBatteryTimeRemaining(elapsedRealtimeUs) : 0;
|
? stats.computeBatteryTimeRemaining(elapsedRealtimeUs) : 0;
|
||||||
BatteryUtils.logRuntime(LOG_TAG, "time for regular BatteryInfo", startTime);
|
BatteryUtils.logRuntime(LOG_TAG, "time for regular BatteryInfo", startTime);
|
||||||
return BatteryInfo.getBatteryInfo(context, batteryBroadcast, stats,
|
return BatteryInfo.getBatteryInfo(context, batteryBroadcast, stats,
|
||||||
elapsedRealtimeUs, shortString, prediction, false);
|
elapsedRealtimeUs, shortString, prediction, false);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(BatteryInfo batteryInfo) {
|
protected void onPostExecute(BatteryInfo batteryInfo) {
|
||||||
|
@@ -55,6 +55,9 @@ public class DebugEstimatesLoader extends AsyncLoader<List<BatteryInfo>> {
|
|||||||
stats, elapsedRealtimeUs, false);
|
stats, elapsedRealtimeUs, false);
|
||||||
|
|
||||||
Estimate estimate = powerUsageFeatureProvider.getEnhancedBatteryPrediction(context);
|
Estimate estimate = powerUsageFeatureProvider.getEnhancedBatteryPrediction(context);
|
||||||
|
if (estimate == null) {
|
||||||
|
estimate = new Estimate(0, false);
|
||||||
|
}
|
||||||
BatteryInfo newInfo = BatteryInfo.getBatteryInfo(getContext(), batteryBroadcast, stats,
|
BatteryInfo newInfo = BatteryInfo.getBatteryInfo(getContext(), batteryBroadcast, stats,
|
||||||
elapsedRealtimeUs, false,
|
elapsedRealtimeUs, false,
|
||||||
BatteryUtils.convertMsToUs(estimate.estimateMillis),
|
BatteryUtils.convertMsToUs(estimate.estimateMillis),
|
||||||
|
Reference in New Issue
Block a user