1d95e75fdSopenharmony_ci/* 2d95e75fdSopenharmony_ci * Copyright (C) 2021-2022 Huawei Device Co., Ltd. 3d95e75fdSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4d95e75fdSopenharmony_ci * you may not use this file except in compliance with the License. 5d95e75fdSopenharmony_ci * You may obtain a copy of the License at 6d95e75fdSopenharmony_ci * 7d95e75fdSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8d95e75fdSopenharmony_ci * 9d95e75fdSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10d95e75fdSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11d95e75fdSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12d95e75fdSopenharmony_ci * See the License for the specific language governing permissions and 13d95e75fdSopenharmony_ci * limitations under the License. 14d95e75fdSopenharmony_ci */ 15d95e75fdSopenharmony_ci 16d95e75fdSopenharmony_ci#ifndef CELLULAR_CALL_CONTROL_BASE_H 17d95e75fdSopenharmony_ci#define CELLULAR_CALL_CONTROL_BASE_H 18d95e75fdSopenharmony_ci 19d95e75fdSopenharmony_ci#include "call_manager_errors.h" 20d95e75fdSopenharmony_ci#include "event_handler.h" 21d95e75fdSopenharmony_ci#include "cellular_call_data_struct.h" 22d95e75fdSopenharmony_ci#include "telephony_log_wrapper.h" 23d95e75fdSopenharmony_ci#include "base_connection.h" 24d95e75fdSopenharmony_ci#include "tel_ril_call_parcel.h" 25d95e75fdSopenharmony_ci#include "mmi_code_utils.h" 26d95e75fdSopenharmony_ci 27d95e75fdSopenharmony_cinamespace OHOS { 28d95e75fdSopenharmony_cinamespace Telephony { 29d95e75fdSopenharmony_ciclass ControlBase { 30d95e75fdSopenharmony_cipublic: 31d95e75fdSopenharmony_ci /** 32d95e75fdSopenharmony_ci * constructor 33d95e75fdSopenharmony_ci */ 34d95e75fdSopenharmony_ci ControlBase() = default; 35d95e75fdSopenharmony_ci 36d95e75fdSopenharmony_ci /** 37d95e75fdSopenharmony_ci * destructor 38d95e75fdSopenharmony_ci */ 39d95e75fdSopenharmony_ci virtual ~ControlBase() = default; 40d95e75fdSopenharmony_ci 41d95e75fdSopenharmony_ci /** 42d95e75fdSopenharmony_ci * Dial 43d95e75fdSopenharmony_ci * 44d95e75fdSopenharmony_ci * 27007-430_2001 6.27 Informative examples 45d95e75fdSopenharmony_ci * 3GPP TS 22.030 [19] 46d95e75fdSopenharmony_ci * 47d95e75fdSopenharmony_ci * originate a voice call 48d95e75fdSopenharmony_ci * 49d95e75fdSopenharmony_ci * @param CellularCallInfo 50d95e75fdSopenharmony_ci * @param bool 51d95e75fdSopenharmony_ci * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure. 52d95e75fdSopenharmony_ci */ 53d95e75fdSopenharmony_ci virtual int32_t Dial(const CellularCallInfo &callInfo, bool isEcc) = 0; 54d95e75fdSopenharmony_ci 55d95e75fdSopenharmony_ci /** 56d95e75fdSopenharmony_ci * HangUp 57d95e75fdSopenharmony_ci * 58d95e75fdSopenharmony_ci * 3GPP TS 27.007 V3.9.0 (2001-06) Call related supplementary services +CHLD 59d95e75fdSopenharmony_ci * 3GPP TS 27.007 V3.9.0 (2001-06) 7.22 Informative examples 60d95e75fdSopenharmony_ci * 3GPP TS 22.030 [19] 61d95e75fdSopenharmony_ci * 62d95e75fdSopenharmony_ci * release call 63d95e75fdSopenharmony_ci * 64d95e75fdSopenharmony_ci * @param CellularCallInfo 65d95e75fdSopenharmony_ci * @param CallSupplementType 66d95e75fdSopenharmony_ci * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure. 67d95e75fdSopenharmony_ci */ 68d95e75fdSopenharmony_ci virtual int32_t HangUp(const CellularCallInfo &callInfo, CallSupplementType type) = 0; 69d95e75fdSopenharmony_ci 70d95e75fdSopenharmony_ci /** 71d95e75fdSopenharmony_ci * Answer 72d95e75fdSopenharmony_ci * 73d95e75fdSopenharmony_ci * 27007-430_2001 6.6 Alternating mode call control method 74d95e75fdSopenharmony_ci * 3GPP TS 22.030 [19] 75d95e75fdSopenharmony_ci * 76d95e75fdSopenharmony_ci * Answer an incoming voice call. 77d95e75fdSopenharmony_ci * 78d95e75fdSopenharmony_ci * @param CellularCallInfo 79d95e75fdSopenharmony_ci * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure. 80d95e75fdSopenharmony_ci */ 81d95e75fdSopenharmony_ci virtual int32_t Answer(const CellularCallInfo &callInfo) = 0; 82d95e75fdSopenharmony_ci 83d95e75fdSopenharmony_ci /** 84d95e75fdSopenharmony_ci * Reject 85d95e75fdSopenharmony_ci * 86d95e75fdSopenharmony_ci * 27007-430_2001 6.6 Alternating mode call control method 87d95e75fdSopenharmony_ci * 3GPP TS 22.030 [19] 88d95e75fdSopenharmony_ci * 89d95e75fdSopenharmony_ci * Reject an incoming voice call 90d95e75fdSopenharmony_ci * 91d95e75fdSopenharmony_ci * @param CellularCallInfo 92d95e75fdSopenharmony_ci * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure. 93d95e75fdSopenharmony_ci */ 94d95e75fdSopenharmony_ci virtual int32_t Reject(const CellularCallInfo &callInfo) = 0; 95d95e75fdSopenharmony_ci 96d95e75fdSopenharmony_ci /** 97d95e75fdSopenharmony_ci * HoldCall 98d95e75fdSopenharmony_ci * 99d95e75fdSopenharmony_ci * 22083-400_2001 2 Call hold 100d95e75fdSopenharmony_ci * 3GPP TS 22.030 [3] 101d95e75fdSopenharmony_ci * 3GPP TS 23.083 V4.2.0 (2001-04) 2 Call hold (HOLD) 102d95e75fdSopenharmony_ci * 103d95e75fdSopenharmony_ci * The call hold service allows a served mobile subscriber 104d95e75fdSopenharmony_ci * 105d95e75fdSopenharmony_ci * @param slotId 106d95e75fdSopenharmony_ci * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure. 107d95e75fdSopenharmony_ci */ 108d95e75fdSopenharmony_ci virtual int32_t HoldCall(int32_t slotId) = 0; 109d95e75fdSopenharmony_ci 110d95e75fdSopenharmony_ci /** 111d95e75fdSopenharmony_ci * UnHoldCall 112d95e75fdSopenharmony_ci * 113d95e75fdSopenharmony_ci * 22083-400_2001 2 Call hold 114d95e75fdSopenharmony_ci * 3GPP TS 22.030 [3] 115d95e75fdSopenharmony_ci * 116d95e75fdSopenharmony_ci * Retrieve the held call. 117d95e75fdSopenharmony_ci * 118d95e75fdSopenharmony_ci * @param slotId 119d95e75fdSopenharmony_ci * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure. 120d95e75fdSopenharmony_ci */ 121d95e75fdSopenharmony_ci virtual int32_t UnHoldCall(int32_t slotId) = 0; 122d95e75fdSopenharmony_ci 123d95e75fdSopenharmony_ci /** 124d95e75fdSopenharmony_ci * SwitchCall 125d95e75fdSopenharmony_ci * 126d95e75fdSopenharmony_ci * 22083-400_2001 2 Call hold 127d95e75fdSopenharmony_ci * 3GPP TS 22.030 [3] 128d95e75fdSopenharmony_ci * 129d95e75fdSopenharmony_ci * Alternate from one call to the other 130d95e75fdSopenharmony_ci * 131d95e75fdSopenharmony_ci * @param slotId 132d95e75fdSopenharmony_ci * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure. 133d95e75fdSopenharmony_ci */ 134d95e75fdSopenharmony_ci virtual int32_t SwitchCall(int32_t slotId) = 0; 135d95e75fdSopenharmony_ci 136d95e75fdSopenharmony_ci /** 137d95e75fdSopenharmony_ci * CombineConference 138d95e75fdSopenharmony_ci * 139d95e75fdSopenharmony_ci * 22084-400_2001 1.3.8.2 Managing an active multiParty call 140d95e75fdSopenharmony_ci * 3GPP TS 22.030 141d95e75fdSopenharmony_ci * 142d95e75fdSopenharmony_ci * Add another remote party 143d95e75fdSopenharmony_ci * @param slotId 144d95e75fdSopenharmony_ci * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure. 145d95e75fdSopenharmony_ci */ 146d95e75fdSopenharmony_ci virtual int32_t CombineConference(int32_t slotId) = 0; 147d95e75fdSopenharmony_ci 148d95e75fdSopenharmony_ci /** 149d95e75fdSopenharmony_ci * HangUpAllConnection 150d95e75fdSopenharmony_ci * 151d95e75fdSopenharmony_ci * @param slotId 152d95e75fdSopenharmony_ci * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure. 153d95e75fdSopenharmony_ci */ 154d95e75fdSopenharmony_ci virtual int32_t HangUpAllConnection(int32_t slotId) = 0; 155d95e75fdSopenharmony_ci 156d95e75fdSopenharmony_ci /** 157d95e75fdSopenharmony_ci * ReportCallsData 158d95e75fdSopenharmony_ci * 159d95e75fdSopenharmony_ci * @param slotId 160d95e75fdSopenharmony_ci * @param CallInfoList 161d95e75fdSopenharmony_ci * @returns Error Code: Returns TELEPHONY_SUCCESS on success, others on failure. 162d95e75fdSopenharmony_ci */ 163d95e75fdSopenharmony_ci virtual int32_t ReportCallsData(int32_t slotId, const CallInfoList &callInfoList) = 0; 164d95e75fdSopenharmony_ci 165d95e75fdSopenharmony_ci /** 166d95e75fdSopenharmony_ci * Dial PreJudgment 167d95e75fdSopenharmony_ci * 168d95e75fdSopenharmony_ci * @param CellularCallInfo 169d95e75fdSopenharmony_ci * @returns Error Code: Returns TELEPHONY_SUCCESS on success, others on failure. 170d95e75fdSopenharmony_ci */ 171d95e75fdSopenharmony_ci int32_t DialPreJudgment(const CellularCallInfo &callInfo, bool isEcc); 172d95e75fdSopenharmony_ci 173d95e75fdSopenharmony_ci /** 174d95e75fdSopenharmony_ci * Is Need Execute MMI 175d95e75fdSopenharmony_ci * 176d95e75fdSopenharmony_ci * @param slotId 177d95e75fdSopenharmony_ci * @param std::string phoneString 178d95e75fdSopenharmony_ci * @param CLIRMode 179d95e75fdSopenharmony_ci * @param isNeedUseIms 180d95e75fdSopenharmony_ci * @returns bool 181d95e75fdSopenharmony_ci */ 182d95e75fdSopenharmony_ci bool IsNeedExecuteMMI(int32_t slotId, std::string &phoneString, CLIRMode &clirMode, bool isNeedUseIms); 183d95e75fdSopenharmony_ci 184d95e75fdSopenharmony_ci /** 185d95e75fdSopenharmony_ci * Is Dtmf Key 186d95e75fdSopenharmony_ci * 187d95e75fdSopenharmony_ci * 23014-400_2001 6 Support of DTMF across the air interface 188d95e75fdSopenharmony_ci * 3GPP TS 22.030 189d95e75fdSopenharmony_ci * 190d95e75fdSopenharmony_ci * @param char 191d95e75fdSopenharmony_ci * @returns bool 192d95e75fdSopenharmony_ci */ 193d95e75fdSopenharmony_ci bool IsDtmfKey(char c) const; 194d95e75fdSopenharmony_ci 195d95e75fdSopenharmony_ci bool IsConnectedOut(TelCallState preState, TelCallState curState); 196d95e75fdSopenharmony_ci 197d95e75fdSopenharmony_ci int32_t SetReadyToCall(int32_t slotId, bool isReadyToCall); 198d95e75fdSopenharmony_ci 199d95e75fdSopenharmony_ci /** 200d95e75fdSopenharmony_ci * Determine whether the call can be initiated currently 201d95e75fdSopenharmony_ci * 202d95e75fdSopenharmony_ci * @param std::map<std::string, BaseConnection> 203d95e75fdSopenharmony_ci * @return Returns true can to call 204d95e75fdSopenharmony_ci */ 205d95e75fdSopenharmony_ci template<typename T> 206d95e75fdSopenharmony_ci bool CanCall(T &&t) 207d95e75fdSopenharmony_ci { 208d95e75fdSopenharmony_ci unsigned int maximumCalls = 6; 209d95e75fdSopenharmony_ci return t.size() <= maximumCalls; 210d95e75fdSopenharmony_ci } 211d95e75fdSopenharmony_ci 212d95e75fdSopenharmony_ci /** 213d95e75fdSopenharmony_ci * FindConnectionByState 214d95e75fdSopenharmony_ci * 215d95e75fdSopenharmony_ci * @param std::map<std::string, BaseConnection> 216d95e75fdSopenharmony_ci * @param TelCallState 217d95e75fdSopenharmony_ci * @return pointer 218d95e75fdSopenharmony_ci */ 219d95e75fdSopenharmony_ci template<typename T1, typename T2> 220d95e75fdSopenharmony_ci T2 FindConnectionByState(const T1 &&t1, TelCallState state) const 221d95e75fdSopenharmony_ci { 222d95e75fdSopenharmony_ci for (auto &it : t1) { 223d95e75fdSopenharmony_ci T2 pConnection = &it.second; 224d95e75fdSopenharmony_ci if (pConnection != nullptr && pConnection->GetStatus() == state) { 225d95e75fdSopenharmony_ci return pConnection; 226d95e75fdSopenharmony_ci } 227d95e75fdSopenharmony_ci } 228d95e75fdSopenharmony_ci return nullptr; 229d95e75fdSopenharmony_ci } 230d95e75fdSopenharmony_ci 231d95e75fdSopenharmony_ci /** 232d95e75fdSopenharmony_ci * FindConnectionByIndex 233d95e75fdSopenharmony_ci * 234d95e75fdSopenharmony_ci * @param std::map<std::string, BaseConnection> 235d95e75fdSopenharmony_ci * @param index 236d95e75fdSopenharmony_ci * @return pointer 237d95e75fdSopenharmony_ci */ 238d95e75fdSopenharmony_ci template<typename T1, typename T2> 239d95e75fdSopenharmony_ci T2 FindConnectionByIndex(const T1 &&t1, int32_t index) const 240d95e75fdSopenharmony_ci { 241d95e75fdSopenharmony_ci for (auto &it : t1) { 242d95e75fdSopenharmony_ci T2 pConnection = &it.second; 243d95e75fdSopenharmony_ci if (pConnection != nullptr && pConnection->GetIndex() == index) { 244d95e75fdSopenharmony_ci return pConnection; 245d95e75fdSopenharmony_ci } 246d95e75fdSopenharmony_ci } 247d95e75fdSopenharmony_ci return nullptr; 248d95e75fdSopenharmony_ci } 249d95e75fdSopenharmony_ci 250d95e75fdSopenharmony_ci /** 251d95e75fdSopenharmony_ci * SetConnectionData 252d95e75fdSopenharmony_ci * 253d95e75fdSopenharmony_ci * @param std::map<std::string, BaseConnection> 254d95e75fdSopenharmony_ci * @param string phoneNum 255d95e75fdSopenharmony_ci * @param BaseConnection 256d95e75fdSopenharmony_ci * @return bool 257d95e75fdSopenharmony_ci */ 258d95e75fdSopenharmony_ci template<typename T1, typename T2> 259d95e75fdSopenharmony_ci bool SetConnectionData(T1 &&t1, const int32_t &key, const T2 &con) 260d95e75fdSopenharmony_ci { 261d95e75fdSopenharmony_ci if (!t1.insert(std::make_pair(key, con)).second) { 262d95e75fdSopenharmony_ci TELEPHONY_LOGE("SetConnectionData, key already exists."); 263d95e75fdSopenharmony_ci return false; 264d95e75fdSopenharmony_ci } 265d95e75fdSopenharmony_ci return true; 266d95e75fdSopenharmony_ci } 267d95e75fdSopenharmony_ci 268d95e75fdSopenharmony_ci /** 269d95e75fdSopenharmony_ci * Determines if a connection is currently in this state 270d95e75fdSopenharmony_ci * 271d95e75fdSopenharmony_ci * @param std::map<std::string, BaseConnection> 272d95e75fdSopenharmony_ci * @param TelCallState 273d95e75fdSopenharmony_ci * @return Returns true or false 274d95e75fdSopenharmony_ci */ 275d95e75fdSopenharmony_ci template<typename T1> 276d95e75fdSopenharmony_ci bool IsInState(T1 &&t, TelCallState state) 277d95e75fdSopenharmony_ci { 278d95e75fdSopenharmony_ci for (const auto &it : t) { 279d95e75fdSopenharmony_ci auto pConnection = &it.second; 280d95e75fdSopenharmony_ci if (pConnection != nullptr && pConnection->GetStatus() == state) { 281d95e75fdSopenharmony_ci return true; 282d95e75fdSopenharmony_ci } 283d95e75fdSopenharmony_ci } 284d95e75fdSopenharmony_ci return false; 285d95e75fdSopenharmony_ci } 286d95e75fdSopenharmony_ci 287d95e75fdSopenharmony_ci /** 288d95e75fdSopenharmony_ci * StartDtmf 289d95e75fdSopenharmony_ci * 290d95e75fdSopenharmony_ci * 23014-400_2001 6 Support of DTMF across the air interface 291d95e75fdSopenharmony_ci * 3GPP TS 22.030 292d95e75fdSopenharmony_ci * 293d95e75fdSopenharmony_ci * START DTMF : Containing the digit value (0-9,A,B,C,D,*,#) 294d95e75fdSopenharmony_ci * @param std::map<std::string, BaseConnection> 295d95e75fdSopenharmony_ci * @param Dtmf Code 296d95e75fdSopenharmony_ci * @param CellularCallInfo 297d95e75fdSopenharmony_ci * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure. 298d95e75fdSopenharmony_ci */ 299d95e75fdSopenharmony_ci template<typename T> 300d95e75fdSopenharmony_ci int32_t StartDtmf(T &&t, char cDtmfCode, const CellularCallInfo &callInfo) const 301d95e75fdSopenharmony_ci { 302d95e75fdSopenharmony_ci /** 303d95e75fdSopenharmony_ci * The messages when sent across the air interface should contain the following information: 304d95e75fdSopenharmony_ci * a) START DTMF : Containing the digit value (0-9,A,B,C,D,*,#); 305d95e75fdSopenharmony_ci * b) START DTMF ACKNOWLEDGE: Containing the digit value (0-9,A,B,C,D,*,#) corresponding to the DTMF tone that 306d95e75fdSopenharmony_ci * the network applies towards the remote user; 307d95e75fdSopenharmony_ci * c) STOP DTMF : No further info; 308d95e75fdSopenharmony_ci * d) STOP DTMF ACKNOWLEDGE: No further info. 309d95e75fdSopenharmony_ci * Only a single digit will be passed in each START DTMF and START DTMF ACKNOWLEDGE message 310d95e75fdSopenharmony_ci */ 311d95e75fdSopenharmony_ci TELEPHONY_LOGD("ControlBase::StartDtmf start"); 312d95e75fdSopenharmony_ci auto pConnection = FindConnectionByIndex<T &, decltype(&t.begin()->second)>(t, callInfo.index); 313d95e75fdSopenharmony_ci 314d95e75fdSopenharmony_ci if (pConnection == nullptr) { 315d95e75fdSopenharmony_ci TELEPHONY_LOGE("StartDtmf, error type: connection is null"); 316d95e75fdSopenharmony_ci return CALL_ERR_CALL_CONNECTION_NOT_EXIST; 317d95e75fdSopenharmony_ci } 318d95e75fdSopenharmony_ci if (!IsDtmfKey(cDtmfCode)) { 319d95e75fdSopenharmony_ci TELEPHONY_LOGE("StartDtmf return, error type: cDtmfCode invalid."); 320d95e75fdSopenharmony_ci return CALL_ERR_PARAMETER_OUT_OF_RANGE; 321d95e75fdSopenharmony_ci } 322d95e75fdSopenharmony_ci return pConnection->StartDtmfRequest(callInfo.slotId, cDtmfCode, pConnection->GetIndex()); 323d95e75fdSopenharmony_ci } 324d95e75fdSopenharmony_ci 325d95e75fdSopenharmony_ci /** 326d95e75fdSopenharmony_ci * StopDtmf 327d95e75fdSopenharmony_ci * 328d95e75fdSopenharmony_ci * 23014-400_2001 6 Support of DTMF across the air interface 329d95e75fdSopenharmony_ci * 3GPP TS 22.030 330d95e75fdSopenharmony_ci * 331d95e75fdSopenharmony_ci * STOP DTMF : No further info 332d95e75fdSopenharmony_ci * @param std::map<std::string, BaseConnection> 333d95e75fdSopenharmony_ci * @param CellularCallInfo 334d95e75fdSopenharmony_ci * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure. 335d95e75fdSopenharmony_ci */ 336d95e75fdSopenharmony_ci template<typename T> 337d95e75fdSopenharmony_ci int32_t StopDtmf(T &&t, const CellularCallInfo &callInfo) const 338d95e75fdSopenharmony_ci { 339d95e75fdSopenharmony_ci /** 340d95e75fdSopenharmony_ci * The messages when sent across the air interface should contain the following information: 341d95e75fdSopenharmony_ci * a) START DTMF : Containing the digit value (0-9,A,B,C,D,*,#); 342d95e75fdSopenharmony_ci * b) START DTMF ACKNOWLEDGE: Containing the digit value (0-9,A,B,C,D,*,#) corresponding to the DTMF tone that 343d95e75fdSopenharmony_ci * the network applies towards the remote user; 344d95e75fdSopenharmony_ci * c) STOP DTMF : No further info; 345d95e75fdSopenharmony_ci * d) STOP DTMF ACKNOWLEDGE: No further info. 346d95e75fdSopenharmony_ci * Only a single digit will be passed in each START DTMF and START DTMF ACKNOWLEDGE message 347d95e75fdSopenharmony_ci */ 348d95e75fdSopenharmony_ci TELEPHONY_LOGD("ControlBase::StopDtmf start"); 349d95e75fdSopenharmony_ci auto pConnection = FindConnectionByIndex<T &, decltype(&t.begin()->second)>(t, callInfo.index); 350d95e75fdSopenharmony_ci if (pConnection == nullptr) { 351d95e75fdSopenharmony_ci TELEPHONY_LOGE("StopDtmf, error type: connection is null"); 352d95e75fdSopenharmony_ci return CALL_ERR_CALL_CONNECTION_NOT_EXIST; 353d95e75fdSopenharmony_ci } 354d95e75fdSopenharmony_ci return pConnection->StopDtmfRequest(callInfo.slotId, pConnection->GetIndex()); 355d95e75fdSopenharmony_ci } 356d95e75fdSopenharmony_ci 357d95e75fdSopenharmony_ci /** 358d95e75fdSopenharmony_ci * SendDtmf 359d95e75fdSopenharmony_ci * 360d95e75fdSopenharmony_ci * 23014-400_2001 6 Support of DTMF across the air interface 361d95e75fdSopenharmony_ci * 3GPP TS 22.030 362d95e75fdSopenharmony_ci * 363d95e75fdSopenharmony_ci * @param std::map<std::string, BaseConnection> 364d95e75fdSopenharmony_ci * @param Dtmf Code 365d95e75fdSopenharmony_ci * @param CellularCallInfo 366d95e75fdSopenharmony_ci * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure. 367d95e75fdSopenharmony_ci */ 368d95e75fdSopenharmony_ci template<typename T> 369d95e75fdSopenharmony_ci int32_t SendDtmf(T &&t, char cDtmfCode, const CellularCallInfo &callInfo) const 370d95e75fdSopenharmony_ci { 371d95e75fdSopenharmony_ci /** 372d95e75fdSopenharmony_ci * 3gpp 27007-430_2001 373d95e75fdSopenharmony_ci * 374d95e75fdSopenharmony_ci * C.2.11 DTMF and tone generation +VTS 375d95e75fdSopenharmony_ci * 376d95e75fdSopenharmony_ci * This command allows the transmission of DTMF tones and arbitrary tones (see note). 377d95e75fdSopenharmony_ci * These tones may be used (for example) when announcing the start of a recording period. 378d95e75fdSopenharmony_ci * The command is write only. 379d95e75fdSopenharmony_ci * In this profile of commands, this command does not operate in data or fax modes of operation (+FCLASS=0,1,2 380d95e75fdSopenharmony_ci 7). NOTE 1: D is used only for dialling. 381d95e75fdSopenharmony_ci 382d95e75fdSopenharmony_ci The string parameter of the command consists of combinations of the following separated by commas: 383d95e75fdSopenharmony_ci 1. <DTMF>. A single ASCII character in the set 0 9, #,*,A D. 384d95e75fdSopenharmony_ci This is interpreted as a single ACSII character whose duration is set by the +VTD command. 385d95e75fdSopenharmony_ci NOTE 2: In GSM this operates only in voice mode. 386d95e75fdSopenharmony_ci 2. [<tone1>,<tone2>,<duration>]. 387d95e75fdSopenharmony_ci This is interpreted as a dual tone of frequencies <tone1> and <tone2>, lasting for a time <duration> (in 10 388d95e75fdSopenharmony_ci ms multiples). NOTE 3: This does not operate in GSM. 389d95e75fdSopenharmony_ci 3. {<DTMF>,<duration>}. This is interpreted as a DTMF tone of different duration from that mandated by the 390d95e75fdSopenharmony_ci +VTD command. NOTE 4: In GSM this operates only in voice mode. 391d95e75fdSopenharmony_ci */ 392d95e75fdSopenharmony_ci TELEPHONY_LOGD("ControlBase::SendDtmf start"); 393d95e75fdSopenharmony_ci auto pConnection = FindConnectionByIndex<T &, decltype(&t.begin()->second)>(t, callInfo.index); 394d95e75fdSopenharmony_ci if (pConnection == nullptr) { 395d95e75fdSopenharmony_ci TELEPHONY_LOGE("SendDtmf, error type: connection is null"); 396d95e75fdSopenharmony_ci return CALL_ERR_CALL_CONNECTION_NOT_EXIST; 397d95e75fdSopenharmony_ci } 398d95e75fdSopenharmony_ci if (!IsDtmfKey(cDtmfCode)) { 399d95e75fdSopenharmony_ci TELEPHONY_LOGE("SendDtmf return, error type: cDtmfCode invalid."); 400d95e75fdSopenharmony_ci return CALL_ERR_PARAMETER_OUT_OF_RANGE; 401d95e75fdSopenharmony_ci } 402d95e75fdSopenharmony_ci return pConnection->SendDtmfRequest(callInfo.slotId, cDtmfCode, pConnection->GetIndex()); 403d95e75fdSopenharmony_ci } 404d95e75fdSopenharmony_ci 405d95e75fdSopenharmony_ci /** 406d95e75fdSopenharmony_ci * GetCallFailReason 407d95e75fdSopenharmony_ci * 408d95e75fdSopenharmony_ci * 3GPP TS 24.008 V17.4.0 (2021-09) 10.5.4.11 Cause 409d95e75fdSopenharmony_ci * 410d95e75fdSopenharmony_ci * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure. 411d95e75fdSopenharmony_ci */ 412d95e75fdSopenharmony_ci template<typename T> 413d95e75fdSopenharmony_ci int32_t GetCallFailReason(int32_t slotId, T &&t) const 414d95e75fdSopenharmony_ci { 415d95e75fdSopenharmony_ci decltype(t.begin()->second) connection; 416d95e75fdSopenharmony_ci return connection.GetCallFailReasonRequest(slotId); 417d95e75fdSopenharmony_ci } 418d95e75fdSopenharmony_ci 419d95e75fdSopenharmony_ciprotected: 420d95e75fdSopenharmony_ci bool isIgnoredIncomingCall_ = false; 421d95e75fdSopenharmony_ci 422d95e75fdSopenharmony_ciprivate: 423d95e75fdSopenharmony_ci /** 424d95e75fdSopenharmony_ci * Check call with airplane mode on 425d95e75fdSopenharmony_ci */ 426d95e75fdSopenharmony_ci bool CheckAirplaneModeScene(const CellularCallInfo &callInfo); 427d95e75fdSopenharmony_ci 428d95e75fdSopenharmony_ci /** 429d95e75fdSopenharmony_ci * check call with activate sim 430d95e75fdSopenharmony_ci */ 431d95e75fdSopenharmony_ci bool CheckActivateSimScene(int32_t slotId); 432d95e75fdSopenharmony_ci 433d95e75fdSopenharmony_ci /** 434d95e75fdSopenharmony_ci * Handle call with airplane mode on 435d95e75fdSopenharmony_ci */ 436d95e75fdSopenharmony_ci int32_t HandleEcc(const CellularCallInfo &callInfo, bool isEcc, bool isAirplaneModeOn, bool isActivateSim); 437d95e75fdSopenharmony_ci 438d95e75fdSopenharmony_ciprivate: 439d95e75fdSopenharmony_ci std::shared_ptr<AppExecFwk::EventRunner> eventLoop_; 440d95e75fdSopenharmony_ci std::condition_variable cv_; 441d95e75fdSopenharmony_ci std::mutex mutex_; 442d95e75fdSopenharmony_ci}; 443d95e75fdSopenharmony_ci} // namespace Telephony 444d95e75fdSopenharmony_ci} // namespace OHOS 445d95e75fdSopenharmony_ci 446d95e75fdSopenharmony_ci#endif // CELLULAR_CALL_CONTROL_BASE_H 447