From c3c59b343723653ef708fed493ccfb2f375fa27c Mon Sep 17 00:00:00 2001 From: Anthony Stange Date: Wed, 10 Feb 2021 15:42:10 +0000 Subject: [PATCH] Update ContextHub v1.2 default HAL Updates ContextHub v1.2 default HAL based on latest tweaks to the API. Bug: 166846988 Test: compile Change-Id: I4a723afab834153d5e59694e70fc9282a96e7954 --- contexthub/1.2/default/Contexthub.cpp | 26 +++++++++++++++++++ contexthub/1.2/default/Contexthub.h | 3 +++ .../1.X/utils/IContextHubCallbackWrapper.h | 11 +++++--- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/contexthub/1.2/default/Contexthub.cpp b/contexthub/1.2/default/Contexthub.cpp index db0c5bc3df..601eccd399 100644 --- a/contexthub/1.2/default/Contexthub.cpp +++ b/contexthub/1.2/default/Contexthub.cpp @@ -23,10 +23,36 @@ namespace contexthub { namespace V1_2 { namespace implementation { +using ::android::hardware::hidl_string; using ::android::hardware::contexthub::V1_0::Result; using ::android::hardware::contexthub::V1_X::implementation::IContextHubCallbackWrapperV1_0; using ::android::hardware::contexthub::V1_X::implementation::IContextHubCallbackWrapperV1_2; +Return Contexthub::getHubs_1_2(getHubs_1_2_cb _hidl_cb) { + ::android::hardware::contexthub::V1_0::ContextHub hub = {}; + hub.name = "Mock Context Hub"; + hub.vendor = "AOSP"; + hub.toolchain = "n/a"; + hub.platformVersion = 1; + hub.toolchainVersion = 1; + hub.hubId = kMockHubId; + hub.peakMips = 1; + hub.peakPowerDrawMw = 1; + hub.maxSupportedMsgLen = 4096; + hub.chrePlatformId = UINT64_C(0x476f6f6754000000); + hub.chreApiMajorVersion = 1; + hub.chreApiMinorVersion = 4; + + // Report a single mock hub + std::vector<::android::hardware::contexthub::V1_0::ContextHub> hubs; + hubs.push_back(hub); + + std::vector hubPermissionList; + + _hidl_cb(hubs, hubPermissionList); + return Void(); +} + Return Contexthub::registerCallback(uint32_t hubId, const sp& cb) { if (hubId == kMockHubId) { diff --git a/contexthub/1.2/default/Contexthub.h b/contexthub/1.2/default/Contexthub.h index 8b89824d6b..32b862dc3f 100644 --- a/contexthub/1.2/default/Contexthub.h +++ b/contexthub/1.2/default/Contexthub.h @@ -35,6 +35,7 @@ class Contexthub using Result = ::android::hardware::contexthub::V1_0::Result; using SettingValue = ::android::hardware::contexthub::V1_1::SettingValue; using SettingV1_1 = ::android::hardware::contexthub::V1_1::Setting; + using getHubs_1_2_cb = ::android::hardware::contexthub::V1_2::IContexthub::getHubs_1_2_cb; public: // Methods from V1_0::IContexthub @@ -47,6 +48,8 @@ class Contexthub Return onSettingChanged(SettingV1_1 setting, SettingValue newValue) override; // Methods from V1_2::IContexthub + Return getHubs_1_2(getHubs_1_2_cb _hidl_cb) override; + Return onSettingChanged_1_2(Setting setting, SettingValue newValue) override; Return registerCallback_1_2(uint32_t hubId, diff --git a/contexthub/common/default/1.X/utils/IContextHubCallbackWrapper.h b/contexthub/common/default/1.X/utils/IContextHubCallbackWrapper.h index df78438750..d8cc37b5f2 100644 --- a/contexthub/common/default/1.X/utils/IContextHubCallbackWrapper.h +++ b/contexthub/common/default/1.X/utils/IContextHubCallbackWrapper.h @@ -54,7 +54,8 @@ inline hidl_vec convertToOldAppInfo(hidl_vec */ class IContextHubCallbackWrapperBase : public VirtualLightRefBase { public: - virtual Return handleClientMsg(V1_2::ContextHubMsg msg) = 0; + virtual Return handleClientMsg(V1_2::ContextHubMsg msg, + hidl_vec msgContentPerms) = 0; virtual Return handleTxnResult(uint32_t txnId, V1_0::TransactionResult result) = 0; @@ -70,7 +71,8 @@ class ContextHubCallbackWrapper : public IContextHubCallbackWrapperBase { public: ContextHubCallbackWrapper(sp callback) : mCallback(callback){}; - virtual Return handleClientMsg(V1_2::ContextHubMsg msg) override { + virtual Return handleClientMsg(V1_2::ContextHubMsg msg, + hidl_vec /* msgContentPerms */) override { return mCallback->handleClientMsg(convertToOldMsg(msg)); } @@ -105,8 +107,9 @@ class IContextHubCallbackWrapperV1_2 : public ContextHubCallbackWrapper callback) : ContextHubCallbackWrapper(callback){}; - Return handleClientMsg(V1_2::ContextHubMsg msg) override { - return mCallback->handleClientMsg_1_2(msg); + Return handleClientMsg(V1_2::ContextHubMsg msg, + hidl_vec msgContentPerms) override { + return mCallback->handleClientMsg_1_2(msg, msgContentPerms); } Return handleAppsInfo(hidl_vec appInfo) override {