1/* 2 * Copyright (C) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 17#include "sms_mms_common.h" 18 19#include "sms_mms_data.h" 20#include "common_event_manager.h" 21#include "common_event_support.h" 22#include "telephony_log_wrapper.h" 23#include "telephony_permission.h" 24#include "want.h" 25 26namespace OHOS { 27namespace Telephony { 28 29SmsMmsCommon::SmsMmsCommon() {} 30 31SmsMmsCommon::~SmsMmsCommon() {} 32 33void SmsMmsCommon::SendBroadcast(uint16_t id, std::string notify, std::string stauts, std::string type) 34{ 35 EventFwk::Want want; 36 EventFwk::CommonEventData data; 37 EventFwk::CommonEventPublishInfo publishInfo; 38 want.SetAction(notify); 39 std::vector<std::string> smsPermissions; 40 smsPermissions.emplace_back(Permission::SEND_MESSAGES); 41 publishInfo.SetSubscriberPermissions(smsPermissions); 42 want.SetParam(SmsMmsCommonData::MSG_ID, id); 43 want.SetParam(SmsMmsCommonData::MSG_TYPE, type); 44 want.SetParam(SmsMmsCommonData::MSG_STATE, stauts); 45 data.SetWant(want); 46 data.SetData(notify); 47 bool result = EventFwk::CommonEventManager::PublishCommonEvent(data, publishInfo, nullptr); 48 TELEPHONY_LOGI( 49 "SmsMmsCommon::SendBroadcast:%{public}d;notify:%{public}s;stauts:%{public}s;type:%{public}s;result:%{public}d", 50 id, notify.c_str(), stauts.c_str(), type.c_str(), result); 51} 52 53} // namespace Telephony 54} // namespace OHOS