healthd: BatteryPropertiesRegistrar binder service ref count fixup
Call addService using a reference to a strong pointer to the service object,
such that the proper IBinder object is ref counted, instead of passing the
object's this pointer.
Bug: None
Change-Id: I72cac08c835a17b8cc263b2dc34864420b7a2841
diff --git a/healthd/BatteryPropertiesRegistrar.cpp b/healthd/BatteryPropertiesRegistrar.cpp
index 09667a1..d3a89d7 100644
--- a/healthd/BatteryPropertiesRegistrar.cpp
+++ b/healthd/BatteryPropertiesRegistrar.cpp
@@ -30,8 +30,9 @@
namespace android {
-void BatteryPropertiesRegistrar::publish() {
- defaultServiceManager()->addService(String16("batteryproperties"), this);
+void BatteryPropertiesRegistrar::publish(
+ const sp<BatteryPropertiesRegistrar>& service) {
+ defaultServiceManager()->addService(String16("batteryproperties"), service);
}
void BatteryPropertiesRegistrar::notifyListeners(struct BatteryProperties props) {