diff options
| author | 2018-07-04 13:36:54 +0900 | |
|---|---|---|
| committer | 2018-07-20 09:56:28 +0900 | |
| commit | 4acdf91fd56cd2e629586b43d6ed9ee8c1a0b165 (patch) | |
| tree | 0e67bb30816fc58b964bb226c577348f63c731fe | |
| parent | 9f9372bcc14238c5700bebce09d4eddf6193c7cb (diff) | |
Add support for default impl
Addition to the meta interface for specifyin the default impl for the
interface.
Bug: 110759835
Test: system/tools/aidl/runtests.sh
Change-Id: I1290f06355bec55d68fdd9420657bdb906e58a85
| -rw-r--r-- | libs/binder/include/binder/IInterface.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/libs/binder/include/binder/IInterface.h b/libs/binder/include/binder/IInterface.h index 227d0ae861..b61278a6aa 100644 --- a/libs/binder/include/binder/IInterface.h +++ b/libs/binder/include/binder/IInterface.h @@ -72,12 +72,18 @@ protected: // ---------------------------------------------------------------------- #define DECLARE_META_INTERFACE(INTERFACE) \ +public: \ static const ::android::String16 descriptor; \ static ::android::sp<I##INTERFACE> asInterface( \ const ::android::sp<::android::IBinder>& obj); \ virtual const ::android::String16& getInterfaceDescriptor() const; \ I##INTERFACE(); \ virtual ~I##INTERFACE(); \ + static bool setDefaultImpl(std::unique_ptr<I##INTERFACE> impl); \ + static const std::unique_ptr<I##INTERFACE>& getDefaultImpl(); \ +private: \ + static std::unique_ptr<I##INTERFACE> default_impl; \ +public: \ #define IMPLEMENT_META_INTERFACE(INTERFACE, NAME) \ @@ -100,6 +106,19 @@ protected: } \ return intr; \ } \ + 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) { \ + I##INTERFACE::default_impl = std::move(impl); \ + return true; \ + } \ + return false; \ + } \ + const std::unique_ptr<I##INTERFACE>& I##INTERFACE::getDefaultImpl() \ + { \ + return I##INTERFACE::default_impl; \ + } \ I##INTERFACE::I##INTERFACE() { } \ I##INTERFACE::~I##INTERFACE() { } \ |