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

Commit 47323fd8 authored by Jooyung Han's avatar Jooyung Han Committed by Automerger Merge Worker
Browse files

Merge "setDefaultImpl aborts on a second call" into rvc-dev am: 513a77cf

Change-Id: I1e5c7c7c508e736842b65a8d8cc045143eada658
parents 01f527aa 513a77cf
Loading
Loading
Loading
Loading
+7 −1
Original line number Original line Diff line number Diff line
@@ -20,6 +20,8 @@


#include <binder/Binder.h>
#include <binder/Binder.h>


#include <assert.h>

namespace android {
namespace android {


// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
@@ -155,7 +157,11 @@ public: \
    std::unique_ptr<I##INTERFACE> I##INTERFACE::default_impl;           \
    std::unique_ptr<I##INTERFACE> I##INTERFACE::default_impl;           \
    bool I##INTERFACE::setDefaultImpl(std::unique_ptr<I##INTERFACE> 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);               \
            I##INTERFACE::default_impl = std::move(impl);               \
            return true;                                                \
            return true;                                                \
        }                                                               \
        }                                                               \