From 92cdc549e301263c4263c7ef7b96433161689057 Mon Sep 17 00:00:00 2001 From: Raff Tsai Date: Mon, 23 Dec 2019 09:11:04 +0800 Subject: [PATCH] Fix battery saver slider is not displaying - Doesn't save Settings values to secondary user, caused BatterySaverUtils.maybeShowBatterySaverConfirmation return true. BatterySaverScheduleRadioButtonsController reset some Settings to default when maybeShowBatterySaverConfirmation is true which lead to the slider hiding. Fixes: 133782238 Test: change to secondary user. Open Settings -> Battery -> Battery Saver -> Set a schedule. User will not see confirm dialog after switch different schedule. Change-Id: I4b8706fd0c542a199fd1e08a44e7a542fbb2d7e7 --- .../com/android/settingslib/fuelgauge/BatterySaverUtils.java | 4 +++- .../com/android/systemui/power/PowerNotificationWarnings.java | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/SettingsLib/src/com/android/settingslib/fuelgauge/BatterySaverUtils.java b/packages/SettingsLib/src/com/android/settingslib/fuelgauge/BatterySaverUtils.java index e19ac815b939c..6d7e86f649444 100644 --- a/packages/SettingsLib/src/com/android/settingslib/fuelgauge/BatterySaverUtils.java +++ b/packages/SettingsLib/src/com/android/settingslib/fuelgauge/BatterySaverUtils.java @@ -21,6 +21,7 @@ import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.os.PowerManager; +import android.os.UserHandle; import android.provider.Settings.Global; import android.provider.Settings.Secure; import android.text.TextUtils; @@ -186,7 +187,8 @@ public class BatterySaverUtils { } private static void setBatterySaverConfirmationAcknowledged(Context context) { - Secure.putInt(context.getContentResolver(), Secure.LOW_POWER_WARNING_ACKNOWLEDGED, 1); + Secure.putIntForUser(context.getContentResolver(), Secure.LOW_POWER_WARNING_ACKNOWLEDGED, 1, + UserHandle.USER_CURRENT); } /** diff --git a/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java b/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java index eb195718c3f75..c8cf02a052429 100644 --- a/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java +++ b/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java @@ -585,10 +585,10 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI { resolver, Global.LOW_POWER_MODE_TRIGGER_LEVEL, batterySaverTriggerLevel); - Secure.putInt( + Secure.putIntForUser( resolver, Secure.LOW_POWER_WARNING_ACKNOWLEDGED, - 1); + 1, UserHandle.USER_CURRENT); }); } else { d.setTitle(R.string.battery_saver_confirmation_title);