healthd: break link between BatteryMonitor and BatteryPropertiesRegistrar
Make it easier to later separate out binder-related code.
Add helper functions healthd_battery_update(), healthd_get_property() to
allow these operations without needing references to the BatteryMonitor
object.
Change-Id: Ie584bf53e5178ce0a098d0d940d6c311fdff62d4
diff --git a/healthd/BatteryPropertiesRegistrar.cpp b/healthd/BatteryPropertiesRegistrar.cpp
index 3e06866..f2edee4 100644
--- a/healthd/BatteryPropertiesRegistrar.cpp
+++ b/healthd/BatteryPropertiesRegistrar.cpp
@@ -23,11 +23,9 @@
#include <utils/Mutex.h>
#include <utils/String16.h>
-namespace android {
+#include "healthd.h"
-BatteryPropertiesRegistrar::BatteryPropertiesRegistrar(BatteryMonitor* monitor) {
- mBatteryMonitor = monitor;
-}
+namespace android {
void BatteryPropertiesRegistrar::publish() {
defaultServiceManager()->addService(String16("batterypropreg"), this);
@@ -53,7 +51,7 @@
mListeners.add(listener);
listener->asBinder()->linkToDeath(this);
}
- mBatteryMonitor->update();
+ healthd_battery_update();
}
void BatteryPropertiesRegistrar::unregisterListener(const sp<IBatteryPropertiesListener>& listener) {
@@ -68,7 +66,7 @@
}
status_t BatteryPropertiesRegistrar::getProperty(int id, struct BatteryProperty *val) {
- return mBatteryMonitor->getProperty(id, val);
+ return healthd_get_property(id, val);
}
void BatteryPropertiesRegistrar::binderDied(const wp<IBinder>& who) {