Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 77cc7926 authored by Steven Moreland's avatar Steven Moreland Committed by android-build-merger
Browse files

Merge "Fix order of hidl unlinkToDeath."

am: 720d797c

Change-Id: I510a2a7d311471cb259c0857059bb9fe6c99a7e9
parents 391a7c38 720d797c
Loading
Loading
Loading
Loading
+6 −6
Original line number Original line Diff line number Diff line
@@ -189,8 +189,7 @@ void HwBinderDeathRecipientList::add(const sp<HwBinderDeathRecipient>& recipient
void HwBinderDeathRecipientList::remove(const sp<HwBinderDeathRecipient>& recipient) {
void HwBinderDeathRecipientList::remove(const sp<HwBinderDeathRecipient>& recipient) {
    AutoMutex _l(mLock);
    AutoMutex _l(mLock);


    List< sp<HwBinderDeathRecipient> >::iterator iter;
    for (auto iter = mList.begin(); iter != mList.end(); iter++) {
    for (iter = mList.begin(); iter != mList.end(); iter++) {
        if (*iter == recipient) {
        if (*iter == recipient) {
            mList.erase(iter);
            mList.erase(iter);
            return;
            return;
@@ -201,12 +200,13 @@ void HwBinderDeathRecipientList::remove(const sp<HwBinderDeathRecipient>& recipi
sp<HwBinderDeathRecipient> HwBinderDeathRecipientList::find(jobject recipient) {
sp<HwBinderDeathRecipient> HwBinderDeathRecipientList::find(jobject recipient) {
    AutoMutex _l(mLock);
    AutoMutex _l(mLock);


    for (const sp<HwBinderDeathRecipient>& deathRecipient : mList) {
    for(auto iter = mList.rbegin(); iter != mList.rend(); iter++) {
        if (deathRecipient->matches(recipient)) {
        if ((*iter)->matches(recipient)) {
            return deathRecipient;
            return (*iter);
        }
        }
    }
    }
    return NULL;

    return nullptr;
}
}


Mutex& HwBinderDeathRecipientList::lock() {
Mutex& HwBinderDeathRecipientList::lock() {
+4 −2
Original line number Original line Diff line number Diff line
@@ -20,9 +20,9 @@
#include <android-base/macros.h>
#include <android-base/macros.h>
#include <hwbinder/Binder.h>
#include <hwbinder/Binder.h>
#include <jni.h>
#include <jni.h>
#include <utils/List.h>
#include <utils/Mutex.h>
#include <utils/Mutex.h>
#include <utils/RefBase.h>
#include <utils/RefBase.h>
#include <vector>


namespace android {
namespace android {


@@ -33,7 +33,7 @@ namespace android {
class HwBinderDeathRecipient;
class HwBinderDeathRecipient;


class HwBinderDeathRecipientList : public RefBase {
class HwBinderDeathRecipientList : public RefBase {
    List< sp<HwBinderDeathRecipient> > mList;
    std::vector<sp<HwBinderDeathRecipient>> mList;
    Mutex mLock;
    Mutex mLock;


public:
public:
@@ -42,6 +42,8 @@ public:


    void add(const sp<HwBinderDeathRecipient>& recipient);
    void add(const sp<HwBinderDeathRecipient>& recipient);
    void remove(const sp<HwBinderDeathRecipient>& recipient);
    void remove(const sp<HwBinderDeathRecipient>& recipient);

    // finds the most recently added matching death recipient
    sp<HwBinderDeathRecipient> find(jobject recipient);
    sp<HwBinderDeathRecipient> find(jobject recipient);


    Mutex& lock();  // Use with care; specifically for mutual exclusion during binder death
    Mutex& lock();  // Use with care; specifically for mutual exclusion during binder death