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

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

Merge "Formalizing states in BatterySaverStateMachine."

parents ba7f46d1 f57f99ed
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -318,6 +318,16 @@ message BatterySaverStateMachineProto {
    // Whether battery saver is enabled.
    optional bool enabled = 1;

    enum StateEnum {
        STATE_UNKNOWN = 0;
        STATE_OFF = 1;
        STATE_MANUAL_ON = 2;
        STATE_AUTOMATIC_ON = 3;
        STATE_OFF_AUTOMATIC_SNOOZED = 4;
        STATE_PENDING_STICKY_ON = 5;
    }
    optional StateEnum state = 18;

    // Whether full battery saver is enabled.
    optional bool is_full_enabled = 14;

@@ -337,8 +347,7 @@ message BatterySaverStateMachineProto {
    // Whether battery status has been set at least once.
    optional bool battery_status_set = 4;

    // Whether automatic battery saver has been canceled by the user.
    optional bool battery_saver_snoozing = 5;
    reserved 5; // battery_saver_snoozing

    // Whether the device is connected to any power source.
    optional bool is_powered = 6;
@@ -373,5 +382,5 @@ message BatterySaverStateMachineProto {
    // using elapsed realtime as the timebase.
    optional int64 last_adaptive_battery_saver_changed_externally_elapsed = 17;

    // Next tag: 18
    // Next tag: 19
}
+35 −3
Original line number Diff line number Diff line
@@ -115,9 +115,41 @@ public class BatterySaverController implements BatterySaverPolicyListener {
    public static final int REASON_SETTING_CHANGED = 8;
    public static final int REASON_DYNAMIC_POWER_SAVINGS_AUTOMATIC_ON = 9;
    public static final int REASON_DYNAMIC_POWER_SAVINGS_AUTOMATIC_OFF = 10;
    public static final int REASON_STICKY_RESTORE_OFF = 11;
    public static final int REASON_ADAPTIVE_DYNAMIC_POWER_SAVINGS_CHANGED = 12;
    public static final int REASON_TIMEOUT = 13;
    public static final int REASON_ADAPTIVE_DYNAMIC_POWER_SAVINGS_CHANGED = 11;
    public static final int REASON_TIMEOUT = 12;

    static String reasonToString(int reason) {
        switch (reason) {
            case BatterySaverController.REASON_PERCENTAGE_AUTOMATIC_ON:
                return "Percentage Auto ON";
            case BatterySaverController.REASON_PERCENTAGE_AUTOMATIC_OFF:
                return "Percentage Auto OFF";
            case BatterySaverController.REASON_MANUAL_ON:
                return "Manual ON";
            case BatterySaverController.REASON_MANUAL_OFF:
                return "Manual OFF";
            case BatterySaverController.REASON_STICKY_RESTORE:
                return "Sticky restore";
            case BatterySaverController.REASON_INTERACTIVE_CHANGED:
                return "Interactivity changed";
            case BatterySaverController.REASON_POLICY_CHANGED:
                return "Policy changed";
            case BatterySaverController.REASON_PLUGGED_IN:
                return "Plugged in";
            case BatterySaverController.REASON_SETTING_CHANGED:
                return "Setting changed";
            case BatterySaverController.REASON_DYNAMIC_POWER_SAVINGS_AUTOMATIC_ON:
                return "Dynamic Warning Auto ON";
            case BatterySaverController.REASON_DYNAMIC_POWER_SAVINGS_AUTOMATIC_OFF:
                return "Dynamic Warning Auto OFF";
            case BatterySaverController.REASON_ADAPTIVE_DYNAMIC_POWER_SAVINGS_CHANGED:
                return "Adaptive Power Savings changed";
            case BatterySaverController.REASON_TIMEOUT:
                return "timeout";
            default:
                return "Unknown reason: " + reason;
        }
    }

    /**
     * Plugin interface. All methods are guaranteed to be called on the same (handler) thread.
+254 −96

File changed.

Preview size limit exceeded, changes collapsed.

+290 −8

File changed.

Preview size limit exceeded, changes collapsed.