Loading core/java/android/provider/Settings.java +8 −1 Original line number Diff line number Diff line Loading @@ -11069,6 +11069,13 @@ public final class Settings { */ public static final String LOW_POWER_MODE_TRIGGER_LEVEL_MAX = "low_power_trigger_level_max"; /** * See com.android.settingslib.fuelgauge.BatterySaverUtils. * @hide */ public static final String LOW_POWER_MODE_SUGGESTION_PARAMS = "low_power_mode_suggestion_params"; /** * If not 0, the activity manager will aggressively finish activities and * processes as soon as they are no longer needed. If 0, the normal Loading core/tests/coretests/src/android/provider/SettingsBackupTest.java +1 −0 Original line number Diff line number Diff line Loading @@ -268,6 +268,7 @@ public class SettingsBackupTest { Settings.Global.LOW_POWER_MODE, Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL_MAX, Settings.Global.LOW_POWER_MODE_STICKY, Settings.Global.LOW_POWER_MODE_SUGGESTION_PARAMS, Settings.Global.LTE_SERVICE_FORCED, Settings.Global.MAX_NOTIFICATION_ENQUEUE_RATE, Settings.Global.MAX_SOUND_TRIGGER_DETECTION_SERVICE_OPS_PER_DAY, Loading packages/SettingsLib/src/com/android/settingslib/fuelgauge/BatterySaverUtils.java +35 −10 Original line number Diff line number Diff line Loading @@ -22,8 +22,9 @@ import android.content.Intent; import android.os.PowerManager; import android.provider.Settings.Global; import android.provider.Settings.Secure; import android.support.annotation.VisibleForTesting; import android.util.KeyValueListParser; import android.util.Log; import android.util.Slog; /** * Utilities related to battery saver. Loading @@ -48,6 +49,9 @@ public class BatterySaverUtils { public static final String ACTION_SHOW_AUTO_SAVER_SUGGESTION = "PNW.autoSaverSuggestion"; private static class Parameters { private final Context mContext; /** * We show the auto battery saver suggestion notification when the user manually enables * battery saver for the START_NTH time through the END_NTH time. Loading @@ -56,6 +60,25 @@ public class BatterySaverUtils { private static final int AUTO_SAVER_SUGGESTION_START_NTH = 4; private static final int AUTO_SAVER_SUGGESTION_END_NTH = 8; public final int startNth; public final int endNth; public Parameters(Context context) { mContext = context; final String newValue = Global.getString(mContext.getContentResolver(), Global.LOW_POWER_MODE_SUGGESTION_PARAMS); final KeyValueListParser parser = new KeyValueListParser(','); try { parser.setString(newValue); } catch (IllegalArgumentException e) { Slog.wtf(TAG, "Bad constants: " + newValue); } startNth = parser.getInt("start_nth", AUTO_SAVER_SUGGESTION_START_NTH); endNth = parser.getInt("end_nth", AUTO_SAVER_SUGGESTION_END_NTH); } } /** * Enable / disable battery saver by user request. * - If it's the first time and needFirstTimeWarning, show the first time dialog. Loading Loading @@ -85,8 +108,10 @@ public class BatterySaverUtils { Secure.getInt(cr, Secure.LOW_POWER_MANUAL_ACTIVATION_COUNT, 0) + 1; Secure.putInt(cr, Secure.LOW_POWER_MANUAL_ACTIVATION_COUNT, count); if ((count >= AUTO_SAVER_SUGGESTION_START_NTH) && (count <= AUTO_SAVER_SUGGESTION_END_NTH) final Parameters parameters = new Parameters(context); if ((count >= parameters.startNth) && (count <= parameters.endNth) && Global.getInt(cr, Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0) == 0 && Secure.getInt(cr, Secure.SUPPRESS_AUTO_BATTERY_SAVER_SUGGESTION, 0) == 0) { Loading Loading
core/java/android/provider/Settings.java +8 −1 Original line number Diff line number Diff line Loading @@ -11069,6 +11069,13 @@ public final class Settings { */ public static final String LOW_POWER_MODE_TRIGGER_LEVEL_MAX = "low_power_trigger_level_max"; /** * See com.android.settingslib.fuelgauge.BatterySaverUtils. * @hide */ public static final String LOW_POWER_MODE_SUGGESTION_PARAMS = "low_power_mode_suggestion_params"; /** * If not 0, the activity manager will aggressively finish activities and * processes as soon as they are no longer needed. If 0, the normal Loading
core/tests/coretests/src/android/provider/SettingsBackupTest.java +1 −0 Original line number Diff line number Diff line Loading @@ -268,6 +268,7 @@ public class SettingsBackupTest { Settings.Global.LOW_POWER_MODE, Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL_MAX, Settings.Global.LOW_POWER_MODE_STICKY, Settings.Global.LOW_POWER_MODE_SUGGESTION_PARAMS, Settings.Global.LTE_SERVICE_FORCED, Settings.Global.MAX_NOTIFICATION_ENQUEUE_RATE, Settings.Global.MAX_SOUND_TRIGGER_DETECTION_SERVICE_OPS_PER_DAY, Loading
packages/SettingsLib/src/com/android/settingslib/fuelgauge/BatterySaverUtils.java +35 −10 Original line number Diff line number Diff line Loading @@ -22,8 +22,9 @@ import android.content.Intent; import android.os.PowerManager; import android.provider.Settings.Global; import android.provider.Settings.Secure; import android.support.annotation.VisibleForTesting; import android.util.KeyValueListParser; import android.util.Log; import android.util.Slog; /** * Utilities related to battery saver. Loading @@ -48,6 +49,9 @@ public class BatterySaverUtils { public static final String ACTION_SHOW_AUTO_SAVER_SUGGESTION = "PNW.autoSaverSuggestion"; private static class Parameters { private final Context mContext; /** * We show the auto battery saver suggestion notification when the user manually enables * battery saver for the START_NTH time through the END_NTH time. Loading @@ -56,6 +60,25 @@ public class BatterySaverUtils { private static final int AUTO_SAVER_SUGGESTION_START_NTH = 4; private static final int AUTO_SAVER_SUGGESTION_END_NTH = 8; public final int startNth; public final int endNth; public Parameters(Context context) { mContext = context; final String newValue = Global.getString(mContext.getContentResolver(), Global.LOW_POWER_MODE_SUGGESTION_PARAMS); final KeyValueListParser parser = new KeyValueListParser(','); try { parser.setString(newValue); } catch (IllegalArgumentException e) { Slog.wtf(TAG, "Bad constants: " + newValue); } startNth = parser.getInt("start_nth", AUTO_SAVER_SUGGESTION_START_NTH); endNth = parser.getInt("end_nth", AUTO_SAVER_SUGGESTION_END_NTH); } } /** * Enable / disable battery saver by user request. * - If it's the first time and needFirstTimeWarning, show the first time dialog. Loading Loading @@ -85,8 +108,10 @@ public class BatterySaverUtils { Secure.getInt(cr, Secure.LOW_POWER_MANUAL_ACTIVATION_COUNT, 0) + 1; Secure.putInt(cr, Secure.LOW_POWER_MANUAL_ACTIVATION_COUNT, count); if ((count >= AUTO_SAVER_SUGGESTION_START_NTH) && (count <= AUTO_SAVER_SUGGESTION_END_NTH) final Parameters parameters = new Parameters(context); if ((count >= parameters.startNth) && (count <= parameters.endNth) && Global.getInt(cr, Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0) == 0 && Secure.getInt(cr, Secure.SUPPRESS_AUTO_BATTERY_SAVER_SUGGESTION, 0) == 0) { Loading