| #include "aidl/android/hardware/neuralnetworks/IExecution.h" |
| |
| #include <android/binder_parcel_utils.h> |
| #include <aidl/android/hardware/neuralnetworks/BnExecution.h> |
| #include <aidl/android/hardware/neuralnetworks/BnFencedExecutionCallback.h> |
| #include <aidl/android/hardware/neuralnetworks/BpExecution.h> |
| #include <aidl/android/hardware/neuralnetworks/BpFencedExecutionCallback.h> |
| #include <aidl/android/hardware/neuralnetworks/IFencedExecutionCallback.h> |
| |
| namespace aidl { |
| namespace android { |
| namespace hardware { |
| namespace neuralnetworks { |
| static binder_status_t _aidl_android_hardware_neuralnetworks_IExecution_onTransact(AIBinder* _aidl_binder, transaction_code_t _aidl_code, const AParcel* _aidl_in, AParcel* _aidl_out) { |
| (void)_aidl_in; |
| (void)_aidl_out; |
| binder_status_t _aidl_ret_status = STATUS_UNKNOWN_TRANSACTION; |
| std::shared_ptr<BnExecution> _aidl_impl = std::static_pointer_cast<BnExecution>(::ndk::ICInterface::asInterface(_aidl_binder)); |
| switch (_aidl_code) { |
| case (FIRST_CALL_TRANSACTION + 0 /*executeSynchronously*/): { |
| int64_t in_deadlineNs; |
| ::aidl::android::hardware::neuralnetworks::ExecutionResult _aidl_return; |
| |
| _aidl_ret_status = ::ndk::AParcel_readData(_aidl_in, &in_deadlineNs); |
| if (_aidl_ret_status != STATUS_OK) break; |
| |
| ::ndk::ScopedAStatus _aidl_status = _aidl_impl->executeSynchronously(in_deadlineNs, &_aidl_return); |
| _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get()); |
| if (_aidl_ret_status != STATUS_OK) break; |
| |
| if (!AStatus_isOk(_aidl_status.get())) break; |
| |
| _aidl_ret_status = ::ndk::AParcel_writeData(_aidl_out, _aidl_return); |
| if (_aidl_ret_status != STATUS_OK) break; |
| |
| break; |
| } |
| case (FIRST_CALL_TRANSACTION + 1 /*executeFenced*/): { |
| std::vector<::ndk::ScopedFileDescriptor> in_waitFor; |
| int64_t in_deadlineNs; |
| int64_t in_durationNs; |
| ::aidl::android::hardware::neuralnetworks::FencedExecutionResult _aidl_return; |
| |
| _aidl_ret_status = ::ndk::AParcel_readData(_aidl_in, &in_waitFor); |
| if (_aidl_ret_status != STATUS_OK) break; |
| |
| _aidl_ret_status = ::ndk::AParcel_readData(_aidl_in, &in_deadlineNs); |
| if (_aidl_ret_status != STATUS_OK) break; |
| |
| _aidl_ret_status = ::ndk::AParcel_readData(_aidl_in, &in_durationNs); |
| if (_aidl_ret_status != STATUS_OK) break; |
| |
| ::ndk::ScopedAStatus _aidl_status = _aidl_impl->executeFenced(in_waitFor, in_deadlineNs, in_durationNs, &_aidl_return); |
| _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get()); |
| if (_aidl_ret_status != STATUS_OK) break; |
| |
| if (!AStatus_isOk(_aidl_status.get())) break; |
| |
| _aidl_ret_status = ::ndk::AParcel_writeData(_aidl_out, _aidl_return); |
| if (_aidl_ret_status != STATUS_OK) break; |
| |
| break; |
| } |
| case (FIRST_CALL_TRANSACTION + 16777214 /*getInterfaceVersion*/): { |
| int32_t _aidl_return; |
| |
| ::ndk::ScopedAStatus _aidl_status = _aidl_impl->getInterfaceVersion(&_aidl_return); |
| _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get()); |
| if (_aidl_ret_status != STATUS_OK) break; |
| |
| if (!AStatus_isOk(_aidl_status.get())) break; |
| |
| _aidl_ret_status = ::ndk::AParcel_writeData(_aidl_out, _aidl_return); |
| if (_aidl_ret_status != STATUS_OK) break; |
| |
| break; |
| } |
| case (FIRST_CALL_TRANSACTION + 16777213 /*getInterfaceHash*/): { |
| std::string _aidl_return; |
| |
| ::ndk::ScopedAStatus _aidl_status = _aidl_impl->getInterfaceHash(&_aidl_return); |
| _aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get()); |
| if (_aidl_ret_status != STATUS_OK) break; |
| |
| if (!AStatus_isOk(_aidl_status.get())) break; |
| |
| _aidl_ret_status = ::ndk::AParcel_writeData(_aidl_out, _aidl_return); |
| if (_aidl_ret_status != STATUS_OK) break; |
| |
| break; |
| } |
| } |
| return _aidl_ret_status; |
| } |
| |
| static AIBinder_Class* _g_aidl_android_hardware_neuralnetworks_IExecution_clazz = ::ndk::ICInterface::defineClass(IExecution::descriptor, _aidl_android_hardware_neuralnetworks_IExecution_onTransact); |
| |
| BpExecution::BpExecution(const ::ndk::SpAIBinder& binder) : BpCInterface(binder) {} |
| BpExecution::~BpExecution() {} |
| |
| ::ndk::ScopedAStatus BpExecution::executeSynchronously(int64_t in_deadlineNs, ::aidl::android::hardware::neuralnetworks::ExecutionResult* _aidl_return) { |
| binder_status_t _aidl_ret_status = STATUS_OK; |
| ::ndk::ScopedAStatus _aidl_status; |
| ::ndk::ScopedAParcel _aidl_in; |
| ::ndk::ScopedAParcel _aidl_out; |
| |
| _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR()); |
| if (_aidl_ret_status != STATUS_OK) goto _aidl_error; |
| |
| _aidl_ret_status = ::ndk::AParcel_writeData(_aidl_in.get(), in_deadlineNs); |
| if (_aidl_ret_status != STATUS_OK) goto _aidl_error; |
| |
| _aidl_ret_status = AIBinder_transact( |
| asBinder().get(), |
| (FIRST_CALL_TRANSACTION + 0 /*executeSynchronously*/), |
| _aidl_in.getR(), |
| _aidl_out.getR(), |
| 0 |
| #ifdef BINDER_STABILITY_SUPPORT |
| | FLAG_PRIVATE_LOCAL |
| #endif // BINDER_STABILITY_SUPPORT |
| ); |
| if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && IExecution::getDefaultImpl()) { |
| _aidl_status = IExecution::getDefaultImpl()->executeSynchronously(in_deadlineNs, _aidl_return); |
| goto _aidl_status_return; |
| } |
| if (_aidl_ret_status != STATUS_OK) goto _aidl_error; |
| |
| _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR()); |
| if (_aidl_ret_status != STATUS_OK) goto _aidl_error; |
| |
| if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return; |
| _aidl_ret_status = ::ndk::AParcel_readData(_aidl_out.get(), _aidl_return); |
| if (_aidl_ret_status != STATUS_OK) goto _aidl_error; |
| |
| _aidl_error: |
| _aidl_status.set(AStatus_fromStatus(_aidl_ret_status)); |
| _aidl_status_return: |
| return _aidl_status; |
| } |
| ::ndk::ScopedAStatus BpExecution::executeFenced(const std::vector<::ndk::ScopedFileDescriptor>& in_waitFor, int64_t in_deadlineNs, int64_t in_durationNs, ::aidl::android::hardware::neuralnetworks::FencedExecutionResult* _aidl_return) { |
| binder_status_t _aidl_ret_status = STATUS_OK; |
| ::ndk::ScopedAStatus _aidl_status; |
| ::ndk::ScopedAParcel _aidl_in; |
| ::ndk::ScopedAParcel _aidl_out; |
| |
| _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR()); |
| if (_aidl_ret_status != STATUS_OK) goto _aidl_error; |
| |
| _aidl_ret_status = ::ndk::AParcel_writeData(_aidl_in.get(), in_waitFor); |
| if (_aidl_ret_status != STATUS_OK) goto _aidl_error; |
| |
| _aidl_ret_status = ::ndk::AParcel_writeData(_aidl_in.get(), in_deadlineNs); |
| if (_aidl_ret_status != STATUS_OK) goto _aidl_error; |
| |
| _aidl_ret_status = ::ndk::AParcel_writeData(_aidl_in.get(), in_durationNs); |
| if (_aidl_ret_status != STATUS_OK) goto _aidl_error; |
| |
| _aidl_ret_status = AIBinder_transact( |
| asBinder().get(), |
| (FIRST_CALL_TRANSACTION + 1 /*executeFenced*/), |
| _aidl_in.getR(), |
| _aidl_out.getR(), |
| 0 |
| #ifdef BINDER_STABILITY_SUPPORT |
| | FLAG_PRIVATE_LOCAL |
| #endif // BINDER_STABILITY_SUPPORT |
| ); |
| if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && IExecution::getDefaultImpl()) { |
| _aidl_status = IExecution::getDefaultImpl()->executeFenced(in_waitFor, in_deadlineNs, in_durationNs, _aidl_return); |
| goto _aidl_status_return; |
| } |
| if (_aidl_ret_status != STATUS_OK) goto _aidl_error; |
| |
| _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR()); |
| if (_aidl_ret_status != STATUS_OK) goto _aidl_error; |
| |
| if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return; |
| _aidl_ret_status = ::ndk::AParcel_readData(_aidl_out.get(), _aidl_return); |
| if (_aidl_ret_status != STATUS_OK) goto _aidl_error; |
| |
| _aidl_error: |
| _aidl_status.set(AStatus_fromStatus(_aidl_ret_status)); |
| _aidl_status_return: |
| return _aidl_status; |
| } |
| ::ndk::ScopedAStatus BpExecution::getInterfaceVersion(int32_t* _aidl_return) { |
| binder_status_t _aidl_ret_status = STATUS_OK; |
| ::ndk::ScopedAStatus _aidl_status; |
| if (_aidl_cached_version != -1) { |
| *_aidl_return = _aidl_cached_version; |
| _aidl_status.set(AStatus_fromStatus(_aidl_ret_status)); |
| return _aidl_status; |
| } |
| ::ndk::ScopedAParcel _aidl_in; |
| ::ndk::ScopedAParcel _aidl_out; |
| |
| _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR()); |
| if (_aidl_ret_status != STATUS_OK) goto _aidl_error; |
| |
| _aidl_ret_status = AIBinder_transact( |
| asBinder().get(), |
| (FIRST_CALL_TRANSACTION + 16777214 /*getInterfaceVersion*/), |
| _aidl_in.getR(), |
| _aidl_out.getR(), |
| 0 |
| #ifdef BINDER_STABILITY_SUPPORT |
| | FLAG_PRIVATE_LOCAL |
| #endif // BINDER_STABILITY_SUPPORT |
| ); |
| if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && IExecution::getDefaultImpl()) { |
| _aidl_status = IExecution::getDefaultImpl()->getInterfaceVersion(_aidl_return); |
| goto _aidl_status_return; |
| } |
| if (_aidl_ret_status != STATUS_OK) goto _aidl_error; |
| |
| _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR()); |
| if (_aidl_ret_status != STATUS_OK) goto _aidl_error; |
| |
| if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return; |
| _aidl_ret_status = ::ndk::AParcel_readData(_aidl_out.get(), _aidl_return); |
| if (_aidl_ret_status != STATUS_OK) goto _aidl_error; |
| |
| _aidl_cached_version = *_aidl_return; |
| _aidl_error: |
| _aidl_status.set(AStatus_fromStatus(_aidl_ret_status)); |
| _aidl_status_return: |
| return _aidl_status; |
| } |
| ::ndk::ScopedAStatus BpExecution::getInterfaceHash(std::string* _aidl_return) { |
| binder_status_t _aidl_ret_status = STATUS_OK; |
| ::ndk::ScopedAStatus _aidl_status; |
| const std::lock_guard<std::mutex> lock(_aidl_cached_hash_mutex); |
| if (_aidl_cached_hash != "-1") { |
| *_aidl_return = _aidl_cached_hash; |
| _aidl_status.set(AStatus_fromStatus(_aidl_ret_status)); |
| return _aidl_status; |
| } |
| ::ndk::ScopedAParcel _aidl_in; |
| ::ndk::ScopedAParcel _aidl_out; |
| |
| _aidl_ret_status = AIBinder_prepareTransaction(asBinder().get(), _aidl_in.getR()); |
| if (_aidl_ret_status != STATUS_OK) goto _aidl_error; |
| |
| _aidl_ret_status = AIBinder_transact( |
| asBinder().get(), |
| (FIRST_CALL_TRANSACTION + 16777213 /*getInterfaceHash*/), |
| _aidl_in.getR(), |
| _aidl_out.getR(), |
| 0 |
| #ifdef BINDER_STABILITY_SUPPORT |
| | FLAG_PRIVATE_LOCAL |
| #endif // BINDER_STABILITY_SUPPORT |
| ); |
| if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && IExecution::getDefaultImpl()) { |
| _aidl_status = IExecution::getDefaultImpl()->getInterfaceHash(_aidl_return); |
| goto _aidl_status_return; |
| } |
| if (_aidl_ret_status != STATUS_OK) goto _aidl_error; |
| |
| _aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR()); |
| if (_aidl_ret_status != STATUS_OK) goto _aidl_error; |
| |
| if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return; |
| _aidl_ret_status = ::ndk::AParcel_readData(_aidl_out.get(), _aidl_return); |
| if (_aidl_ret_status != STATUS_OK) goto _aidl_error; |
| |
| _aidl_cached_hash = *_aidl_return; |
| _aidl_error: |
| _aidl_status.set(AStatus_fromStatus(_aidl_ret_status)); |
| _aidl_status_return: |
| return _aidl_status; |
| } |
| // Source for BnExecution |
| BnExecution::BnExecution() {} |
| BnExecution::~BnExecution() {} |
| ::ndk::SpAIBinder BnExecution::createBinder() { |
| AIBinder* binder = AIBinder_new(_g_aidl_android_hardware_neuralnetworks_IExecution_clazz, static_cast<void*>(this)); |
| #ifdef BINDER_STABILITY_SUPPORT |
| AIBinder_markVintfStability(binder); |
| #endif // BINDER_STABILITY_SUPPORT |
| return ::ndk::SpAIBinder(binder); |
| } |
| ::ndk::ScopedAStatus BnExecution::getInterfaceVersion(int32_t* _aidl_return) { |
| *_aidl_return = IExecution::version; |
| return ::ndk::ScopedAStatus(AStatus_newOk()); |
| } |
| ::ndk::ScopedAStatus BnExecution::getInterfaceHash(std::string* _aidl_return) { |
| *_aidl_return = IExecution::hash; |
| return ::ndk::ScopedAStatus(AStatus_newOk()); |
| } |
| // Source for IExecution |
| const char* IExecution::descriptor = "android.hardware.neuralnetworks.IExecution"; |
| IExecution::IExecution() {} |
| IExecution::~IExecution() {} |
| |
| |
| std::shared_ptr<IExecution> IExecution::fromBinder(const ::ndk::SpAIBinder& binder) { |
| if (!AIBinder_associateClass(binder.get(), _g_aidl_android_hardware_neuralnetworks_IExecution_clazz)) { return nullptr; } |
| std::shared_ptr<::ndk::ICInterface> interface = ::ndk::ICInterface::asInterface(binder.get()); |
| if (interface) { |
| return std::static_pointer_cast<IExecution>(interface); |
| } |
| return ::ndk::SharedRefBase::make<BpExecution>(binder); |
| } |
| |
| binder_status_t IExecution::writeToParcel(AParcel* parcel, const std::shared_ptr<IExecution>& instance) { |
| return AParcel_writeStrongBinder(parcel, instance ? instance->asBinder().get() : nullptr); |
| } |
| binder_status_t IExecution::readFromParcel(const AParcel* parcel, std::shared_ptr<IExecution>* instance) { |
| ::ndk::SpAIBinder binder; |
| binder_status_t status = AParcel_readStrongBinder(parcel, binder.getR()); |
| if (status != STATUS_OK) return status; |
| *instance = IExecution::fromBinder(binder); |
| return STATUS_OK; |
| } |
| bool IExecution::setDefaultImpl(const std::shared_ptr<IExecution>& 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(!IExecution::default_impl); |
| if (impl) { |
| IExecution::default_impl = impl; |
| return true; |
| } |
| return false; |
| } |
| const std::shared_ptr<IExecution>& IExecution::getDefaultImpl() { |
| return IExecution::default_impl; |
| } |
| std::shared_ptr<IExecution> IExecution::default_impl = nullptr; |
| ::ndk::ScopedAStatus IExecutionDefault::executeSynchronously(int64_t /*in_deadlineNs*/, ::aidl::android::hardware::neuralnetworks::ExecutionResult* /*_aidl_return*/) { |
| ::ndk::ScopedAStatus _aidl_status; |
| _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION)); |
| return _aidl_status; |
| } |
| ::ndk::ScopedAStatus IExecutionDefault::executeFenced(const std::vector<::ndk::ScopedFileDescriptor>& /*in_waitFor*/, int64_t /*in_deadlineNs*/, int64_t /*in_durationNs*/, ::aidl::android::hardware::neuralnetworks::FencedExecutionResult* /*_aidl_return*/) { |
| ::ndk::ScopedAStatus _aidl_status; |
| _aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION)); |
| return _aidl_status; |
| } |
| ::ndk::ScopedAStatus IExecutionDefault::getInterfaceVersion(int32_t* _aidl_return) { |
| *_aidl_return = 0; |
| return ::ndk::ScopedAStatus(AStatus_newOk()); |
| } |
| ::ndk::ScopedAStatus IExecutionDefault::getInterfaceHash(std::string* _aidl_return) { |
| *_aidl_return = ""; |
| return ::ndk::ScopedAStatus(AStatus_newOk()); |
| } |
| ::ndk::SpAIBinder IExecutionDefault::asBinder() { |
| return ::ndk::SpAIBinder(); |
| } |
| bool IExecutionDefault::isRemote() { |
| return false; |
| } |
| } // namespace neuralnetworks |
| } // namespace hardware |
| } // namespace android |
| } // namespace aidl |