blob: 88538744df3a92666377dd2211376ca54aa109db [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>
Todd Poynor020369d2013-09-18 20:09:33 -070022#include <utils/String16.h>
Todd Poynor752faf22013-06-12 13:25:59 -070023#include <utils/Vector.h>
24#include <batteryservice/BatteryService.h>
25#include <batteryservice/IBatteryPropertiesListener.h>
26#include <batteryservice/IBatteryPropertiesRegistrar.h>
27
28namespace android {
29
Todd Poynor752faf22013-06-12 13:25:59 -070030class BatteryPropertiesRegistrar : public BnBatteryPropertiesRegistrar,
31 public IBinder::DeathRecipient {
32public:
Todd Poynor752faf22013-06-12 13:25:59 -070033 void publish();
34 void notifyListeners(struct BatteryProperties props);
35
36private:
Todd Poynor752faf22013-06-12 13:25:59 -070037 Mutex mRegistrationLock;
38 Vector<sp<IBatteryPropertiesListener> > mListeners;
39
40 void registerListener(const sp<IBatteryPropertiesListener>& listener);
41 void unregisterListener(const sp<IBatteryPropertiesListener>& listener);
Todd Poynorc133b712013-08-14 17:39:13 -070042 status_t getProperty(int id, struct BatteryProperty *val);
Todd Poynor020369d2013-09-18 20:09:33 -070043 status_t dump(int fd, const Vector<String16>& args);
Todd Poynor752faf22013-06-12 13:25:59 -070044 void binderDied(const wp<IBinder>& who);
45};
46
47}; // namespace android
48
49#endif // HEALTHD_BATTERYPROPERTIES_REGISTRAR_H