NULL check in registerListener
Prevents crash in batteryproperties. Now with two times as much NULL checking. Bug: 13730158 Change-Id: Ica083da60c6543431c2d82d46aed48eaccc3b4b4
This commit is contained in:
parent
de4dea765a
commit
3e6d3319b2
1 changed files with 4 additions and 0 deletions
|
|
@ -43,6 +43,8 @@ void BatteryPropertiesRegistrar::notifyListeners(struct BatteryProperties props)
|
|||
|
||||
void BatteryPropertiesRegistrar::registerListener(const sp<IBatteryPropertiesListener>& listener) {
|
||||
{
|
||||
if (listener == NULL)
|
||||
return;
|
||||
Mutex::Autolock _l(mRegistrationLock);
|
||||
// check whether this is a duplicate
|
||||
for (size_t i = 0; i < mListeners.size(); i++) {
|
||||
|
|
@ -58,6 +60,8 @@ void BatteryPropertiesRegistrar::registerListener(const sp<IBatteryPropertiesLis
|
|||
}
|
||||
|
||||
void BatteryPropertiesRegistrar::unregisterListener(const sp<IBatteryPropertiesListener>& listener) {
|
||||
if (listener == NULL)
|
||||
return;
|
||||
Mutex::Autolock _l(mRegistrationLock);
|
||||
for (size_t i = 0; i < mListeners.size(); i++) {
|
||||
if (mListeners[i]->asBinder() == listener->asBinder()) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue