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

Commit 1e08dd8e authored by Makoto Onuki's avatar Makoto Onuki
Browse files

Add 50% and 100% to auto battery saver settings

The settings UI will be updated for P eventually, but let's add more
options to the settings for dogfooders until the UI update happens.

Also add the current value to the choices, so that if we push a number
that's not in the choices, the settings app will work properly.

Bug: 68769804
Bug: 71762373
Test: Manual test
Change-Id: I22fd14d43f4575885b4b8e068d3df1e65f60c9e1
parent 537f0b81
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -983,6 +983,8 @@
        <item>0</item>
        <item>5</item>
        <item>15</item>
        <item>50</item>
        <item>100</item>
    </integer-array>

    <!-- Process stats memory use details: labels for memory states -->
+10 −2
Original line number Diff line number Diff line
@@ -26,12 +26,14 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.PowerManager;
import android.provider.SearchIndexableResource;
import android.provider.Settings;
import android.provider.Settings.Global;
import android.support.annotation.VisibleForTesting;
import android.util.Log;
import android.widget.Switch;

import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.util.ArrayUtils;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.SettingsPreferenceFragment;
@@ -88,13 +90,19 @@ public class BatterySaverSettings extends SettingsPreferenceFragment
        mSwitch = mSwitchBar.getSwitch();
        mSwitchBar.show();

        int[] levelChoices = getResources().getIntArray(R.array.battery_saver_trigger_values);
        final int currentThreshold = Global.getInt(mContext.getContentResolver(),
                Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0);
        levelChoices = ArrayUtils.appendInt(levelChoices, currentThreshold);
        Arrays.sort(levelChoices);

        mTriggerPref = new SettingPref(SettingPref.TYPE_GLOBAL, KEY_TURN_ON_AUTOMATICALLY,
                Global.LOW_POWER_MODE_TRIGGER_LEVEL,
                0, /*default*/
                getResources().getIntArray(R.array.battery_saver_trigger_values)) {
                levelChoices) {
            @Override
            protected String getCaption(Resources res, int value) {
                if (value > 0 && value < 100) {
                if (value > 0 && value <= 100) {
                    return res.getString(R.string.battery_saver_turn_on_automatically_pct,
                            Utils.formatPercentage(value));
                }