blob: 3e86fdf17b4cfb99380c016ae8f4a7eaef7bdeb3 [file] [log] [blame]
Todd Poynor752faf22013-06-12 13:25:59 -07001/*
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
Todd Poynor752faf22013-06-12 13:25:59 -070020#include <binder/IBinder.h>
21#include <utils/Mutex.h>
22#include <utils/Vector.h>
23#include <batteryservice/BatteryService.h>
24#include <batteryservice/IBatteryPropertiesListener.h>
25#include <batteryservice/IBatteryPropertiesRegistrar.h>
26
27namespace android {
28
Todd Poynor752faf22013-06-12 13:25:59 -070029class BatteryPropertiesRegistrar : public BnBatteryPropertiesRegistrar,
30 public IBinder::DeathRecipient {
31public:
Todd Poynor752faf22013-06-12 13:25:59 -070032 void publish();
33 void notifyListeners(struct BatteryProperties props);
34
35private:
Todd Poynor752faf22013-06-12 13:25:59 -070036 Mutex mRegistrationLock;
37 Vector<sp<IBatteryPropertiesListener> > mListeners;
38
39 void registerListener(const sp<IBatteryPropertiesListener>& listener);
40 void unregisterListener(const sp<IBatteryPropertiesListener>& listener);
Todd Poynorc133b712013-08-14 17:39:13 -070041 status_t getProperty(int id, struct BatteryProperty *val);
Todd Poynor752faf22013-06-12 13:25:59 -070042 void binderDied(const wp<IBinder>& who);
43};
44
45}; // namespace android
46
47#endif // HEALTHD_BATTERYPROPERTIES_REGISTRAR_H