Merge "NULL check in registerListener"

This commit is contained in:
Natalie Silvanovich 2014-05-01 00:19:39 +00:00 committed by Android (Google) Code Review
commit 50bc186c75
1 changed files with 4 additions and 0 deletions

View File

@ -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()) {