From e15f2e8304a891599a342627c15245fddb7fc6e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=AF=E4=BF=8A=E6=A1=A6?= Date: Wed, 2 Jul 2025 17:53:10 +0800 Subject: [PATCH 1/3] =?UTF-8?q?AI=E6=A3=80=E8=A7=86=E6=84=8F=E8=A7=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 冯俊桦 --- .../audio_source/src/daudio_hdf_operate.cpp | 2 +- .../audiosinktest/src/daudio_sink_proxy_test.cpp | 2 +- .../src/daudio_ipc_callback_test.cpp | 2 +- .../src/daudio_source_handler_test.cpp | 14 +++++++------- .../src/daudio_source_dev_ctrl_manager_test.cpp | 2 +- services/audiohdiproxy/src/daudio_hdi_handler.cpp | 2 +- .../src/daudio_hdi_handler_test.cpp | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/interfaces/inner_kits/native_cpp/audio_source/src/daudio_hdf_operate.cpp b/interfaces/inner_kits/native_cpp/audio_source/src/daudio_hdf_operate.cpp index 61a78108..40c2e4e9 100644 --- a/interfaces/inner_kits/native_cpp/audio_source/src/daudio_hdf_operate.cpp +++ b/interfaces/inner_kits/native_cpp/audio_source/src/daudio_hdf_operate.cpp @@ -281,7 +281,7 @@ int32_t DaudioHdfOperate::MakeFwkDAudioHdfCallback() { std::lock_guard locker(fwkDAudioHdfCallbackMutex_); if (fwkDAudioHdfCallback_ == nullptr) { - fwkDAudioHdfCallback_ = new FwkDAudioHdfCallback(); + fwkDAudioHdfCallback_ = sptr(new FwkDAudioHdfCallback()); if (fwkDAudioHdfCallback_ == nullptr) { return ERR_DH_AUDIO_NULLPTR; } diff --git a/interfaces/inner_kits/native_cpp/test/unittest/audiosinktest/src/daudio_sink_proxy_test.cpp b/interfaces/inner_kits/native_cpp/test/unittest/audiosinktest/src/daudio_sink_proxy_test.cpp index 393ed6c7..0d8c4874 100644 --- a/interfaces/inner_kits/native_cpp/test/unittest/audiosinktest/src/daudio_sink_proxy_test.cpp +++ b/interfaces/inner_kits/native_cpp/test/unittest/audiosinktest/src/daudio_sink_proxy_test.cpp @@ -104,7 +104,7 @@ HWTEST_F(DAudioSinkProxyTest, InitSink_001, TestSize.Level1) { ASSERT_TRUE(dAudioProxy != nullptr); const std::string params = "params"; - auto dAudioSinkIpcCallback = new DAudioSinkIpcCallback(); + auto dAudioSinkIpcCallback = sptr(new DAudioSinkIpcCallback()); int32_t ret = dAudioProxy->InitSink(params, dAudioSinkIpcCallback); EXPECT_EQ(DH_SUCCESS, ret); ret = dAudioProxy->ReleaseSink(); diff --git a/interfaces/inner_kits/native_cpp/test/unittest/audiosourcetest/src/daudio_ipc_callback_test.cpp b/interfaces/inner_kits/native_cpp/test/unittest/audiosourcetest/src/daudio_ipc_callback_test.cpp index 5768c77a..ad5f3de6 100644 --- a/interfaces/inner_kits/native_cpp/test/unittest/audiosourcetest/src/daudio_ipc_callback_test.cpp +++ b/interfaces/inner_kits/native_cpp/test/unittest/audiosourcetest/src/daudio_ipc_callback_test.cpp @@ -28,7 +28,7 @@ void DAudioIpcCallbackTest::TearDownTestCase(void) {} void DAudioIpcCallbackTest::SetUp(void) { - dAudioIpcCallback_ = new DAudioIpcCallback(); + dAudioIpcCallback_ = sptr(new DAudioIpcCallback()); } void DAudioIpcCallbackTest::TearDown(void) diff --git a/interfaces/inner_kits/native_cpp/test/unittest/audiosourcetest/src/daudio_source_handler_test.cpp b/interfaces/inner_kits/native_cpp/test/unittest/audiosourcetest/src/daudio_source_handler_test.cpp index 0e5752b7..65635e59 100644 --- a/interfaces/inner_kits/native_cpp/test/unittest/audiosourcetest/src/daudio_source_handler_test.cpp +++ b/interfaces/inner_kits/native_cpp/test/unittest/audiosourcetest/src/daudio_source_handler_test.cpp @@ -50,7 +50,7 @@ HWTEST_F(DAudioSourceHandlerTest, RegisterDistributedHardware_001, TestSize.Leve param.sinkVersion = "1"; param.sinkAttrs = "attrs"; std::shared_ptr callback = std::make_shared(); - DAudioSourceHandler::GetInstance().dAudioSourceProxy_ = new MockIDAudioSource(); + DAudioSourceHandler::GetInstance().dAudioSourceProxy_ =sptr(new MockIDAudioSource()); int32_t ret = DAudioSourceHandler::GetInstance().RegisterDistributedHardware(devId, dhId, param, callback); EXPECT_EQ(DH_SUCCESS, ret); std::shared_ptr uncallback = std::make_shared(); @@ -73,7 +73,7 @@ HWTEST_F(DAudioSourceHandlerTest, RegisterDistributedHardware_002, TestSize.Leve param.sinkAttrs = "attrs"; std::shared_ptr callback = std::make_shared(); DAudioSourceHandler::GetInstance().dAudioIpcCallback_ = nullptr; - DAudioSourceHandler::GetInstance().dAudioSourceProxy_ = new MockIDAudioSource(); + DAudioSourceHandler::GetInstance().dAudioSourceProxy_ = sptr(new MockIDAudioSource()); int32_t ret = DAudioSourceHandler::GetInstance().RegisterDistributedHardware(devId, dhId, param, callback); EXPECT_EQ(ERR_DH_AUDIO_NULLPTR, ret); std::shared_ptr uncallback = std::make_shared(); @@ -121,8 +121,8 @@ HWTEST_F(DAudioSourceHandlerTest, RegisterDistributedHardware_004, TestSize.Leve param.sinkVersion = "1"; param.sinkAttrs = "attrs"; std::shared_ptr callback = std::make_shared(); - DAudioSourceHandler::GetInstance().dAudioSourceProxy_ = new MockIDAudioSource(); - DAudioSourceHandler::GetInstance().dAudioIpcCallback_ = new DAudioIpcCallback(); + DAudioSourceHandler::GetInstance().dAudioSourceProxy_ =sptr(new MockIDAudioSource()); + DAudioSourceHandler::GetInstance().dAudioIpcCallback_ =sptr(new DAudioIpcCallback()); int32_t ret = DAudioSourceHandler::GetInstance().RegisterDistributedHardware(devId, dhId, param, callback); EXPECT_EQ(ERR_DH_AUDIO_SA_DEVID_ILLEGAL, ret); std::shared_ptr uncallback = std::make_shared(); @@ -157,7 +157,7 @@ HWTEST_F(DAudioSourceHandlerTest, ReleaseSource_001, TestSize.Level1) */ HWTEST_F(DAudioSourceHandlerTest, ReleaseSource_002, TestSize.Level1) { - DAudioSourceHandler::GetInstance().dAudioSourceProxy_ = new MockIDAudioSource(); + DAudioSourceHandler::GetInstance().dAudioSourceProxy_ =sptr(new MockIDAudioSource()); int32_t ret = DAudioSourceHandler::GetInstance().ReleaseSource(); EXPECT_EQ(DH_SUCCESS, ret); wptr remote = nullptr; @@ -196,7 +196,7 @@ HWTEST_F(DAudioSourceHandlerTest, ConfigDistributedHardware_002, TestSize.Level1 size_t DAUDIO_LEGAL_DEVICE_ID_LEN = 10; std::string devId; devId.resize(DAUDIO_MAX_DEVICE_ID_LEN); - DAudioSourceHandler::GetInstance().dAudioSourceProxy_ = new MockIDAudioSource(); + DAudioSourceHandler::GetInstance().dAudioSourceProxy_ =sptr(new MockIDAudioSource()); int32_t ret = DAudioSourceHandler::GetInstance().ConfigDistributedHardware(devId, dhId, key, value); EXPECT_EQ(ERR_DH_AUDIO_SA_DEVID_ILLEGAL, ret); devId.resize(DAUDIO_LEGAL_DEVICE_ID_LEN); @@ -217,7 +217,7 @@ HWTEST_F(DAudioSourceHandlerTest, ConfigDistributedHardware_003, TestSize.Level1 std::string dhId = "dhId"; std::string key = "key"; std::string value = "value"; - DAudioSourceHandler::GetInstance().dAudioSourceProxy_ = new MockIDAudioSource(); + DAudioSourceHandler::GetInstance().dAudioSourceProxy_ =sptr(new MockIDAudioSource()); int32_t ret = DAudioSourceHandler::GetInstance().ConfigDistributedHardware(devId, dhId, key, value); EXPECT_EQ(DH_SUCCESS, ret); } diff --git a/services/audiocontrol/test/unittest/controlsource/src/daudio_source_dev_ctrl_manager_test.cpp b/services/audiocontrol/test/unittest/controlsource/src/daudio_source_dev_ctrl_manager_test.cpp index a3a63c86..cf3fcd04 100644 --- a/services/audiocontrol/test/unittest/controlsource/src/daudio_source_dev_ctrl_manager_test.cpp +++ b/services/audiocontrol/test/unittest/controlsource/src/daudio_source_dev_ctrl_manager_test.cpp @@ -30,7 +30,7 @@ void DAudioSourceDevCtrlMgrTest::TearDownTestCase(void) {} void DAudioSourceDevCtrlMgrTest::SetUp(void) { uint64_t tokenId; - const char** perms = new const char *[2]; + const char* perms[2] = {"ohos.permisson.DISTRIBUTED_DATASYNC", "ohos.permission.DISTRIBUTED_SOFTBUS_CENTER"} perms[0] = "ohos.permission.DISTRIBUTED_DATASYNC"; perms[1] = "ohos.permission.DISTRIBUTED_SOFTBUS_CENTER"; NativeTokenInfoParams infoInstance = { diff --git a/services/audiohdiproxy/src/daudio_hdi_handler.cpp b/services/audiohdiproxy/src/daudio_hdi_handler.cpp index 50cd997f..04023714 100644 --- a/services/audiohdiproxy/src/daudio_hdi_handler.cpp +++ b/services/audiohdiproxy/src/daudio_hdi_handler.cpp @@ -40,7 +40,7 @@ IMPLEMENT_SINGLE_INSTANCE(DAudioHdiHandler); DAudioHdiHandler::DAudioHdiHandler() { DHLOGD("Distributed audio hdi handler construct."); - audioHdiRecipient_ = new AudioHdiRecipient(); + audioHdiRecipient_ =sptr(new AudioHdiRecipient()); } DAudioHdiHandler::~DAudioHdiHandler() diff --git a/services/audiohdiproxy/test/unittest/daudio_hdi_handler/src/daudio_hdi_handler_test.cpp b/services/audiohdiproxy/test/unittest/daudio_hdi_handler/src/daudio_hdi_handler_test.cpp index 79308438..c8652dbf 100644 --- a/services/audiohdiproxy/test/unittest/daudio_hdi_handler/src/daudio_hdi_handler_test.cpp +++ b/services/audiohdiproxy/test/unittest/daudio_hdi_handler/src/daudio_hdi_handler_test.cpp @@ -109,7 +109,7 @@ HWTEST_F(DAudioHdiHandlerTest, NotifyEvent_002, TestSize.Level1) { ASSERT_TRUE(hdiHandler_ != nullptr); EXPECT_EQ(HDF_SUCCESS, hdiHandler_->InitHdiHandler()); - hdiHandler_->audioSrvHdf_ = new MockIDAudioManager(); + hdiHandler_->audioSrvHdf_ =sptr(new MockIDAudioManager()); AudioEvent audioEvent1(AudioEventType::NOTIFY_OPEN_SPEAKER_RESULT, ""); EXPECT_EQ(HDF_SUCCESS, hdiHandler_->NotifyEvent(devId_, dhId_, streamId_, audioEvent1)); AudioEvent audioEvent2(AudioEventType::NOTIFY_CLOSE_SPEAKER_RESULT, ""); -- Gitee From 1b9e0a9abe4e795a32308713218068ccc9abfc45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=AF=E4=BF=8A=E6=A1=A6?= Date: Wed, 2 Jul 2025 17:59:58 +0800 Subject: [PATCH 2/3] =?UTF-8?q?AI=E6=A3=80=E8=A7=86=E6=84=8F=E8=A7=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 冯俊桦 --- .../src/daudio_source_handler_test.cpp | 12 ++++++------ .../src/daudio_source_dev_ctrl_manager_test.cpp | 2 +- services/audiohdiproxy/src/daudio_hdi_handler.cpp | 2 +- .../src/daudio_hdi_handler_test.cpp | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/interfaces/inner_kits/native_cpp/test/unittest/audiosourcetest/src/daudio_source_handler_test.cpp b/interfaces/inner_kits/native_cpp/test/unittest/audiosourcetest/src/daudio_source_handler_test.cpp index 65635e59..7f41fb1e 100644 --- a/interfaces/inner_kits/native_cpp/test/unittest/audiosourcetest/src/daudio_source_handler_test.cpp +++ b/interfaces/inner_kits/native_cpp/test/unittest/audiosourcetest/src/daudio_source_handler_test.cpp @@ -50,7 +50,7 @@ HWTEST_F(DAudioSourceHandlerTest, RegisterDistributedHardware_001, TestSize.Leve param.sinkVersion = "1"; param.sinkAttrs = "attrs"; std::shared_ptr callback = std::make_shared(); - DAudioSourceHandler::GetInstance().dAudioSourceProxy_ =sptr(new MockIDAudioSource()); + DAudioSourceHandler::GetInstance().dAudioSourceProxy_ = sptr(new MockIDAudioSource()); int32_t ret = DAudioSourceHandler::GetInstance().RegisterDistributedHardware(devId, dhId, param, callback); EXPECT_EQ(DH_SUCCESS, ret); std::shared_ptr uncallback = std::make_shared(); @@ -121,8 +121,8 @@ HWTEST_F(DAudioSourceHandlerTest, RegisterDistributedHardware_004, TestSize.Leve param.sinkVersion = "1"; param.sinkAttrs = "attrs"; std::shared_ptr callback = std::make_shared(); - DAudioSourceHandler::GetInstance().dAudioSourceProxy_ =sptr(new MockIDAudioSource()); - DAudioSourceHandler::GetInstance().dAudioIpcCallback_ =sptr(new DAudioIpcCallback()); + DAudioSourceHandler::GetInstance().dAudioSourceProxy_ = sptr(new MockIDAudioSource()); + DAudioSourceHandler::GetInstance().dAudioIpcCallback_ = sptr(new DAudioIpcCallback()); int32_t ret = DAudioSourceHandler::GetInstance().RegisterDistributedHardware(devId, dhId, param, callback); EXPECT_EQ(ERR_DH_AUDIO_SA_DEVID_ILLEGAL, ret); std::shared_ptr uncallback = std::make_shared(); @@ -157,7 +157,7 @@ HWTEST_F(DAudioSourceHandlerTest, ReleaseSource_001, TestSize.Level1) */ HWTEST_F(DAudioSourceHandlerTest, ReleaseSource_002, TestSize.Level1) { - DAudioSourceHandler::GetInstance().dAudioSourceProxy_ =sptr(new MockIDAudioSource()); + DAudioSourceHandler::GetInstance().dAudioSourceProxy_ = sptr(new MockIDAudioSource()); int32_t ret = DAudioSourceHandler::GetInstance().ReleaseSource(); EXPECT_EQ(DH_SUCCESS, ret); wptr remote = nullptr; @@ -196,7 +196,7 @@ HWTEST_F(DAudioSourceHandlerTest, ConfigDistributedHardware_002, TestSize.Level1 size_t DAUDIO_LEGAL_DEVICE_ID_LEN = 10; std::string devId; devId.resize(DAUDIO_MAX_DEVICE_ID_LEN); - DAudioSourceHandler::GetInstance().dAudioSourceProxy_ =sptr(new MockIDAudioSource()); + DAudioSourceHandler::GetInstance().dAudioSourceProxy_ = sptr(new MockIDAudioSource()); int32_t ret = DAudioSourceHandler::GetInstance().ConfigDistributedHardware(devId, dhId, key, value); EXPECT_EQ(ERR_DH_AUDIO_SA_DEVID_ILLEGAL, ret); devId.resize(DAUDIO_LEGAL_DEVICE_ID_LEN); @@ -217,7 +217,7 @@ HWTEST_F(DAudioSourceHandlerTest, ConfigDistributedHardware_003, TestSize.Level1 std::string dhId = "dhId"; std::string key = "key"; std::string value = "value"; - DAudioSourceHandler::GetInstance().dAudioSourceProxy_ =sptr(new MockIDAudioSource()); + DAudioSourceHandler::GetInstance().dAudioSourceProxy_ = sptr(new MockIDAudioSource()); int32_t ret = DAudioSourceHandler::GetInstance().ConfigDistributedHardware(devId, dhId, key, value); EXPECT_EQ(DH_SUCCESS, ret); } diff --git a/services/audiocontrol/test/unittest/controlsource/src/daudio_source_dev_ctrl_manager_test.cpp b/services/audiocontrol/test/unittest/controlsource/src/daudio_source_dev_ctrl_manager_test.cpp index cf3fcd04..fe8a711a 100644 --- a/services/audiocontrol/test/unittest/controlsource/src/daudio_source_dev_ctrl_manager_test.cpp +++ b/services/audiocontrol/test/unittest/controlsource/src/daudio_source_dev_ctrl_manager_test.cpp @@ -30,7 +30,7 @@ void DAudioSourceDevCtrlMgrTest::TearDownTestCase(void) {} void DAudioSourceDevCtrlMgrTest::SetUp(void) { uint64_t tokenId; - const char* perms[2] = {"ohos.permisson.DISTRIBUTED_DATASYNC", "ohos.permission.DISTRIBUTED_SOFTBUS_CENTER"} + const char* perms[2] = {"ohos.permisson.DISTRIBUTED_DATASYNC", "ohos.permission.DISTRIBUTED_SOFTBUS_CENTER"}; perms[0] = "ohos.permission.DISTRIBUTED_DATASYNC"; perms[1] = "ohos.permission.DISTRIBUTED_SOFTBUS_CENTER"; NativeTokenInfoParams infoInstance = { diff --git a/services/audiohdiproxy/src/daudio_hdi_handler.cpp b/services/audiohdiproxy/src/daudio_hdi_handler.cpp index 04023714..29fcb356 100644 --- a/services/audiohdiproxy/src/daudio_hdi_handler.cpp +++ b/services/audiohdiproxy/src/daudio_hdi_handler.cpp @@ -40,7 +40,7 @@ IMPLEMENT_SINGLE_INSTANCE(DAudioHdiHandler); DAudioHdiHandler::DAudioHdiHandler() { DHLOGD("Distributed audio hdi handler construct."); - audioHdiRecipient_ =sptr(new AudioHdiRecipient()); + audioHdiRecipient_ = sptr(new AudioHdiRecipient()); } DAudioHdiHandler::~DAudioHdiHandler() diff --git a/services/audiohdiproxy/test/unittest/daudio_hdi_handler/src/daudio_hdi_handler_test.cpp b/services/audiohdiproxy/test/unittest/daudio_hdi_handler/src/daudio_hdi_handler_test.cpp index c8652dbf..4e51346b 100644 --- a/services/audiohdiproxy/test/unittest/daudio_hdi_handler/src/daudio_hdi_handler_test.cpp +++ b/services/audiohdiproxy/test/unittest/daudio_hdi_handler/src/daudio_hdi_handler_test.cpp @@ -109,7 +109,7 @@ HWTEST_F(DAudioHdiHandlerTest, NotifyEvent_002, TestSize.Level1) { ASSERT_TRUE(hdiHandler_ != nullptr); EXPECT_EQ(HDF_SUCCESS, hdiHandler_->InitHdiHandler()); - hdiHandler_->audioSrvHdf_ =sptr(new MockIDAudioManager()); + hdiHandler_->audioSrvHdf_ = sptr(new MockIDAudioManager()); AudioEvent audioEvent1(AudioEventType::NOTIFY_OPEN_SPEAKER_RESULT, ""); EXPECT_EQ(HDF_SUCCESS, hdiHandler_->NotifyEvent(devId_, dhId_, streamId_, audioEvent1)); AudioEvent audioEvent2(AudioEventType::NOTIFY_CLOSE_SPEAKER_RESULT, ""); -- Gitee From cd3010519e8460eb2d6c5e5d897f85c5a590314d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=AF=E4=BF=8A=E6=A1=A6?= Date: Wed, 2 Jul 2025 18:38:03 +0800 Subject: [PATCH 3/3] =?UTF-8?q?AI=E6=A3=80=E8=A7=86=E6=84=8F=E8=A7=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 冯俊桦 --- .../native_cpp/audio_sink/src/daudio_sink_ipc_callback.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/interfaces/inner_kits/native_cpp/audio_sink/src/daudio_sink_ipc_callback.cpp b/interfaces/inner_kits/native_cpp/audio_sink/src/daudio_sink_ipc_callback.cpp index b9bdcb1b..7b5033fb 100644 --- a/interfaces/inner_kits/native_cpp/audio_sink/src/daudio_sink_ipc_callback.cpp +++ b/interfaces/inner_kits/native_cpp/audio_sink/src/daudio_sink_ipc_callback.cpp @@ -36,6 +36,7 @@ int32_t DAudioSinkIpcCallback::OnNotifyResourceInfo(const ResourceEventType &typ std::lock_guard resourceLck(privacyResMtx_); auto iter = privacyResCallback_.begin(); if (iter != privacyResCallback_.end()) { + CHECK_NULL_RETURN(*iter, ERR_DH_AUDIO_NULLPTR); ret = (*iter)->OnPrivaceResourceMessage(type, subType, networkId, isSensitive, isSameAccount); } return ret; -- Gitee