diff --git a/services/sim/src/ruim_file.cpp b/services/sim/src/ruim_file.cpp index 61624ab7..a4e33941 100644 --- a/services/sim/src/ruim_file.cpp +++ b/services/sim/src/ruim_file.cpp @@ -155,6 +155,10 @@ bool RuimFile::ProcessIccLocked(const AppExecFwk::InnerEvent::Pointer &event) IccFile::ProcessIccLocked(); lockQueried_ = true; AppExecFwk::InnerEvent::Pointer eventICCID = BuildCallerInfo(MSG_SIM_OBTAIN_ICCID_DONE); + if (fileController_ == nullptr) { + TELEPHONY_LOGE("fileController_ is nullptr!"); + return false; + } fileController_->ObtainBinaryFile(ELEMENTARY_FILE_ICCID, eventICCID); fileToGet_++; return false; diff --git a/services/sim/src/sim_file.cpp b/services/sim/src/sim_file.cpp index 4a85e6f1..dd647f09 100755 --- a/services/sim/src/sim_file.cpp +++ b/services/sim/src/sim_file.cpp @@ -260,6 +260,10 @@ bool SimFile::ProcessIccLocked(const AppExecFwk::InnerEvent::Pointer &event) IccFile::ProcessIccLocked(); lockQueried_ = true; AppExecFwk::InnerEvent::Pointer eventIccId = BuildCallerInfo(MSG_SIM_OBTAIN_ICCID_DONE); + if (fileController_ == nullptr) { + TELEPHONY_LOGE("fileController_ is nullptr!"); + return false; + } fileController_->ObtainBinaryFile(ELEMENTARY_FILE_ICCID, eventIccId); fileToGet_++; return false; diff --git a/test/unittest/core_service_gtest/zero_branch_test.cpp b/test/unittest/core_service_gtest/zero_branch_test.cpp index 1aa7e108..22fd8db0 100644 --- a/test/unittest/core_service_gtest/zero_branch_test.cpp +++ b/test/unittest/core_service_gtest/zero_branch_test.cpp @@ -751,6 +751,27 @@ HWTEST_F(BranchTest, Telephony_SimFile_005, Function | MediumTest | Level1) EXPECT_FALSE(simFile->opl5gFiles_.empty()); } +/** + * @tc.number Telephony_SimFile_006 + * @tc.name test error branch + * @tc.desc Function test + */ +HWTEST_F(BranchTest, Telephony_SimFile_006, Function | MediumTest | Level1) +{ + std::shared_ptr telRilManager = std::make_shared(); + std::shared_ptr simStateManager = std::make_shared(telRilManager); + std::shared_ptr simFile = std::make_shared(simStateManager); + EventFwk::MatchingSkills matchingSkills; + matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_OPERATOR_CONFIG_CHANGED); + EventFwk::CommonEventSubscribeInfo subcribeInfo(matchingSkills); + auto simFileManager = std::make_shared(subcribeInfo, std::weak_ptr(telRilManager), + std::weak_ptr(simStateManager)); + simFileManager->Init(0); + auto event = AppExecFwk::InnerEvent::Get(0); + event = nullptr; + EXPECT_FALSE(simFile->ProcessIccLocked(event)); +} + /** * @tc.number Telephony_ISimFile_001 * @tc.name test error branch @@ -839,6 +860,27 @@ HWTEST_F(BranchTest, Telephony_RuimFile_001, Function | MediumTest | Level1) EXPECT_TRUE(rUimFile->ProcessGetSpnDone(event)); } +/** + * @tc.number Telephony_RuimFile_002 + * @tc.name test error branch + * @tc.desc Function test + */ +HWTEST_F(BranchTest, Telephony_RuimFile_002, Function | MediumTest | Level1) +{ + std::shared_ptr telRilManager = std::make_shared(); + std::shared_ptr simStateManager = std::make_shared(telRilManager); + std::shared_ptr rUimFile = std::make_shared(simStateManager); + EventFwk::MatchingSkills matchingSkills; + matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_OPERATOR_CONFIG_CHANGED); + EventFwk::CommonEventSubscribeInfo subcribeInfo(matchingSkills); + auto simFileManager = std::make_shared(subcribeInfo, std::weak_ptr(telRilManager), + std::weak_ptr(simStateManager)); + simFileManager->Init(0); + auto event = AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_SIM_STATE_READY, 1); + event = nullptr; + EXPECT_FALSE(rUimFile->ProcessIccLocked(event)); +} + /** * @tc.number Telephony_IccFileController_001 * @tc.name test error branch