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

Commit 76578943 authored by Vick Wang's avatar Vick Wang Committed by Gerrit Code Review
Browse files

Merge changes from topic "vendor_thread_hal" into main

* changes:
  Add vendor callback for receiving spinel frames
  Add cc_library for threadnetwork module
parents 7e79f0d0 a803f275
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
@@ -45,6 +45,41 @@ cc_binary {
    ],
}

cc_library_static {
    name: "android.hardware.threadnetwork.lib",

    vendor: true,
    export_include_dirs: ["."],

    defaults: ["android.hardware.threadnetwork-service.defaults"],

    srcs: [
        "service.cpp",
        "thread_chip.cpp",
        "utils.cpp",
    ],

    shared_libs: [
        "libbinder_ndk",
        "liblog",
    ],

    static_libs: [
        "android.hardware.threadnetwork-V1-ndk",
        "libbase",
        "libcutils",
        "libutils",
        "openthread-common",
        "openthread-hdlc",
        "openthread-platform",
        "openthread-posix",
        "openthread-spi",
        "openthread-url",
    ],

    stl: "c++_static",
}

cc_defaults {
    name: "android.hardware.threadnetwork-service.defaults",
    product_variables: {
+9 −0
Original line number Diff line number Diff line
@@ -83,6 +83,11 @@ void ThreadChip::handleReceivedFrame(void) {
                mRxFrameBuffer.GetFrame(), mRxFrameBuffer.GetFrame() + mRxFrameBuffer.GetLength()));
    }

    if (mVendorCallback != nullptr) {
        mVendorCallback->onReceiveSpinelFrame(std::vector<uint8_t>(
                mRxFrameBuffer.GetFrame(), mRxFrameBuffer.GetFrame() + mRxFrameBuffer.GetLength()));
    }

    mRxFrameBuffer.DiscardFrame();
}

@@ -193,6 +198,10 @@ void ThreadChip::Process(const otSysMainloopContext& context) {
    }
}

void ThreadChip::setVendorCallback(const std::shared_ptr<IThreadChipCallback>& vendorCallback) {
    mVendorCallback = vendorCallback;
}

ndk::ScopedAStatus ThreadChip::errorStatus(int32_t error, const char* message) {
    return ndk::ScopedAStatus(AStatus_fromServiceSpecificErrorWithMessage(error, message));
}
+2 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ class ThreadChip : public BnThreadChip, ot::Posix::Mainloop::Source {
    ndk::ScopedAStatus hardwareReset() override;
    void Update(otSysMainloopContext& context) override;
    void Process(const otSysMainloopContext& context) override;
    void setVendorCallback(const std::shared_ptr<IThreadChipCallback>& vendorCallback);

  private:
    static void onBinderDiedJump(void* context);
@@ -59,6 +60,7 @@ class ThreadChip : public BnThreadChip, ot::Posix::Mainloop::Source {
    std::shared_ptr<ot::Spinel::SpinelInterface> mSpinelInterface;
    ot::Spinel::SpinelInterface::RxFrameBuffer mRxFrameBuffer;
    std::shared_ptr<IThreadChipCallback> mCallback;
    std::shared_ptr<IThreadChipCallback> mVendorCallback;
    ::ndk::ScopedAIBinder_DeathRecipient mDeathRecipient;
};