Loading contexthub/aidl/default/ContextHub.cpp +51 −17 Original line number Diff line number Diff line Loading @@ -21,38 +21,50 @@ namespace android { namespace hardware { namespace contexthub { // TODO(b/194285834): Implement AIDL HAL ::ndk::ScopedAStatus ContextHub::getContextHubs(std::vector<ContextHubInfo>* out_contextHubInfos) { ContextHubInfo hub = {}; hub.name = "Mock Context Hub"; hub.vendor = "AOSP"; hub.toolchain = "n/a"; hub.id = kMockHubId; hub.peakMips = 1; hub.maxSupportedMessageLengthBytes = 4096; hub.chrePlatformId = UINT64_C(0x476f6f6754000000); hub.chreApiMajorVersion = 1; hub.chreApiMinorVersion = 6; out_contextHubInfos->push_back(hub); ::ndk::ScopedAStatus ContextHub::getContextHubs( std::vector<ContextHubInfo>* /* out_contextHubInfos */) { return ndk::ScopedAStatus::ok(); } // We don't expose any nanoapps for the default impl, therefore all nanoapp-related APIs fail. ::ndk::ScopedAStatus ContextHub::loadNanoapp(int32_t /* in_contextHubId */, const NanoappBinary& /* in_appBinary */, int32_t /* in_transactionId */, bool* /* _aidl_return */) { int32_t /* in_transactionId */, bool* _aidl_return) { *_aidl_return = false; return ndk::ScopedAStatus::ok(); } ::ndk::ScopedAStatus ContextHub::unloadNanoapp(int32_t /* in_contextHubId */, int64_t /* in_appId */, int32_t /* in_transactionId */, bool* /* _aidl_return */) { int32_t /* in_transactionId */, bool* _aidl_return) { *_aidl_return = false; return ndk::ScopedAStatus::ok(); } ::ndk::ScopedAStatus ContextHub::disableNanoapp(int32_t /* in_contextHubId */, int64_t /* in_appId */, int32_t /* in_transactionId */, bool* /* _aidl_return */) { bool* _aidl_return) { *_aidl_return = false; return ndk::ScopedAStatus::ok(); } ::ndk::ScopedAStatus ContextHub::enableNanoapp(int32_t /* in_contextHubId */, int64_t /* in_appId */, int32_t /* in_transactionId */, bool* /* _aidl_return */) { int32_t /* in_transactionId */, bool* _aidl_return) { *_aidl_return = false; return ndk::ScopedAStatus::ok(); } Loading @@ -60,20 +72,42 @@ namespace contexthub { return ndk::ScopedAStatus::ok(); } ::ndk::ScopedAStatus ContextHub::queryNanoapps(int32_t /* in_contextHubId */, bool* /* _aidl_return */) { ::ndk::ScopedAStatus ContextHub::queryNanoapps(int32_t in_contextHubId, bool* _aidl_return) { if (in_contextHubId == kMockHubId && mCallback != nullptr) { std::vector<NanoappInfo> nanoapps; mCallback->handleNanoappInfo(nanoapps); *_aidl_return = true; } else { *_aidl_return = false; } return ndk::ScopedAStatus::ok(); } ::ndk::ScopedAStatus ContextHub::registerCallback( int32_t /* in_contextHubId */, const std::shared_ptr<IContextHubCallback>& /* in_cb */, bool* /* _aidl_return */) { ::ndk::ScopedAStatus ContextHub::registerCallback(int32_t in_contextHubId, const std::shared_ptr<IContextHubCallback>& in_cb, bool* _aidl_return) { if (in_contextHubId == kMockHubId) { mCallback = in_cb; *_aidl_return = true; } else { *_aidl_return = false; } return ndk::ScopedAStatus::ok(); } ::ndk::ScopedAStatus ContextHub::sendMessageToHub(int32_t /* in_contextHubId */, ::ndk::ScopedAStatus ContextHub::sendMessageToHub(int32_t in_contextHubId, const ContextHubMessage& /* in_message */, bool* /* _aidl_return */) { bool* _aidl_return) { if (in_contextHubId == kMockHubId) { // Return true here to indicate that the HAL has accepted the message. // Successful delivery of the message to a nanoapp should be handled at // a higher level protocol. *_aidl_return = true; } else { *_aidl_return = false; } return ndk::ScopedAStatus::ok(); } Loading contexthub/aidl/default/include/contexthub-impl/ContextHub.h +4 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,10 @@ class ContextHub : public BnContextHub { ::ndk::ScopedAStatus sendMessageToHub(int32_t in_contextHubId, const ContextHubMessage& in_message, bool* _aidl_return) override; private: static constexpr uint32_t kMockHubId = 0; std::shared_ptr<IContextHubCallback> mCallback; }; } // namespace contexthub Loading Loading
contexthub/aidl/default/ContextHub.cpp +51 −17 Original line number Diff line number Diff line Loading @@ -21,38 +21,50 @@ namespace android { namespace hardware { namespace contexthub { // TODO(b/194285834): Implement AIDL HAL ::ndk::ScopedAStatus ContextHub::getContextHubs(std::vector<ContextHubInfo>* out_contextHubInfos) { ContextHubInfo hub = {}; hub.name = "Mock Context Hub"; hub.vendor = "AOSP"; hub.toolchain = "n/a"; hub.id = kMockHubId; hub.peakMips = 1; hub.maxSupportedMessageLengthBytes = 4096; hub.chrePlatformId = UINT64_C(0x476f6f6754000000); hub.chreApiMajorVersion = 1; hub.chreApiMinorVersion = 6; out_contextHubInfos->push_back(hub); ::ndk::ScopedAStatus ContextHub::getContextHubs( std::vector<ContextHubInfo>* /* out_contextHubInfos */) { return ndk::ScopedAStatus::ok(); } // We don't expose any nanoapps for the default impl, therefore all nanoapp-related APIs fail. ::ndk::ScopedAStatus ContextHub::loadNanoapp(int32_t /* in_contextHubId */, const NanoappBinary& /* in_appBinary */, int32_t /* in_transactionId */, bool* /* _aidl_return */) { int32_t /* in_transactionId */, bool* _aidl_return) { *_aidl_return = false; return ndk::ScopedAStatus::ok(); } ::ndk::ScopedAStatus ContextHub::unloadNanoapp(int32_t /* in_contextHubId */, int64_t /* in_appId */, int32_t /* in_transactionId */, bool* /* _aidl_return */) { int32_t /* in_transactionId */, bool* _aidl_return) { *_aidl_return = false; return ndk::ScopedAStatus::ok(); } ::ndk::ScopedAStatus ContextHub::disableNanoapp(int32_t /* in_contextHubId */, int64_t /* in_appId */, int32_t /* in_transactionId */, bool* /* _aidl_return */) { bool* _aidl_return) { *_aidl_return = false; return ndk::ScopedAStatus::ok(); } ::ndk::ScopedAStatus ContextHub::enableNanoapp(int32_t /* in_contextHubId */, int64_t /* in_appId */, int32_t /* in_transactionId */, bool* /* _aidl_return */) { int32_t /* in_transactionId */, bool* _aidl_return) { *_aidl_return = false; return ndk::ScopedAStatus::ok(); } Loading @@ -60,20 +72,42 @@ namespace contexthub { return ndk::ScopedAStatus::ok(); } ::ndk::ScopedAStatus ContextHub::queryNanoapps(int32_t /* in_contextHubId */, bool* /* _aidl_return */) { ::ndk::ScopedAStatus ContextHub::queryNanoapps(int32_t in_contextHubId, bool* _aidl_return) { if (in_contextHubId == kMockHubId && mCallback != nullptr) { std::vector<NanoappInfo> nanoapps; mCallback->handleNanoappInfo(nanoapps); *_aidl_return = true; } else { *_aidl_return = false; } return ndk::ScopedAStatus::ok(); } ::ndk::ScopedAStatus ContextHub::registerCallback( int32_t /* in_contextHubId */, const std::shared_ptr<IContextHubCallback>& /* in_cb */, bool* /* _aidl_return */) { ::ndk::ScopedAStatus ContextHub::registerCallback(int32_t in_contextHubId, const std::shared_ptr<IContextHubCallback>& in_cb, bool* _aidl_return) { if (in_contextHubId == kMockHubId) { mCallback = in_cb; *_aidl_return = true; } else { *_aidl_return = false; } return ndk::ScopedAStatus::ok(); } ::ndk::ScopedAStatus ContextHub::sendMessageToHub(int32_t /* in_contextHubId */, ::ndk::ScopedAStatus ContextHub::sendMessageToHub(int32_t in_contextHubId, const ContextHubMessage& /* in_message */, bool* /* _aidl_return */) { bool* _aidl_return) { if (in_contextHubId == kMockHubId) { // Return true here to indicate that the HAL has accepted the message. // Successful delivery of the message to a nanoapp should be handled at // a higher level protocol. *_aidl_return = true; } else { *_aidl_return = false; } return ndk::ScopedAStatus::ok(); } Loading
contexthub/aidl/default/include/contexthub-impl/ContextHub.h +4 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,10 @@ class ContextHub : public BnContextHub { ::ndk::ScopedAStatus sendMessageToHub(int32_t in_contextHubId, const ContextHubMessage& in_message, bool* _aidl_return) override; private: static constexpr uint32_t kMockHubId = 0; std::shared_ptr<IContextHubCallback> mCallback; }; } // namespace contexthub Loading