Merge "Add Battery Saver Schedule screen logic"

This commit is contained in:
TreeHugger Robot
2018-12-18 00:41:43 +00:00
committed by Android (Google) Code Review
15 changed files with 386 additions and 502 deletions

View File

@@ -15,6 +15,7 @@
*/
package com.android.settings.fuelgauge;
import android.content.ContentResolver;
import android.content.Context;
import android.database.ContentObserver;
import android.os.Handler;
@@ -22,6 +23,7 @@ import android.os.Looper;
import android.os.PowerManager;
import android.provider.Settings;
import android.provider.Settings.Global;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
@@ -31,6 +33,7 @@ import com.android.settings.core.BasePreferenceController;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.core.lifecycle.events.OnStop;
import com.android.settingslib.fuelgauge.BatterySaverUtils;
public class BatterySaverController extends BasePreferenceController
implements LifecycleObserver, OnStart, OnStop, BatterySaverReceiver.BatterySaverListener {
@@ -45,6 +48,7 @@ public class BatterySaverController extends BasePreferenceController
mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
mBatteryStateChangeReceiver = new BatterySaverReceiver(context);
mBatteryStateChangeReceiver.setBatterySaverListener(this);
BatterySaverUtils.revertScheduleToNoneIfNeeded(context);
}
@Override
@@ -81,16 +85,23 @@ public class BatterySaverController extends BasePreferenceController
@Override
public CharSequence getSummary() {
final ContentResolver resolver = mContext.getContentResolver();
final boolean isPowerSaveOn = mPowerManager.isPowerSaveMode();
final int percent = Settings.Global.getInt(mContext.getContentResolver(),
final int percent = Settings.Global.getInt(resolver,
Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0);
final int mode = Settings.Global.getInt(resolver,
Global.AUTOMATIC_POWER_SAVER_MODE, PowerManager.POWER_SAVER_MODE_PERCENTAGE);
if (isPowerSaveOn) {
return mContext.getString(R.string.battery_saver_on_summary);
} else if (percent != 0) {
return mContext.getString(R.string.battery_saver_off_scheduled_summary,
Utils.formatPercentage(percent));
} else if (mode == PowerManager.POWER_SAVER_MODE_PERCENTAGE) {
if (percent != 0) {
return mContext.getString(R.string.battery_saver_off_scheduled_summary,
Utils.formatPercentage(percent));
} else {
return mContext.getString(R.string.battery_saver_off_summary);
}
} else {
return mContext.getString(R.string.battery_saver_off_summary);
return mContext.getString(R.string.battery_saver_auto_routine);
}
}

View File

@@ -1,70 +0,0 @@
/*
* Copyright (C) 2018 The Android Open Source Project
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.fuelgauge.batterysaver;
import android.content.Context;
import android.provider.Settings;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import com.android.settings.core.TogglePreferenceController;
import com.android.settingslib.fuelgauge.BatterySaverUtils;
/**
* Controller that update whether to turn on battery saver automatically
*/
public class AutoBatterySaverPreferenceController extends TogglePreferenceController implements
Preference.OnPreferenceChangeListener {
/**
* Default value for {@link Settings.Global#LOW_POWER_MODE_TRIGGER_LEVEL}.
*/
static final int DEFAULT_TRIGGER_LEVEL = 0;
/**
* The default value to set to {@link Settings.Global#LOW_POWER_MODE_TRIGGER_LEVEL} when the
* user enables battery saver.
*/
private final int mDefaultTriggerLevelForOn;
@VisibleForTesting
static final String KEY_AUTO_BATTERY_SAVER = "auto_battery_saver";
public AutoBatterySaverPreferenceController(Context context) {
super(context, KEY_AUTO_BATTERY_SAVER);
mDefaultTriggerLevelForOn = mContext.getResources().getInteger(
com.android.internal.R.integer.config_lowBatteryWarningLevel);
}
@Override
public int getAvailabilityStatus() {
return AVAILABLE;
}
@Override
public boolean isChecked() {
return Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, DEFAULT_TRIGGER_LEVEL) != 0;
}
@Override
public boolean setChecked(boolean isChecked) {
BatterySaverUtils.setAutoBatterySaverTriggerLevel(mContext,
isChecked ? mDefaultTriggerLevelForOn : 0);
return true;
}
}

View File

@@ -1,166 +0,0 @@
/*
* Copyright (C) 2018 The Android Open Source Project
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.fuelgauge.batterysaver;
import android.content.ContentResolver;
import android.content.Context;
import android.database.ContentObserver;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.provider.Settings;
import android.util.Log;
import android.view.accessibility.AccessibilityNodeInfo;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.widget.SeekBarPreference;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.core.lifecycle.events.OnStop;
/**
* Controller that update the battery saver seekbar
*/
public class AutoBatterySeekBarPreferenceController extends BasePreferenceController implements
LifecycleObserver, OnStart, OnStop, SeekBarPreference.OnPreferenceChangeListener {
private static final String TAG = "AutoBatterySeekBarPreferenceController";
private static final int INTERVAL = 5;
@VisibleForTesting
static final String KEY_AUTO_BATTERY_SEEK_BAR = "battery_saver_seek_bar";
private SeekBarPreference mPreference;
private AutoBatterySaverSettingObserver mContentObserver;
public AutoBatterySeekBarPreferenceController(Context context, Lifecycle lifecycle) {
super(context, KEY_AUTO_BATTERY_SEEK_BAR);
mContentObserver = new AutoBatterySaverSettingObserver(new Handler(Looper.getMainLooper()));
if (lifecycle != null) {
lifecycle.addObserver(this);
}
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SeekBarPreference) screen.findPreference(
KEY_AUTO_BATTERY_SEEK_BAR);
mPreference.setContinuousUpdates(true);
mPreference.setAccessibilityRangeInfoType(
AccessibilityNodeInfo.RangeInfo.RANGE_TYPE_PERCENT);
updatePreference(mPreference);
}
@Override
public int getAvailabilityStatus() {
return AVAILABLE;
}
@Override
public void updateState(Preference preference) {
super.updateState(preference);
updatePreference(preference);
}
@Override
public void onStart() {
mContentObserver.registerContentObserver();
}
@Override
public void onStop() {
mContentObserver.unRegisterContentObserver();
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final int progress = (int) newValue;
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, progress * INTERVAL);
return true;
}
@VisibleForTesting
void updatePreference(Preference preference) {
final ContentResolver contentResolver = mContext.getContentResolver();
// Override the max value with LOW_POWER_MODE_TRIGGER_LEVEL_MAX, if set.
final int maxLevel = Settings.Global.getInt(contentResolver,
Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL_MAX, 0) / INTERVAL;
if (maxLevel > 0) {
if (!(preference instanceof SeekBarPreference)) {
Log.e(TAG, "Unexpected preference class: " + preference.getClass());
} else {
final SeekBarPreference seekBarPreference = (SeekBarPreference) preference;
if (maxLevel < seekBarPreference.getMin()) {
Log.e(TAG, "LOW_POWER_MODE_TRIGGER_LEVEL_MAX too low; ignored.");
} else {
seekBarPreference.setMax(maxLevel);
}
}
}
// Set the current value.
final int level = Settings.Global.getInt(contentResolver,
Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL,
AutoBatterySaverPreferenceController.DEFAULT_TRIGGER_LEVEL);
if (level == 0) {
preference.setVisible(false);
} else {
preference.setVisible(true);
preference.setTitle(mContext.getString(R.string.battery_saver_seekbar_title,
Utils.formatPercentage(level)));
SeekBarPreference seekBarPreference = (SeekBarPreference) preference;
seekBarPreference.setProgress(level / INTERVAL);
seekBarPreference.setSeekBarContentDescription(
mContext.getString(R.string.battery_saver_turn_on_automatically_title));
}
}
/**
* Observer that listens to change from {@link Settings.Global#LOW_POWER_MODE_TRIGGER_LEVEL}
*/
private final class AutoBatterySaverSettingObserver extends ContentObserver {
private final Uri mUri = Settings.Global.getUriFor(
Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL);
private final ContentResolver mContentResolver;
public AutoBatterySaverSettingObserver(Handler handler) {
super(handler);
mContentResolver = mContext.getContentResolver();
}
public void registerContentObserver() {
mContentResolver.registerContentObserver(mUri, false, this);
}
public void unRegisterContentObserver() {
mContentResolver.unregisterContentObserver(this);
}
@Override
public void onChange(boolean selfChange, Uri uri, int userId) {
if (mUri.equals(uri)) {
updatePreference(mPreference);
}
}
}
}

View File

@@ -26,7 +26,13 @@ import androidx.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.core.BasePreferenceController;
import com.android.settingslib.fuelgauge.BatterySaverUtils;
/**
* Simple controller to navigate users to the scheduling page from
* "Settings > Battery > Battery Saver". Also updates the summary for preference based on
* the currently selected settings.
*/
public class BatterySaverSchedulePreferenceController extends BasePreferenceController {
@VisibleForTesting
@@ -36,6 +42,7 @@ public class BatterySaverSchedulePreferenceController extends BasePreferenceCont
public BatterySaverSchedulePreferenceController(Context context) {
super(context, KEY_BATTERY_SAVER_SCHEDULE);
BatterySaverUtils.revertScheduleToNoneIfNeeded(context);
}
@Override

View File

@@ -0,0 +1,91 @@
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.fuelgauge.batterysaver;
import android.content.ContentResolver;
import android.content.Context;
import android.os.PowerManager;
import android.provider.Settings;
import android.provider.Settings.Global;
/**
* Responds to user actions in the Settings > Battery > Set a Schedule Screen
*
* Note that this is not a preference controller since that screen does not inherit from
* DashboardFragment.
*
* Will call the appropriate power manager APIs and modify the correct settings to enable
* users to control their automatic battery saver toggling preferences.
* See {@link Settings.Global#AUTOMATIC_POWER_SAVER_MODE} for more details.
*/
public class BatterySaverScheduleRadioButtonsController {
public static final String KEY_NO_SCHEDULE = "key_battery_saver_no_schedule";
public static final String KEY_ROUTINE = "key_battery_saver_routine";
public static final String KEY_PERCENTAGE = "key_battery_saver_percentage";
private Context mContext;
private BatterySaverScheduleSeekBarController mSeekBarController;
public BatterySaverScheduleRadioButtonsController(Context context,
BatterySaverScheduleSeekBarController seekbar) {
mContext = context;
mSeekBarController = seekbar;
}
public String getDefaultKey() {
final ContentResolver resolver = mContext.getContentResolver();
// Note: this can also be obtained via PowerManager.getPowerSaveMode()
final int mode = Settings.Global.getInt(resolver, Global.AUTOMATIC_POWER_SAVER_MODE,
PowerManager.POWER_SAVER_MODE_PERCENTAGE);
// if mode is "dynamic" we are in routine mode, percentage with non-zero threshold is
// percentage mode, otherwise it is no schedule mode
if (mode == PowerManager.POWER_SAVER_MODE_PERCENTAGE) {
final int threshold =
Settings.Global.getInt(resolver, Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0);
if (threshold <= 0) {
return KEY_NO_SCHEDULE;
}
return KEY_PERCENTAGE;
}
return KEY_ROUTINE;
}
public boolean setDefaultKey(String key) {
final ContentResolver resolver = mContext.getContentResolver();
switch(key) {
case KEY_NO_SCHEDULE:
Settings.Global.putInt(resolver, Global.AUTOMATIC_POWER_SAVER_MODE,
PowerManager.POWER_SAVER_MODE_PERCENTAGE);
Settings.Global.putInt(resolver, Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0);
break;
case KEY_PERCENTAGE:
Settings.Global.putInt(resolver, Global.AUTOMATIC_POWER_SAVER_MODE,
PowerManager.POWER_SAVER_MODE_PERCENTAGE);
Settings.Global.putInt(resolver, Global.LOW_POWER_MODE_TRIGGER_LEVEL, 5);
break;
case KEY_ROUTINE:
Settings.Global.putInt(resolver, Global.AUTOMATIC_POWER_SAVER_MODE,
PowerManager.POWER_SAVER_MODE_DYNAMIC);
break;
default:
throw new IllegalStateException(
"Not a valid key for " + this.getClass().getSimpleName());
}
mSeekBarController.updateSeekBar();
return true;
}
}

View File

@@ -0,0 +1,100 @@
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.fuelgauge.batterysaver;
import android.content.ContentResolver;
import android.content.Context;
import android.os.PowerManager;
import android.provider.Settings;
import android.provider.Settings.Global;
import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceChangeListener;
import androidx.preference.PreferenceScreen;
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.widget.SeekBarPreference;
/**
* Responds to user actions in the Settings > Battery > Set a Schedule Screen for the seekbar.
* Note that this seekbar is only visible when the radio button selected is "Percentage".
*
* Note that this is not a preference controller since that screen does not inherit from
* DashboardFragment.
*
* Will call the appropriate power manager APIs and modify the correct settings to enable
* users to control their automatic battery saver toggling preferences.
* See {@link Settings.Global#AUTOMATIC_POWER_SAVER_MODE} for more details.
*/
public class BatterySaverScheduleSeekBarController implements
OnPreferenceChangeListener {
public static final int MAX_SEEKBAR_VALUE = 15;
public static final int MIN_SEEKBAR_VALUE = 1;
public static final String KEY_BATTERY_SAVER_SEEK_BAR = "battery_saver_seek_bar";
@VisibleForTesting
public SeekBarPreference mSeekBarPreference;
private Context mContext;
public BatterySaverScheduleSeekBarController(Context context) {
mContext = context;
mSeekBarPreference = new SeekBarPreference(context);
mSeekBarPreference.setOnPreferenceChangeListener(this);
mSeekBarPreference.setMax(BatterySaverScheduleSeekBarController.MAX_SEEKBAR_VALUE);
mSeekBarPreference.setMin(BatterySaverScheduleSeekBarController.MIN_SEEKBAR_VALUE);
mSeekBarPreference.setKey(KEY_BATTERY_SAVER_SEEK_BAR);
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
// The nits are in intervals of 5%
final int percentage = ((Integer) newValue) * 5;
Settings.Global.putInt(mContext.getContentResolver(), Global.LOW_POWER_MODE_TRIGGER_LEVEL,
percentage);
preference.setTitle(mContext.getString(
R.string.battery_saver_seekbar_title, Utils.formatPercentage(percentage)));
return true;
}
public void updateSeekBar() {
final ContentResolver resolver = mContext.getContentResolver();
// Note: this can also be obtained via PowerManager.getPowerSaveMode()
final int mode = Settings.Global.getInt(resolver, Global.AUTOMATIC_POWER_SAVER_MODE,
PowerManager.POWER_SAVER_MODE_PERCENTAGE);
// if mode is "dynamic" we are in routine mode, percentage with non-zero threshold is
// percentage mode, otherwise it is no schedule mode
if (mode == PowerManager.POWER_SAVER_MODE_PERCENTAGE) {
final int threshold =
Settings.Global.getInt(resolver, Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0);
if (threshold <= 0) {
mSeekBarPreference.setVisible(false);
} else {
mSeekBarPreference.setVisible(true);
mSeekBarPreference.setProgress(MIN_SEEKBAR_VALUE);
mSeekBarPreference.setTitle(mContext.getString(
R.string.battery_saver_seekbar_title,
Utils.formatPercentage(MIN_SEEKBAR_VALUE * 5)));
}
} else {
mSeekBarPreference.setVisible(false);
}
}
public void addToScreen(PreferenceScreen screen) {
screen.addPreference(mSeekBarPreference);
}
}

View File

@@ -18,48 +18,77 @@ package com.android.settings.fuelgauge.batterysaver;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import androidx.preference.PreferenceScreen;
import com.android.settings.widget.RadioButtonPickerFragment;
import com.android.settings.R;
import com.android.settings.widget.RadioButtonPreference;
import com.android.settings.widget.SeekBarPreference;
import com.android.settingslib.fuelgauge.BatterySaverUtils;
import com.android.settingslib.widget.CandidateInfo;
import com.google.common.collect.Lists;
import java.util.List;
/**
* Fragment that allows users to customize their automatic battery saver mode settings.
*
* Location: Settings > Battery > Battery Saver > Set a Schedule
* See {@link BatterySaverSchedulePreferenceController} for the controller that manages navigation
* to this screen from "Settings > Battery > Battery Saver" and the summary.
* See {@link BatterySaverScheduleRadioButtonsController} &
* {@link BatterySaverScheduleSeekBarController} for the controller that manages user
* interactions in this screen.
*/
public class BatterySaverScheduleSettings extends RadioButtonPickerFragment {
private static final String KEY_NO_SCHEDULE = "key_battery_saver_no_schedule";
private static final String KEY_ROUTINE = "key_battery_saver_routine";
private static final String KEY_PERCENTAGE = "key_battery_saver_percentage";
public static final int MAX_SEEKBAR_VALUE = 15;
public static final int MIN_SEEKBAR_VALUE = 1;
public static final String KEY_BATTERY_SAVER_SEEK_BAR = "battery_saver_seek_bar";
public BatterySaverScheduleRadioButtonsController mRadioButtonController;
private BatterySaverScheduleSeekBarController mSeekBarController;
@Override
protected int getPreferenceScreenResId() {
return R.xml.battery_saver_schedule_settings;
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
mSeekBarController = new BatterySaverScheduleSeekBarController(context);
mRadioButtonController = new BatterySaverScheduleRadioButtonsController(
context, mSeekBarController);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
protected List<? extends CandidateInfo> getCandidates() {
Context context = getContext();
List<CandidateInfo> candidates = Lists.newArrayList();
String routineProviderApp = getContext().getResources()
.getString(com.android.internal.R.string.config_batterySaverScheduleProvider);
candidates.add(new BatterySaverScheduleCandidateInfo(
context.getText(R.string.battery_saver_auto_no_schedule),
/* summary */ null,
KEY_NO_SCHEDULE,
/* enabled */ true));
candidates.add(new BatterySaverScheduleCandidateInfo(
context.getText(R.string.battery_saver_auto_routine),
context.getText(R.string.battery_saver_auto_routine_summary),
KEY_ROUTINE,
BatterySaverScheduleRadioButtonsController.KEY_NO_SCHEDULE,
/* enabled */ true));
// only add routine option if an app has been specified
if (!TextUtils.isEmpty(routineProviderApp)) {
candidates.add(new BatterySaverScheduleCandidateInfo(
context.getText(R.string.battery_saver_auto_routine),
context.getText(R.string.battery_saver_auto_routine_summary),
BatterySaverScheduleRadioButtonsController.KEY_ROUTINE,
/* enabled */ true));
} else {
// Make sure routine is not selected if no provider app is configured
BatterySaverUtils.revertScheduleToNoneIfNeeded(context);
}
candidates.add(new BatterySaverScheduleCandidateInfo(
context.getText(R.string.battery_saver_auto_percentage),
/* summary */ null,
KEY_PERCENTAGE,
BatterySaverScheduleRadioButtonsController.KEY_PERCENTAGE,
/* enabled */ true));
return candidates;
@@ -79,22 +108,18 @@ public class BatterySaverScheduleSettings extends RadioButtonPickerFragment {
@Override
protected void addStaticPreferences(PreferenceScreen screen) {
SeekBarPreference seekbar = new SeekBarPreference(getContext());
seekbar.setMax(MAX_SEEKBAR_VALUE);
seekbar.setMin(MIN_SEEKBAR_VALUE);
seekbar.setTitle(R.string.battery_saver_seekbar_title_placeholder);
seekbar.setKey(KEY_BATTERY_SAVER_SEEK_BAR);
screen.addPreference(seekbar);
mSeekBarController.updateSeekBar();
mSeekBarController.addToScreen(screen);
}
@Override
protected String getDefaultKey() {
return null;
return mRadioButtonController.getDefaultKey();
}
@Override
protected boolean setDefaultKey(String key) {
return false;
return mRadioButtonController.setDefaultKey(key);
}
@Override

View File

@@ -60,24 +60,11 @@ public class BatterySaverSettings extends DashboardFragment {
return TAG;
}
@Override
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
return buildPreferenceControllers(context, getSettingsLifecycle());
}
@Override
public int getHelpResource() {
return R.string.help_url_battery_saver_settings;
}
private static List<AbstractPreferenceController> buildPreferenceControllers(
Context context, Lifecycle lifecycle) {
final List<AbstractPreferenceController> controllers = new ArrayList<>();
controllers.add(new AutoBatterySaverPreferenceController(context));
controllers.add(new AutoBatterySeekBarPreferenceController(context, lifecycle));
return controllers;
}
/**
* For Search.
*/
@@ -90,11 +77,5 @@ public class BatterySaverSettings extends DashboardFragment {
sir.xmlResId = R.xml.battery_saver_settings;
return Arrays.asList(sir);
}
@Override
public List<AbstractPreferenceController> createPreferenceControllers(
Context context) {
return buildPreferenceControllers(context, null);
}
};
}