healthd: notify listeners using local copy of list, drop lock
am: fd68370074
Change-Id: I8b8c8bb2b2eede878bb44afcaa08f73142a10d64
This commit is contained in:
commit
a1f4cddfea
1 changed files with 13 additions and 3 deletions
|
|
@ -36,9 +36,19 @@ void BatteryPropertiesRegistrar::publish(
|
||||||
}
|
}
|
||||||
|
|
||||||
void BatteryPropertiesRegistrar::notifyListeners(const struct BatteryProperties& props) {
|
void BatteryPropertiesRegistrar::notifyListeners(const struct BatteryProperties& props) {
|
||||||
Mutex::Autolock _l(mRegistrationLock);
|
Vector<sp<IBatteryPropertiesListener> > listenersCopy;
|
||||||
for (size_t i = 0; i < mListeners.size(); i++) {
|
|
||||||
mListeners[i]->batteryPropertiesChanged(props);
|
// Binder currently may service an incoming oneway transaction whenever an
|
||||||
|
// outbound oneway call is made (if there is already a pending incoming
|
||||||
|
// oneway call waiting). This is considered a bug and may change in the
|
||||||
|
// future. For now, avoid recursive mutex lock while making outbound
|
||||||
|
// calls by making a local copy of the current list of listeners.
|
||||||
|
{
|
||||||
|
Mutex::Autolock _l(mRegistrationLock);
|
||||||
|
listenersCopy = mListeners;
|
||||||
|
}
|
||||||
|
for (size_t i = 0; i < listenersCopy.size(); i++) {
|
||||||
|
listenersCopy[i]->batteryPropertiesChanged(props);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue