Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 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 | |
| 17 | package com.android.systemui.statusbar.policy; |
| 18 | |
Evan Laird | 85ee4a3 | 2019-03-06 18:09:20 -0500 | [diff] [blame] | 19 | import android.annotation.Nullable; |
| 20 | |
Jason Monk | 98d7c7a | 2016-04-12 13:08:31 -0400 | [diff] [blame] | 21 | import com.android.systemui.DemoMode; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 22 | import com.android.systemui.Dumpable; |
Jason Monk | 8852905 | 2016-11-04 13:29:58 -0400 | [diff] [blame] | 23 | import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback; |
Jason Monk | 98d7c7a | 2016-04-12 13:08:31 -0400 | [diff] [blame] | 24 | |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 25 | import java.io.FileDescriptor; |
| 26 | import java.io.PrintWriter; |
John Spurlock | de84f0e | 2013-06-12 12:41:00 -0400 | [diff] [blame] | 27 | |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 28 | public interface BatteryController extends DemoMode, Dumpable, |
Jason Monk | 8852905 | 2016-11-04 13:29:58 -0400 | [diff] [blame] | 29 | CallbackController<BatteryStateChangeCallback> { |
Anthony Chen | da62fdcd5 | 2016-04-06 16:15:14 -0700 | [diff] [blame] | 30 | /** |
| 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 Monk | abe1974 | 2015-09-29 09:47:06 -0400 | [diff] [blame] | 34 | |
Anthony Chen | da62fdcd5 | 2016-04-06 16:15:14 -0700 | [diff] [blame] | 35 | /** |
| 36 | * Sets if the current device is in power save mode. |
| 37 | */ |
| 38 | void setPowerSaveMode(boolean powerSave); |
Jason Monk | abe1974 | 2015-09-29 09:47:06 -0400 | [diff] [blame] | 39 | |
Anthony Chen | da62fdcd5 | 2016-04-06 16:15:14 -0700 | [diff] [blame] | 40 | /** |
| 41 | * Returns {@code true} if the device is currently in power save mode. |
| 42 | */ |
| 43 | boolean isPowerSave(); |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 44 | |
Anthony Chen | da62fdcd5 | 2016-04-06 16:15:14 -0700 | [diff] [blame] | 45 | /** |
Lucas Dupin | 92a62e5 | 2018-01-30 17:22:20 -0800 | [diff] [blame] | 46 | * Returns {@code true} if AOD was disabled by power saving policies. |
| 47 | */ |
| 48 | default boolean isAodPowerSave() { |
| 49 | return isPowerSave(); |
| 50 | } |
| 51 | |
| 52 | /** |
Evan Laird | a5a73c5 | 2019-01-11 13:36:32 -0500 | [diff] [blame] | 53 | * A listener that will be notified whenever a change in battery level or power save mode has |
| 54 | * occurred. |
Anthony Chen | da62fdcd5 | 2016-04-06 16:15:14 -0700 | [diff] [blame] | 55 | */ |
| 56 | interface BatteryStateChangeCallback { |
Evan Laird | a5a73c5 | 2019-01-11 13:36:32 -0500 | [diff] [blame] | 57 | |
| 58 | default void onBatteryLevelChanged(int level, boolean pluggedIn, boolean charging) { |
| 59 | } |
| 60 | |
| 61 | default void onPowerSaveChanged(boolean isPowerSave) { |
| 62 | } |
John Spurlock | 0ff62e0 | 2014-07-22 16:15:08 -0400 | [diff] [blame] | 63 | } |
Evan Laird | 4bf21df | 2018-10-22 14:24:32 -0400 | [diff] [blame] | 64 | |
| 65 | /** |
Evan Laird | a5a73c5 | 2019-01-11 13:36:32 -0500 | [diff] [blame] | 66 | * 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 Laird | 4bf21df | 2018-10-22 14:24:32 -0400 | [diff] [blame] | 71 | */ |
Evan Laird | a5a73c5 | 2019-01-11 13:36:32 -0500 | [diff] [blame] | 72 | 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 Laird | 85ee4a3 | 2019-03-06 18:09:20 -0500 | [diff] [blame] | 83 | void onBatteryRemainingEstimateRetrieved(@Nullable String estimate); |
Evan Laird | 4bf21df | 2018-10-22 14:24:32 -0400 | [diff] [blame] | 84 | } |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 85 | } |