BatteryController.java revision 9c7844cb91b43929d0a86b1c90aa1efb37f5463a
1fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onorato/*
2fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onorato * Copyright (C) 2010 The Android Open Source Project
3fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onorato *
4fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onorato * Licensed under the Apache License, Version 2.0 (the "License");
5fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onorato * you may not use this file except in compliance with the License.
6fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onorato * You may obtain a copy of the License at
7fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onorato *
8fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onorato *      http://www.apache.org/licenses/LICENSE-2.0
9fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onorato *
10fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onorato * Unless required by applicable law or agreed to in writing, software
11fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onorato * distributed under the License is distributed on an "AS IS" BASIS,
12fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onorato * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onorato * See the License for the specific language governing permissions and
14fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onorato * limitations under the License.
15fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onorato */
16fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onorato
17fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onoratopackage com.android.systemui.statusbar.policy;
18fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onorato
1998d7c7a84d007d3de0c3394d8a93253a313eda27Jason Monkimport com.android.systemui.DemoMode;
209c7844cb91b43929d0a86b1c90aa1efb37f5463aJason Monkimport com.android.systemui.Dumpable;
218852905b0b3837e326127c6dfef6f699124ce715Jason Monkimport com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback;
2298d7c7a84d007d3de0c3394d8a93253a313eda27Jason Monk
230ff62e09116dd125fc36f7af5de7a0b60aaa789bJohn Spurlockimport java.io.FileDescriptor;
240ff62e09116dd125fc36f7af5de7a0b60aaa789bJohn Spurlockimport java.io.PrintWriter;
250ff62e09116dd125fc36f7af5de7a0b60aaa789bJohn Spurlock
269c7844cb91b43929d0a86b1c90aa1efb37f5463aJason Monkpublic interface BatteryController extends DemoMode, Dumpable,
278852905b0b3837e326127c6dfef6f699124ce715Jason Monk        CallbackController<BatteryStateChangeCallback> {
28da62fdcd502e772546bd98c016ab20fff6ee62e7Anthony Chen    /**
29da62fdcd502e772546bd98c016ab20fff6ee62e7Anthony Chen     * Prints the current state of the {@link BatteryController} to the given {@link PrintWriter}.
30da62fdcd502e772546bd98c016ab20fff6ee62e7Anthony Chen     */
31da62fdcd502e772546bd98c016ab20fff6ee62e7Anthony Chen    void dump(FileDescriptor fd, PrintWriter pw, String[] args);
32da62fdcd502e772546bd98c016ab20fff6ee62e7Anthony Chen
33da62fdcd502e772546bd98c016ab20fff6ee62e7Anthony Chen    /**
34da62fdcd502e772546bd98c016ab20fff6ee62e7Anthony Chen     * Sets if the current device is in power save mode.
35da62fdcd502e772546bd98c016ab20fff6ee62e7Anthony Chen     */
36da62fdcd502e772546bd98c016ab20fff6ee62e7Anthony Chen    void setPowerSaveMode(boolean powerSave);
37da62fdcd502e772546bd98c016ab20fff6ee62e7Anthony Chen
38da62fdcd502e772546bd98c016ab20fff6ee62e7Anthony Chen    /**
39da62fdcd502e772546bd98c016ab20fff6ee62e7Anthony Chen     * Returns {@code true} if the device is currently in power save mode.
40da62fdcd502e772546bd98c016ab20fff6ee62e7Anthony Chen     */
41da62fdcd502e772546bd98c016ab20fff6ee62e7Anthony Chen    boolean isPowerSave();
42da62fdcd502e772546bd98c016ab20fff6ee62e7Anthony Chen
43da62fdcd502e772546bd98c016ab20fff6ee62e7Anthony Chen    /**
44da62fdcd502e772546bd98c016ab20fff6ee62e7Anthony Chen     * A listener that will be notified whenever a change in battery level or power save mode
45da62fdcd502e772546bd98c016ab20fff6ee62e7Anthony Chen     * has occurred.
46da62fdcd502e772546bd98c016ab20fff6ee62e7Anthony Chen     */
47da62fdcd502e772546bd98c016ab20fff6ee62e7Anthony Chen    interface BatteryStateChangeCallback {
480ff62e09116dd125fc36f7af5de7a0b60aaa789bJohn Spurlock        void onBatteryLevelChanged(int level, boolean pluggedIn, boolean charging);
49c06fbb12984a3d3e4c80ab9f819841acae5b0133Jason Monk        void onPowerSaveChanged(boolean isPowerSave);
500ff62e09116dd125fc36f7af5de7a0b60aaa789bJohn Spurlock    }
51fd52b18d9bf3cd62c7a07058536e9f97db65beeaJoe Onorato}
52