From 76d91210a133a04dfc1d978302f4501f6ecabe36 Mon Sep 17 00:00:00 2001 From: chen0088 Date: Thu, 30 Nov 2023 21:03:11 +0800 Subject: [PATCH] add plugin subtype Signed-off-by: chen0088 --- screenhandler/include/dscreen_handler.h | 2 +- screenhandler/src/dscreen_handler.cpp | 7 ++++--- .../pluginhardware_fuzzer/pluginhardware_fuzzer.cpp | 3 ++- .../unittest/screenhandler/include/dscreen_handler_test.h | 3 ++- .../unittest/screenhandler/src/dscreen_handler_test.cpp | 5 +++-- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/screenhandler/include/dscreen_handler.h b/screenhandler/include/dscreen_handler.h index 21b4f2aa..272fb260 100644 --- a/screenhandler/include/dscreen_handler.h +++ b/screenhandler/include/dscreen_handler.h @@ -40,7 +40,7 @@ public: bool IsSupportPlugin() override; void RegisterPluginListener(std::shared_ptr listener) override; void UnRegisterPluginListener() override; - void PluginHardware(const std::string &dhId, const std::string &attr); + void PluginHardware(const std::string &dhId, const std::string &attr, const std::string &subtype); void UnPluginHardware(const std::string &dhId); std::string QueryCodecInfo(); diff --git a/screenhandler/src/dscreen_handler.cpp b/screenhandler/src/dscreen_handler.cpp index 68b017ea..d127e6f0 100644 --- a/screenhandler/src/dscreen_handler.cpp +++ b/screenhandler/src/dscreen_handler.cpp @@ -95,8 +95,9 @@ void ScreenListener::OnConnect(uint64_t screenId) attrJson[KEY_SCREEN_WIDTH] = screenWidth; attrJson[KEY_SCREEN_HEIGHT] = screenHeight; attrJson[KEY_CODECTYPE] = DScreenHandler::GetInstance().QueryCodecInfo(); + std::string subtype = "screen"; - DScreenHandler::GetInstance().PluginHardware(dhId, attrJson.dump()); + DScreenHandler::GetInstance().PluginHardware(dhId, attrJson.dump(), subtype); } void ScreenListener::OnDisconnect(uint64_t screenId) @@ -106,11 +107,11 @@ void ScreenListener::OnDisconnect(uint64_t screenId) DScreenHandler::GetInstance().UnPluginHardware(dhId); } -void DScreenHandler::PluginHardware(const std::string &dhId, const std::string &attr) +void DScreenHandler::PluginHardware(const std::string &dhId, const std::string &attr, const std::string &subtype) { DHLOGI("DScreenHandler PluginHardware"); if (listener_ != nullptr) { - listener_->PluginHardware(dhId, attr); + listener_->PluginHardware(dhId, attr, subtype); } } diff --git a/screenhandler/test/fuzztest/pluginhardware_fuzzer/pluginhardware_fuzzer.cpp b/screenhandler/test/fuzztest/pluginhardware_fuzzer/pluginhardware_fuzzer.cpp index dc8d2f23..b24a1c2f 100644 --- a/screenhandler/test/fuzztest/pluginhardware_fuzzer/pluginhardware_fuzzer.cpp +++ b/screenhandler/test/fuzztest/pluginhardware_fuzzer/pluginhardware_fuzzer.cpp @@ -30,8 +30,9 @@ void PluginHardwareFuzzTest(const uint8_t* data, size_t size) std::string dhId(reinterpret_cast(data), size); std::string attr(reinterpret_cast(data), size); + std::string subtype(reinterpret_cast(data), size); - DScreenHandler::GetInstance().PluginHardware(dhId, attr); + DScreenHandler::GetInstance().PluginHardware(dhId, attr, subtype); } } } diff --git a/screenhandler/test/unittest/screenhandler/include/dscreen_handler_test.h b/screenhandler/test/unittest/screenhandler/include/dscreen_handler_test.h index 0533fcd0..3e0ea6e7 100644 --- a/screenhandler/test/unittest/screenhandler/include/dscreen_handler_test.h +++ b/screenhandler/test/unittest/screenhandler/include/dscreen_handler_test.h @@ -39,10 +39,11 @@ class MockPluginListener : public PluginListener { public: MockPluginListener() = default; virtual ~MockPluginListener() = default; - void PluginHardware(const std::string &dhId, const std::string &attrs) override + void PluginHardware(const std::string &dhId, const std::string &attrs, const std::string &subtype) override { (void) dhId; (void) attrs; + (void) subtype; return; } void UnPluginHardware(const std::string &dhId) override diff --git a/screenhandler/test/unittest/screenhandler/src/dscreen_handler_test.cpp b/screenhandler/test/unittest/screenhandler/src/dscreen_handler_test.cpp index 182179bc..e1268a64 100644 --- a/screenhandler/test/unittest/screenhandler/src/dscreen_handler_test.cpp +++ b/screenhandler/test/unittest/screenhandler/src/dscreen_handler_test.cpp @@ -47,11 +47,12 @@ HWTEST_F(DScreenHandlerTest, Initialize_001, TestSize.Level1) const std::string dhId = "dhId"; const std::string attr = "attr"; + const std::string subtype = "screen"; DScreenHandler::GetInstance().listener_ = nullptr; - DScreenHandler::GetInstance().PluginHardware(dhId, attr); + DScreenHandler::GetInstance().PluginHardware(dhId, attr, subtype); DScreenHandler::GetInstance().UnPluginHardware(dhId); DScreenHandler::GetInstance().listener_ = std::make_shared(); - DScreenHandler::GetInstance().PluginHardware(dhId, attr); + DScreenHandler::GetInstance().PluginHardware(dhId, attr, subtype); DScreenHandler::GetInstance().UnPluginHardware(dhId); EXPECT_EQ(DH_SUCCESS, ret); } -- Gitee