diff --git a/common/src/utils/dcamera_utils_tools.cpp b/common/src/utils/dcamera_utils_tools.cpp index 8d21d2d0b425e796a086c698dbb113e7dca67962..ddba00d77c70261367b9d5a3670238d1ef8283e0 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 258d3fbbc49fa1076482c0514cada2ef6f779c87..44020a1597e2f055eead8d2ac9dd967087d234f9 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 bcbc124a071b44c5bc35158c2f118d1202fe3ad4..b42201efb3790c84cfa2b6632eb3fd276889b946 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 8947d9236e8757fa04ff7c123b23f35cc0930710..ad71efacc8f797b655777ed7fcf6e8cf0115f8f4 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 c5f470a678be9c042cd9f2795ad18c99d2131747..b60216670b8d7bd779346d557f2fe93e6022dec2 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 453b1ac2d78951fc650d65b9c374682dd72496ad..d4dd02557dea9034324ee9bc1d9cfc7e0da2c2cf 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 1bf7996ecd684ed334b5c63272824377bfb01a75..f1ac84dd67e731500d974e86ba4bfb3cd1c99f9c 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 09766a4f71bd643116e1d8f1385817f462f4924d..5bbd20b549a04c547e6bdf6f1a085d2cd56d9ec7 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 fa85b599fc815b87920acd833695c1d93b11747b..bdf73e2fb1952bde48750c20fb6fd68de1253714 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 495126a7992934391af257925eeb15104fd6c711..4d3bef6db7f6b44adbda2170ec7a97a9ba5c8655 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 13355d90235b26d387b49ac722b7fe03fd99c16c..b3d29b04c956f91a17c3b52ed365064d547a969d 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 7a75bbb6fda6c0fb9932796d32867ba5addb2477..7829e4a8af35d9f46625d9b0bda442163e90cd6a 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 4ffe5f415efe25543dda4ca792158c194a235659..653940498138a6a3676628ff98b35f190c201cb3 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 624c533466258ef8791a9f8c21f7ca818e748dc8..62fdc521c2c17a551d4aec09eb387990fd586118 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 d88493ec987e90b8754ed23c601989f0b443e559..d5473d44efaf11a7a40f209bd9049917d2bd0a16 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 3a943a543a681985e4b90851fbbfb45f4c0710ef..8db6750311f033b8de83efde942edd111e898474 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 44fca0f19244457b16545067cf19b4392df090e8..504228f7d13a143885d432b3b6d8359243a9fbb7 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 e04c84d8c7515411c956b318aaabcc051253f2e8..ee6443be636afb97b014d42f3018aef914012b68 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 713d0c93cf6d23e8a7df8087813dbbc1ea876556..e16eb98c5a835230f09c695354bbe06c00acd183 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 dc5a4101754bad56740d5555bc56ef67579b9d48..c63ffb9a391c9a1b454644234a210659bdf45cf2 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 5c64ce86b372e3cf85d5fbb06800623ea2d41376..8a5c7122819b2f32ddafb4e18816193e51ceb706 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 a0f2fa77a8d2287fc999c736251c410cf7a2e3e3..9528dc7b1054af349d6de0cd08a5dc0444cab310 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 616bee39218593955af0bd0013bdede7b473f267..d72a7d4bbf3986b5b25b33671e80d8a619ea6d7a 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 208469030441d8ca776cecae1d4073ab0d6a5819..8a7481b4f7c08463e2f5f9af6797de050915369e 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 5ce68a62141707bd8d43f96ad201a547521b3ad9..5e2b2a3dd30d36bb8325dc2a98d133ee91f8d952 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 e7a922b66faac44ae14fd69740b1eb32141a7446..795dcda9087e83973b13452a653b97ad69c622a2 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 8d456ca797b27201262a931208bb73ce25929179..902ade161bde0bac7d5b24735c98e43fa7fcc160 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 5e588116df985143b81cddede0cb802f0f1d4d58..6d767f662a1bd1ab6dd564e52252e8b9de9e8238 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 e3efaca10f821f4c031e8265b1424aa6e4ad973c..e9c5e44a623d6f33a4de3ac8532abc14578b9f65 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 25a286f9564ee84c9ada04af85c12edd703f713a..b2d35fe51e43b5dbf85052a3cf98680a919ab9d9 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 1dcd4b7389f659de556b336d84795d6e06d4826c..6348a813aab41433c634edcee0c5d3489cbc7251 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 dcf91a8a2f5ea74c9539be9e235d1a796be07cf9..0fef4a9ecab36f35da9bfc61584c152c62fd3464 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 ad2aec0685e666ba827e2354a93c11a7fce8c3b5..093c36e6924a700223e757cf30def16f2be89498 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 eaad52101017451bf4e9ade5e5b8327f1e85abc5..b045950de5a67658615e5f23a9c189f90b91cf00 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 f264135d4a3b8f999bb602c9cad65e1df464ed09..c2b676bc3658c8144b81fcd1582f6bc3d8b93c9c 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 d3cd7158b5ae72f471b1db7b0f50de9cacdd80cf..294ab4d200daa297857ad383c6ca317780d6b1f1 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 5747a9b5f976b785799f37fb40f70cb358c5e234..361a08f3e65703e903166a84a4b54cec7f1e5ef2 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 d220992d3652284e2007a6a00273d9680fb248fa..97e78bcf3bb40d5c39702f66ec50d5de25307a1d 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 1aeff239f37380357fb5e8aa2882c97e12bc320e..34ba50def63ebec5ba5667695daa6f571ef93d06 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 6d13dc88e4680fdf1f519f79c05367e646e0cf5d..6d507f790e98b09f31779b5ed894a8dc2ef0b6f2 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 635ccfd83b9f8d02e8c7c67f1a0cc26f7be4841b..6f91a337e97b62aa018ebd21883971aeed45a277 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 2b94317d77b956835c6ead1052503cd1cebc3b2f..0932d667cdb96726cabba62a176ffb3b98b135fe 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 cb79c5565038e7231ae3889ebde0c6d55105a788..82e72616f809776618c31eb5746df423598bfff1 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 c76804efacc325302fabb46cfa8d417cfa014c16..25d4fe5f6db5150f8a8a1d57f0c480c6e28c9edc 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 ca54607449de081ebed1c9bbb25b4ba81a7bd1db..80d1d3bca3b8eb3194ec361d5bdb96b9afd9bc87 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 1703c3ed871c43a6fb15540776056364ba60cb8a..2b93551838c098f1960444920067374bc30aa1f9 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 79d3d7ab61edaf8c70d8d1c418255747caf1bc8b..fed14e418dce75c721957998f299ab4107c50937 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 64ca02d68f3ab7fb13fac16284701b089589ef00..188c9c062aafe60ab9c31c4d3fbee0154d293ca7 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 6ba64b5df2dcf50fefcebb0e22630125274df90b..dd8cd63c54a8d2385a02d3628c1045bc938946cf 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 418c0cdca8cdcaeb2f4e5f0a8c9159244cb97121..7caa25a36b5fcd1e82eca13c1e92cbc349ac6744 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 0a22b70ce55557413680e02a971e6b37d67de90f..4e8a425edf6643e1556af83b1fd09ba24a43f365 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 cd01addbbdf4a86a40ae3b5fea1f78e6d9e9ae30..89b429dc62791154a892e8d0c1de1daf0d31b4f3 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 d2c7c0d37f3c7e381847bf6c7cf081a02c6806df..9aac898e69a08344fa53dd9a6d73d213bd96d4a5 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; }