Update battery usage summary
- Set up different summary for AOSP Bug: 185855825 Bug: 187667156 Test: make SettingsRoboTests Change-Id: I94dccfc325ecfcff8013fe4d3b5b65c427dcae5c
This commit is contained in:
committed by
Wesley Wang
parent
021e6b131f
commit
8d5010f6ec
@@ -52,10 +52,13 @@ import java.util.List;
|
||||
public class PowerUsageSummary extends PowerUsageBase implements
|
||||
BatteryTipPreferenceController.BatteryTipListener {
|
||||
|
||||
private static final String KEY_BATTERY_ERROR = "battery_help_message";
|
||||
|
||||
static final String TAG = "PowerUsageSummary";
|
||||
|
||||
@VisibleForTesting
|
||||
static final String KEY_BATTERY_ERROR = "battery_help_message";
|
||||
@VisibleForTesting
|
||||
static final String KEY_BATTERY_USAGE = "battery_usage_summary";
|
||||
|
||||
@VisibleForTesting
|
||||
static final int BATTERY_INFO_LOADER = 1;
|
||||
@VisibleForTesting
|
||||
@@ -78,6 +81,8 @@ public class PowerUsageSummary extends PowerUsageBase implements
|
||||
boolean mNeedUpdateBatteryTip;
|
||||
@VisibleForTesting
|
||||
Preference mHelpPreference;
|
||||
@VisibleForTesting
|
||||
Preference mBatteryUsagePreference;
|
||||
|
||||
@VisibleForTesting
|
||||
final ContentObserver mSettingsObserver = new ContentObserver(new Handler()) {
|
||||
@@ -154,12 +159,10 @@ public class PowerUsageSummary extends PowerUsageBase implements
|
||||
setAnimationAllowed(true);
|
||||
|
||||
initFeatureProvider();
|
||||
initPreference();
|
||||
|
||||
mBatteryUtils = BatteryUtils.getInstance(getContext());
|
||||
|
||||
mHelpPreference = findPreference(KEY_BATTERY_ERROR);
|
||||
mHelpPreference.setVisible(false);
|
||||
|
||||
if (Utils.isBatteryPresent(getContext())) {
|
||||
restartBatteryInfoLoader();
|
||||
} else {
|
||||
@@ -248,6 +251,18 @@ public class PowerUsageSummary extends PowerUsageBase implements
|
||||
.getPowerUsageFeatureProvider(context);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void initPreference() {
|
||||
mBatteryUsagePreference = findPreference(KEY_BATTERY_USAGE);
|
||||
mBatteryUsagePreference.setSummary(
|
||||
mPowerFeatureProvider.isChartGraphEnabled(getContext()) ?
|
||||
getString(R.string.advanced_battery_preference_summary_with_hours) :
|
||||
getString(R.string.advanced_battery_preference_summary));
|
||||
|
||||
mHelpPreference = findPreference(KEY_BATTERY_ERROR);
|
||||
mHelpPreference.setVisible(false);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void restartBatteryInfoLoader() {
|
||||
if (getContext() == null) {
|
||||
|
Reference in New Issue
Block a user