From 1d336a94829e0d0c6e5c84a933457e7ac4689ba9 Mon Sep 17 00:00:00 2001 From: Tome Date: Mon, 14 Jul 2025 14:19:01 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A9=BA=E6=8C=87=E9=92=88=E8=A7=A3=E5=BC=95?= =?UTF-8?q?=E7=94=A8=E3=80=81UT=E7=AD=89=E6=A3=80=E8=A7=86=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tome --- common/src/utils/dcamera_utils_tools.cpp | 2 +- .../src/callback/dcamera_source_callback.cpp | 12 +++++++ .../src/distributed_camera_source_proxy.cpp | 2 +- .../onsinklocalcamsrvdied_fuzzer.cpp | 3 ++ .../sinkonloadsystemabilitysuccess_fuzzer.cpp | 3 ++ .../sinkproxychannelneg_fuzzer.cpp | 3 ++ .../sinkproxyclosechannel_fuzzer.cpp | 3 ++ .../sinkproxygetcamerainfo_fuzzer.cpp | 3 ++ .../sinkproxyinitsink_fuzzer.cpp | 3 ++ .../sinkproxyopenchannel_fuzzer.cpp | 3 ++ .../sinkproxyreleasesink_fuzzer.cpp | 3 ++ .../sinkproxystopcapture_fuzzer.cpp | 3 ++ ...sinkproxysubscribelocalhardware_fuzzer.cpp | 3 ++ ...nkproxyunsubscribelocalhardware_fuzzer.cpp | 3 ++ .../onsourcelocalcamsrvdied_fuzzer.cpp | 3 ++ .../sourceproxydcameranotify_fuzzer.cpp | 3 ++ .../sourceproxyinitsource_fuzzer.cpp | 3 ++ ...roxyregisterdistributedhardware_fuzzer.cpp | 3 ++ ...xyunregisterdistributedhardware_fuzzer.cpp | 3 ++ .../dcamera_sink_handler_ipc_test.cpp | 1 + .../camera_sink/dcamera_sink_handler_test.cpp | 1 + .../dcamera_source_handler_ipc_test.cpp | 1 + .../dcamera_source_handler_test.cpp | 1 + .../base/src/dcamera_channel_info_cmd.cpp | 4 +++ .../client/src/dcamera_client.cpp | 32 +++++++++++++---- .../handler/src/dcamera_handler.cpp | 14 +++++--- .../distributed_camera_sink_service.cpp | 7 ++-- .../dcamera_sink_data_process.cpp | 1 + .../dcamera_sink_output.cpp | 16 ++++++++- .../dcamera_sink_service_ipc.cpp | 4 ++- .../dcamera_sink_callback_proxy_test.cpp | 1 + .../dcamera_source_dev.cpp | 1 + .../dcamera_source_service_ipc.cpp | 4 ++- .../dcamera_source_controller.cpp | 5 +++ .../dcamera_source_data_process.cpp | 6 ++++ .../dcameradata/dcamera_source_input.cpp | 34 ++++++++++++++++--- .../dcamera_stream_data_process.cpp | 3 ++ .../dcamera_stream_data_process_producer.cpp | 2 ++ .../base/ifeeding_smoother.cpp | 1 + .../base/time_statistician.cpp | 1 + .../derived/dcamera_feeding_smoother.cpp | 1 + .../derived/dcamera_time_statistician.cpp | 2 ++ .../dcamera_source_capture_state.cpp | 6 ++++ .../dcamera_source_config_stream_state.cpp | 7 ++++ .../dcamera_source_init_state.cpp | 1 + .../dcamera_source_opened_state.cpp | 5 +++ .../dcamera_source_regist_state.cpp | 4 +++ .../dcamera_source_state_machine.cpp | 5 +++ .../dcamera_source_callback_proxy_test.cpp | 7 ++++ ...distributed_camera_source_service_test.cpp | 1 + .../dcamera_source_service_ipc_test.cpp | 1 + .../distributed_camera_allconnect_manager.cpp | 2 ++ .../fpscontroller/fps_controller_process.cpp | 2 +- 53 files changed, 223 insertions(+), 25 deletions(-) diff --git a/common/src/utils/dcamera_utils_tools.cpp b/common/src/utils/dcamera_utils_tools.cpp index 8d21d2d0..ddba00d7 100644 --- a/common/src/utils/dcamera_utils_tools.cpp +++ b/common/src/utils/dcamera_utils_tools.cpp @@ -324,7 +324,7 @@ FILE *DumpFileUtil::OpenDumpFileInner(std::string para, std::string fileName) g_lastPara[para] = dumpPara; return dumpFile; } - DHLOGD("%{public}s = %{public}s, filePath: %{public}s", para.c_str(), dumpPara.c_str(), path); + if (dumpPara == "w") { dumpFile = fopen(path, "wb+"); CHECK_AND_RETURN_RET_LOG(dumpFile == nullptr, dumpFile, "Error opening dump file!"); diff --git a/interfaces/inner_kits/native_cpp/camera_source/src/callback/dcamera_source_callback.cpp b/interfaces/inner_kits/native_cpp/camera_source/src/callback/dcamera_source_callback.cpp index 258d3fbb..44020a15 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/src/callback/dcamera_source_callback.cpp +++ b/interfaces/inner_kits/native_cpp/camera_source/src/callback/dcamera_source_callback.cpp @@ -39,6 +39,13 @@ int32_t DCameraSourceCallback::OnNotifyRegResult(const std::string& devId, const GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str()); return DCAMERA_NOT_FOUND; } + + if (iter->second == nullptr) { + DHLOGE("DCameraSourceCallback OnNotifyRegResult callback is null"); + regCallbacks_.erase(iter); + return DCAMERA_BAD_VALUE; + } + int32_t ret = iter->second->OnRegisterResult(devId, dhId, status, data); if (ret != DCAMERA_OK) { DHLOGE("DCameraSourceCallback OnNotifyRegResult failed, devId: %{public}s dhId: %{public}s ret: %{public}d", @@ -60,6 +67,11 @@ int32_t DCameraSourceCallback::OnNotifyUnregResult(const std::string& devId, con GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str()); return DCAMERA_NOT_FOUND; } + if (iter->second == nullptr) { + DHLOGE("DCameraSourceCallback OnNotifyUnregResult callback is null"); + unregCallbacks_.erase(iter); + return DCAMERA_BAD_VALUE; + } int32_t ret = iter->second->OnUnregisterResult(devId, dhId, status, data); if (ret != DCAMERA_OK) { DHLOGE("DCameraSourceCallback OnNotifyUnregResult failed, devId: %{public}s dhId: %{public}s ret: %{public}d", diff --git a/interfaces/inner_kits/native_cpp/camera_source/src/distributed_camera_source_proxy.cpp b/interfaces/inner_kits/native_cpp/camera_source/src/distributed_camera_source_proxy.cpp index bcbc124a..b42201ef 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/src/distributed_camera_source_proxy.cpp +++ b/interfaces/inner_kits/native_cpp/camera_source/src/distributed_camera_source_proxy.cpp @@ -51,7 +51,7 @@ int32_t DistributedCameraSourceProxy::InitSource(const std::string& params, return DCAMERA_BAD_VALUE; } - if (!data.WriteRemoteObject(callback->AsObject())) { + if (callback != nullptr && !data.WriteRemoteObject(callback->AsObject())) { DHLOGE("write callback failed"); return DCAMERA_BAD_VALUE; } diff --git a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/onsinklocalcamsrvdied_fuzzer/onsinklocalcamsrvdied_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/onsinklocalcamsrvdied_fuzzer/onsinklocalcamsrvdied_fuzzer.cpp index 8947d923..ad71efac 100644 --- a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/onsinklocalcamsrvdied_fuzzer/onsinklocalcamsrvdied_fuzzer.cpp +++ b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/onsinklocalcamsrvdied_fuzzer/onsinklocalcamsrvdied_fuzzer.cpp @@ -35,6 +35,9 @@ void OnSinkLocalCamSrvDiedFuzzTest(const uint8_t* data, size_t size) int32_t saId = *(reinterpret_cast(data)); sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (samgr == nullptr) { + return; + } sptr remoteObject = samgr->GetSystemAbility(saId); wptr remote (remoteObject); diff --git a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkonloadsystemabilitysuccess_fuzzer/sinkonloadsystemabilitysuccess_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkonloadsystemabilitysuccess_fuzzer/sinkonloadsystemabilitysuccess_fuzzer.cpp index c5f470a6..b6021667 100644 --- a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkonloadsystemabilitysuccess_fuzzer/sinkonloadsystemabilitysuccess_fuzzer.cpp +++ b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkonloadsystemabilitysuccess_fuzzer/sinkonloadsystemabilitysuccess_fuzzer.cpp @@ -37,6 +37,9 @@ void SinkOnLoadSystemAbilitySuccessFuzzTest(const uint8_t* data, size_t size) sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (samgr == nullptr) { + return; + } sptr remoteObject = samgr->GetSystemAbility(systemAbilityId); callback->OnLoadSystemAbilitySuccess(systemAbilityId, remoteObject); diff --git a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxychannelneg_fuzzer/sinkproxychannelneg_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxychannelneg_fuzzer/sinkproxychannelneg_fuzzer.cpp index 453b1ac2..d4dd0255 100644 --- a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxychannelneg_fuzzer/sinkproxychannelneg_fuzzer.cpp +++ b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxychannelneg_fuzzer/sinkproxychannelneg_fuzzer.cpp @@ -36,6 +36,9 @@ void SinkProxyChannelNegFuzzTest(const uint8_t* data, size_t size) sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (samgr == nullptr) { + return; + } sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID); std::shared_ptr dCSinkProxy = std::make_shared(remoteObject); diff --git a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxyclosechannel_fuzzer/sinkproxyclosechannel_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxyclosechannel_fuzzer/sinkproxyclosechannel_fuzzer.cpp index 1bf7996e..f1ac84dd 100644 --- a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxyclosechannel_fuzzer/sinkproxyclosechannel_fuzzer.cpp +++ b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxyclosechannel_fuzzer/sinkproxyclosechannel_fuzzer.cpp @@ -34,6 +34,9 @@ void SinkProxyCloseChannelFuzzTest(const uint8_t* data, size_t size) sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (samgr == nullptr) { + return; + } sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID); std::shared_ptr dCSinkProxy = std::make_shared(remoteObject); diff --git a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxygetcamerainfo_fuzzer/sinkproxygetcamerainfo_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxygetcamerainfo_fuzzer/sinkproxygetcamerainfo_fuzzer.cpp index 09766a4f..5bbd20b5 100644 --- a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxygetcamerainfo_fuzzer/sinkproxygetcamerainfo_fuzzer.cpp +++ b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxygetcamerainfo_fuzzer/sinkproxygetcamerainfo_fuzzer.cpp @@ -36,6 +36,9 @@ void SinkProxyGetCameraInfoFuzzTest(const uint8_t* data, size_t size) sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (samgr == nullptr) { + return; + } sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID); std::shared_ptr dCSinkProxy = std::make_shared(remoteObject); diff --git a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxyinitsink_fuzzer/sinkproxyinitsink_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxyinitsink_fuzzer/sinkproxyinitsink_fuzzer.cpp index fa85b599..bdf73e2f 100644 --- a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxyinitsink_fuzzer/sinkproxyinitsink_fuzzer.cpp +++ b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxyinitsink_fuzzer/sinkproxyinitsink_fuzzer.cpp @@ -36,6 +36,9 @@ void SinkProxyInitSinkFuzzTest(const uint8_t* data, size_t size) sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (samgr == nullptr) { + return; + } sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID); std::shared_ptr dCSinkProxy = std::make_shared(remoteObject); diff --git a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxyopenchannel_fuzzer/sinkproxyopenchannel_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxyopenchannel_fuzzer/sinkproxyopenchannel_fuzzer.cpp index 495126a7..4d3bef6d 100644 --- a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxyopenchannel_fuzzer/sinkproxyopenchannel_fuzzer.cpp +++ b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxyopenchannel_fuzzer/sinkproxyopenchannel_fuzzer.cpp @@ -36,6 +36,9 @@ void SinkProxyOpenChannelFuzzTest(const uint8_t* data, size_t size) sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (samgr == nullptr) { + return; + } sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID); std::shared_ptr dCSinkProxy = std::make_shared(remoteObject); diff --git a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxyreleasesink_fuzzer/sinkproxyreleasesink_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxyreleasesink_fuzzer/sinkproxyreleasesink_fuzzer.cpp index 13355d90..b3d29b04 100644 --- a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxyreleasesink_fuzzer/sinkproxyreleasesink_fuzzer.cpp +++ b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxyreleasesink_fuzzer/sinkproxyreleasesink_fuzzer.cpp @@ -34,6 +34,9 @@ void SinkProxyReleaseSinkFuzzTest(const uint8_t* data, size_t size) sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (samgr == nullptr) { + return; + } sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID); std::shared_ptr dCSinkProxy = std::make_shared(remoteObject); diff --git a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxystopcapture_fuzzer/sinkproxystopcapture_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxystopcapture_fuzzer/sinkproxystopcapture_fuzzer.cpp index 7a75bbb6..7829e4a8 100644 --- a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxystopcapture_fuzzer/sinkproxystopcapture_fuzzer.cpp +++ b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxystopcapture_fuzzer/sinkproxystopcapture_fuzzer.cpp @@ -35,6 +35,9 @@ void SinkProxyStopCaptureFuzzTest(const uint8_t* data, size_t size) sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (samgr == nullptr) { + return; + } sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID); std::shared_ptr dCSinkProxy = std::make_shared(remoteObject); diff --git a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxysubscribelocalhardware_fuzzer/sinkproxysubscribelocalhardware_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxysubscribelocalhardware_fuzzer/sinkproxysubscribelocalhardware_fuzzer.cpp index 4ffe5f41..65394049 100644 --- a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxysubscribelocalhardware_fuzzer/sinkproxysubscribelocalhardware_fuzzer.cpp +++ b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxysubscribelocalhardware_fuzzer/sinkproxysubscribelocalhardware_fuzzer.cpp @@ -36,6 +36,9 @@ void SinkProxySubscribeLocalHardwareFuzzTest(const uint8_t* data, size_t size) sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (samgr == nullptr) { + return; + } sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID); std::shared_ptr dCSinkProxy = std::make_shared(remoteObject); diff --git a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxyunsubscribelocalhardware_fuzzer/sinkproxyunsubscribelocalhardware_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxyunsubscribelocalhardware_fuzzer/sinkproxyunsubscribelocalhardware_fuzzer.cpp index 624c5334..62fdc521 100644 --- a/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxyunsubscribelocalhardware_fuzzer/sinkproxyunsubscribelocalhardware_fuzzer.cpp +++ b/interfaces/inner_kits/native_cpp/test/sinkfuzztest/sinkproxyunsubscribelocalhardware_fuzzer/sinkproxyunsubscribelocalhardware_fuzzer.cpp @@ -35,6 +35,9 @@ void SinkProxyUnsubscribeLocalHardwareFuzzTest(const uint8_t* data, size_t size) sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (samgr == nullptr) { + return; + } sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID); std::shared_ptr dCSinkProxy = std::make_shared(remoteObject); diff --git a/interfaces/inner_kits/native_cpp/test/sourcefuzztest/onsourcelocalcamsrvdied_fuzzer/onsourcelocalcamsrvdied_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/onsourcelocalcamsrvdied_fuzzer/onsourcelocalcamsrvdied_fuzzer.cpp index d88493ec..d5473d44 100644 --- a/interfaces/inner_kits/native_cpp/test/sourcefuzztest/onsourcelocalcamsrvdied_fuzzer/onsourcelocalcamsrvdied_fuzzer.cpp +++ b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/onsourcelocalcamsrvdied_fuzzer/onsourcelocalcamsrvdied_fuzzer.cpp @@ -35,6 +35,9 @@ void OnSourceLocalCamSrvDiedFuzzTest(const uint8_t* data, size_t size) int32_t saId = *(reinterpret_cast(data)); sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (samgr == nullptr) { + return; + } sptr remoteObject = samgr->GetSystemAbility(saId); wptr remote (remoteObject); diff --git a/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceproxydcameranotify_fuzzer/sourceproxydcameranotify_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceproxydcameranotify_fuzzer/sourceproxydcameranotify_fuzzer.cpp index 3a943a54..8db67503 100644 --- a/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceproxydcameranotify_fuzzer/sourceproxydcameranotify_fuzzer.cpp +++ b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceproxydcameranotify_fuzzer/sourceproxydcameranotify_fuzzer.cpp @@ -35,6 +35,9 @@ void SourceProxyDCameraNotifyFuzzTest(const uint8_t* data, size_t size) sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (samgr == nullptr) { + return; + } sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID); std::shared_ptr dCSourceProxy = std::make_shared(remoteObject); diff --git a/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceproxyinitsource_fuzzer/sourceproxyinitsource_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceproxyinitsource_fuzzer/sourceproxyinitsource_fuzzer.cpp index 44fca0f1..504228f7 100644 --- a/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceproxyinitsource_fuzzer/sourceproxyinitsource_fuzzer.cpp +++ b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceproxyinitsource_fuzzer/sourceproxyinitsource_fuzzer.cpp @@ -32,6 +32,9 @@ void SourceProxyInitSourceFuzzTest(const uint8_t* data, size_t size) sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (samgr == nullptr) { + return; + } sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID); std::shared_ptr dCSourceProxy = std::make_shared(remoteObject); diff --git a/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceproxyregisterdistributedhardware_fuzzer/sourceproxyregisterdistributedhardware_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceproxyregisterdistributedhardware_fuzzer/sourceproxyregisterdistributedhardware_fuzzer.cpp index e04c84d8..ee6443be 100644 --- a/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceproxyregisterdistributedhardware_fuzzer/sourceproxyregisterdistributedhardware_fuzzer.cpp +++ b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceproxyregisterdistributedhardware_fuzzer/sourceproxyregisterdistributedhardware_fuzzer.cpp @@ -44,6 +44,9 @@ void SourceProxyRegisterDistributedHardwareFuzzTest(const uint8_t* data, size_t sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (samgr == nullptr) { + return; + } sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID); std::shared_ptr dCSourceProxy = std::make_shared(remoteObject); diff --git a/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceproxyunregisterdistributedhardware_fuzzer/sourceproxyunregisterdistributedhardware_fuzzer.cpp b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceproxyunregisterdistributedhardware_fuzzer/sourceproxyunregisterdistributedhardware_fuzzer.cpp index 713d0c93..e16eb98c 100644 --- a/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceproxyunregisterdistributedhardware_fuzzer/sourceproxyunregisterdistributedhardware_fuzzer.cpp +++ b/interfaces/inner_kits/native_cpp/test/sourcefuzztest/sourceproxyunregisterdistributedhardware_fuzzer/sourceproxyunregisterdistributedhardware_fuzzer.cpp @@ -35,6 +35,9 @@ void SourceProxyUnregisterDistributedHardwareFuzzTest(const uint8_t* data, size_ sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (samgr == nullptr) { + return; + } sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID); std::shared_ptr dCSourceProxy = std::make_shared(remoteObject); diff --git a/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/dcamera_sink_handler_ipc_test.cpp b/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/dcamera_sink_handler_ipc_test.cpp index dc5a4101..c63ffb9a 100644 --- a/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/dcamera_sink_handler_ipc_test.cpp +++ b/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/dcamera_sink_handler_ipc_test.cpp @@ -134,6 +134,7 @@ HWTEST_F(DCameraSinkHandlerIpcTest, dcamera_sink_handler_ipc_test_005, TestSize. int32_t systemAbilityId = 4804; sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + ASSERT_NE(samgr, nullptr); wptr remoteObject = samgr->GetSystemAbility(systemAbilityId); DCameraSinkHandlerIpc::GetInstance().OnSinkLocalCamSrvDied(remoteObject); EXPECT_EQ(nullptr, DCameraSinkHandlerIpc::GetInstance().localSink_); diff --git a/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/dcamera_sink_handler_test.cpp b/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/dcamera_sink_handler_test.cpp index 5c64ce86..8a5c7122 100644 --- a/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/dcamera_sink_handler_test.cpp +++ b/interfaces/inner_kits/native_cpp/test/unittest/common/camera_sink/dcamera_sink_handler_test.cpp @@ -168,6 +168,7 @@ HWTEST_F(DCameraSinkHandlerTest, dcamera_sink_handler_test_005, TestSize.Level1) int32_t systemAbilityId = 4804; sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + ASSERT_NE(samgr, nullptr); sptr remoteObject = samgr->GetSystemAbility(systemAbilityId); sptr loadCallback(new DCameraSinkLoadCallback(params)); ASSERT_NE(loadCallback, nullptr); diff --git a/interfaces/inner_kits/native_cpp/test/unittest/common/camera_source/dcamera_source_handler_ipc_test.cpp b/interfaces/inner_kits/native_cpp/test/unittest/common/camera_source/dcamera_source_handler_ipc_test.cpp index a0f2fa77..9528dc7b 100644 --- a/interfaces/inner_kits/native_cpp/test/unittest/common/camera_source/dcamera_source_handler_ipc_test.cpp +++ b/interfaces/inner_kits/native_cpp/test/unittest/common/camera_source/dcamera_source_handler_ipc_test.cpp @@ -134,6 +134,7 @@ HWTEST_F(DCameraSourceHandlerIpcTest, dcamera_source_handler_ipc_test_005, TestS int32_t systemAbilityId = 4803; sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + ASSERT_NE(samgr, nullptr); wptr remoteObject = samgr->GetSystemAbility(systemAbilityId); DCameraSourceHandlerIpc::GetInstance().OnSourceLocalCamSrvDied(remoteObject); EXPECT_EQ(nullptr, DCameraSourceHandlerIpc::GetInstance().localSource_); diff --git a/interfaces/inner_kits/native_cpp/test/unittest/common/camera_source/dcamera_source_handler_test.cpp b/interfaces/inner_kits/native_cpp/test/unittest/common/camera_source/dcamera_source_handler_test.cpp index 616bee39..d72a7d4b 100644 --- a/interfaces/inner_kits/native_cpp/test/unittest/common/camera_source/dcamera_source_handler_test.cpp +++ b/interfaces/inner_kits/native_cpp/test/unittest/common/camera_source/dcamera_source_handler_test.cpp @@ -154,6 +154,7 @@ HWTEST_F(DCameraSourceHandlerTest, dcamera_source_handler_test_005, TestSize.Lev int32_t systemAbilityId = 4803; sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + ASSERT_NE(samgr, nullptr); sptr remoteObject = samgr->GetSystemAbility(systemAbilityId); sptr loadCallback(new DCameraSourceLoadCallback(params)); ASSERT_NE(loadCallback, nullptr); diff --git a/services/cameraservice/base/src/dcamera_channel_info_cmd.cpp b/services/cameraservice/base/src/dcamera_channel_info_cmd.cpp index 20846903..8a7481b4 100644 --- a/services/cameraservice/base/src/dcamera_channel_info_cmd.cpp +++ b/services/cameraservice/base/src/dcamera_channel_info_cmd.cpp @@ -31,6 +31,8 @@ int32_t DCameraChannelInfoCmd::Marshal(std::string& jsonStr) cJSON_AddStringToObject(rootValue, "dhId", dhId_.c_str()); cJSON_AddStringToObject(rootValue, "Command", command_.c_str()); + CHECK_AND_FREE_RETURN_RET_LOG(value_ == nullptr, DCAMERA_BAD_VALUE, rootValue, "value_ is nullptr"); + cJSON *channelInfo = cJSON_CreateObject(); if (channelInfo == nullptr) { cJSON_Delete(rootValue); @@ -119,6 +121,8 @@ int32_t DCameraChannelInfoCmd::Unmarshal(const std::string& jsonStr) int32_t DCameraChannelInfoCmd::UnmarshalDetails(cJSON *details, std::shared_ptr channelInfo) { + CHECK_AND_RETURN_RET_LOG(details == nullptr, DCAMERA_BAD_VALUE, "details is nullptr"); + CHECK_AND_RETURN_RET_LOG(channelInfo == nullptr, DCAMERA_BAD_VALUE, "channelInfo is nullptr"); cJSON *detail = nullptr; cJSON_ArrayForEach(detail, details) { cJSON *dataSessionFlag = cJSON_GetObjectItemCaseSensitive(detail, "DataSessionFlag"); diff --git a/services/cameraservice/cameraoperator/client/src/dcamera_client.cpp b/services/cameraservice/cameraoperator/client/src/dcamera_client.cpp index 5ce68a62..5e2b2a3d 100644 --- a/services/cameraservice/cameraoperator/client/src/dcamera_client.cpp +++ b/services/cameraservice/cameraoperator/client/src/dcamera_client.cpp @@ -66,7 +66,7 @@ int32_t DCameraClient::Init() uint64_t listSize = static_cast(cameraList.size()); DHLOGI("Init camera size: %{public}" PRIu64, listSize); for (auto& info : cameraList) { - if (info->GetID() == cameraId_) { + if (info != nullptr && info->GetID() == cameraId_) { DHLOGI("Init cameraInfo get id: %{public}s", GetAnonyString(info->GetID()).c_str()); cameraInfo_ = info; break; @@ -101,6 +101,10 @@ int32_t DCameraClient::UpdateSettings(std::vectortype_) { case UPDATE_METADATA: { DHLOGI("UpdateSettings %{public}s update metadata settings", GetAnonyString(cameraId_).c_str()); @@ -194,7 +198,7 @@ int32_t DCameraClient::StartCapture(std::vectorstreamType_ == CONTINUOUS_FRAME) || (!info->isCapture_)) { + if (info != nullptr && ((info->streamType_ == CONTINUOUS_FRAME) || (!info->isCapture_))) { continue; } int32_t ret = StartCaptureInner(info); @@ -340,6 +344,7 @@ int32_t DCameraClient::ConfigCaptureSession(std::vector &)cameraInput_)->Open(); if (rc != DCAMERA_OK) { DHLOGE("ConfigCaptureSession cameraInput_ Open failed, cameraId: %{public}s, ret: %{public}d", @@ -384,6 +389,8 @@ int32_t DCameraClient::ConfigCaptureSession(std::vectorBeginConfig(); if (ret != DCAMERA_OK) { DHLOGE("ConfigCaptureSession %{public}s config captureSession failed, ret: %{public}d", @@ -441,14 +448,14 @@ int32_t DCameraClient::CreateCaptureOutput(std::vectorstreamType_ == SNAPSHOT_FRAME) { + if (info != nullptr && info->streamType_ == SNAPSHOT_FRAME) { int32_t ret = CreatePhotoOutput(info); if (ret != DCAMERA_OK) { DHLOGE("CreateCaptureOutput %{public}s create photo output failed, ret: %{public}d", GetAnonyString(cameraId_).c_str(), ret); return ret; } - } else if (info->streamType_ == CONTINUOUS_FRAME) { + } else if (info != nullptr && info->streamType_ == CONTINUOUS_FRAME) { int32_t ret = CreatePreviewOutput(info); if (ret != DCAMERA_OK) { DHLOGE("CreateCaptureOutput %{public}s create video output failed, ret: %{public}d", @@ -465,10 +472,13 @@ int32_t DCameraClient::CreateCaptureOutput(std::vector& info) { + CHECK_AND_RETURN_RET_LOG(info == nullptr, DCAMERA_BAD_VALUE, "CreatePhotoOutput info is null"); DHLOGI("CreatePhotoOutput dhId: %{public}s, width: %{public}d, height: %{public}d, format: %{public}d, stream: " "%{public}d, isCapture: %{public}d", GetAnonyString(cameraId_).c_str(), info->width_, info->height_, info->format_, info->streamType_, info->isCapture_); photoSurface_ = IConsumerSurface::Create(); + CHECK_AND_RETURN_RET_LOG(photoSurface_ == nullptr, DCAMERA_BAD_VALUE, + "CreatePhotoOutput create photo surface failed"); photoListener_ = sptr( new DCameraPhotoSurfaceListener(photoSurface_, resultCallback_)); photoSurface_->RegisterConsumerListener((sptr &)photoListener_); @@ -478,7 +488,7 @@ int32_t DCameraClient::CreatePhotoOutput(std::shared_ptr& in sptr bp = photoSurface_->GetProducer(); int32_t rv = cameraManager_->CreatePhotoOutput( photoProfile, bp, &((sptr &)photoOutput_)); - if (rv != DCAMERA_OK) { + if (rv != DCAMERA_OK || photoOutput_ == nullptr) { DHLOGE("CreatePhotoOutput %{public}s create photo output failed", GetAnonyString(cameraId_).c_str()); return DCAMERA_BAD_VALUE; } @@ -490,6 +500,7 @@ int32_t DCameraClient::CreatePhotoOutput(std::shared_ptr& in int32_t DCameraClient::CreatePreviewOutput(std::shared_ptr& info) { + CHECK_AND_RETURN_RET_LOG(info == nullptr, DCAMERA_BAD_VALUE, "CreatePreviewOutput info is null"); DHLOGI("CreatePreviewOutput dhId: %{public}s, width: %{public}d, height: %{public}d, format: %{public}d, stream:" " %{public}d, isCapture: %{public}d", GetAnonyString(cameraId_).c_str(), info->width_, info->height_, info->format_, info->streamType_, info->isCapture_); @@ -533,7 +544,7 @@ CameraStandard::CameraFormat DCameraClient::ConvertToCameraFormat(int32_t format int32_t DCameraClient::StartCaptureInner(std::shared_ptr& info) { - if (info->streamType_ != SNAPSHOT_FRAME) { + if (info !=nullptr && info->streamType_ != SNAPSHOT_FRAME) { DHLOGE("StartCaptureInner unknown stream type"); return DCAMERA_BAD_VALUE; } @@ -542,6 +553,7 @@ int32_t DCameraClient::StartCaptureInner(std::shared_ptr& in int32_t DCameraClient::StartPhotoOutput(std::shared_ptr& info) { + CHECK_AND_RETURN_RET_LOG(info == nullptr, DCAMERA_BAD_VALUE, "StartPhotoOutput info is null"); DHLOGI("StartPhotoOutput cameraId: %{public}s", GetAnonyString(cameraId_).c_str()); if (photoOutput_ == nullptr) { DHLOGE("StartPhotoOutput photoOutput is null"); @@ -588,6 +600,8 @@ void DCameraClient::SetPhotoCaptureRotation(const std::shared_ptr& photoCaptureSetting) { CHECK_AND_RETURN_LOG(cameraMetadata == nullptr, "SetPhotoCaptureRotation param cameraMetadata is null"); + CHECK_AND_RETURN_LOG(photoCaptureSetting == nullptr, + "SetPhotoCaptureRotation param photoCaptureSetting is null"); uint32_t rotationCount = 1; camera_metadata_item_t item; int32_t ret = Camera::FindCameraMetadataItem(cameraMetadata->get(), OHOS_JPEG_ORIENTATION, &item); @@ -603,6 +617,9 @@ void DCameraClient::SetPhotoCaptureRotation(const std::shared_ptr& cameraMetadata, std::shared_ptr& photoCaptureSetting) { + CHECK_AND_RETURN_LOG(cameraMetadata == nullptr, "SetPhotoCaptureRotation param cameraMetadata is null"); + CHECK_AND_RETURN_LOG(photoCaptureSetting == nullptr, + "SetPhotoCaptureRotation param photoCaptureSetting is null"); uint32_t qualityCount = 1; camera_metadata_item_t item; int32_t ret = Camera::FindCameraMetadataItem(cameraMetadata->get(), OHOS_JPEG_QUALITY, &item); @@ -618,6 +635,9 @@ void DCameraClient::SetPhotoCaptureQuality(const std::shared_ptr& cameraMetadata, std::shared_ptr& photoCaptureSetting) { + CHECK_AND_RETURN_LOG(cameraMetadata == nullptr, "SetPhotoCaptureRotation param cameraMetadata is null"); + CHECK_AND_RETURN_LOG(photoCaptureSetting == nullptr, + "SetPhotoCaptureRotation param photoCaptureSetting is null"); uint32_t locationCount = 3; camera_metadata_item_t item; int32_t ret = Camera::FindCameraMetadataItem(cameraMetadata->get(), OHOS_JPEG_GPS_COORDINATES, &item); diff --git a/services/cameraservice/cameraoperator/handler/src/dcamera_handler.cpp b/services/cameraservice/cameraoperator/handler/src/dcamera_handler.cpp index e7a922b6..795dcda9 100644 --- a/services/cameraservice/cameraoperator/handler/src/dcamera_handler.cpp +++ b/services/cameraservice/cameraoperator/handler/src/dcamera_handler.cpp @@ -64,7 +64,8 @@ std::vector DCameraHandler::QueryMeta() return itemList; } for (auto& info : cameraList) { - if (info->GetConnectionType() != CameraStandard::ConnectionType::CAMERA_CONNECTION_BUILT_IN) { + if (info != nullptr && + info->GetConnectionType() != CameraStandard::ConnectionType::CAMERA_CONNECTION_BUILT_IN) { DHLOGI("connection type: %{public}d", info->GetConnectionType()); continue; } @@ -92,7 +93,8 @@ std::vector DCameraHandler::Query() return itemList; } for (auto& info : cameraList) { - if ((info->GetConnectionType() != CameraStandard::ConnectionType::CAMERA_CONNECTION_BUILT_IN)) { + if (info != nullptr && + info->GetConnectionType() != CameraStandard::ConnectionType::CAMERA_CONNECTION_BUILT_IN) { DHLOGI("connection type: %{public}d", info->GetConnectionType()); continue; } @@ -159,7 +161,8 @@ std::vector DCameraHandler::GetCameras() DHLOGI("get supported capability is null"); continue; } - if (info->GetConnectionType() != CameraStandard::ConnectionType::CAMERA_CONNECTION_BUILT_IN) { + if (info != nullptr && + info->GetConnectionType() != CameraStandard::ConnectionType::CAMERA_CONNECTION_BUILT_IN) { DHLOGI("connection type: %{public}d", info->GetConnectionType()); continue; } @@ -205,6 +208,7 @@ int32_t DCameraHandler::CreateAVCodecList(cJSON *root) int32_t DCameraHandler::CreateMetaDHItem(sptr& info, DHItem& item) { + CHECK_AND_RETURN_RET_LOG(info == nullptr, DCAMERA_BAD_VALUE, "CreateMetaDHItem info is null"); std::string id = info->GetID(); item.dhId = CAMERA_ID_PREFIX + id; item.subtype = "camera"; @@ -226,6 +230,7 @@ int32_t DCameraHandler::CreateMetaDHItem(sptr& inf int32_t DCameraHandler::CreateDHItem(sptr& info, DHItem& item) { + CHECK_AND_RETURN_RET_LOG(info == nullptr, DCAMERA_BAD_VALUE, "CreateDHItem info is null"); std::string id = info->GetID(); item.dhId = CAMERA_ID_PREFIX + id; item.subtype = "camera"; @@ -280,13 +285,14 @@ int32_t DCameraHandler::CreateDHItem(sptr& info, D int32_t DCameraHandler::CreateMeatdataStr(sptr& info, cJSON *root) { + CHECK_AND_RETURN_RET_LOG(cameraManager_ == nullptr, DCAMERA_BAD_VALUE, "cameraManager is null"); sptr cameraInput = nullptr; int32_t rv = cameraManager_->CreateCameraInput(info, &cameraInput); if (rv != DCAMERA_OK) { DHLOGE("create cameraInput failed"); return DCAMERA_BAD_VALUE; } - + CHECK_AND_RETURN_RET_LOG(cameraInput == nullptr, DCAMERA_BAD_VALUE, "cameraInput is null"); std::hash h; std::string abilityStr = cameraInput->GetCameraSettings(); DHLOGI("abilityString hash: %{public}zu, length: %{public}zu", h(abilityStr), abilityStr.length()); diff --git a/services/cameraservice/sinkservice/src/distributedcamera/distributed_camera_sink_service.cpp b/services/cameraservice/sinkservice/src/distributedcamera/distributed_camera_sink_service.cpp index 8d456ca7..902ade16 100644 --- a/services/cameraservice/sinkservice/src/distributedcamera/distributed_camera_sink_service.cpp +++ b/services/cameraservice/sinkservice/src/distributedcamera/distributed_camera_sink_service.cpp @@ -159,7 +159,8 @@ int32_t DistributedCameraSinkService::SubscribeLocalHardware(const std::string& } sinkDevice = iter->second; } - + CHECK_AND_RETURN_RET_LOG(sinkDevice == nullptr, DCAMERA_BAD_VALUE, + "sink device is null, dhId: %{public}s", GetAnonyString(dhId).c_str()); int32_t ret = sinkDevice->SubscribeLocalHardware(parameters); CHECK_AND_RETURN_RET_LOG(ret != DCAMERA_OK, ret, "SubscribeLocalHardware failed, ret: %{public}d", ret); DHLOGI("SubscribeLocalHardware success"); @@ -179,7 +180,6 @@ int32_t DistributedCameraSinkService::UnsubscribeLocalHardware(const std::string } sinkDevice = iter->second; } - int32_t ret = sinkDevice->UnsubscribeLocalHardware(); CHECK_AND_RETURN_RET_LOG(ret != DCAMERA_OK, ret, "UnsubscribeLocalHardware failed, ret: %{public}d", ret); DHLOGI("UnsubscribeLocalHardware success"); @@ -199,7 +199,6 @@ int32_t DistributedCameraSinkService::StopCapture(const std::string& dhId) } sinkDevice = iter->second; } - int32_t ret = sinkDevice->StopCapture(); CHECK_AND_RETURN_RET_LOG(ret != DCAMERA_OK, ret, "StopCapture failed, ret: %{public}d", ret); DHLOGI("StopCapture success"); @@ -239,7 +238,6 @@ int32_t DistributedCameraSinkService::GetCameraInfo(const std::string& dhId, std } sinkDevice = iter->second; } - int32_t ret = sinkDevice->GetCameraInfo(cameraInfo); CHECK_AND_RETURN_RET_LOG(ret != DCAMERA_OK, ret, "GetCameraInfo failed, ret: %{public}d", ret); DHLOGI("GetCameraInfo success"); @@ -259,7 +257,6 @@ int32_t DistributedCameraSinkService::OpenChannel(const std::string& dhId, std:: } sinkDevice = iter->second; } - int32_t ret = sinkDevice->OpenChannel(openInfo); if (ret != DCAMERA_OK) { DHLOGE("OpenChannel failed, ret: %{public}d", ret); diff --git a/services/cameraservice/sinkservice/src/distributedcameramgr/dcamera_sink_data_process.cpp b/services/cameraservice/sinkservice/src/distributedcameramgr/dcamera_sink_data_process.cpp index 5e588116..6d767f66 100644 --- a/services/cameraservice/sinkservice/src/distributedcameramgr/dcamera_sink_data_process.cpp +++ b/services/cameraservice/sinkservice/src/distributedcameramgr/dcamera_sink_data_process.cpp @@ -70,6 +70,7 @@ void DCameraSinkDataProcess::StartEventHandler() int32_t DCameraSinkDataProcess::StartCapture(std::shared_ptr& captureInfo) { + CHECK_AND_RETURN_RET_LOG(captureInfo == nullptr, DCAMERA_BAD_VALUE, "StartCapture captureInfo is null"); DHLOGI("StartCapture dhId: %{public}s, width: %{public}d, height: %{public}d, format: %{public}d, stream: " "%{public}d, encode: %{public}d", GetAnonyString(dhId_).c_str(), captureInfo->width_, captureInfo->height_, captureInfo->format_, captureInfo->streamType_, captureInfo->encodeType_); diff --git a/services/cameraservice/sinkservice/src/distributedcameramgr/dcamera_sink_output.cpp b/services/cameraservice/sinkservice/src/distributedcameramgr/dcamera_sink_output.cpp index e3efaca1..e9c5e44a 100644 --- a/services/cameraservice/sinkservice/src/distributedcameramgr/dcamera_sink_output.cpp +++ b/services/cameraservice/sinkservice/src/distributedcameramgr/dcamera_sink_output.cpp @@ -43,6 +43,7 @@ DCameraSinkOutput::~DCameraSinkOutput() int32_t DCameraSinkOutput::Init() { + CHECK_AND_RETURN_RET_LOG(operator_ == nullptr, DCAMERA_BAD_VALUE, "operator_ is null"); DHLOGI("Init dhId: %{public}s", GetAnonyString(dhId_).c_str()); auto output = std::shared_ptr(shared_from_this()); std::shared_ptr resultCallback = std::make_shared(output); @@ -79,6 +80,7 @@ int32_t DCameraSinkOutput::UnInit() int32_t DCameraSinkOutput::OpenChannel(std::shared_ptr& info) { DHLOGI("OpenChannel dhId: %{public}s", GetAnonyString(dhId_).c_str()); + CHECK_AND_RETURN_RET_LOG(info == nullptr, DCAMERA_BAD_VALUE, "OpenChannel info is null"); std::map modeMaps; modeMaps.emplace(CONTINUOUS_FRAME, DCAMERA_SESSION_MODE_VIDEO); modeMaps.emplace(SNAPSHOT_FRAME, DCAMERA_SESSION_MODE_JPEG); @@ -113,6 +115,8 @@ int32_t DCameraSinkOutput::CloseChannel() auto iterCon = channels_.find(CONTINUOUS_FRAME); if (iterCon != channels_.end()) { int32_t ret = DCAMERA_OK; + CHECK_AND_RETURN_RET_LOG(iterCon->second == nullptr, DCAMERA_BAD_VALUE, + "CloseChannel continuous channel is null"); ret = iterCon->second->ReleaseSession(); if (ret != DCAMERA_OK) { DHLOGI("DCameraSinkOutput UnInit release continue session failed, dhId: %{public}s, ret: %{public}d", @@ -124,6 +128,8 @@ int32_t DCameraSinkOutput::CloseChannel() auto iterSnap = channels_.find(SNAPSHOT_FRAME); if (iterSnap != channels_.end()) { int32_t ret = DCAMERA_OK; + CHECK_AND_RETURN_RET_LOG(iterSnap->second == nullptr, DCAMERA_BAD_VALUE, + "CloseChannel snapshot channel is null"); ret = iterSnap->second->ReleaseSession(); if (ret != DCAMERA_OK) { DHLOGI("DCameraSinkOutput UnInit release snapshot session failed, dhId: %{public}s, ret: %{public}d", @@ -138,7 +144,7 @@ int32_t DCameraSinkOutput::StartCapture(std::vectorstreamType_) == dataProcesses_.end()) { + if (info != nullptr && dataProcesses_.find(info->streamType_) == dataProcesses_.end()) { DHLOGE("has no data process, streamType: %{public}d", info->streamType_); break; } @@ -157,6 +163,8 @@ int32_t DCameraSinkOutput::StopCapture() auto iterCon = dataProcesses_.find(CONTINUOUS_FRAME); if (iterCon != dataProcesses_.end()) { DHLOGI("StopCapture %{public}s continuous frame stop capture", GetAnonyString(dhId_).c_str()); + CHECK_AND_RETURN_RET_LOG(iterCon->second == nullptr, DCAMERA_BAD_VALUE, + "StopCapture continuous data process is null"); int32_t ret = iterCon->second->StopCapture(); if (ret != DCAMERA_OK) { DHLOGE("continuous data process stop capture failed, dhId: %{public}s, ret: %{public}d", @@ -167,6 +175,8 @@ int32_t DCameraSinkOutput::StopCapture() auto iterSnap = dataProcesses_.find(SNAPSHOT_FRAME); if (iterSnap != dataProcesses_.end()) { DHLOGI("StopCapture %{public}s snapshot frame stop capture", GetAnonyString(dhId_).c_str()); + CHECK_AND_RETURN_RET_LOG(iterSnap->second == nullptr, DCAMERA_BAD_VALUE, + "StopCapture snapshot data process is null"); int32_t ret = iterSnap->second->StopCapture(); if (ret != DCAMERA_OK) { DHLOGE("snapshot data process stop capture failed, dhId: %{public}s, ret: %{public}d", @@ -188,6 +198,8 @@ void DCameraSinkOutput::OnVideoResult(std::shared_ptr& buffer) DHLOGE("OnVideoResult %{public}s has no continuous data process", GetAnonyString(dhId_).c_str()); return; } + CHECK_AND_RETURN_LOG(dataProcesses_[CONTINUOUS_FRAME] == nullptr, + "OnVideoResult continuous data process is null"); dataProcesses_[CONTINUOUS_FRAME]->FeedStream(buffer); } @@ -197,6 +209,8 @@ void DCameraSinkOutput::OnPhotoResult(std::shared_ptr& buffer) DHLOGE("OnPhotoResult %{public}s has no snapshot data process", GetAnonyString(dhId_).c_str()); return; } + CHECK_AND_RETURN_LOG(dataProcesses_[SNAPSHOT_FRAME] == nullptr, + "OnPhotoResult snapshot data process is null"); dataProcesses_[SNAPSHOT_FRAME]->FeedStream(buffer); } diff --git a/services/cameraservice/sinkservice/src/distributedcameramgr/dcamera_sink_service_ipc.cpp b/services/cameraservice/sinkservice/src/distributedcameramgr/dcamera_sink_service_ipc.cpp index 25a286f9..b2d35fe5 100644 --- a/services/cameraservice/sinkservice/src/distributedcameramgr/dcamera_sink_service_ipc.cpp +++ b/services/cameraservice/sinkservice/src/distributedcameramgr/dcamera_sink_service_ipc.cpp @@ -105,7 +105,7 @@ sptr DCameraSinkServiceIpc::GetSourceRemoteCamSrv(cons { std::lock_guard autoLock(sourceRemoteCamSrvLock_); auto iter = remoteSources_.find(deviceId); - if (iter != remoteSources_.end()) { + if (iter != remoteSources_.end() && iter->second != nullptr) { iter->second->AsObject()->RemoveDeathRecipient(sourceRemoteRecipient_); } remoteSources_[deviceId] = remoteCamSrvObj; @@ -160,6 +160,8 @@ void DCameraSinkServiceIpc::OnSourceRemoteCamSrvDied(const wptr& } auto iter = std::find_if(remoteSources_.begin(), remoteSources_.end(), [&]( const std::pair> &item)->bool { + CHECK_AND_RETURN_RET_LOG(item.second == nullptr, false, + "OnSourceRemoteCamSrvDied item.second is null"); return item.second->AsObject() == diedRemoted; }); if (iter == remoteSources_.end()) { diff --git a/services/cameraservice/sinkservice/test/unittest/common/distributedcamera/dcamera_sink_callback_proxy_test.cpp b/services/cameraservice/sinkservice/test/unittest/common/distributedcamera/dcamera_sink_callback_proxy_test.cpp index 1dcd4b73..6348a813 100644 --- a/services/cameraservice/sinkservice/test/unittest/common/distributedcamera/dcamera_sink_callback_proxy_test.cpp +++ b/services/cameraservice/sinkservice/test/unittest/common/distributedcamera/dcamera_sink_callback_proxy_test.cpp @@ -67,6 +67,7 @@ HWTEST_F(DcameraSinkCallbackProxyTest, dcamera_sink_callback_proxy_test_001, Tes DHLOGI("DcameraSinkCallbackProxyTest::dcamera_sink_callback_proxy_test_001"); sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + ASSERT_NE(samgr, nullptr); sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID); sptr callbackProxy(new DCameraSinkCallbackProxy(remoteObject)); EXPECT_EQ(false, callbackProxy == nullptr); diff --git a/services/cameraservice/sourceservice/src/distributedcameramgr/dcamera_source_dev.cpp b/services/cameraservice/sourceservice/src/distributedcameramgr/dcamera_source_dev.cpp index dcf91a8a..0fef4a9e 100644 --- a/services/cameraservice/sourceservice/src/distributedcameramgr/dcamera_source_dev.cpp +++ b/services/cameraservice/sourceservice/src/distributedcameramgr/dcamera_source_dev.cpp @@ -815,6 +815,7 @@ void DCameraSourceDev::NotifyHalResult(DCAMERA_EVENT eventType, DCameraSourceEve int32_t DCameraSourceDev::GetStateInfo() { + CHECK_AND_RETURN_RET_LOG(stateMachine_ == nullptr, DCAMERA_BAD_VALUE, "stateMachine_ is nullptr."); DHLOGI("GetStateInfo In state %{public}d", stateMachine_->GetCameraState()); return stateMachine_->GetCameraState(); } diff --git a/services/cameraservice/sourceservice/src/distributedcameramgr/dcamera_source_service_ipc.cpp b/services/cameraservice/sourceservice/src/distributedcameramgr/dcamera_source_service_ipc.cpp index ad2aec06..093c36e6 100644 --- a/services/cameraservice/sourceservice/src/distributedcameramgr/dcamera_source_service_ipc.cpp +++ b/services/cameraservice/sourceservice/src/distributedcameramgr/dcamera_source_service_ipc.cpp @@ -105,7 +105,7 @@ sptr DCameraSourceServiceIpc::GetSinkRemoteCamSrv(const { std::lock_guard autoLock(sinkRemoteCamSrvLock_); auto iter = remoteSinks_.find(deviceId); - if (iter != remoteSinks_.end()) { + if (iter != remoteSinks_.end() && iter->second != nullptr) { iter->second->AsObject()->RemoveDeathRecipient(sinkRemoteRecipient_); } remoteSinks_[deviceId] = remoteCamSrvObj; @@ -160,6 +160,8 @@ void DCameraSourceServiceIpc::OnSinkRemoteCamSrvDied(const wptr& } auto iter = std::find_if(remoteSinks_.begin(), remoteSinks_.end(), [&]( const std::pair> &item)->bool { + CHECK_AND_RETURN_RET_LOG(item.second == nullptr, false, + "OnSinkRemoteCamSrvDied item.second is null"); return item.second->AsObject() == diedRemoted; }); if (iter == remoteSinks_.end()) { diff --git a/services/cameraservice/sourceservice/src/distributedcameramgr/dcameracontrol/dcamera_source_controller.cpp b/services/cameraservice/sourceservice/src/distributedcameramgr/dcameracontrol/dcamera_source_controller.cpp index eaad5210..b045950d 100644 --- a/services/cameraservice/sourceservice/src/distributedcameramgr/dcameracontrol/dcamera_source_controller.cpp +++ b/services/cameraservice/sourceservice/src/distributedcameramgr/dcameracontrol/dcamera_source_controller.cpp @@ -169,6 +169,7 @@ int32_t DCameraSourceController::StopCapture() int32_t DCameraSourceController::ChannelNeg(std::shared_ptr& info) { + CHECK_AND_RETURN_RET_LOG(info == nullptr, DCAMERA_BAD_VALUE, "ChannelNeg info is nullptr"); if (!ManageSelectChannel::GetInstance().GetSrcConnect()) { if (indexs_.empty() || indexs_.size() > DCAMERA_MAX_NUM) { DHLOGE("ChannelNeg not support operate %{public}zu camera", indexs_.size()); @@ -212,6 +213,7 @@ int32_t DCameraSourceController::ChannelNeg(std::shared_ptr& int32_t DCameraSourceController::DCameraNotify(std::shared_ptr& events) { + CHECK_AND_RETURN_RET_LOG(events == nullptr, DCAMERA_BAD_VALUE, "DCameraNotify events is nullptr"); if (events->eventResult_ == DCAMERA_EVENT_CAMERA_SUCCESS && events->eventContent_ == START_CAPTURE_SUCC) { DcameraRadar::GetInstance().ReportDcameraOpen("StartCapture", CameraOpen::START_CAPTURE, @@ -328,6 +330,7 @@ int32_t DCameraSourceController::GetCameraInfo(std::shared_ptr& cam int32_t DCameraSourceController::OpenChannel(std::shared_ptr& openInfo) { + CHECK_AND_RETURN_RET_LOG(openInfo == nullptr, DCAMERA_BAD_VALUE, "OpenChannel openInfo is nullptr"); if (indexs_.empty() || indexs_.size() > DCAMERA_MAX_NUM) { DHLOGE("OpenChannel not support operate %{public}zu camera", indexs_.size()); return DCAMERA_BAD_OPERATE; @@ -542,6 +545,7 @@ void DCameraSourceController::OnSessionState(int32_t state, std::string networkI case DCAMERA_CHANNEL_STATE_CONNECTED: { DcameraFinishAsyncTrace(DCAMERA_OPEN_CHANNEL_CONTROL, DCAMERA_OPEN_CHANNEL_TASKID); isChannelConnected_.store(true); + CHECK_AND_RETURN_LOG(stateMachine_ == nullptr, "stateMachine_ is nullptr"); stateMachine_->UpdateState(DCAMERA_STATE_OPENED); std::shared_ptr camDev = camDev_.lock(); if (camDev == nullptr) { @@ -586,6 +590,7 @@ void DCameraSourceController::OnDataReceived(std::vector& dataBuffer) { + CHECK_AND_RETURN_LOG(dataBuffer == nullptr, "dataBuffer is nullptr"); DHLOGI("DCameraSourceController::HandleReceivedData dhId: %{public}s", GetAnonyString(dhId_).c_str()); uint8_t *data = dataBuffer->Data(); std::string jsonStr(reinterpret_cast(data), dataBuffer->Capacity()); diff --git a/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/dcamera_source_data_process.cpp b/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/dcamera_source_data_process.cpp index f264135d..c2b676bc 100644 --- a/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/dcamera_source_data_process.cpp +++ b/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/dcamera_source_data_process.cpp @@ -54,6 +54,8 @@ int32_t DCameraSourceDataProcess::FeedStream(std::vector(buffer->Size()); DHLOGD("DCameraSourceDataProcess FeedStream devId %{public}s dhId %{public}s streamType %{public}d streamSize: " "%{public}" PRIu64, GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str(), streamType_, buffersSize); @@ -76,6 +78,10 @@ int32_t DCameraSourceDataProcess::ConfigStreams(std::vector> streamConfigs; for (auto iter = streamInfos.begin(); iter != streamInfos.end(); iter++) { std::shared_ptr streamInfo = *iter; + if (streamInfo == nullptr) { + DHLOGE("DCameraSourceDataProcess ConfigStreams streamInfo is nullptr"); + continue; + } DCameraStreamConfig streamConfig(streamInfo->width_, streamInfo->height_, streamInfo->format_, streamInfo->dataspace_, streamInfo->encodeType_, streamInfo->type_); DHLOGI("DCameraSourceDataProcess ConfigStreams devId %{public}s dhId %{public}s, streamId: %{public}d info: " diff --git a/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/dcamera_source_input.cpp b/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/dcamera_source_input.cpp index d3cd7158..294ab4d2 100644 --- a/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/dcamera_source_input.cpp +++ b/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/dcamera_source_input.cpp @@ -54,15 +54,17 @@ int32_t DCameraSourceInput::ConfigStreams(std::vector> snapStreams; std::vector> continueStreams; for (auto iter = streamInfos.begin(); iter != streamInfos.end(); iter++) { std::shared_ptr streamInfo = *iter; + if (streamInfo == nullptr) { + DHLOGE("DCameraSourceInput ConfigStreams streamInfo is nullptr"); + continue; + } DHLOGI("DCameraSourceInput ConfigStreams devId: %{public}s, dhId: %{public}s, streamId: %{public}d, width: " "%{public}d, height: %{public}d, format: %{public}d, dataspace: %{public}d, encodeType:%{public}d " "streamType: %{public}d", GetAnonyString(devId_).c_str(), @@ -75,7 +77,6 @@ int32_t DCameraSourceInput::ConfigStreams(std::vectorConfigStreams(continueStreams); if (ret != DCAMERA_OK) { @@ -90,7 +91,6 @@ int32_t DCameraSourceInput::ConfigStreams(std::vector& streamIds, bool& is { DHLOGI("DCameraSourceInput ReleaseStreams devId %{public}s dhId %{public}s", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); + CHECK_AND_RETURN_RET_LOG(dataProcess_[CONTINUOUS_FRAME] == nullptr, + DCAMERA_BAD_VALUE, "DCameraSourceInput ReleaseStreams continuous frame dataProcess_ is nullptr"); + CHECK_AND_RETURN_RET_LOG(dataProcess_[SNAPSHOT_FRAME] == nullptr, + DCAMERA_BAD_VALUE, "DCameraSourceInput ReleaseStreams snapshot frame dataProcess_ is nullptr"); int32_t ret = dataProcess_[CONTINUOUS_FRAME]->ReleaseStreams(streamIds); if (ret != DCAMERA_OK) { DHLOGE("DCameraSourceInput ReleaseStreams continue stream ReleaseStreams ret: %{public}d, devId: %{public}s," @@ -130,6 +134,10 @@ int32_t DCameraSourceInput::StartCapture(std::vectorstreamIds_.begin(); iterSet != (*iter)->streamIds_.end(); iterSet++) { DHLOGI("DCameraSourceInput StartCapture devId %{public}s dhId %{public}s StartCapture id: %{public}d", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str(), *iterSet); @@ -138,6 +146,10 @@ int32_t DCameraSourceInput::StartCapture(std::vectortype_, idSize, (*iter)->isCapture_ ? 1 : 0); + if (dataProcess_[(*iter)->type_] == nullptr) { + DHLOGE("DCameraSourceInput StartCapture dataProcess_ is nullptr"); + continue; + } ret = dataProcess_[(*iter)->type_]->StartCapture(*iter); if (ret != DCAMERA_OK) { DHLOGE("DCameraSourceInput StartCapture ret: %{public}d, devId: %{public}s, dhId: %{public}s", ret, @@ -152,6 +164,8 @@ int32_t DCameraSourceInput::StopCapture(std::vector& streamIds, bool& isAll { DHLOGI("DCameraSourceInput StopCapture devId %{public}s dhId %{public}s", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); + CHECK_AND_RETURN_RET_LOG(dataProcess_[CONTINUOUS_FRAME] == nullptr, + DCAMERA_BAD_VALUE, "DCameraSourceInput StopCapture continuous frame dataProcess_ is nullptr"); int32_t ret = dataProcess_[CONTINUOUS_FRAME]->StopCapture(streamIds); if (ret != DCAMERA_OK) { DHLOGE("DCameraSourceInput StopCapture continue ret: %{public}d, devId: %{public}s, dhId: %{public}s", ret, @@ -161,6 +175,8 @@ int32_t DCameraSourceInput::StopCapture(std::vector& streamIds, bool& isAll int32_t size = dataProcess_[CONTINUOUS_FRAME]->GetProducerSize(); if (size == 0) { + CHECK_AND_RETURN_RET_LOG(dataProcess_[SNAPSHOT_FRAME] == nullptr, + DCAMERA_BAD_VALUE, "DCameraSourceInput StopCapture snapshot frame dataProcess_ is nullptr"); isAllStop = true; std::vector snapStreamIds; dataProcess_[SNAPSHOT_FRAME]->GetAllStreamIds(snapStreamIds); @@ -230,6 +246,8 @@ int32_t DCameraSourceInput::OpenChannel(std::vector& indexs) isOpenChannelCond_.notify_one(); DHLOGI("openChannel continuous frame task completed"); }; + CHECK_AND_RETURN_RET_LOG(handler_ == nullptr, DCAMERA_BAD_VALUE, + "DCameraSourceInput OpenChannel handler is nullptr"); handler_->PostTask(task, "DCameraSourceInput:OpenChannel", 0, AppExecFwk::EventQueue::Priority::HIGH); } if (snapshotNeeded) { @@ -394,6 +412,10 @@ int32_t DCameraSourceInput::ReleaseAllStreams() { DHLOGI("ReleaseAllStreams devId %{public}s dhId %{public}s", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); + CHECK_AND_RETURN_RET_LOG(dataProcess_[CONTINUOUS_FRAME] == nullptr, + DCAMERA_BAD_VALUE, "DCameraSourceInput ReleaseAllStreams continuous frame dataProcess_ is nullptr"); + CHECK_AND_RETURN_RET_LOG(dataProcess_[SNAPSHOT_FRAME] == nullptr, + DCAMERA_BAD_VALUE, "DCameraSourceInput ReleaseAllStreams snapshot frame dataProcess_ is nullptr"); std::vector continueStreamIds; dataProcess_[CONTINUOUS_FRAME]->GetAllStreamIds(continueStreamIds); int32_t ret = dataProcess_[CONTINUOUS_FRAME]->ReleaseStreams(continueStreamIds); @@ -419,6 +441,10 @@ int32_t DCameraSourceInput::StopAllCapture() DHLOGI("StopAllCapture devId %{public}s dhId %{public}s", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); std::vector continueStreamIds; + CHECK_AND_RETURN_RET_LOG(dataProcess_[CONTINUOUS_FRAME] == nullptr, + DCAMERA_BAD_VALUE, "DCameraSourceInput StopAllCapture continuous frame dataProcess_ is nullptr"); + CHECK_AND_RETURN_RET_LOG(dataProcess_[SNAPSHOT_FRAME] == nullptr, + DCAMERA_BAD_VALUE, "DCameraSourceInput StopAllCapture snapshot frame dataProcess_ is nullptr"); dataProcess_[CONTINUOUS_FRAME]->GetAllStreamIds(continueStreamIds); int32_t ret = dataProcess_[CONTINUOUS_FRAME]->StopCapture(continueStreamIds); if (ret != DCAMERA_OK) { diff --git a/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/dcamera_stream_data_process.cpp b/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/dcamera_stream_data_process.cpp index 5747a9b5..361a08f3 100644 --- a/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/dcamera_stream_data_process.cpp +++ b/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/dcamera_stream_data_process.cpp @@ -70,6 +70,7 @@ void DCameraStreamDataProcess::FeedStream(std::shared_ptr& buffer) void DCameraStreamDataProcess::ConfigStreams(std::shared_ptr& dstConfig, std::set& streamIds) { + CHECK_AND_RETURN_LOG(dstConfig == nullptr, "dstConfig is nullptr"); for (auto streamId : streamIds) { DHLOGI("ConfigStreams devId %{public}s dhId %{public}s streamId %{public}d, width: %{public}d, height: " "%{public}d, format: %{public}d, dataspace: %{public}d, encodeType: %{public}d, streamType: %{public}d", @@ -104,6 +105,7 @@ void DCameraStreamDataProcess::ReleaseStreams(std::set& streamIds) void DCameraStreamDataProcess::StartCapture(std::shared_ptr& srcConfig, std::set& streamIds) { + CHECK_AND_RETURN_LOG(srcConfig == nullptr, "srcConfig is nullptr"); for (auto iter = streamIds.begin(); iter != streamIds.end(); iter++) { DHLOGI("StartCapture devId %{public}s dhId %{public}s streamType: %{public}d streamId: %{public}d, " "srcConfig: width: %{public}d, height: %{public}d, format: %{public}d, dataspace: %{public}d, " @@ -221,6 +223,7 @@ void DCameraStreamDataProcess::FeedStreamToContinue(const std::shared_ptr& videoResult) { + CHECK_AND_LOG(videoResult == nullptr, "videoResult is nullptr."); uint64_t resultSize = static_cast(videoResult->Size()); DHLOGI("DCameraStreamDataProcess OnProcessedVideoBuffer devId %{public}s dhId %{public}s streamType: %{public}d " "streamSize: %{public}" PRIu64, GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str(), diff --git a/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/dcamera_stream_data_process_producer.cpp b/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/dcamera_stream_data_process_producer.cpp index d220992d..97e78bcf 100644 --- a/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/dcamera_stream_data_process_producer.cpp +++ b/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/dcamera_stream_data_process_producer.cpp @@ -108,6 +108,7 @@ void DCameraStreamDataProcessProducer::Stop() void DCameraStreamDataProcessProducer::FeedStream(const std::shared_ptr& buffer) { + CHECK_AND_RETURN_LOG(buffer == nullptr, "buffer is nullptr."); buffer->frameInfo_.timePonit.startSmooth = GetNowTimeStampUs(); { std::lock_guard lock(bufferMutex_); @@ -269,6 +270,7 @@ int32_t DCameraStreamDataProcessProducer::CheckSharedMemory(const DCameraBuffer& void DCameraStreamDataProcessProducer::OnSmoothFinished(const std::shared_ptr& data) { std::shared_ptr buffer = std::reinterpret_pointer_cast(data); + CHECK_AND_RETURN_LOG(buffer == nullptr, "buffer is nullptr."); DHBase dhBase; dhBase.deviceId_ = devId_; dhBase.dhId_ = dhId_; diff --git a/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/feedingsmoother/base/ifeeding_smoother.cpp b/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/feedingsmoother/base/ifeeding_smoother.cpp index 1aeff239..34ba50de 100644 --- a/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/feedingsmoother/base/ifeeding_smoother.cpp +++ b/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/feedingsmoother/base/ifeeding_smoother.cpp @@ -95,6 +95,7 @@ void IFeedingSmoother::LooperSmooth() void IFeedingSmoother::SmoothFeeding(const std::shared_ptr& data) { + CHECK_AND_RETURN_LOG(data == nullptr, "data is nullptr"); int64_t enterTime = GetNowTimeStampUs(); SetClockTime(enterTime); int64_t timeStamp = data->GetTimeStamp(); diff --git a/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/feedingsmoother/base/time_statistician.cpp b/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/feedingsmoother/base/time_statistician.cpp index 6d13dc88..6d507f79 100644 --- a/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/feedingsmoother/base/time_statistician.cpp +++ b/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/feedingsmoother/base/time_statistician.cpp @@ -20,6 +20,7 @@ namespace OHOS { namespace DistributedHardware { void TimeStatistician::CalProcessTime(const std::shared_ptr& data) { + CHECK_AND_RETURN_LOG(data == nullptr, "data is nullptr"); int64_t feedTime = GetNowTimeStampUs(); int64_t timeStamp = data->GetTimeStamp(); CalAverFeedInterval(feedTime); diff --git a/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/feedingsmoother/derived/dcamera_feeding_smoother.cpp b/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/feedingsmoother/derived/dcamera_feeding_smoother.cpp index 635ccfd8..6f91a337 100644 --- a/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/feedingsmoother/derived/dcamera_feeding_smoother.cpp +++ b/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/feedingsmoother/derived/dcamera_feeding_smoother.cpp @@ -52,6 +52,7 @@ int32_t DCameraFeedingSmoother::NotifySmoothFinished(const std::shared_ptr buffer = std::reinterpret_pointer_cast(data); + CHECK_AND_RETURN_RET_LOG(buffer == nullptr, NOTIFY_FAILED, "buffer is nullptr."); buffer->frameInfo_.timePonit.finishSmooth = finishSmoothT; CHECK_AND_RETURN_RET_LOG(dCameraStatistician_ == nullptr, NOTIFY_FAILED, "dCameraStatistician_ is null."); dCameraStatistician_->CalWholeProcessTime(buffer); diff --git a/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/feedingsmoother/derived/dcamera_time_statistician.cpp b/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/feedingsmoother/derived/dcamera_time_statistician.cpp index 2b94317d..0932d667 100644 --- a/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/feedingsmoother/derived/dcamera_time_statistician.cpp +++ b/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/feedingsmoother/derived/dcamera_time_statistician.cpp @@ -21,6 +21,7 @@ namespace OHOS { namespace DistributedHardware { void DCameraTimeStatistician::CalProcessTime(const std::shared_ptr& data) { + CHECK_AND_RETURN_LOG(data == nullptr, "data is nullptr"); TimeStatistician::CalProcessTime(data); std::shared_ptr dataBuffer = std::reinterpret_pointer_cast(data); DCameraFrameInfo frameInfo = dataBuffer->frameInfo_; @@ -48,6 +49,7 @@ void DCameraTimeStatistician::CalProcessTime(const std::shared_ptr& data) { + CHECK_AND_RETURN_LOG(data == nullptr, "data is nullptr"); DCameraFrameInfo frameInfo = data->frameInfo_; int64_t smooth = frameInfo.timePonit.finishSmooth - frameInfo.timePonit.startSmooth; int64_t sink = frameInfo.timePonit.send - frameInfo.timePonit.startEncode; diff --git a/services/cameraservice/sourceservice/src/distributedcameramgr/dcamerastate/dcamera_source_capture_state.cpp b/services/cameraservice/sourceservice/src/distributedcameramgr/dcamerastate/dcamera_source_capture_state.cpp index cb79c556..82e72616 100644 --- a/services/cameraservice/sourceservice/src/distributedcameramgr/dcamerastate/dcamera_source_capture_state.cpp +++ b/services/cameraservice/sourceservice/src/distributedcameramgr/dcamerastate/dcamera_source_capture_state.cpp @@ -89,6 +89,7 @@ int32_t DCameraSourceCaptureState::DoRegisterTask(std::shared_ptr& camDev, DCameraSourceEvent& event) { + CHECK_AND_RETURN_RET_LOG(camDev == nullptr, DCAMERA_BAD_VALUE, "camDev is nullptr"); std::shared_ptr camEvent = std::make_shared(); camEvent->eventType_ = DCAMERA_MESSAGE; camEvent->eventResult_ = DCAMERA_EVENT_CHANNEL_DISCONNECTED; @@ -143,6 +144,7 @@ int32_t DCameraSourceCaptureState::DoOpenTask(std::shared_ptr& int32_t DCameraSourceCaptureState::DoCloseTask(std::shared_ptr& camDev, DCameraSourceEvent& event) { + CHECK_AND_RETURN_RET_LOG(camDev == nullptr, DCAMERA_BAD_VALUE, "camDev is nullptr"); int32_t ret = camDev->StopAllCapture(); if (ret != DCAMERA_OK) { DHLOGE("StopAllCapture failed, ret: %{public}d", ret); @@ -172,6 +174,7 @@ int32_t DCameraSourceCaptureState::DoCloseTask(std::shared_ptr int32_t DCameraSourceCaptureState::DoStartCaptureTask(std::shared_ptr& camDev, DCameraSourceEvent& event) { + CHECK_AND_RETURN_RET_LOG(camDev == nullptr, DCAMERA_BAD_VALUE, "camDev is nullptr"); std::vector> captureInfos; int32_t ret = event.GetCaptureInfos(captureInfos); if (ret != DCAMERA_OK) { @@ -189,6 +192,7 @@ int32_t DCameraSourceCaptureState::DoStartCaptureTask(std::shared_ptr& camDev, DCameraSourceEvent& event) { + CHECK_AND_RETURN_RET_LOG(camDev == nullptr, DCAMERA_BAD_VALUE, "camDev is nullptr"); std::vector streamIds; int32_t ret = event.GetStreamIds(streamIds); if (ret != DCAMERA_OK) { @@ -216,6 +220,7 @@ int32_t DCameraSourceCaptureState::DoStopCaptureTask(std::shared_ptr& camDev, DCameraSourceEvent& event) { + CHECK_AND_RETURN_RET_LOG(camDev == nullptr, DCAMERA_BAD_VALUE, "camDev is nullptr"); std::vector> settings; int32_t ret = event.GetCameraSettings(settings); if (ret != DCAMERA_OK) { @@ -233,6 +238,7 @@ int32_t DCameraSourceCaptureState::DoUpdateSettingsTask(std::shared_ptr& camDev, DCameraSourceEvent& event) { + CHECK_AND_RETURN_RET_LOG(camDev == nullptr, DCAMERA_BAD_VALUE, "camDev is nullptr"); std::shared_ptr camEvent; int32_t ret = event.GetCameraEvent(camEvent); if (ret != DCAMERA_OK) { diff --git a/services/cameraservice/sourceservice/src/distributedcameramgr/dcamerastate/dcamera_source_config_stream_state.cpp b/services/cameraservice/sourceservice/src/distributedcameramgr/dcamerastate/dcamera_source_config_stream_state.cpp index c76804ef..25d4fe5f 100644 --- a/services/cameraservice/sourceservice/src/distributedcameramgr/dcamerastate/dcamera_source_config_stream_state.cpp +++ b/services/cameraservice/sourceservice/src/distributedcameramgr/dcamerastate/dcamera_source_config_stream_state.cpp @@ -98,6 +98,7 @@ int32_t DCameraSourceConfigStreamState::DoRegisterTask(std::shared_ptr& camDev, DCameraSourceEvent& event) { + CHECK_AND_RETURN_RET_LOG(camDev == nullptr, DCAMERA_BAD_VALUE, "camDev is nullptr"); std::shared_ptr camEvent = std::make_shared(); camEvent->eventType_ = DCAMERA_MESSAGE; camEvent->eventResult_ = DCAMERA_EVENT_CHANNEL_DISCONNECTED; @@ -147,6 +148,7 @@ int32_t DCameraSourceConfigStreamState::DoOpenTask(std::shared_ptr& camDev, DCameraSourceEvent& event) { + CHECK_AND_RETURN_RET_LOG(camDev == nullptr, DCAMERA_BAD_VALUE, "camDev is nullptr"); int32_t ret = camDev->CloseCamera(); if (ret != DCAMERA_OK) { DHLOGE("CloseCamera failed, ret: %{public}d", ret); @@ -170,6 +172,7 @@ int32_t DCameraSourceConfigStreamState::DoCloseTask(std::shared_ptr& camDev, DCameraSourceEvent& event) { + CHECK_AND_RETURN_RET_LOG(camDev == nullptr, DCAMERA_BAD_VALUE, "camDev is nullptr"); std::vector> streamInfos; int32_t ret = event.GetStreamInfos(streamInfos); if (ret != DCAMERA_OK) { @@ -196,6 +199,7 @@ int32_t DCameraSourceConfigStreamState::DoConfigStreamsTask(std::shared_ptr& camDev, DCameraSourceEvent& event) { + CHECK_AND_RETURN_RET_LOG(camDev == nullptr, DCAMERA_BAD_VALUE, "camDev is nullptr"); std::vector streamIds; int32_t ret = event.GetStreamIds(streamIds); if (ret != DCAMERA_OK) { @@ -223,6 +227,7 @@ int32_t DCameraSourceConfigStreamState::DoReleaseStreamsTask(std::shared_ptr& camDev, DCameraSourceEvent& event) { + CHECK_AND_RETURN_RET_LOG(camDev == nullptr, DCAMERA_BAD_VALUE, "camDev is nullptr"); std::vector> captureInfos; int32_t ret = event.GetCaptureInfos(captureInfos); if (ret != DCAMERA_OK) { @@ -253,6 +258,7 @@ int32_t DCameraSourceConfigStreamState::DoStopCaptureTask(std::shared_ptr& camDev, DCameraSourceEvent& event) { + CHECK_AND_RETURN_RET_LOG(camDev == nullptr, DCAMERA_BAD_VALUE, "camDev is nullptr"); std::vector> settings; int32_t ret = event.GetCameraSettings(settings); if (ret != DCAMERA_OK) { @@ -270,6 +276,7 @@ int32_t DCameraSourceConfigStreamState::DoUpdateSettingsTask(std::shared_ptr& camDev, DCameraSourceEvent& event) { + CHECK_AND_RETURN_RET_LOG(camDev == nullptr, DCAMERA_BAD_VALUE, "camDev is nullptr"); std::shared_ptr camEvent; int32_t ret = event.GetCameraEvent(camEvent); if (ret != DCAMERA_OK) { diff --git a/services/cameraservice/sourceservice/src/distributedcameramgr/dcamerastate/dcamera_source_init_state.cpp b/services/cameraservice/sourceservice/src/distributedcameramgr/dcamerastate/dcamera_source_init_state.cpp index ca546074..80d1d3bc 100644 --- a/services/cameraservice/sourceservice/src/distributedcameramgr/dcamerastate/dcamera_source_init_state.cpp +++ b/services/cameraservice/sourceservice/src/distributedcameramgr/dcamerastate/dcamera_source_init_state.cpp @@ -58,6 +58,7 @@ DCameraStateType DCameraSourceInitState::GetStateType() int32_t DCameraSourceInitState::DoRegisterTask(std::shared_ptr& camDev, DCameraSourceEvent& event) { + CHECK_AND_RETURN_RET_LOG(camDev == nullptr, DCAMERA_BAD_VALUE, "camDev is nullptr"); std::shared_ptr param; int32_t ret = event.GetDCameraRegistParam(param); if (ret != DCAMERA_OK) { diff --git a/services/cameraservice/sourceservice/src/distributedcameramgr/dcamerastate/dcamera_source_opened_state.cpp b/services/cameraservice/sourceservice/src/distributedcameramgr/dcamerastate/dcamera_source_opened_state.cpp index 1703c3ed..2b935518 100644 --- a/services/cameraservice/sourceservice/src/distributedcameramgr/dcamerastate/dcamera_source_opened_state.cpp +++ b/services/cameraservice/sourceservice/src/distributedcameramgr/dcamerastate/dcamera_source_opened_state.cpp @@ -90,6 +90,7 @@ int32_t DCameraSourceOpenedState::DoRegisterTask(std::shared_ptr& camDev, DCameraSourceEvent& event) { + CHECK_AND_RETURN_RET_LOG(camDev == nullptr, DCAMERA_BAD_VALUE, "camDev is nullptr"); std::shared_ptr camEvent = std::make_shared(); camEvent->eventType_ = DCAMERA_MESSAGE; camEvent->eventResult_ = DCAMERA_EVENT_CHANNEL_DISCONNECTED; @@ -127,6 +128,7 @@ int32_t DCameraSourceOpenedState::DoUnregisterTask(std::shared_ptr& camDev, DCameraSourceEvent& event) { + CHECK_AND_RETURN_RET_LOG(camDev == nullptr, DCAMERA_BAD_VALUE, "camDev is nullptr"); std::vector> streamInfos; int32_t ret = event.GetStreamInfos(streamInfos); if (ret != DCAMERA_OK) { @@ -159,6 +161,7 @@ int32_t DCameraSourceOpenedState::DoReleaseStreamsTask(std::shared_ptr& camDev, DCameraSourceEvent& event) { + CHECK_AND_RETURN_RET_LOG(camDev == nullptr, DCAMERA_BAD_VALUE, "camDev is nullptr"); std::vector> settings; int32_t ret = event.GetCameraSettings(settings); if (ret != DCAMERA_OK) { @@ -183,6 +186,7 @@ int32_t DCameraSourceOpenedState::DoOpenTask(std::shared_ptr& int32_t DCameraSourceOpenedState::DoCloseTask(std::shared_ptr& camDev, DCameraSourceEvent& event) { + CHECK_AND_RETURN_RET_LOG(camDev == nullptr, DCAMERA_BAD_VALUE, "camDev is nullptr"); int32_t ret = camDev->CloseCamera(); if (ret != DCAMERA_OK) { DHLOGE("CloseCamera failed, ret: %{public}d", ret); @@ -200,6 +204,7 @@ int32_t DCameraSourceOpenedState::DoCloseTask(std::shared_ptr& int32_t DCameraSourceOpenedState::DoEventNofityTask(std::shared_ptr& camDev, DCameraSourceEvent& event) { + CHECK_AND_RETURN_RET_LOG(camDev == nullptr, DCAMERA_BAD_VALUE, "camDev is nullptr"); std::shared_ptr camEvent; int32_t ret = event.GetCameraEvent(camEvent); if (ret != DCAMERA_OK) { diff --git a/services/cameraservice/sourceservice/src/distributedcameramgr/dcamerastate/dcamera_source_regist_state.cpp b/services/cameraservice/sourceservice/src/distributedcameramgr/dcamerastate/dcamera_source_regist_state.cpp index 79d3d7ab..fed14e41 100644 --- a/services/cameraservice/sourceservice/src/distributedcameramgr/dcamerastate/dcamera_source_regist_state.cpp +++ b/services/cameraservice/sourceservice/src/distributedcameramgr/dcamerastate/dcamera_source_regist_state.cpp @@ -74,6 +74,7 @@ DCameraStateType DCameraSourceRegistState::GetStateType() int32_t DCameraSourceRegistState::DoRegisterTask(std::shared_ptr& camDev, DCameraSourceEvent& event) { + CHECK_AND_RETURN_RET_LOG(camDev == nullptr, DCAMERA_BAD_VALUE, "camDev is nullptr"); DHLOGI("DCameraSourceRegistState DoRegisterTask"); std::shared_ptr param; int32_t ret = event.GetDCameraRegistParam(param); @@ -92,6 +93,7 @@ int32_t DCameraSourceRegistState::DoRegisterTask(std::shared_ptr& camDev, DCameraSourceEvent& event) { + CHECK_AND_RETURN_RET_LOG(camDev == nullptr, DCAMERA_BAD_VALUE, "camDev is nullptr"); std::shared_ptr param; int32_t ret = event.GetDCameraRegistParam(param); if (ret != DCAMERA_OK) { @@ -112,6 +114,7 @@ int32_t DCameraSourceRegistState::DoUnregisterTask(std::shared_ptr& camDev, DCameraSourceEvent& event) { + CHECK_AND_RETURN_RET_LOG(camDev == nullptr, DCAMERA_BAD_VALUE, "camDev is nullptr"); int32_t ret = camDev->OpenCamera(); if (ret != DCAMERA_OK) { DHLOGE("DCameraSourceRegistState OpenCamera failed, ret: %{public}d", ret); @@ -129,6 +132,7 @@ int32_t DCameraSourceRegistState::DoCloseTask(std::shared_ptr& int32_t DCameraSourceRegistState::DoEventNofityTask(std::shared_ptr& camDev, DCameraSourceEvent& event) { + CHECK_AND_RETURN_RET_LOG(camDev == nullptr, DCAMERA_BAD_VALUE, "camDev is nullptr"); std::shared_ptr camEvent; int32_t ret = event.GetCameraEvent(camEvent); if (ret != DCAMERA_OK) { diff --git a/services/cameraservice/sourceservice/src/distributedcameramgr/dcamerastate/dcamera_source_state_machine.cpp b/services/cameraservice/sourceservice/src/distributedcameramgr/dcamerastate/dcamera_source_state_machine.cpp index 64ca02d6..188c9c06 100644 --- a/services/cameraservice/sourceservice/src/distributedcameramgr/dcamerastate/dcamera_source_state_machine.cpp +++ b/services/cameraservice/sourceservice/src/distributedcameramgr/dcamerastate/dcamera_source_state_machine.cpp @@ -35,6 +35,8 @@ DCameraSourceStateMachine::~DCameraSourceStateMachine() int32_t DCameraSourceStateMachine::Execute(DCAMERA_EVENT eventType, DCameraSourceEvent& event) { + CHECK_AND_RETURN_RET_LOG(currentState_ == nullptr, DCAMERA_WRONG_STATE, + "DCameraSourceStateMachine currentState_ is nullptr, please check the state machine initialization"); DHLOGI("In state %{public}d execute event %{public}d", currentState_->GetStateType(), eventType); std::shared_ptr camDev = camDev_.lock(); if (camDev == nullptr) { @@ -52,6 +54,7 @@ int32_t DCameraSourceStateMachine::Execute(DCAMERA_EVENT eventType, DCameraSourc void DCameraSourceStateMachine::UpdateState(DCameraStateType stateType) { + CHECK_AND_RETURN_LOG(currentState_ == nullptr, "DCameraSourceStateMachine currentState_ is nullptr"); if (stateType != DCAMERA_STATE_INIT) { DHLOGI("DCameraSourceStateMachine update state from %{public}d to %{public}d", currentState_->GetStateType(), stateType); @@ -64,6 +67,8 @@ void DCameraSourceStateMachine::UpdateState(DCameraStateType stateType) int32_t DCameraSourceStateMachine::GetCameraState() { + CHECK_AND_RETURN_RET_LOG(currentState_ == nullptr, DCAMERA_WRONG_STATE, + "DCameraSourceStateMachine currentState_ is nullptr"); DHLOGI("GetCameraState In state %{public}d", currentState_->GetStateType()); return currentState_->GetStateType(); } diff --git a/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/dcamera_source_callback_proxy_test.cpp b/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/dcamera_source_callback_proxy_test.cpp index 6ba64b5d..dd8cd63c 100644 --- a/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/dcamera_source_callback_proxy_test.cpp +++ b/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/dcamera_source_callback_proxy_test.cpp @@ -74,6 +74,7 @@ HWTEST_F(DcameraSourceCallbackProxyTest, dcamera_source_callback_proxy_test_001, DHLOGI("DcameraSourceCallbackProxyTest::dcamera_source_callback_proxy_test_001"); sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + ASSERT_NE(samgr, nullptr); sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID); sptr callbackProxy(new DCameraSourceCallbackProxy(remoteObject)); EXPECT_EQ(false, callbackProxy == nullptr); @@ -98,6 +99,7 @@ HWTEST_F(DcameraSourceCallbackProxyTest, dcamera_source_callback_proxy_test_002, DHLOGI("DcameraSourceCallbackProxyTest::dcamera_source_callback_proxy_test_002"); sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + ASSERT_NE(samgr, nullptr); sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID); sptr callbackProxy(new DCameraSourceCallbackProxy(remoteObject)); EXPECT_EQ(false, callbackProxy == nullptr); @@ -122,6 +124,7 @@ HWTEST_F(DcameraSourceCallbackProxyTest, dcamera_source_callback_proxy_test_003, DHLOGI("DcameraSourceCallbackProxyTest::dcamera_source_callback_proxy_test_003"); sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + ASSERT_NE(samgr, nullptr); sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID); sptr callbackProxy(new DCameraSourceCallbackProxy(remoteObject)); EXPECT_EQ(false, callbackProxy == nullptr); @@ -145,6 +148,7 @@ HWTEST_F(DcameraSourceCallbackProxyTest, dcamera_source_callback_proxy_test_004, DHLOGI("DcameraSourceCallbackProxyTest::dcamera_source_callback_proxy_test_004"); sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + ASSERT_NE(samgr, nullptr); sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID); sptr callbackProxy(new DCameraSourceCallbackProxy(remoteObject)); EXPECT_EQ(false, callbackProxy == nullptr); @@ -183,6 +187,7 @@ HWTEST_F(DcameraSourceCallbackProxyTest, CheckParams_001, TestSize.Level1) DHLOGI("DcameraSourceCallbackProxyTest::CheckParams_001"); sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + ASSERT_NE(samgr, nullptr); sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID); sptr callbackProxy(new DCameraSourceCallbackProxy(remoteObject)); @@ -210,6 +215,7 @@ HWTEST_F(DcameraSourceCallbackProxyTest, OnDataSyncTrigger_001, TestSize.Level1) DHLOGI("DcameraSourceCallbackProxyTest::OnDataSyncTrigger_001"); sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + ASSERT_NE(samgr, nullptr); sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID); sptr callbackProxy(new DCameraSourceCallbackProxy(remoteObject)); @@ -245,6 +251,7 @@ HWTEST_F(DcameraSourceCallbackProxyTest, OnHardwareStateChanged_001, TestSize.Le DHLOGI("DcameraSourceCallbackProxyTest::OnHardwareStateChanged_001"); sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + ASSERT_NE(samgr, nullptr); sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID); sptr callbackProxy(new DCameraSourceCallbackProxy(remoteObject)); diff --git a/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/distributed_camera_source_service_test.cpp b/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/distributed_camera_source_service_test.cpp index 418c0cdc..7caa25a3 100644 --- a/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/distributed_camera_source_service_test.cpp +++ b/services/cameraservice/sourceservice/test/unittest/common/distributedcamera/distributed_camera_source_service_test.cpp @@ -180,6 +180,7 @@ HWTEST_F(DistributedCameraSourceServiceTest, dcamera_source_service_test_006, Te std::string params = "test006"; sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + ASSERT_NE(samgr, nullptr); sptr remoteObject = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SOURCE_SA_ID); sptr callbackProxy(new DCameraSourceCallbackProxy(remoteObject)); testSrcService_->listener_ = std::make_shared(); diff --git a/services/cameraservice/sourceservice/test/unittest/common/distributedcameramgr/dcamera_source_service_ipc_test.cpp b/services/cameraservice/sourceservice/test/unittest/common/distributedcameramgr/dcamera_source_service_ipc_test.cpp index 0a22b70c..4e8a425e 100644 --- a/services/cameraservice/sourceservice/test/unittest/common/distributedcameramgr/dcamera_source_service_ipc_test.cpp +++ b/services/cameraservice/sourceservice/test/unittest/common/distributedcameramgr/dcamera_source_service_ipc_test.cpp @@ -142,6 +142,7 @@ HWTEST_F(DCameraSourceServiceIpcTest, dcamera_source_service_ipc_test_005, TestS DCameraSourceServiceIpc::GetInstance().Init(); sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + ASSERT_NE(samgr, nullptr); wptr remote = samgr->GetSystemAbility(DISTRIBUTED_HARDWARE_CAMERA_SINK_SA_ID); DCameraSourceServiceIpc::GetInstance().OnSinkRemoteCamSrvDied(remote); DCameraSourceServiceIpc::GetInstance().UnInit(); diff --git a/services/channel/src/allconnect/distributed_camera_allconnect_manager.cpp b/services/channel/src/allconnect/distributed_camera_allconnect_manager.cpp index cd01addb..89b429dc 100644 --- a/services/channel/src/allconnect/distributed_camera_allconnect_manager.cpp +++ b/services/channel/src/allconnect/distributed_camera_allconnect_manager.cpp @@ -243,6 +243,8 @@ int32_t DCameraAllConnectManager::UnRegisterLifecycleCallback() int32_t DCameraAllConnectManager::ApplyResult(int32_t errorcode, int32_t result, const char *reason) { + CHECK_AND_RETURN_RET_LOG(applyResultBlock_ == nullptr, DistributedCameraErrno::DCAMERA_ERR_APPLY_RESULT, + "DCamera allconnect ApplyResult applyResultBlock_ is nullptr"); DHLOGI("DCamera allconnect ApplyResult begin"); if (result != PASS) { DHLOGE("DCamera allconnect Apply Result is Reject, errorcode is %{public}d, reason is %{public}s", diff --git a/services/data_process/src/pipeline_node/fpscontroller/fps_controller_process.cpp b/services/data_process/src/pipeline_node/fpscontroller/fps_controller_process.cpp index d2c7c0d3..9aac898e 100644 --- a/services/data_process/src/pipeline_node/fpscontroller/fps_controller_process.cpp +++ b/services/data_process/src/pipeline_node/fpscontroller/fps_controller_process.cpp @@ -269,7 +269,7 @@ bool FpsControllerProcess::IsDropFrame(float incomingFps) bool FpsControllerProcess::ReduceFrameRateByUniformStrategy(int32_t incomingFrmRate) { DHLOGD("Frame control, reduce frame rate by uniform rate strategy"); - if (incomingFrmRate > targetFrameRate_) { + if (incomingFrmRate <= targetFrameRate_) { DHLOGD("incoming fps not more than targetFrameRate_, not drop"); return false; } -- Gitee