summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Steven Moreland <smoreland@google.com> 2018-07-25 18:12:27 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2018-07-25 18:12:27 +0000
commit720d797c0ae347df0c150d435b299a68d0fda72d (patch)
tree65dbec4d8a733aaea45cccfc40ccd5a232a01f09
parent894d8cf470c74aed139da89a4bd9c33dd146b83c (diff)
parent90a986880251f8a82c101a1ad1e11ea9c93550fb (diff)
Merge "Fix order of hidl unlinkToDeath."
-rw-r--r--core/jni/android_os_HwRemoteBinder.cpp12
-rw-r--r--core/jni/android_os_HwRemoteBinder.h6
2 files changed, 10 insertions, 8 deletions
diff --git a/core/jni/android_os_HwRemoteBinder.cpp b/core/jni/android_os_HwRemoteBinder.cpp
index ca5e1e45dcdc..f8f841c6fd26 100644
--- a/core/jni/android_os_HwRemoteBinder.cpp
+++ b/core/jni/android_os_HwRemoteBinder.cpp
@@ -189,8 +189,7 @@ void HwBinderDeathRecipientList::add(const sp<HwBinderDeathRecipient>& recipient
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;
@@ -201,12 +200,13 @@ void HwBinderDeathRecipientList::remove(const sp<HwBinderDeathRecipient>& recipi
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() {
diff --git a/core/jni/android_os_HwRemoteBinder.h b/core/jni/android_os_HwRemoteBinder.h
index 63aad0ab2923..4b5a4c8c837c 100644
--- a/core/jni/android_os_HwRemoteBinder.h
+++ b/core/jni/android_os_HwRemoteBinder.h
@@ -20,9 +20,9 @@
#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 {
@@ -33,7 +33,7 @@ namespace android {
class HwBinderDeathRecipient;
class HwBinderDeathRecipientList : public RefBase {
- List< sp<HwBinderDeathRecipient> > mList;
+ std::vector<sp<HwBinderDeathRecipient>> mList;
Mutex mLock;
public:
@@ -42,6 +42,8 @@ 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