• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2013 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 #ifndef HEALTHD_BATTERYPROPERTIES_REGISTRAR_H
18 #define HEALTHD_BATTERYPROPERTIES_REGISTRAR_H
19 
20 #include "BatteryMonitor.h"
21 
22 #include <binder/IBinder.h>
23 #include <utils/Mutex.h>
24 #include <utils/Vector.h>
25 #include <batteryservice/BatteryService.h>
26 #include <batteryservice/IBatteryPropertiesListener.h>
27 #include <batteryservice/IBatteryPropertiesRegistrar.h>
28 
29 namespace android {
30 
31 class BatteryMonitor;
32 
33 class BatteryPropertiesRegistrar : public BnBatteryPropertiesRegistrar,
34                                    public IBinder::DeathRecipient {
35 public:
36     BatteryPropertiesRegistrar(BatteryMonitor* monitor);
37     void publish();
38     void notifyListeners(struct BatteryProperties props);
39 
40 private:
41     BatteryMonitor* mBatteryMonitor;
42     Mutex mRegistrationLock;
43     Vector<sp<IBatteryPropertiesListener> > mListeners;
44 
45     void registerListener(const sp<IBatteryPropertiesListener>& listener);
46     void unregisterListener(const sp<IBatteryPropertiesListener>& listener);
47     void binderDied(const wp<IBinder>& who);
48 };
49 
50 };  // namespace android
51 
52 #endif // HEALTHD_BATTERYPROPERTIES_REGISTRAR_H
53