Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[android] replace VendorServer with OtDaemonServer #1967

Merged
merged 1 commit into from
Aug 29, 2023

Conversation

wgtdkp
Copy link
Member

@wgtdkp wgtdkp commented Aug 13, 2023

To make it easier to update the OtDaemonServer implementation
since we have to save the OtDaemonServer as a field of Application
anyway.

To make it easier to update the OtDaemonServer implementation
without making separate changes on both GitHub and AOSP.
Copy link
Contributor

@zhanglongxia zhanglongxia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wgtdkp wgtdkp requested a review from jwhui August 29, 2023 03:45
@jwhui jwhui merged commit 300cfed into openthread:main Aug 29, 2023
31 checks passed
@DarthBo
Copy link

DarthBo commented Sep 1, 2023

I liked the generic VendorServer though, we used it to hook our own api in... though the header did need patching to be usable.

Instead of replacing the generic VendorServer with something Android specific, could we not make the header more flexible so it's useable for everyone? Don't implement the constructor, and add some private storage.

The PIMPL pattern seems fitting for this?

class VendorServer
{
public:
    /**
     * The constructor of vendor server.
     *
     * @param[in] aNcp  A reference to the NCP controller.
     *
     */
    VendorServer(otbr::Ncp::ControllerOpenThread &aNcp);

    /**
     * This method initializes the vendor server.
     *
     */
    void Init(void);

private:
    class Impl;
    std::unique_ptr<Impl> mImpl;
};

@wgtdkp
Copy link
Member Author

wgtdkp commented Sep 1, 2023

@DarthBo Can you edit your application.cpp directly without being proxied by VendorServer? As you mentioned, you already need to patch the header, so just forget about it. You can add your server just we do for the OtDaemonServer, but on your own branch (you can make whatever changes on your own branch anyway). Previous VendorServer code doesn't provide any abstraction so there isn't too much value other than keeping the github and aosp branches from diverge, but it shouldn't be an issue of your branch :)

@DarthBo
Copy link

DarthBo commented Sep 4, 2023

@wgtdkp I could fork it, sure, but I'd prefer to avoid that.

We get around the issues of the header by replacing it with some CMake magic, no forks needed. I probably should have tried to upstream my suggested header changes earlier, sorry about that.

Before the Vendor Server, we used our own fork, and it was a pain to keep the stack updated because there was always something that changed. I'm sure you had the same problem in Android as well.

I thought the point of the VendorServer was to avoid this pain for all vendors. Replacing something generic (but flawed) with something android specific (instead of just fixing it) feels backwards, and not a little like cheating. I doubt every vendor can upstream their own ifdef...

@wgtdkp
Copy link
Member Author

wgtdkp commented Sep 4, 2023

Hi @DarthBo, If you can't live without VendorServer, then it's proven to be useful and I am happy to revert this change :)

We get around the issues of the header by replacing it with some CMake magic, no forks needed. I probably should have tried to upstream my suggested header changes earlier, sorry about that.

I an curious how can you managed to work, are you using otbr-agent as a library of your vendor server? I don't see how it can work without modifying the upstream code.

@wgtdkp
Copy link
Member Author

wgtdkp commented Sep 4, 2023

The PIMPL pattern seems fitting for this?

class VendorServer
{
public:
    /**
     * The constructor of vendor server.
     *
     * @param[in] aNcp  A reference to the NCP controller.
     *
     */
    VendorServer(otbr::Ncp::ControllerOpenThread &aNcp);

    /**
     * This method initializes the vendor server.
     *
     */
    void Init(void);

private:
    class Impl;
    std::unique_ptr<Impl> mImpl;
};

It looks like we need at least three classes to support a custom FooServer as I don't want to call my specific VendorServer as "Impl".

What about making VendorServer an abstract class instead?

class VendorServer {
public:
    static shared_ptr<VendorServer> newInstance();
    virtual void Init(void) = 0;
}

class FooServer: public VendorServer {
// Adds whatever implementation you need
}

class Application {
public:
    Application()
        : mVendorServer(VendorServer::newInstance()) {}

private:
    shared_ptr<VendorServer> mVendorServer;
}

So we needs only two classes.

BTW, I need shared_ptr for Android, does it work for you?

wgtdkp added a commit to wgtdkp/ot-br-posix that referenced this pull request Sep 4, 2023
wgtdkp added a commit to wgtdkp/ot-br-posix that referenced this pull request Sep 4, 2023
This commit changes VendorServer to an abstract class so that it
can be extended to have different implementations.

Fulfills request from openthread#1967 (comment)
@wgtdkp
Copy link
Member Author

wgtdkp commented Sep 4, 2023

Opening #1995 to make generic VendorServer. @DarthBo Can you help check if this resolves your issue?

wgtdkp added a commit to wgtdkp/ot-br-posix that referenced this pull request Sep 4, 2023
…d#1967)" (openthread#1995)

This reverts commit 300cfed.

Change-Id: Ic8694b97ddb4125599314769361ea10d483b01cc
wgtdkp added a commit to wgtdkp/ot-br-posix that referenced this pull request Sep 4, 2023
This commit changes VendorServer to an abstract class so that it
can be extended to have different implementations.

Fulfills request from openthread#1967 (comment)

Change-Id: Ic322efbee9b58d7a2743c72a511572ec7ebfb262
wgtdkp added a commit to wgtdkp/ot-br-posix that referenced this pull request Sep 4, 2023
This commit changes VendorServer to an abstract class so that it
can be extended to have different implementations.

Fulfills request from openthread#1967 (comment)

Change-Id: Ic322efbee9b58d7a2743c72a511572ec7ebfb262
wgtdkp added a commit to wgtdkp/ot-br-posix that referenced this pull request Sep 4, 2023
This commit changes VendorServer to an abstract class so that it
can be extended to have different implementations.

Fulfills request from openthread#1967 (comment)
wgtdkp added a commit to wgtdkp/ot-br-posix that referenced this pull request Sep 4, 2023
This commit changes VendorServer to an abstract class so that it
can be extended to have different implementations.

Fulfills request from openthread#1967 (comment)
@DarthBo
Copy link

DarthBo commented Sep 4, 2023

I an curious how can you managed to work, are you using otbr-agent as a library of your vendor server? I don't see how it can work without modifying the upstream code.

We include ot-br-posix as a git submodule, the root project has the VendorServer implementation and links against otbr-agent. We override the header by including ours first with target_include_directories(otbr-agent BEFORE PRIVATE include_overrides). I'll be glad to no longer need that hack though.

What about making VendorServer an abstract class instead?

That also works for me

BTW, I need shared_ptr for Android, does it work for you?

Sure!

wgtdkp added a commit to wgtdkp/ot-br-posix that referenced this pull request Sep 5, 2023
This commit changes VendorServer to an abstract class so that it
can be extended to have different implementations.

Fulfills request from openthread#1967 (comment)
wgtdkp added a commit to wgtdkp/ot-br-posix that referenced this pull request Sep 5, 2023
This commit changes VendorServer to an abstract class so that it
can be extended to have different implementations.

Fulfills request from openthread#1967 (comment)
wgtdkp added a commit to wgtdkp/ot-br-posix that referenced this pull request Sep 6, 2023
This commit changes VendorServer to an abstract class so that it
can be extended to have different implementations.

Fulfills request from openthread#1967 (comment)

Change-Id: Ic1b41b8b60e5953142854f761e377e080f1937fc
jwhui pushed a commit that referenced this pull request Sep 6, 2023
…1995)

This reverts commit 300cfed.

Change-Id: Ic8694b97ddb4125599314769361ea10d483b01cc
jwhui pushed a commit that referenced this pull request Sep 6, 2023
This commit changes VendorServer to an abstract class so that it
can be extended to have different implementations.

Fulfills request from #1967 (comment)

Change-Id: Ic1b41b8b60e5953142854f761e377e080f1937fc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants