Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c3c59b34 authored by Anthony Stange's avatar Anthony Stange
Browse files

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
parent 2bdef6ae
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -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<void> 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<hidl_string> hubPermissionList;

    _hidl_cb(hubs, hubPermissionList);
    return Void();
}

Return<Result> Contexthub::registerCallback(uint32_t hubId,
                                            const sp<V1_0::IContexthubCallback>& cb) {
    if (hubId == kMockHubId) {
+3 −0
Original line number Diff line number Diff line
@@ -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<void> onSettingChanged(SettingV1_1 setting, SettingValue newValue) override;

    // Methods from V1_2::IContexthub
    Return<void> getHubs_1_2(getHubs_1_2_cb _hidl_cb) override;

    Return<void> onSettingChanged_1_2(Setting setting, SettingValue newValue) override;

    Return<Result> registerCallback_1_2(uint32_t hubId,
+7 −4
Original line number Diff line number Diff line
@@ -54,7 +54,8 @@ inline hidl_vec<V1_0::HubAppInfo> convertToOldAppInfo(hidl_vec<V1_2::HubAppInfo>
 */
class IContextHubCallbackWrapperBase : public VirtualLightRefBase {
  public:
    virtual Return<void> handleClientMsg(V1_2::ContextHubMsg msg) = 0;
    virtual Return<void> handleClientMsg(V1_2::ContextHubMsg msg,
                                         hidl_vec<hidl_string> msgContentPerms) = 0;

    virtual Return<void> handleTxnResult(uint32_t txnId, V1_0::TransactionResult result) = 0;

@@ -70,7 +71,8 @@ class ContextHubCallbackWrapper : public IContextHubCallbackWrapperBase {
  public:
    ContextHubCallbackWrapper(sp<T> callback) : mCallback(callback){};

    virtual Return<void> handleClientMsg(V1_2::ContextHubMsg msg) override {
    virtual Return<void> handleClientMsg(V1_2::ContextHubMsg msg,
                                         hidl_vec<hidl_string> /* msgContentPerms */) override {
        return mCallback->handleClientMsg(convertToOldMsg(msg));
    }

@@ -105,8 +107,9 @@ class IContextHubCallbackWrapperV1_2 : public ContextHubCallbackWrapper<V1_2::IC
    IContextHubCallbackWrapperV1_2(sp<V1_2::IContexthubCallback> callback)
        : ContextHubCallbackWrapper(callback){};

    Return<void> handleClientMsg(V1_2::ContextHubMsg msg) override {
        return mCallback->handleClientMsg_1_2(msg);
    Return<void> handleClientMsg(V1_2::ContextHubMsg msg,
                                 hidl_vec<hidl_string> msgContentPerms) override {
        return mCallback->handleClientMsg_1_2(msg, msgContentPerms);
    }

    Return<void> handleAppsInfo(hidl_vec<V1_2::HubAppInfo> appInfo) override {