diff options
| author | 2020-05-14 23:18:24 +0000 | |
|---|---|---|
| committer | 2020-05-14 23:18:24 +0000 | |
| commit | 196feae68804cf20f85fd64cd43728fc30c4313d (patch) | |
| tree | 003ff443ba3185aa72a07424062878d9a60399a2 | |
| parent | dd44f7465d53fe155c03c0b1129c467a1f1c5830 (diff) | |
| parent | 81087399e99984db8049d1b319522536bac6f557 (diff) | |
Merge "setDefaultImpl aborts on a second call"
| -rw-r--r-- | libs/binder/include/binder/IInterface.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/libs/binder/include/binder/IInterface.h b/libs/binder/include/binder/IInterface.h index 79d9b79915..cabfc7ff8e 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; \ } \ |