Fix order of hidl unlinkToDeath.
Calling unlinkToDeath after linking to death multiple
times will unregister the most recently registered
death recipient as expected.
Note: the hash test was also removed since 'hidl_hash_test'
is more comprehensive and it assumes that the IBase hash
hasn't changed.
Bug: 67503915
Test: hidl_test, hidl_test_java
Change-Id: I6bc0c653dd63f71f2283f55afd48d44ceb132224
diff --git a/Interface.cpp b/Interface.cpp
index 9fb7442..0cf891c 100644
--- a/Interface.cpp
+++ b/Interface.cpp
@@ -171,13 +171,13 @@
{IMPL_PROXY,
[](auto &out) {
out << "std::unique_lock<std::mutex> lock(_hidl_mMutex);\n"
- << "for (auto it = _hidl_mDeathRecipients.begin();"
- << "it != _hidl_mDeathRecipients.end();"
+ << "for (auto it = _hidl_mDeathRecipients.rbegin();"
+ << "it != _hidl_mDeathRecipients.rend();"
<< "++it) {\n";
out.indent([&] {
out.sIf("(*it)->getRecipient() == recipient", [&] {
out << "::android::status_t status = remote()->unlinkToDeath(*it);\n"
- << "_hidl_mDeathRecipients.erase(it);\n"
+ << "_hidl_mDeathRecipients.erase(it.base()-1);\n"
<< "return status == ::android::OK;\n";
});
}).endl();