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