Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6cf1399d authored by Salvador Martinez's avatar Salvador Martinez Committed by Android (Google) Code Review
Browse files

Merge "Rename battery saver schedule mode apis"

parents f28a845b 7fb560af
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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));
+3 −3
Original line number Diff line number Diff line
@@ -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) {
+11 −11
Original line number Diff line number Diff line
@@ -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(
+5 −5
Original line number Diff line number Diff line
@@ -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) {
+3 −3
Original line number Diff line number Diff line
@@ -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);

Loading