1/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.systemui.statusbar.policy;
18
19import com.android.systemui.DemoMode;
20import com.android.systemui.Dumpable;
21import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback;
22
23import java.io.FileDescriptor;
24import java.io.PrintWriter;
25
26public interface BatteryController extends DemoMode, Dumpable,
27        CallbackController<BatteryStateChangeCallback> {
28    /**
29     * Prints the current state of the {@link BatteryController} to the given {@link PrintWriter}.
30     */
31    void dump(FileDescriptor fd, PrintWriter pw, String[] args);
32
33    /**
34     * Sets if the current device is in power save mode.
35     */
36    void setPowerSaveMode(boolean powerSave);
37
38    /**
39     * Returns {@code true} if the device is currently in power save mode.
40     */
41    boolean isPowerSave();
42
43    /**
44     * Returns {@code true} if AOD was disabled by power saving policies.
45     */
46    default boolean isAodPowerSave() {
47        return isPowerSave();
48    }
49
50    /**
51     * A listener that will be notified whenever a change in battery level or power save mode
52     * has occurred.
53     */
54    interface BatteryStateChangeCallback {
55        default void onBatteryLevelChanged(int level, boolean pluggedIn, boolean charging) {}
56        default void onPowerSaveChanged(boolean isPowerSave) {}
57    }
58}
59