1 /* 2 * Copyright (C) 2021-2022 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 #ifndef CELLULAR_CALL_CONTROL_IMS_H 17 #define CELLULAR_CALL_CONTROL_IMS_H 18 19 #include "tel_ril_call_parcel.h" 20 #include "cellular_call_data_struct.h" 21 #include "cellular_call_connection_ims.h" 22 #include "control_base.h" 23 24 namespace OHOS { 25 namespace Telephony { 26 using ImsConnectionMap = std::map<int32_t, CellularCallConnectionIMS>; 27 class IMSControl : public ControlBase { 28 public: 29 /** 30 * constructor 31 */ 32 IMSControl() = default; 33 34 /** 35 * destructor 36 */ 37 ~IMSControl(); 38 39 /** 40 * IMS Dial 41 */ 42 int32_t Dial(const CellularCallInfo &callInfo, bool isEcc) override; 43 44 /** 45 * HangUp 46 * 47 * @param CellularCallInfo 48 * @param CallSupplementType 49 * @return Error Code: Returns TELEPHONY_NO_ERROR on success, others on failure. 50 */ 51 int32_t HangUp(const CellularCallInfo &callInfo, CallSupplementType type) override; 52 53 /** 54 * Answer 55 * 56 * @param CellularCallInfo 57 * @return Error Code: Returns TELEPHONY_NO_ERROR on success, others on failure. 58 */ 59 int32_t Answer(const CellularCallInfo &callInfo) override; 60 61 /** 62 * Reject 63 * 64 * @param CellularCallInfo 65 * @return Error Code: Returns TELEPHONY_NO_ERROR on success, others on failure. 66 */ 67 int32_t Reject(const CellularCallInfo &callInfo) override; 68 69 /** 70 * HoldCall 71 * 72 * @param slotId 73 * @return Error Code: Returns TELEPHONY_NO_ERROR on success, others on failure. 74 */ 75 int32_t HoldCall(int32_t slotId) override; 76 77 /** 78 * UnHoldCall 79 * 80 * @param slotId 81 * @return Error Code: Returns TELEPHONY_NO_ERROR on success, others on failure. 82 */ 83 int32_t UnHoldCall(int32_t slotId) override; 84 85 /** 86 * SwitchCall 87 * 88 * @param slotId 89 * @return Error Code: Returns TELEPHONY_NO_ERROR on success, others on failure. 90 */ 91 int32_t SwitchCall(int32_t slotId) override; 92 93 /** 94 * CombineConference 95 * 96 * 22084-400_2001 1.3.8.2 Managing an active multiParty call 97 * 3GPP TS 22.030 98 * 99 * Add another remote party 100 * @param slotId 101 * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure. 102 */ 103 int32_t CombineConference(int32_t slotId) override; 104 105 /** 106 * InviteToConference 107 * 108 * @param slotId 109 * @param numberList 110 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 111 */ 112 int32_t InviteToConference(int32_t slotId, const std::vector<std::string> &numberList); 113 114 /** 115 * KickOutFromConference 116 * 117 * @param slotId 118 * @param index 119 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 120 */ 121 int32_t KickOutFromConference(int32_t slotId, const std::string &KickOutString, int32_t index); 122 123 /** 124 * HangUpAllConnection 125 * 126 * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure. 127 */ 128 int32_t HangUpAllConnection(int32_t slotId) override; 129 130 /** 131 * Start Rtt 132 * 133 * @param msg 134 * @param slotId 135 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 136 */ 137 int32_t StartRtt(int32_t slotId, const std::string &msg); 138 139 /** 140 * Stop Rtt 141 * 142 * @param slotId 143 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 144 */ 145 int32_t StopRtt(int32_t slotId); 146 147 /** 148 * Release all Connection 149 */ 150 void ReleaseAllConnection(); 151 152 /** 153 * GetConnectionMap 154 * 155 * @return ImsConnectionMap 156 */ 157 ImsConnectionMap GetConnectionMap(); 158 159 /** 160 * IMSControl ReportImsCallsData. 161 * 162 * @param slotId 163 * @param CallInfoList 164 * @returns Error Code: Returns TELEPHONY_NO_ERROR on success, others on failure. 165 */ 166 int32_t ReportImsCallsData(int32_t slotId, const ImsCurrentCallList &callInfoList); 167 168 /** 169 * IMSControl ReportCallsData. 170 * 171 * @param slotId 172 * @param CallInfoList 173 * @returns Error Code: Returns TELEPHONY_NO_ERROR on success, others on failure. 174 */ 175 int32_t ReportCallsData(int32_t slotId, const CallInfoList &callInfoList) override; 176 177 int32_t PostDialProceed(const CellularCallInfo &callInfo, const bool proceed); 178 179 int32_t ExecutePostDial(int32_t slotId, int64_t callId); 180 181 int32_t RestoreConnection(const std::vector<CellularCallInfo> &infos, int32_t slotId); 182 183 int32_t ReportHangUp(const std::vector<CellularCallInfo> &infos, int32_t slotId); 184 185 void DialAfterHold(int32_t slotId); 186 187 /** 188 * Report being hang up data 189 * 190 * @return Error Code: Returns TELEPHONY_NO_ERROR on success, others on 191 * failure. 192 */ 193 int32_t ReportHangUpInfo(int32_t slotId); 194 195 void RecoverPendingHold(); 196 197 private: 198 /** 199 * handle dial judgment 200 * 201 * @param slotId 202 * @param std::string phoneNum 203 * @param CLIRMode clirMode 204 * @param videoState 0: audio 1:video 205 * @returns Error Code: Returns TELEPHONY_NO_ERROR on success, others on failure. 206 */ 207 int32_t DialJudgment(int32_t slotId, const std::string &phoneNum, CLIRMode &clirMode, int32_t videoState); 208 209 /** 210 * Encapsulate Dial Common 211 * 212 * @param std::string phoneNum 213 * @param CLIRMode clirMode 214 * @param videoState 0: audio 1:video 215 * @returns Error Code: Returns TELEPHONY_NO_ERROR on success, others on failure. 216 */ 217 int32_t EncapsulateDial(int32_t slotId, const std::string &phoneNum, CLIRMode &clirMode, int32_t videoState) const; 218 219 /** 220 * Report Incoming info 221 * 222 * @param CallInfoList 223 * @return Error Code: Returns TELEPHONY_NO_ERROR on success, others on failure. 224 */ 225 int32_t ReportIncomingInfo(int32_t slotId, const ImsCurrentCallList &callInfoList); 226 227 /** 228 * Report update info 229 * 230 * @param CallInfoList 231 * @return Error Code: Returns TELEPHONY_NO_ERROR on success, others on failure. 232 */ 233 int32_t ReportUpdateInfo(int32_t slotId, const ImsCurrentCallList &callInfoList); 234 235 /** 236 * Encapsulation CallReportInfo 237 * 238 * @param CallInfo 239 * @return CallReportInfo 240 */ 241 CallReportInfo EncapsulationCallReportInfo(int32_t slotId, const ImsCurrentCall &callInfo); 242 243 /** 244 * DeleteConnection Connection send 245 * 246 * @param CallsReportInfo 247 * @param CallInfoList 248 */ 249 void DeleteConnection(CallsReportInfo &callsReportInfo, const ImsCurrentCallList &callInfoList); 250 251 /** 252 * Check if active and holding call exist, hangup all holding call 253 * 254 */ 255 int32_t CheckAndHangupHoldingCall(); 256 257 private: 258 ImsConnectionMap connectionMap_; // save callConnection map 259 std::string pendingPhoneNumber_; 260 std::recursive_mutex connectionMapMutex_; 261 }; 262 } // namespace Telephony 263 } // namespace OHOS 264 265 #endif // CELLULAR_CALL_CONTROL_IMS_H 266