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

Commit cb91b276 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Making Battery Saver policy setting more defensive."

parents e17af32f c1d844a5
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -58,7 +58,8 @@ public final class BatterySaverPolicyConfig implements Parcelable {
        mAdvertiseIsEnabled = in.mAdvertiseIsEnabled;
        mDeferFullBackup = in.mDeferFullBackup;
        mDeferKeyValueBackup = in.mDeferKeyValueBackup;
        mDeviceSpecificSettings = Collections.unmodifiableMap(in.mDeviceSpecificSettings);
        mDeviceSpecificSettings = Collections.unmodifiableMap(
                new ArrayMap<>(in.mDeviceSpecificSettings));
        mDisableAnimation = in.mDisableAnimation;
        mDisableAod = in.mDisableAod;
        mDisableLaunchBoost = in.mDisableLaunchBoost;
+4 −2
Original line number Diff line number Diff line
@@ -773,8 +773,10 @@ public final class PowerManager {
     */
    public static final int LOCATION_MODE_THROTTLE_REQUESTS_WHEN_SCREEN_OFF = 4;

    static final int MIN_LOCATION_MODE = LOCATION_MODE_NO_CHANGE;
    static final int MAX_LOCATION_MODE = LOCATION_MODE_THROTTLE_REQUESTS_WHEN_SCREEN_OFF;
    /** @hide */
    public static final int MIN_LOCATION_MODE = LOCATION_MODE_NO_CHANGE;
    /** @hide */
    public static final int MAX_LOCATION_MODE = LOCATION_MODE_THROTTLE_REQUESTS_WHEN_SCREEN_OFF;

    /**
     * @hide
+9 −2
Original line number Diff line number Diff line
@@ -594,7 +594,7 @@ public class BatterySaverPolicy extends ContentObserver {
                boolean forceBackgroundCheck,
                int locationMode) {

            this.adjustBrightnessFactor = adjustBrightnessFactor;
            this.adjustBrightnessFactor = Math.min(1, Math.max(0, adjustBrightnessFactor));
            this.advertiseIsEnabled = advertiseIsEnabled;
            this.deferFullBackup = deferFullBackup;
            this.deferKeyValueBackup = deferKeyValueBackup;
@@ -613,7 +613,14 @@ public class BatterySaverPolicy extends ContentObserver {
            this.filesForNoninteractive = filesForNoninteractive;
            this.forceAllAppsStandby = forceAllAppsStandby;
            this.forceBackgroundCheck = forceBackgroundCheck;

            if (locationMode < PowerManager.MIN_LOCATION_MODE
                    || PowerManager.MAX_LOCATION_MODE < locationMode) {
                Slog.e(TAG, "Invalid location mode: " + locationMode);
                this.locationMode = PowerManager.LOCATION_MODE_NO_CHANGE;
            } else {
                this.locationMode = locationMode;
            }

            mHashCode = Objects.hash(
                    adjustBrightnessFactor,