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
This commit is contained in:
Raff Tsai
2019-12-23 09:11:04 +08:00
parent bc189e7d11
commit 92cdc549e3
2 changed files with 5 additions and 3 deletions

View File

@@ -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);
}
/**

View File

@@ -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);