summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jooyung Han <jooyung@google.com> 2020-05-19 23:00:08 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2020-05-19 23:00:08 +0000
commit513a77cffdbad1be2cacff7a9ed272659c376c64 (patch)
treebcc057c97b407fd61f1fe4bc3c31da023c556fbf
parentc30ebd0188e8c43bdfc59cc87a2a9da8f0caa4ab (diff)
parent01097e2410e75f1883f4e48af6a7889bd8cda052 (diff)
Merge "setDefaultImpl aborts on a second call" into rvc-dev
-rw-r--r--libs/binder/include/binder/IInterface.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/libs/binder/include/binder/IInterface.h b/libs/binder/include/binder/IInterface.h
index 3a401adfa5..7116154951 100644
--- a/libs/binder/include/binder/IInterface.h
+++ b/libs/binder/include/binder/IInterface.h
@@ -20,6 +20,8 @@
#include <binder/Binder.h>
+#include <assert.h>
+
namespace android {
// ----------------------------------------------------------------------
@@ -155,7 +157,11 @@ public: \
std::unique_ptr<I##INTERFACE> I##INTERFACE::default_impl; \
bool I##INTERFACE::setDefaultImpl(std::unique_ptr<I##INTERFACE> impl)\
{ \
- if (!I##INTERFACE::default_impl && impl) { \
+ /* Only one user of this interface can use this function */ \
+ /* at a time. This is a heuristic to detect if two different */ \
+ /* users in the same process use this function. */ \
+ assert(!I##INTERFACE::default_impl); \
+ if (impl) { \
I##INTERFACE::default_impl = std::move(impl); \
return true; \
} \