diff --git a/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/src/dscreen_source_handler_test.cpp b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/src/dscreen_source_handler_test.cpp index 9e02c4fe6fbf29044bf3de76d286e923e1a9aa11..672064aa82d2b20275fc73fa7721a7e68380d8a4 100644 --- a/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/src/dscreen_source_handler_test.cpp +++ b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/src/dscreen_source_handler_test.cpp @@ -32,7 +32,7 @@ void DScreenSourceHandlerTest::TearDownTestCase(void) {} void DScreenSourceHandlerTest::SetUp(void) { - DScreenSourceHandler::GetInstance().InitSource("DScreenSourceHandlerTest"); + DScreenSourceHandler::GetInstance().InitSource("2.0"); } void DScreenSourceHandlerTest::TearDown(void) @@ -84,12 +84,11 @@ HWTEST_F(DScreenSourceHandlerTest, RegisterDistributedHardware_001, TestSize.Lev param.version = "2.0"; param.attrs = "attrs"; std::string callbackParam = "callbackParam"; - DScreenSourceHandler::GetInstance().InitSource("DScreenSourceHandlerTest"); sptr loadCallback = new DScreenSourceLoadCallback(callbackParam); loadCallback->OnLoadSystemAbilitySuccess(DISTRIBUTED_HARDWARE_SCREEN_SOURCE_SA_ID, nullptr); std::shared_ptr callback = std::make_shared(); int32_t ret = DScreenSourceHandler::GetInstance().RegisterDistributedHardware(devId, dhId, param, callback); - EXPECT_EQ(ERR_DH_SCREEN_SA_ENABLE_FAILED, ret); + EXPECT_EQ(DH_SUCCESS, ret); } /** diff --git a/services/screenservice/sinkservice/screenregionmgr/2.0/src/screenregion.cpp b/services/screenservice/sinkservice/screenregionmgr/2.0/src/screenregion.cpp index c0a5dbc8e28bd4bcaf5d7f1bcd3fc93ea22a6ebf..413cf2ac41d91269cfd59ab2cc6aac6602d0646d 100644 --- a/services/screenservice/sinkservice/screenregionmgr/2.0/src/screenregion.cpp +++ b/services/screenservice/sinkservice/screenregionmgr/2.0/src/screenregion.cpp @@ -337,7 +337,6 @@ void ScreenRegion::OnEngineDataDone(const std::shared_ptr &buffer return; } GetWSBuffer(wsBuffer, buffer); - BufferFlushConfig flushConfig = { {0, 0, wsBuffer->GetWidth(), wsBuffer->GetHeight()}, 0}; surfaceErr = windowSurface_->FlushBuffer(wsBuffer, -1, flushConfig); if (surfaceErr != SURFACE_ERROR_OK) { diff --git a/services/screenservice/sourceservice/dscreenmgr/1.0/src/dscreen_manager.cpp b/services/screenservice/sourceservice/dscreenmgr/1.0/src/dscreen_manager.cpp index 8843ef5e858ff941f98e3cb2d44d9a03c71fa4ad..7208302b5fb6050272df5caa429f5308c2529aaa 100644 --- a/services/screenservice/sourceservice/dscreenmgr/1.0/src/dscreen_manager.cpp +++ b/services/screenservice/sourceservice/dscreenmgr/1.0/src/dscreen_manager.cpp @@ -65,7 +65,6 @@ int32_t DScreenManager::Init() int32_t ret = ScreenMgrAdapter::GetInstance().RegisterScreenGroupListener(dScreenGroupListener_); if (ret != DH_SUCCESS) { DHLOGE("DScreenManager Init failed, err: %" PRId32, ret); - delete dScreenGroupListener_; dScreenGroupListener_ = nullptr; return ret; } @@ -293,7 +292,10 @@ int32_t DScreenManager::DisableDistributedScreen(const std::string &devId, const GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str()); return ERR_DH_SCREEN_SA_DISABLE_FAILED; } - + if (dScreens_[dScreenIdx] == nullptr) { + DHLOGE("dScreen is nullptr."); + return ERR_DH_SCREEN_SA_DISABLE_FAILED; + } int32_t dScreenState = dScreens_[dScreenIdx]->GetState(); int32_t ret = DH_SUCCESS; switch (dScreenState) { @@ -540,6 +542,10 @@ void DScreenManager::HandleNotifySetUpResult(const std::string &remoteDevId, con if (errCode != DH_SUCCESS) { DHLOGE("remote sink set up failed, errCode: %" PRId32", reason: %s", errCode, errContent.c_str()); + if (dScreens_[dScreenIdx] == nullptr) { + DHLOGE("dScreen is nullptr."); + return; + } dScreens_[dScreenIdx]->SetState(ENABLED); return; }