From 8c18f8f784bc0210707568b03278339ae513bbfa Mon Sep 17 00:00:00 2001 From: wangziming Date: Fri, 23 Sep 2022 21:52:56 +0800 Subject: [PATCH] safety Signed-off-by: wangziming --- service/src/telephony_state_registry_service.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/service/src/telephony_state_registry_service.cpp b/service/src/telephony_state_registry_service.cpp index 25c5cfc..73858a2 100644 --- a/service/src/telephony_state_registry_service.cpp +++ b/service/src/telephony_state_registry_service.cpp @@ -425,9 +425,17 @@ void TelephonyStateRegistryService::SendCallStateChanged( want.SetParam("state", state); want.SetParam("number", Str16ToStr8(number)); want.SetAction(CALL_STATE_CHANGE_ACTION); - int32_t eventCode = 1; - std::string eventData("callStateChanged"); - PublishCommonEvent(want, eventCode, eventData); + EventFwk::CommonEventData data; + data.SetWant(want); + EventFwk::CommonEventPublishInfo publishInfo; + publishInfo.SetOrdered(true); + std::vector callPermissions; + callPermissions.emplace_back(Permission::GET_TELEPHONY_STATE); + publishInfo.SetSubscriberPermissions(callPermissions); + bool publishResult = EventFwk::CommonEventManager::PublishCommonEvent(data, publishInfo, nullptr); + if (!publishResult) { + TELEPHONY_LOGE("SendCallStateChanged PublishBroadcastEvent result fail"); + } } void TelephonyStateRegistryService::SendCellularDataConnectStateChanged( @@ -564,4 +572,4 @@ std::string TelephonyStateRegistryService::GetBindSpendTime() return oss.str(); } } // namespace Telephony -} // namespace OHOS \ No newline at end of file +} // namespace OHOS -- Gitee