Merge "Fix enhanced estimate discharge text showing while charging" into oc-dr1-dev

This commit is contained in:
TreeHugger Robot
2017-07-14 21:47:50 +00:00
committed by Android (Google) Code Review
7 changed files with 79 additions and 23 deletions

View File

@@ -35,8 +35,9 @@ public class BatteryHistoryPreference extends Preference {
private CharSequence mSummary;
private TextView mSummaryView;
private boolean hideSummary;
@VisibleForTesting
boolean hideSummary;
@VisibleForTesting
BatteryInfo mBatteryInfo;
@@ -56,8 +57,10 @@ public class BatteryHistoryPreference extends Preference {
public void setBottomSummary(CharSequence text) {
mSummary = text;
if (mSummaryView != null) {
mSummaryView.setVisibility(View.VISIBLE);
mSummaryView.setText(mSummary);
}
hideSummary = false;
}
public void hideBottomSummary() {

View File

@@ -15,7 +15,10 @@ package com.android.settings.fuelgauge;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.os.BatteryManager;
import android.os.BatteryStats;
import android.os.Bundle;
import android.os.Handler;
@@ -171,7 +174,11 @@ public class PowerUsageAdvanced extends PowerUsageBase {
updatePreference(mHistPref);
refreshPowerUsageDataList(mStatsHelper, mUsageListGroup);
if (mPowerUsageFeatureProvider.isEnhancedBatteryPredictionEnabled(context)) {
Intent batteryIntent =
context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
final boolean plugged = batteryIntent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1) != 0;
if (mPowerUsageFeatureProvider.isEnhancedBatteryPredictionEnabled(context) && !plugged) {
mHistPref.setBottomSummary(
mPowerUsageFeatureProvider.getAdvancedUsageScreenInfoString());
} else {