summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--storaged/include/storaged.h6
-rw-r--r--storaged/storaged.cpp13
2 files changed, 17 insertions, 2 deletions
diff --git a/storaged/include/storaged.h b/storaged/include/storaged.h
index b6a0850c8..514798bff 100644
--- a/storaged/include/storaged.h
+++ b/storaged/include/storaged.h
@@ -27,6 +27,7 @@
27#include <vector> 27#include <vector>
28 28
29#include <batteryservice/IBatteryPropertiesListener.h> 29#include <batteryservice/IBatteryPropertiesListener.h>
30#include <batteryservice/IBatteryPropertiesRegistrar.h>
30 31
31#include "storaged_info.h" 32#include "storaged_info.h"
32#include "storaged_uid_monitor.h" 33#include "storaged_uid_monitor.h"
@@ -245,7 +246,8 @@ struct storaged_config {
245 int event_time_check_usec; // check how much cputime spent in event loop 246 int event_time_check_usec; // check how much cputime spent in event loop
246}; 247};
247 248
248class storaged_t : public BnBatteryPropertiesListener { 249class storaged_t : public BnBatteryPropertiesListener,
250 public IBinder::DeathRecipient {
249private: 251private:
250 time_t mTimer; 252 time_t mTimer;
251 storaged_config mConfig; 253 storaged_config mConfig;
@@ -253,6 +255,7 @@ private:
253 disk_stats_monitor mDsm; 255 disk_stats_monitor mDsm;
254 uid_monitor mUidm; 256 uid_monitor mUidm;
255 time_t mStarttime; 257 time_t mStarttime;
258 sp<IBatteryPropertiesRegistrar> battery_properties;
256public: 259public:
257 storaged_t(void); 260 storaged_t(void);
258 ~storaged_t() {} 261 ~storaged_t() {}
@@ -281,6 +284,7 @@ public:
281 284
282 void init_battery_service(); 285 void init_battery_service();
283 virtual void batteryPropertiesChanged(struct BatteryProperties props); 286 virtual void batteryPropertiesChanged(struct BatteryProperties props);
287 void binderDied(const wp<IBinder>& who);
284}; 288};
285 289
286// Eventlog tag 290// Eventlog tag
diff --git a/storaged/storaged.cpp b/storaged/storaged.cpp
index 1770922ef..aa3d1de73 100644
--- a/storaged/storaged.cpp
+++ b/storaged/storaged.cpp
@@ -173,7 +173,7 @@ void storaged_t::init_battery_service() {
173 if (!mConfig.proc_uid_io_available) 173 if (!mConfig.proc_uid_io_available)
174 return; 174 return;
175 175
176 sp<IBatteryPropertiesRegistrar> battery_properties = get_battery_properties_service(); 176 battery_properties = get_battery_properties_service();
177 if (battery_properties == NULL) { 177 if (battery_properties == NULL) {
178 LOG_TO(SYSTEM, WARNING) << "failed to find batteryproperties service"; 178 LOG_TO(SYSTEM, WARNING) << "failed to find batteryproperties service";
179 return; 179 return;
@@ -185,6 +185,17 @@ void storaged_t::init_battery_service() {
185 185
186 // register listener after init uid_monitor 186 // register listener after init uid_monitor
187 battery_properties->registerListener(this); 187 battery_properties->registerListener(this);
188 IInterface::asBinder(battery_properties)->linkToDeath(this);
189}
190
191void storaged_t::binderDied(const wp<IBinder>& who) {
192 if (battery_properties != NULL &&
193 IInterface::asBinder(battery_properties) == who) {
194 LOG_TO(SYSTEM, ERROR) << "batteryproperties service died, exiting";
195 exit(1);
196 } else {
197 LOG_TO(SYSTEM, ERROR) << "unknown service died";
198 }
188} 199}
189 200
190/* storaged_t */ 201/* storaged_t */