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

Commit 51eba2ed authored by Yifei Zhang's avatar Yifei Zhang
Browse files

Update contexhub stub impl to V4

- Include actual implementation for getHubs()

Test: build
Bug: 361830233
Flag: N/A
Change-Id: Ib6b0d5628fb8f7c88c935e61093cf3f6a3dd0e65
parent 6b424755
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ cc_library_static {
    shared_libs: [
        "libbase",
        "libbinder_ndk",
        "android.hardware.contexthub-V3-ndk",
        "android.hardware.contexthub-V4-ndk",
    ],
    export_include_dirs: ["include"],
    srcs: [
@@ -51,7 +51,7 @@ cc_binary {
    shared_libs: [
        "libbase",
        "libbinder_ndk",
        "android.hardware.contexthub-V3-ndk",
        "android.hardware.contexthub-V4-ndk",
    ],
    static_libs: [
        "libcontexthubexampleimpl",
+79 −0
Original line number Diff line number Diff line
@@ -136,4 +136,83 @@ ScopedAStatus ContextHub::sendMessageDeliveryStatusToHub(
    return ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
}

ScopedAStatus ContextHub::getHubs(std::vector<HubInfo>* _aidl_return) {
    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;
    hub.supportsReliableMessages = false;

    HubInfo hubInfo1 = {};
    hubInfo1.hubId = hub.chrePlatformId;
    hubInfo1.hubDetails = HubInfo::HubDetails::make<HubInfo::HubDetails::Tag::contextHubInfo>(hub);

    VendorHubInfo vendorHub = {};
    vendorHub.name = "Mock Vendor Hub";
    vendorHub.version = 42;

    HubInfo hubInfo2 = {};
    hubInfo1.hubId = UINT64_C(0x1234567812345678);
    hubInfo1.hubDetails =
            HubInfo::HubDetails::make<HubInfo::HubDetails::Tag::vendorHubInfo>(vendorHub);

    _aidl_return->push_back(hubInfo1);
    _aidl_return->push_back(hubInfo2);

    return ScopedAStatus::ok();
};

ScopedAStatus ContextHub::getEndpoints(std::vector<EndpointInfo>* /* _aidl_return */) {
    return ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
};

ScopedAStatus ContextHub::registerEndpoint(const EndpointInfo& /* in_endpoint */) {
    return ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
};

ScopedAStatus ContextHub::unregisterEndpoint(const EndpointInfo& /* in_endpoint */) {
    return ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
};

ScopedAStatus ContextHub::registerEndpointCallback(
        const std::shared_ptr<IEndpointCallback>& /* in_callback */) {
    return ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
};

ScopedAStatus ContextHub::requestSessionIdRange(int32_t /* in_size */,
                                                std::vector<int32_t>* /* _aidl_return */) {
    return ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
};

ScopedAStatus ContextHub::openEndpointSession(
        int32_t /* in_sessionId */, const EndpointId& /* in_destination */,
        const EndpointId& /* in_initiator */,
        const std::optional<std::string>& /* in_serviceDescriptor */) {
    return ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
};

ScopedAStatus ContextHub::sendMessageToEndpoint(int32_t /* in_sessionId */,
                                                const Message& /* in_msg */) {
    return ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
};

ScopedAStatus ContextHub::sendMessageDeliveryStatusToEndpoint(
        int32_t /* in_sessionId */, const MessageDeliveryStatus& /* in_msgStatus */) {
    return ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
};

ScopedAStatus ContextHub::closeEndpointSession(int32_t /* in_sessionId */, Reason /* in_reason */) {
    return ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
};

ScopedAStatus ContextHub::endpointSessionOpenComplete(int32_t /* in_sessionId */) {
    return ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
};

}  // namespace aidl::android::hardware::contexthub
+1 −1
Original line number Diff line number Diff line
<manifest version="1.0" type="device">
    <hal format="aidl">
        <name>android.hardware.contexthub</name>
        <version>3</version>
        <version>4</version>
        <interface>
            <name>IContextHub</name>
            <instance>default</instance>
+18 −0
Original line number Diff line number Diff line
@@ -53,6 +53,24 @@ class ContextHub : public BnContextHub {
            int32_t in_contextHubId,
            const MessageDeliveryStatus& in_messageDeliveryStatus) override;

    ::ndk::ScopedAStatus getHubs(std::vector<HubInfo>* _aidl_return) override;
    ::ndk::ScopedAStatus getEndpoints(std::vector<EndpointInfo>* _aidl_return) override;
    ::ndk::ScopedAStatus registerEndpoint(const EndpointInfo& in_endpoint) override;
    ::ndk::ScopedAStatus unregisterEndpoint(const EndpointInfo& in_endpoint) override;
    ::ndk::ScopedAStatus registerEndpointCallback(
            const std::shared_ptr<IEndpointCallback>& in_callback) override;
    ::ndk::ScopedAStatus requestSessionIdRange(int32_t in_size,
                                               std::vector<int32_t>* _aidl_return) override;
    ::ndk::ScopedAStatus openEndpointSession(
            int32_t in_sessionId, const EndpointId& in_destination, const EndpointId& in_initiator,
            const std::optional<std::string>& in_serviceDescriptor) override;
    ::ndk::ScopedAStatus sendMessageToEndpoint(int32_t in_sessionId,
                                               const Message& in_msg) override;
    ::ndk::ScopedAStatus sendMessageDeliveryStatusToEndpoint(
            int32_t in_sessionId, const MessageDeliveryStatus& in_msgStatus) override;
    ::ndk::ScopedAStatus closeEndpointSession(int32_t in_sessionId, Reason in_reason) override;
    ::ndk::ScopedAStatus endpointSessionOpenComplete(int32_t in_sessionId) override;

  private:
    static constexpr uint32_t kMockHubId = 0;
    std::shared_ptr<IContextHubCallback> mCallback;