From 8f68132f456ace78fdcf077d160ccc1d56d99e14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=B3=BB=E6=9C=8B?= Date: Fri, 1 Aug 2025 07:02:08 +0000 Subject: [PATCH 1/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9UpdateNetworkState?= =?UTF-8?q?=E6=8C=81=E9=94=81=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 刘峻朋 --- .../include/telephony_state_registry_record.h | 1 + services/src/telephony_state_registry_record.cpp | 16 ++++++++++++++++ .../src/telephony_state_registry_service.cpp | 14 ++++++++++++-- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/services/include/telephony_state_registry_record.h b/services/include/telephony_state_registry_record.h index 434c23b..7b1b577 100644 --- a/services/include/telephony_state_registry_record.h +++ b/services/include/telephony_state_registry_record.h @@ -24,6 +24,7 @@ namespace OHOS { namespace Telephony { class TelephonyStateRegistryRecord { public: + TelephonyStateRegistryRecord(const TelephonyStateRegistryRecord &Record); bool IsCanReadCallHistory(); /** * IsExistStateListener diff --git a/services/src/telephony_state_registry_record.cpp b/services/src/telephony_state_registry_record.cpp index 14c41cb..1274522 100644 --- a/services/src/telephony_state_registry_record.cpp +++ b/services/src/telephony_state_registry_record.cpp @@ -23,6 +23,22 @@ namespace OHOS { namespace Telephony { using namespace OHOS::Security::AccessToken; +TelephonyStateRegistryRecord::TelephonyStateRegistryRecord(const TelephonyStateRegistryRecord &Record) +{ + bundleName_ = Record.bundleName_ + tokenId_ = Record.tokenId_; + uid_ = Record.uid_ + pid_ = Record.pid_; + mask_ = Record.mask_; + slotId_ = Record.slotId_; + + if (Record.telephonyObserver_ != nullptr) { + telephonyObserver_ = std::make_shared(*Record.telephonyObserver_); + } else { + telephonyObserver_ = nullptr; + } +} + bool TelephonyStateRegistryRecord::IsCanReadCallHistory() { if (AccessTokenKit::VerifyAccessToken(tokenId_, Permission::READ_CALL_LOG) == PERMISSION_DENIED) { diff --git a/services/src/telephony_state_registry_service.cpp b/services/src/telephony_state_registry_service.cpp index 1a89f7e..205ae77 100644 --- a/services/src/telephony_state_registry_service.cpp +++ b/services/src/telephony_state_registry_service.cpp @@ -338,9 +338,15 @@ int32_t TelephonyStateRegistryService::UpdateNetworkState(int32_t slotId, const } std::lock_guard guard(lock_); searchNetworkState_[slotId] = networkState; + std::vector copyStateRecords; + for(size_t i = 0; i < stateRecords_.size(); i++) { + TelephonyStateRegistryRecord r(stateRecords_[i]); + copyStateRecords.push_back(r); + } + guard.unlock(); int32_t result = TELEPHONY_STATE_REGISTRY_DATA_NOT_EXIST; - for (size_t i = 0; i < stateRecords_.size(); i++) { - TelephonyStateRegistryRecord r = stateRecords_[i]; + for (size_t i = 0; i < copyStateRecords.size(); i++) { + TelephonyStateRegistryRecord r = copyStateRecords[i]; if (r.IsExistStateListener(TelephonyObserverBroker::OBSERVER_MASK_NETWORK_STATE) && (r.slotId_ == slotId) && r.telephonyObserver_ != nullptr) { if (TELEPHONY_EXT_WRAPPER.onNetworkStateUpdated_ != nullptr) { @@ -887,5 +893,9 @@ bool TelephonyStateRegistryService::IsCommonEventServiceAbilityExist() __attribu } return true; } + +std::vector TelephonyStateRegistryService::Copy + + } // namespace Telephony } // namespace OHOS -- Gitee From a4b02c5790bcf997122858615832e2070c8b5bf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=B3=BB=E6=9C=8B?= Date: Fri, 1 Aug 2025 07:11:31 +0000 Subject: [PATCH 2/6] update services/src/telephony_state_registry_service.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 刘峻朋 --- services/src/telephony_state_registry_service.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/src/telephony_state_registry_service.cpp b/services/src/telephony_state_registry_service.cpp index 205ae77..83d9a14 100644 --- a/services/src/telephony_state_registry_service.cpp +++ b/services/src/telephony_state_registry_service.cpp @@ -339,7 +339,7 @@ int32_t TelephonyStateRegistryService::UpdateNetworkState(int32_t slotId, const std::lock_guard guard(lock_); searchNetworkState_[slotId] = networkState; std::vector copyStateRecords; - for(size_t i = 0; i < stateRecords_.size(); i++) { + for (size_t i = 0; i < stateRecords_.size(); i++) { TelephonyStateRegistryRecord r(stateRecords_[i]); copyStateRecords.push_back(r); } -- Gitee From bcb19d4447ee94c4188aab06e5ae0f88e93cb1f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=B3=BB=E6=9C=8B?= Date: Fri, 1 Aug 2025 08:30:17 +0000 Subject: [PATCH 3/6] update services/src/telephony_state_registry_service.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 刘峻朋 --- services/src/telephony_state_registry_service.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/src/telephony_state_registry_service.cpp b/services/src/telephony_state_registry_service.cpp index 83d9a14..b9dfb26 100644 --- a/services/src/telephony_state_registry_service.cpp +++ b/services/src/telephony_state_registry_service.cpp @@ -340,7 +340,7 @@ int32_t TelephonyStateRegistryService::UpdateNetworkState(int32_t slotId, const searchNetworkState_[slotId] = networkState; std::vector copyStateRecords; for (size_t i = 0; i < stateRecords_.size(); i++) { - TelephonyStateRegistryRecord r(stateRecords_[i]); + TelephonyStateRegistryRecord r = (stateRecords_[i]); copyStateRecords.push_back(r); } guard.unlock(); -- Gitee From a91407c36460bbe4db7ca8cdf89e20f7aa896310 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=B3=BB=E6=9C=8B?= Date: Fri, 1 Aug 2025 08:33:36 +0000 Subject: [PATCH 4/6] update services/src/telephony_state_registry_service.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 刘峻朋 --- services/src/telephony_state_registry_service.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/src/telephony_state_registry_service.cpp b/services/src/telephony_state_registry_service.cpp index b9dfb26..8774b95 100644 --- a/services/src/telephony_state_registry_service.cpp +++ b/services/src/telephony_state_registry_service.cpp @@ -340,7 +340,7 @@ int32_t TelephonyStateRegistryService::UpdateNetworkState(int32_t slotId, const searchNetworkState_[slotId] = networkState; std::vector copyStateRecords; for (size_t i = 0; i < stateRecords_.size(); i++) { - TelephonyStateRegistryRecord r = (stateRecords_[i]); + TelephonyStateRegistryRecord r = stateRecords_[i]; copyStateRecords.push_back(r); } guard.unlock(); -- Gitee From 7e94420811bf17648eebc117af98d6ae2d9808d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=B3=BB=E6=9C=8B?= Date: Fri, 1 Aug 2025 09:07:59 +0000 Subject: [PATCH 5/6] update services/src/telephony_state_registry_service.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 刘峻朋 --- services/src/telephony_state_registry_service.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/src/telephony_state_registry_service.cpp b/services/src/telephony_state_registry_service.cpp index 8774b95..7cc0d97 100644 --- a/services/src/telephony_state_registry_service.cpp +++ b/services/src/telephony_state_registry_service.cpp @@ -346,7 +346,7 @@ int32_t TelephonyStateRegistryService::UpdateNetworkState(int32_t slotId, const guard.unlock(); int32_t result = TELEPHONY_STATE_REGISTRY_DATA_NOT_EXIST; for (size_t i = 0; i < copyStateRecords.size(); i++) { - TelephonyStateRegistryRecord r = copyStateRecords[i]; + r = copyStateRecords[i]; if (r.IsExistStateListener(TelephonyObserverBroker::OBSERVER_MASK_NETWORK_STATE) && (r.slotId_ == slotId) && r.telephonyObserver_ != nullptr) { if (TELEPHONY_EXT_WRAPPER.onNetworkStateUpdated_ != nullptr) { -- Gitee From 9aa560ce4f44535f336af65ec3d6755fdec16fae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=B3=BB=E6=9C=8B?= Date: Fri, 1 Aug 2025 09:16:49 +0000 Subject: [PATCH 6/6] update services/src/telephony_state_registry_service.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 刘峻朋 --- services/src/telephony_state_registry_service.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/services/src/telephony_state_registry_service.cpp b/services/src/telephony_state_registry_service.cpp index 7cc0d97..67196ad 100644 --- a/services/src/telephony_state_registry_service.cpp +++ b/services/src/telephony_state_registry_service.cpp @@ -893,9 +893,5 @@ bool TelephonyStateRegistryService::IsCommonEventServiceAbilityExist() __attribu } return true; } - -std::vector TelephonyStateRegistryService::Copy - - } // namespace Telephony } // namespace OHOS -- Gitee