blob: 111cdd2cc32a6f6621fce64bb9bfd65a94650e3a [file] [log] [blame]
Joe Onoratofd52b182010-11-10 18:00:52 -08001/*
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
Evan Laird85ee4a32019-03-06 18:09:20 -050019import android.annotation.Nullable;
20
Jason Monk98d7c7a2016-04-12 13:08:31 -040021import com.android.systemui.DemoMode;
Jason Monk9c7844c2017-01-18 15:21:53 -050022import com.android.systemui.Dumpable;
Jason Monk88529052016-11-04 13:29:58 -040023import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback;
Jason Monk98d7c7a2016-04-12 13:08:31 -040024
John Spurlock0ff62e02014-07-22 16:15:08 -040025import java.io.FileDescriptor;
26import java.io.PrintWriter;
John Spurlockde84f0e2013-06-12 12:41:00 -040027
Jason Monk9c7844c2017-01-18 15:21:53 -050028public interface BatteryController extends DemoMode, Dumpable,
Jason Monk88529052016-11-04 13:29:58 -040029 CallbackController<BatteryStateChangeCallback> {
Anthony Chenda62fdcd52016-04-06 16:15:14 -070030 /**
31 * Prints the current state of the {@link BatteryController} to the given {@link PrintWriter}.
32 */
33 void dump(FileDescriptor fd, PrintWriter pw, String[] args);
Jason Monkabe19742015-09-29 09:47:06 -040034
Anthony Chenda62fdcd52016-04-06 16:15:14 -070035 /**
36 * Sets if the current device is in power save mode.
37 */
38 void setPowerSaveMode(boolean powerSave);
Jason Monkabe19742015-09-29 09:47:06 -040039
Anthony Chenda62fdcd52016-04-06 16:15:14 -070040 /**
41 * Returns {@code true} if the device is currently in power save mode.
42 */
43 boolean isPowerSave();
Joe Onoratofd52b182010-11-10 18:00:52 -080044
Anthony Chenda62fdcd52016-04-06 16:15:14 -070045 /**
Lucas Dupin92a62e52018-01-30 17:22:20 -080046 * Returns {@code true} if AOD was disabled by power saving policies.
47 */
48 default boolean isAodPowerSave() {
49 return isPowerSave();
50 }
51
52 /**
Evan Lairda5a73c52019-01-11 13:36:32 -050053 * A listener that will be notified whenever a change in battery level or power save mode has
54 * occurred.
Anthony Chenda62fdcd52016-04-06 16:15:14 -070055 */
56 interface BatteryStateChangeCallback {
Evan Lairda5a73c52019-01-11 13:36:32 -050057
58 default void onBatteryLevelChanged(int level, boolean pluggedIn, boolean charging) {
59 }
60
61 default void onPowerSaveChanged(boolean isPowerSave) {
62 }
John Spurlock0ff62e02014-07-22 16:15:08 -040063 }
Evan Laird4bf21df2018-10-22 14:24:32 -040064
65 /**
Evan Lairda5a73c52019-01-11 13:36:32 -050066 * If available, get the estimated battery time remaining as a string.
67 *
68 * @param completion A lambda that will be called with the result of fetching the estimate. The
69 * first time this method is called may need to be dispatched to a background thread. The
70 * completion is called on the main thread
Evan Laird4bf21df2018-10-22 14:24:32 -040071 */
Evan Lairda5a73c52019-01-11 13:36:32 -050072 default void getEstimatedTimeRemainingString(EstimateFetchCompletion completion) {}
73
74 /**
75 * Callback called when the estimated time remaining text is fetched.
76 */
77 public interface EstimateFetchCompletion {
78
79 /**
80 * The callback
81 * @param estimate the estimate
82 */
Evan Laird85ee4a32019-03-06 18:09:20 -050083 void onBatteryRemainingEstimateRetrieved(@Nullable String estimate);
Evan Laird4bf21df2018-10-22 14:24:32 -040084 }
Joe Onoratofd52b182010-11-10 18:00:52 -080085}