From 19cca1bea7c24670b0da26ee8c7a9e926c9485ae Mon Sep 17 00:00:00 2001 From: Kangping Dong Date: Mon, 4 Sep 2023 20:18:51 +0800 Subject: [PATCH] Revert "[android] replace VendorServer with OtDaemonServer (#1967)" (#1995) This reverts commit 300cfedf0d87dce5606862601850d8fad9af1f07. Change-Id: Ic8694b97ddb4125599314769361ea10d483b01cc --- src/agent/CMakeLists.txt | 1 + src/agent/application.cpp | 8 ++--- src/agent/application.hpp | 8 ++--- src/agent/vendor.hpp | 69 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 78 insertions(+), 8 deletions(-) create mode 100644 src/agent/vendor.hpp diff --git a/src/agent/CMakeLists.txt b/src/agent/CMakeLists.txt index ce64ba28436..60d19b7e715 100644 --- a/src/agent/CMakeLists.txt +++ b/src/agent/CMakeLists.txt @@ -30,6 +30,7 @@ add_executable(otbr-agent application.cpp main.cpp uris.hpp + vendor.hpp ) target_link_libraries(otbr-agent PRIVATE diff --git a/src/agent/application.cpp b/src/agent/application.cpp index fd1314039f1..6d7499676bc 100644 --- a/src/agent/application.cpp +++ b/src/agent/application.cpp @@ -76,8 +76,8 @@ Application::Application(const std::string &aInterfaceName, #if OTBR_ENABLE_DBUS_SERVER && OTBR_ENABLE_BORDER_AGENT , mDBusAgent(mNcp, mBorderAgent.GetPublisher()) #endif -#if OTBR_ENABLE_ANDROID_OTDAEMON_SERVER - , mOtDaemonServer(ndk::SharedRefBase::make()) +#if OTBR_ENABLE_VENDOR_SERVER + , mVendorServer(mNcp) #endif { OTBR_UNUSED_VARIABLE(aRestListenAddress); @@ -103,8 +103,8 @@ void Application::Init(void) #if OTBR_ENABLE_DBUS_SERVER mDBusAgent.Init(); #endif -#if OTBR_ENABLE_ANDROID_OTDAEMON_SERVER - mOtDaemonServer->InitOrDie(&mNcp); +#if OTBR_ENABLE_VENDOR_SERVER + mVendorServer.Init(); #endif } diff --git a/src/agent/application.hpp b/src/agent/application.hpp index 9af66d0f6a4..9bfeee33e66 100644 --- a/src/agent/application.hpp +++ b/src/agent/application.hpp @@ -57,8 +57,8 @@ #if OTBR_ENABLE_OPENWRT #include "openwrt/ubus/otubus.hpp" #endif -#if OTBR_ENABLE_ANDROID_OTDAEMON_SERVER -#include "android/otdaemon_server.hpp" +#if OTBR_ENABLE_VENDOR_SERVER +#include "agent/vendor.hpp" #endif #include "utils/infra_link_selector.hpp" @@ -146,8 +146,8 @@ class Application : private NonCopyable #if OTBR_ENABLE_DBUS_SERVER DBus::DBusAgent mDBusAgent; #endif -#if OTBR_ENABLE_ANDROID_OTDAEMON_SERVER - std::shared_ptr mOtDaemonServer; +#if OTBR_ENABLE_VENDOR_SERVER + vendor::VendorServer mVendorServer; #endif static std::atomic_bool sShouldTerminate; diff --git a/src/agent/vendor.hpp b/src/agent/vendor.hpp new file mode 100644 index 00000000000..833072225ed --- /dev/null +++ b/src/agent/vendor.hpp @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2021, The OpenThread Authors. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * This file includes definitions of the vendor server. The implementation of the + * vendor server should be implemented by users. + */ +#ifndef OTBR_AGENT_VENDOR_HPP_ +#define OTBR_AGENT_VENDOR_HPP_ + +#include "openthread-br/config.h" + +#include "ncp/ncp_openthread.hpp" + +namespace otbr { +namespace vendor { + +class VendorServer +{ +public: + /** + * The constructor of vendor server. + * + * @param[in] aNcp A reference to the NCP controller. + * + */ + VendorServer(otbr::Ncp::ControllerOpenThread &aNcp) + : mNcp(aNcp) + { + } + + /** + * This method initializes the vendor server. + * + */ + void Init(void); + +private: + otbr::Ncp::ControllerOpenThread &mNcp; +}; +} // namespace vendor +} // namespace otbr +#endif // OTBR_AGENT_VENDOR_HPP_