Improve messaging for enhanced notifications
The message displayed in battery settings will now more accurately reflect when an estimate is enhanced based on our updated definition of what that means. Test: robotests Bug: 64833846 Change-Id: Id635d78d8f56d10253e22df2705af93f2693db70
This commit is contained in:
@@ -21,8 +21,6 @@ import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.BatteryManager;
|
||||
import android.os.BatteryStats;
|
||||
import android.os.Bundle;
|
||||
@@ -410,19 +408,19 @@ public class BatteryUtils {
|
||||
final boolean discharging = batteryBroadcast.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1)
|
||||
== 0;
|
||||
// Get enhanced prediction if available and discharging, otherwise use the old code
|
||||
Cursor cursor = null;
|
||||
Estimate estimate = null;
|
||||
if (discharging && mPowerUsageFeatureProvider != null &&
|
||||
mPowerUsageFeatureProvider.isEnhancedBatteryPredictionEnabled(mContext)) {
|
||||
final Uri queryUri = mPowerUsageFeatureProvider.getEnhancedBatteryPredictionUri();
|
||||
cursor = mContext.getContentResolver().query(queryUri, null, null, null, null);
|
||||
estimate = mPowerUsageFeatureProvider.getEnhancedBatteryPrediction(mContext);
|
||||
}
|
||||
final BatteryStats stats = statsHelper.getStats();
|
||||
BatteryUtils.logRuntime(tag, "BatteryInfoLoader post query", startTime);
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
long enhancedEstimate = mPowerUsageFeatureProvider.getTimeRemainingEstimate(cursor);
|
||||
|
||||
if (estimate != null) {
|
||||
batteryInfo = BatteryInfo.getBatteryInfo(mContext, batteryBroadcast, stats,
|
||||
elapsedRealtimeUs, false /* shortString */,
|
||||
BatteryUtils.convertMsToUs(enhancedEstimate), true /* basedOnUsage */);
|
||||
BatteryUtils.convertMsToUs(estimate.estimateMillis),
|
||||
estimate.isBasedOnUsage);
|
||||
} else {
|
||||
batteryInfo = BatteryInfo.getBatteryInfo(mContext, batteryBroadcast, stats,
|
||||
elapsedRealtimeUs, false /* shortString */,
|
||||
|
Reference in New Issue
Block a user