#define IMPLEMENT_META_INTERFACE(INTERFACE, NAME) \ static_assert(internal::allowedManualInterface(NAME), \ "b/64223827: Manually written binder interfaces are " \ "considered error prone and frequently have bugs. " \ "The preferred way to add interfaces is to define " \ "an .aidl file to auto-generate the interface. If " \ "an interface must be manually written, add its " \ "name to the whitelist."); \ DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_INTERFACE(INTERFACE, NAME) \ #else
// Macro to be used by both IMPLEMENT_META_INTERFACE and IMPLEMENT_META_NESTED_INTERFACE #define DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_INTERFACE0(ITYPE, INAME, BPTYPE) \ const ::android::String16& ITYPE::getInterfaceDescriptor() const { return ITYPE::descriptor; } \ ::android::sp<ITYPE> ITYPE::asInterface(const ::android::sp<::android::IBinder>& obj) { \ ::android::sp<ITYPE> intr; \ if (obj != nullptr) { \ intr = ::android::sp<ITYPE>::cast(obj->queryLocalInterface(ITYPE::descriptor)); \ if (intr == nullptr) { \ intr = ::android::sp<BPTYPE>::make(obj); \ } \ } \ return intr; \ } \ ::android::sp<ITYPE> ITYPE::default_impl; \ bool ITYPE::setDefaultImpl(::android::sp<ITYPE> 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(!ITYPE::default_impl); \ if (impl) { \ ITYPE::default_impl = std::move(impl); \ return true; \ } \ return false; \ } \ const ::android::sp<ITYPE>& ITYPE::getDefaultImpl() { return ITYPE::default_impl; } \ ITYPE::INAME() {} \ ITYPE::~INAME() {}