1e1c44949Sopenharmony_ci/* 2e1c44949Sopenharmony_ci * Copyright (C) 2021 Huawei Device Co., Ltd. 3e1c44949Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4e1c44949Sopenharmony_ci * you may not use this file except in compliance with the License. 5e1c44949Sopenharmony_ci * You may obtain a copy of the License at 6e1c44949Sopenharmony_ci * 7e1c44949Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8e1c44949Sopenharmony_ci * 9e1c44949Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10e1c44949Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11e1c44949Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12e1c44949Sopenharmony_ci * See the License for the specific language governing permissions and 13e1c44949Sopenharmony_ci * limitations under the License. 14e1c44949Sopenharmony_ci */ 15e1c44949Sopenharmony_ci 16e1c44949Sopenharmony_ci#include "ott_call_connection.h" 17e1c44949Sopenharmony_ci 18e1c44949Sopenharmony_ci#include "call_manager_errors.h" 19e1c44949Sopenharmony_ci#include "telephony_log_wrapper.h" 20e1c44949Sopenharmony_ci 21e1c44949Sopenharmony_ci#include "call_ability_report_proxy.h" 22e1c44949Sopenharmony_ci 23e1c44949Sopenharmony_cinamespace OHOS { 24e1c44949Sopenharmony_cinamespace Telephony { 25e1c44949Sopenharmony_ciint32_t OTTCallConnection::Answer(const OttCallRequestInfo &requestInfo) 26e1c44949Sopenharmony_ci{ 27e1c44949Sopenharmony_ci AppExecFwk::PacMap info; 28e1c44949Sopenharmony_ci PackCellularCallInfo(requestInfo, info); 29e1c44949Sopenharmony_ci return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->OttCallRequest( 30e1c44949Sopenharmony_ci OttCallRequestId::OTT_REQUEST_ANSWER, info); 31e1c44949Sopenharmony_ci} 32e1c44949Sopenharmony_ci 33e1c44949Sopenharmony_ciint32_t OTTCallConnection::HangUp(const OttCallRequestInfo &requestInfo) 34e1c44949Sopenharmony_ci{ 35e1c44949Sopenharmony_ci AppExecFwk::PacMap info; 36e1c44949Sopenharmony_ci PackCellularCallInfo(requestInfo, info); 37e1c44949Sopenharmony_ci return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->OttCallRequest( 38e1c44949Sopenharmony_ci OttCallRequestId::OTT_REQUEST_HANG_UP, info); 39e1c44949Sopenharmony_ci} 40e1c44949Sopenharmony_ci 41e1c44949Sopenharmony_ciint32_t OTTCallConnection::Reject(const OttCallRequestInfo &requestInfo) 42e1c44949Sopenharmony_ci{ 43e1c44949Sopenharmony_ci AppExecFwk::PacMap info; 44e1c44949Sopenharmony_ci PackCellularCallInfo(requestInfo, info); 45e1c44949Sopenharmony_ci return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->OttCallRequest( 46e1c44949Sopenharmony_ci OttCallRequestId::OTT_REQUEST_REJECT, info); 47e1c44949Sopenharmony_ci} 48e1c44949Sopenharmony_ci 49e1c44949Sopenharmony_ciint32_t OTTCallConnection::HoldCall(const OttCallRequestInfo &requestInfo) 50e1c44949Sopenharmony_ci{ 51e1c44949Sopenharmony_ci AppExecFwk::PacMap info; 52e1c44949Sopenharmony_ci PackCellularCallInfo(requestInfo, info); 53e1c44949Sopenharmony_ci return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->OttCallRequest( 54e1c44949Sopenharmony_ci OttCallRequestId::OTT_REQUEST_HOLD, info); 55e1c44949Sopenharmony_ci} 56e1c44949Sopenharmony_ci 57e1c44949Sopenharmony_ciint32_t OTTCallConnection::UnHoldCall(const OttCallRequestInfo &requestInfo) 58e1c44949Sopenharmony_ci{ 59e1c44949Sopenharmony_ci AppExecFwk::PacMap info; 60e1c44949Sopenharmony_ci PackCellularCallInfo(requestInfo, info); 61e1c44949Sopenharmony_ci return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->OttCallRequest( 62e1c44949Sopenharmony_ci OttCallRequestId::OTT_REQUEST_UN_HOLD, info); 63e1c44949Sopenharmony_ci} 64e1c44949Sopenharmony_ci 65e1c44949Sopenharmony_ciint32_t OTTCallConnection::SwitchCall(const OttCallRequestInfo &requestInfo) 66e1c44949Sopenharmony_ci{ 67e1c44949Sopenharmony_ci AppExecFwk::PacMap info; 68e1c44949Sopenharmony_ci PackCellularCallInfo(requestInfo, info); 69e1c44949Sopenharmony_ci return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->OttCallRequest( 70e1c44949Sopenharmony_ci OttCallRequestId::OTT_REQUEST_SWITCH, info); 71e1c44949Sopenharmony_ci} 72e1c44949Sopenharmony_ci 73e1c44949Sopenharmony_ciint32_t OTTCallConnection::CombineConference(const OttCallRequestInfo &requestInfo) 74e1c44949Sopenharmony_ci{ 75e1c44949Sopenharmony_ci AppExecFwk::PacMap info; 76e1c44949Sopenharmony_ci PackCellularCallInfo(requestInfo, info); 77e1c44949Sopenharmony_ci return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->OttCallRequest( 78e1c44949Sopenharmony_ci OttCallRequestId::OTT_REQUEST_COMBINE_CONFERENCE, info); 79e1c44949Sopenharmony_ci} 80e1c44949Sopenharmony_ci 81e1c44949Sopenharmony_ciint32_t OTTCallConnection::SeparateConference(const OttCallRequestInfo &requestInfo) 82e1c44949Sopenharmony_ci{ 83e1c44949Sopenharmony_ci AppExecFwk::PacMap info; 84e1c44949Sopenharmony_ci PackCellularCallInfo(requestInfo, info); 85e1c44949Sopenharmony_ci return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->OttCallRequest( 86e1c44949Sopenharmony_ci OttCallRequestId::OTT_REQUEST_SEPARATE_CONFERENCE, info); 87e1c44949Sopenharmony_ci} 88e1c44949Sopenharmony_ci 89e1c44949Sopenharmony_ciint32_t OTTCallConnection::KickOutFromConference(const OttCallRequestInfo &requestInfo) 90e1c44949Sopenharmony_ci{ 91e1c44949Sopenharmony_ci AppExecFwk::PacMap info; 92e1c44949Sopenharmony_ci PackCellularCallInfo(requestInfo, info); 93e1c44949Sopenharmony_ci return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->OttCallRequest( 94e1c44949Sopenharmony_ci OttCallRequestId::OTT_REQUEST_KICK_OUT_CONFERENCE, info); 95e1c44949Sopenharmony_ci} 96e1c44949Sopenharmony_ci 97e1c44949Sopenharmony_ciint32_t OTTCallConnection::InviteToConference( 98e1c44949Sopenharmony_ci const OttCallRequestInfo &requestInfo, const std::vector<std::string> &numberList) 99e1c44949Sopenharmony_ci{ 100e1c44949Sopenharmony_ci if (numberList.empty()) { 101e1c44949Sopenharmony_ci TELEPHONY_LOGE("numberList is empty!"); 102e1c44949Sopenharmony_ci return TELEPHONY_ERR_ARGUMENT_INVALID; 103e1c44949Sopenharmony_ci } 104e1c44949Sopenharmony_ci AppExecFwk::PacMap info; 105e1c44949Sopenharmony_ci std::vector<std::string> list = numberList; 106e1c44949Sopenharmony_ci PackCellularCallInfo(requestInfo, info); 107e1c44949Sopenharmony_ci info.PutIntValue("listCnt", list.size()); 108e1c44949Sopenharmony_ci std::vector<std::string>::iterator it = list.begin(); 109e1c44949Sopenharmony_ci for (; it != list.end(); ++it) { 110e1c44949Sopenharmony_ci if (!(*it).empty()) { 111e1c44949Sopenharmony_ci info.PutStringValue("number", *it); 112e1c44949Sopenharmony_ci } 113e1c44949Sopenharmony_ci } 114e1c44949Sopenharmony_ci return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->OttCallRequest( 115e1c44949Sopenharmony_ci OttCallRequestId::OTT_REQUEST_INVITE_TO_CONFERENCE, info); 116e1c44949Sopenharmony_ci} 117e1c44949Sopenharmony_ci 118e1c44949Sopenharmony_ciint32_t OTTCallConnection::UpdateImsCallMode(const OttCallRequestInfo &requestInfo, ImsCallMode mode) 119e1c44949Sopenharmony_ci{ 120e1c44949Sopenharmony_ci AppExecFwk::PacMap info; 121e1c44949Sopenharmony_ci PackCellularCallInfo(requestInfo, info); 122e1c44949Sopenharmony_ci info.PutIntValue("callMediaMode", mode); 123e1c44949Sopenharmony_ci return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->OttCallRequest( 124e1c44949Sopenharmony_ci OttCallRequestId::OTT_REQUEST_UPDATE_CALL_MEDIA_MODE, info); 125e1c44949Sopenharmony_ci} 126e1c44949Sopenharmony_ci 127e1c44949Sopenharmony_civoid OTTCallConnection::PackCellularCallInfo(const OttCallRequestInfo &requestInfo, AppExecFwk::PacMap &info) 128e1c44949Sopenharmony_ci{ 129e1c44949Sopenharmony_ci std::string number(requestInfo.phoneNum); 130e1c44949Sopenharmony_ci std::string name(requestInfo.bundleName); 131e1c44949Sopenharmony_ci info.PutStringValue("phoneNum", number); 132e1c44949Sopenharmony_ci info.PutStringValue("bundleName", name); 133e1c44949Sopenharmony_ci info.PutIntValue("videoState", static_cast<int32_t>(requestInfo.videoState)); 134e1c44949Sopenharmony_ci} 135e1c44949Sopenharmony_ci} // namespace Telephony 136e1c44949Sopenharmony_ci} // namespace OHOS