void HwBinderDeathRecipientList::remove(const sp<HwBinderDeathRecipient>& recipient) {
AutoMutex _l(mLock);
- List< sp<HwBinderDeathRecipient> >::iterator iter;
- for (iter = mList.begin(); iter != mList.end(); iter++) {
+ for (auto iter = mList.begin(); iter != mList.end(); iter++) {
if (*iter == recipient) {
mList.erase(iter);
return;
sp<HwBinderDeathRecipient> HwBinderDeathRecipientList::find(jobject recipient) {
AutoMutex _l(mLock);
- for (const sp<HwBinderDeathRecipient>& deathRecipient : mList) {
- if (deathRecipient->matches(recipient)) {
- return deathRecipient;
+ for(auto iter = mList.rbegin(); iter != mList.rend(); iter++) {
+ if ((*iter)->matches(recipient)) {
+ return (*iter);
}
}
- return NULL;
+
+ return nullptr;
}
Mutex& HwBinderDeathRecipientList::lock() {
#include <android-base/macros.h>
#include <hwbinder/Binder.h>
#include <jni.h>
-#include <utils/List.h>
#include <utils/Mutex.h>
#include <utils/RefBase.h>
+#include <vector>
namespace android {
class HwBinderDeathRecipient;
class HwBinderDeathRecipientList : public RefBase {
- List< sp<HwBinderDeathRecipient> > mList;
+ std::vector<sp<HwBinderDeathRecipient>> mList;
Mutex mLock;
public:
void add(const sp<HwBinderDeathRecipient>& recipient);
void remove(const sp<HwBinderDeathRecipient>& recipient);
+
+ // finds the most recently added matching death recipient
sp<HwBinderDeathRecipient> find(jobject recipient);
Mutex& lock(); // Use with care; specifically for mutual exclusion during binder death