diff --git a/services/include/telephony_state_registry_record.h b/services/include/telephony_state_registry_record.h index 434c23b0c011a36c1082079014cd962a671d79cf..7b1b577508cd38cf178c1355b1d36756f282242c 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 14c41cbfdf0f71b823e729bcc2094f570e764e3e..1274522f053b1edff9d9f7b5cc38d5f04e7a53d7 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 1a89f7ee36c948a1a498c8a643178d8b1046fa24..67196ad7f4db4f65166b21e4416e5f0c2307f8a4 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; - int32_t result = TELEPHONY_STATE_REGISTRY_DATA_NOT_EXIST; + 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 < copyStateRecords.size(); i++) { + r = copyStateRecords[i]; if (r.IsExistStateListener(TelephonyObserverBroker::OBSERVER_MASK_NETWORK_STATE) && (r.slotId_ == slotId) && r.telephonyObserver_ != nullptr) { if (TELEPHONY_EXT_WRAPPER.onNetworkStateUpdated_ != nullptr) {