Rename battery saver schedule mode apis
The APIs that back these settings got renamed so this CL just refactors all the calls to use the new names. Test: robotests still pass Bug: 126944845 Change-Id: I2975c7c79998823058db2c0ced2e5cf02216a106
This commit is contained in:
@@ -90,10 +90,10 @@ public class BatterySaverController extends BasePreferenceController
|
||||
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);
|
||||
Global.AUTOMATIC_POWER_SAVE_MODE, PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE);
|
||||
if (isPowerSaveOn) {
|
||||
return mContext.getString(R.string.battery_saver_on_summary);
|
||||
} else if (mode == PowerManager.POWER_SAVER_MODE_PERCENTAGE) {
|
||||
} else if (mode == PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE) {
|
||||
if (percent != 0) {
|
||||
return mContext.getString(R.string.battery_saver_off_scheduled_summary,
|
||||
Utils.formatPercentage(percent));
|
||||
|
@@ -61,9 +61,9 @@ public class BatterySaverSchedulePreferenceController extends BasePreferenceCont
|
||||
@Override
|
||||
public CharSequence getSummary() {
|
||||
final ContentResolver resolver = mContext.getContentResolver();
|
||||
final int mode = Settings.Global.getInt(resolver, Global.AUTOMATIC_POWER_SAVER_MODE,
|
||||
PowerManager.POWER_SAVER_MODE_PERCENTAGE);
|
||||
if (mode == PowerManager.POWER_SAVER_MODE_PERCENTAGE) {
|
||||
final int mode = Settings.Global.getInt(resolver, Global.AUTOMATIC_POWER_SAVE_MODE,
|
||||
PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE);
|
||||
if (mode == PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE) {
|
||||
final int threshold =
|
||||
Settings.Global.getInt(resolver, Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0);
|
||||
if (threshold <= 0) {
|
||||
|
@@ -29,7 +29,7 @@ import android.provider.Settings.Global;
|
||||
*
|
||||
* 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.
|
||||
* See {@link Settings.Global#AUTOMATIC_POWER_SAVE_MODE} for more details.
|
||||
*/
|
||||
public class BatterySaverScheduleRadioButtonsController {
|
||||
|
||||
@@ -48,12 +48,12 @@ public class BatterySaverScheduleRadioButtonsController {
|
||||
|
||||
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);
|
||||
// Note: this can also be obtained via PowerManager.getPowerSaveModeTrigger()
|
||||
final int mode = Settings.Global.getInt(resolver, Global.AUTOMATIC_POWER_SAVE_MODE,
|
||||
PowerManager.POWER_SAVE_MODE_TRIGGER_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) {
|
||||
if (mode == PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE) {
|
||||
final int threshold =
|
||||
Settings.Global.getInt(resolver, Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0);
|
||||
if (threshold <= 0) {
|
||||
@@ -68,18 +68,18 @@ public class BatterySaverScheduleRadioButtonsController {
|
||||
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.AUTOMATIC_POWER_SAVE_MODE,
|
||||
PowerManager.POWER_SAVE_MODE_TRIGGER_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.AUTOMATIC_POWER_SAVE_MODE,
|
||||
PowerManager.POWER_SAVE_MODE_TRIGGER_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);
|
||||
Settings.Global.putInt(resolver, Global.AUTOMATIC_POWER_SAVE_MODE,
|
||||
PowerManager.POWER_SAVE_MODE_TRIGGER_DYNAMIC);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException(
|
||||
|
@@ -39,7 +39,7 @@ import com.android.settings.widget.SeekBarPreference;
|
||||
*
|
||||
* 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.
|
||||
* See {@link Settings.Global#AUTOMATIC_POWER_SAVE_MODE} for more details.
|
||||
*/
|
||||
public class BatterySaverScheduleSeekBarController implements
|
||||
OnPreferenceChangeListener {
|
||||
@@ -76,12 +76,12 @@ public class BatterySaverScheduleSeekBarController implements
|
||||
|
||||
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);
|
||||
// Note: this can also be obtained via PowerManager.getPowerSaveModeTrigger()
|
||||
final int mode = Settings.Global.getInt(resolver, Global.AUTOMATIC_POWER_SAVE_MODE,
|
||||
PowerManager.POWER_SAVE_MODE_TRIGGER_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) {
|
||||
if (mode == PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE) {
|
||||
final int threshold =
|
||||
Settings.Global.getInt(resolver, Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0);
|
||||
if (threshold <= 0) {
|
||||
|
@@ -62,7 +62,7 @@ public class BatterySaverSchedulePreferenceControllerTest {
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0);
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Global.AUTOMATIC_POWER_SAVER_MODE, PowerManager.POWER_SAVER_MODE_PERCENTAGE);
|
||||
Global.AUTOMATIC_POWER_SAVE_MODE, PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE);
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
@@ -74,7 +74,7 @@ public class BatterySaverSchedulePreferenceControllerTest {
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, TRIGGER_LEVEL);
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Global.AUTOMATIC_POWER_SAVER_MODE, PowerManager.POWER_SAVER_MODE_PERCENTAGE);
|
||||
Global.AUTOMATIC_POWER_SAVE_MODE, PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE);
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
@@ -87,7 +87,7 @@ public class BatterySaverSchedulePreferenceControllerTest {
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, TRIGGER_LEVEL);
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Global.AUTOMATIC_POWER_SAVER_MODE, PowerManager.POWER_SAVER_MODE_DYNAMIC);
|
||||
Global.AUTOMATIC_POWER_SAVE_MODE, PowerManager.POWER_SAVE_MODE_TRIGGER_DYNAMIC);
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
|
@@ -31,16 +31,16 @@ public class BatterySaverScheduleRadioButtonsControllerTest {
|
||||
|
||||
@Test
|
||||
public void getDefaultKey_routine_returnsCorrectValue() {
|
||||
Settings.Global.putInt(mResolver, Global.AUTOMATIC_POWER_SAVER_MODE,
|
||||
PowerManager.POWER_SAVER_MODE_DYNAMIC);
|
||||
Settings.Global.putInt(mResolver, Global.AUTOMATIC_POWER_SAVE_MODE,
|
||||
PowerManager.POWER_SAVE_MODE_TRIGGER_DYNAMIC);
|
||||
assertThat(mController.getDefaultKey())
|
||||
.isEqualTo(BatterySaverScheduleRadioButtonsController.KEY_ROUTINE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDefaultKey_automatic_returnsCorrectValue() {
|
||||
Settings.Global.putInt(mResolver, Global.AUTOMATIC_POWER_SAVER_MODE,
|
||||
PowerManager.POWER_SAVER_MODE_PERCENTAGE);
|
||||
Settings.Global.putInt(mResolver, Global.AUTOMATIC_POWER_SAVE_MODE,
|
||||
PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE);
|
||||
Settings.Global.putInt(mResolver, Global.LOW_POWER_MODE_TRIGGER_LEVEL, 5);
|
||||
assertThat(mController.getDefaultKey())
|
||||
.isEqualTo(BatterySaverScheduleRadioButtonsController.KEY_PERCENTAGE);
|
||||
@@ -48,8 +48,8 @@ public class BatterySaverScheduleRadioButtonsControllerTest {
|
||||
|
||||
@Test
|
||||
public void getDefaultKey_none_returnsCorrectValue() {
|
||||
Settings.Global.putInt(mResolver, Global.AUTOMATIC_POWER_SAVER_MODE,
|
||||
PowerManager.POWER_SAVER_MODE_PERCENTAGE);
|
||||
Settings.Global.putInt(mResolver, Global.AUTOMATIC_POWER_SAVE_MODE,
|
||||
PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE);
|
||||
Settings.Global.putInt(mResolver, Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0);
|
||||
assertThat(mController.getDefaultKey())
|
||||
.isEqualTo(BatterySaverScheduleRadioButtonsController.KEY_NO_SCHEDULE);
|
||||
|
@@ -39,16 +39,16 @@ public class BatterySaverScheduleSeekBarControllerTest {
|
||||
|
||||
@Test
|
||||
public void updateSeekBar_routineMode_hasCorrectProperties() {
|
||||
Settings.Global.putInt(mResolver, Global.AUTOMATIC_POWER_SAVER_MODE,
|
||||
PowerManager.POWER_SAVER_MODE_DYNAMIC);
|
||||
Settings.Global.putInt(mResolver, Global.AUTOMATIC_POWER_SAVE_MODE,
|
||||
PowerManager.POWER_SAVE_MODE_TRIGGER_DYNAMIC);
|
||||
mController.updateSeekBar();
|
||||
assertThat(mController.mSeekBarPreference.isVisible()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateSeekBar_percentageMode_hasCorrectProperties() {
|
||||
Settings.Global.putInt(mResolver, Global.AUTOMATIC_POWER_SAVER_MODE,
|
||||
PowerManager.POWER_SAVER_MODE_PERCENTAGE);
|
||||
Settings.Global.putInt(mResolver, Global.AUTOMATIC_POWER_SAVE_MODE,
|
||||
PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE);
|
||||
Settings.Global.putInt(mResolver, Global.LOW_POWER_MODE_TRIGGER_LEVEL, 5);
|
||||
mController.updateSeekBar();
|
||||
assertThat(mController.mSeekBarPreference.isVisible()).isTrue();
|
||||
@@ -56,8 +56,8 @@ public class BatterySaverScheduleSeekBarControllerTest {
|
||||
|
||||
@Test
|
||||
public void updateSeekBar_noneMode_hasCorrectProperties() {
|
||||
Settings.Global.putInt(mResolver, Global.AUTOMATIC_POWER_SAVER_MODE,
|
||||
PowerManager.POWER_SAVER_MODE_PERCENTAGE);
|
||||
Settings.Global.putInt(mResolver, Global.AUTOMATIC_POWER_SAVE_MODE,
|
||||
PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE);
|
||||
Settings.Global.putInt(mResolver, Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0);
|
||||
mController.updateSeekBar();
|
||||
assertThat(mController.mSeekBarPreference.isVisible()).isFalse();
|
||||
|
Reference in New Issue
Block a user