Adds additional host info exchanges in Context Hub HAL
Bug: 194287786
Test: Run VTS
Change-Id: I5459e44f752cd04bc1bec3b5e99f398be9f4ce11
diff --git a/contexthub/aidl/default/ContextHub.cpp b/contexthub/aidl/default/ContextHub.cpp
index 1fbccc5..6da690d 100644
--- a/contexthub/aidl/default/ContextHub.cpp
+++ b/contexthub/aidl/default/ContextHub.cpp
@@ -111,6 +111,21 @@
return ndk::ScopedAStatus::ok();
}
+::ndk::ScopedAStatus ContextHub::onHostEndpointConnected(const HostEndpointInfo& in_info) {
+ mConnectedHostEndpoints.insert(in_info.hostEndpointId);
+
+ return ndk::ScopedAStatus::ok();
+}
+
+::ndk::ScopedAStatus ContextHub::onHostEndpointDisconnected(char16_t in_hostEndpointId) {
+ if (mConnectedHostEndpoints.count(in_hostEndpointId) > 0) {
+ mConnectedHostEndpoints.erase(in_hostEndpointId);
+ return ndk::ScopedAStatus::ok();
+ } else {
+ return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_ILLEGAL_ARGUMENT));
+ }
+}
+
} // namespace contexthub
} // namespace hardware
} // namespace android
diff --git a/contexthub/aidl/default/include/contexthub-impl/ContextHub.h b/contexthub/aidl/default/include/contexthub-impl/ContextHub.h
index 0dbb61b..dd739e6 100644
--- a/contexthub/aidl/default/include/contexthub-impl/ContextHub.h
+++ b/contexthub/aidl/default/include/contexthub-impl/ContextHub.h
@@ -18,6 +18,8 @@
#include <aidl/android/hardware/contexthub/BnContextHub.h>
+#include <unordered_set>
+
namespace aidl {
namespace android {
namespace hardware {
@@ -41,10 +43,15 @@
::ndk::ScopedAStatus sendMessageToHub(int32_t in_contextHubId,
const ContextHubMessage& in_message,
bool* _aidl_return) override;
+ ::ndk::ScopedAStatus onHostEndpointConnected(const HostEndpointInfo& in_info) override;
+
+ ::ndk::ScopedAStatus onHostEndpointDisconnected(char16_t in_hostEndpointId) override;
private:
static constexpr uint32_t kMockHubId = 0;
std::shared_ptr<IContextHubCallback> mCallback;
+
+ std::unordered_set<char16_t> mConnectedHostEndpoints;
};
} // namespace contexthub