From 05f6cc583aaa2cb368f3a6a1e650f0047fe32bfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=AA=E5=B0=91=E4=BF=8A?= Date: Fri, 24 Jan 2025 14:57:25 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=9C=AC=E6=9C=BA=E5=8F=B7=E7=A0=81?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E9=A2=91=E7=B9=81=E8=AE=BF=E9=97=AE=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 汪少俊 --- services/sim/src/multi_sim_controller.cpp | 20 +++++++++++++------ .../core_service_gtest/core_service_test.cpp | 13 ++++++++++++ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/services/sim/src/multi_sim_controller.cpp b/services/sim/src/multi_sim_controller.cpp index ca8c3d72f..e2176d12c 100644 --- a/services/sim/src/multi_sim_controller.cpp +++ b/services/sim/src/multi_sim_controller.cpp @@ -353,6 +353,8 @@ bool MultiSimController::InitShowNumber(int slotId) int32_t result = TELEPHONY_ERROR; if (!showNumber.empty()) { result = SetShowNumberToDB(slotId, showNumber); + TELEPHONY_LOGI( + "Init slotId: %{public}d get phone number from sim and save result: %{public}d", slotId, result); } return result == TELEPHONY_ERR_SUCCESS; } @@ -1101,8 +1103,13 @@ int32_t MultiSimController::GetShowNumber(int32_t slotId, std::u16string &showNu } showNumber = simFileManager_[slotId]->GetSimTelephoneNumber(); if (!showNumber.empty()) { - int32_t result = SetShowNumberToDB(slotId, showNumber); - TELEPHONY_LOGI("slotId: %{public}d get phone number from sim and save result: %{public}d", slotId, result); + if (showNumber != Str8ToStr16(localCacheInfo_[slotId].phoneNumber)) { + TelFFRTUtils::Submit([=]() { + int32_t result = SetShowNumberToDB(slotId, showNumber); + TELEPHONY_LOGI( + "slotId: %{public}d get phone number from sim and save result: %{public}d", slotId, result); + }); + } return TELEPHONY_ERR_SUCCESS; } int curSimId; @@ -1232,10 +1239,11 @@ int32_t MultiSimController::GetSimTelephoneNumber(int32_t slotId, std::u16string telephoneNumber = Str8ToStr16(result); TELEPHONY_LOGI("impu result is empty:%{public}s, slotId:%{public}d", (telephoneNumber.empty() ? "true" : "false"), slotId); - if (!telephoneNumber.empty()) { - int32_t result = TELEPHONY_ERROR; - result = SetShowNumberToDB(slotId, telephoneNumber); - TELEPHONY_LOGI("slotId: %{public}d save impu phone number result: %{public}d", slotId, result); + if (!telephoneNumber.empty() && telephoneNumber != Str8ToStr16(localCacheInfo_[slotId].phoneNumber)) { + TelFFRTUtils::Submit([=]() { + int32_t ret = SetShowNumberToDB(slotId, telephoneNumber); + TELEPHONY_LOGI("slotId: %{public}d save impu phone number result: %{public}d", slotId, ret); + }); } return TELEPHONY_ERR_SUCCESS; } diff --git a/test/unittest/core_service_gtest/core_service_test.cpp b/test/unittest/core_service_gtest/core_service_test.cpp index a22934729..182a59d6a 100644 --- a/test/unittest/core_service_gtest/core_service_test.cpp +++ b/test/unittest/core_service_gtest/core_service_test.cpp @@ -610,6 +610,19 @@ HWTEST_F(CoreServiceTest, CoreService_DelIccDiallingNumbers_001, Function | Medi ASSERT_EQ(result, TELEPHONY_ERR_ILLEGAL_USE_OF_SYSTEM_API); } +/** + * @tc.number CoreService_GetSimTelephoneNumber_002 + * @tc.name test normal branch + * @tc.desc Function test + */ +HWTEST_F(CoreServiceTest, CoreService_GetSimTelephoneNumber_002, Function | MediumTest | Level1) +{ + SecurityToken token; + std::u16string telephoneNumber = u""; + auto result = DelayedSingleton::GetInstance()->GetSimTelephoneNumber(1, telephoneNumber); + EXPECT_EQ(result, TELEPHONY_ERR_ILLEGAL_USE_OF_SYSTEM_API); +} + /** * @tc.number CoreService_UpdateIccDiallingNumbers_001 * @tc.name test normal branch -- Gitee From 1f104a5693c6d829ec2a02ec701b8369653bb61c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=AA=E5=B0=91=E4=BF=8A?= Date: Fri, 24 Jan 2025 07:35:57 +0000 Subject: [PATCH 2/2] update services/sim/src/multi_sim_controller.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 汪少俊 --- services/sim/src/multi_sim_controller.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/sim/src/multi_sim_controller.cpp b/services/sim/src/multi_sim_controller.cpp index e2176d12c..1c50e4820 100644 --- a/services/sim/src/multi_sim_controller.cpp +++ b/services/sim/src/multi_sim_controller.cpp @@ -1240,7 +1240,7 @@ int32_t MultiSimController::GetSimTelephoneNumber(int32_t slotId, std::u16string TELEPHONY_LOGI("impu result is empty:%{public}s, slotId:%{public}d", (telephoneNumber.empty() ? "true" : "false"), slotId); if (!telephoneNumber.empty() && telephoneNumber != Str8ToStr16(localCacheInfo_[slotId].phoneNumber)) { - TelFFRTUtils::Submit([=]() { + TelFFRTUtils::Submit([=]() { int32_t ret = SetShowNumberToDB(slotId, telephoneNumber); TELEPHONY_LOGI("slotId: %{public}d save impu phone number result: %{public}d", slotId, ret); }); -- Gitee