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_CS_H 17 #define CELLULAR_CALL_CONTROL_CS_H 18 19 #include "call_manager_inner_type.h" 20 21 #include "tel_ril_call_parcel.h" 22 #include "cellular_call_connection_cs.h" 23 #include "control_base.h" 24 #include "call_manager_disconnected_details.h" 25 #include "ffrt.h" 26 27 namespace OHOS { 28 namespace Telephony { 29 using CsConnectionMap = std::map<int32_t, CellularCallConnectionCS>; 30 class CSControl : public ControlBase { 31 public: 32 /** 33 * new CSControl 34 * 35 */ 36 CSControl() = default; 37 38 /** 39 * ~CSControl destructor 40 */ 41 ~CSControl(); 42 43 /** 44 * CS Dial 45 * 46 * 27007-430_2001 6.27 Informative examples 47 * 3GPP TS 22.030 [19] 48 */ 49 int32_t Dial(const CellularCallInfo &callInfo, bool isEcc) override; 50 51 /** 52 * CSControl HangUp 53 * 54 * 27007-430_2001 7.13 Call related supplementary services +CHLD 55 * 3GPP TS 22.030 [19] 56 * 57 * release the active call 58 * 59 * @param CellularCallInfo 60 * @param CallSupplementType 61 * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure. 62 */ 63 int32_t HangUp(const CellularCallInfo &callInfo, CallSupplementType type) override; 64 65 /** 66 * CSControl Answer 67 * 68 * 27007-430_2001 6.6 Alternating mode call control method 69 * 3GPP TS 22.030 [19] 70 * 71 * Answer an incoming voice call. 72 * 73 * @param CellularCallInfo 74 * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure. 75 */ 76 int32_t Answer(const CellularCallInfo &callInfo) override; 77 78 /** 79 * CSControl Reject 80 * 81 * 27007-430_2001 6.6 Alternating mode call control method 82 * 3GPP TS 22.030 [19] 83 * 84 * Reject an incoming voice call 85 * 86 * @param CellularCallInfo 87 * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure. 88 */ 89 int32_t Reject(const CellularCallInfo &callInfo) override; 90 91 /** 92 * CSControl HoldCall 93 * 94 * 22083-400_2001 2 Call hold 95 * 3GPP TS 22.030 [3] 96 * 3GPP TS 23.083 V4.2.0 (2001-04) 2 Call hold (HOLD) 97 * 98 * The call hold service allows a served mobile subscriber 99 * 100 * @param slotId 101 * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure. 102 */ 103 int32_t HoldCall(int32_t slotId) override; 104 105 /** 106 * CSControl UnHoldCall 107 * 108 * 22083-400_2001 2 Call hold 109 * 3GPP TS 22.030 [3] 110 * 111 * Retrieve the held call. 112 * 113 * @param slotId 114 * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure. 115 */ 116 int32_t UnHoldCall(int32_t slotId) override; 117 118 /** 119 * CSControl SwitchCall 120 * 121 * 22083-400_2001 2 Call hold 122 * 3GPP TS 22.030 [3] 123 * 124 * Alternate from one call to the other 125 * 126 * @param slotId 127 * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure. 128 */ 129 int32_t SwitchCall(int32_t slotId) override; 130 131 /** 132 * CSControl CombineConference 133 * 134 * 22084-400_2001 1.3.8.2 Managing an active multiParty call 135 * 3GPP TS 22.030 136 * 137 * Add another remote party 138 * @param slotId 139 * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure. 140 */ 141 int32_t CombineConference(int32_t slotId) override; 142 143 /** 144 * CSControl SeparateConference 145 * 146 * 22084-400_2001 1.3.8.2 Managing an active multiParty call 147 * 3GPP TS 22.030 148 * 149 * Separate a remote party 150 * @param slotId 151 * @param std::string splitString 152 * @param index 153 * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure. 154 */ 155 int32_t SeparateConference(int32_t slotId, const std::string &splitString, int32_t index); 156 157 /** 158 * HangUpAllConnection 159 * 160 * @param slotId 161 * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure. 162 */ 163 int32_t HangUpAllConnection(int32_t slotId) override; 164 165 /** 166 * CSControl ReleaseAllConnection 167 */ 168 void ReleaseAllConnection(); 169 170 /** 171 * CSControl GetConnectionMap 172 * 173 * @return CsConnectionMap 174 */ 175 CsConnectionMap GetConnectionMap(); 176 177 /** 178 * CSControl ReportCallsData 179 * 180 * @returns Error Code: Returns TELEPHONY_SUCCESS on success, others on failure. 181 */ 182 int32_t ReportCallsData(int32_t slotId, const CallInfoList &callInfoList) override; 183 184 /** 185 * CSControl ReportCsCallsData. 186 * 187 * @param slotId 188 * @param CallInfoList 189 * @returns Error Code: Returns TELEPHONY_NO_ERROR on success, others on failure. 190 */ 191 int32_t ReportCsCallsData(int32_t slotId, const CallInfoList &callInfoList, bool isNeedQuery = true) ; 192 193 int32_t ExecutePostDial(int32_t slotId, int64_t callId); 194 195 int32_t PostDialProceed(const CellularCallInfo &callInfo, const bool proceed); 196 197 int32_t ReportHangUp(const std::vector<CellularCallInfo> &infos, int32_t slotId); 198 199 /** 200 * Report being hang up data 201 * 202 * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure. 203 */ 204 int32_t ReportHangUpInfo(int32_t slotId); 205 206 void UpdateDisconnectedReason(const CallInfoList &callInfoList, RilDisconnectedReason reason); 207 208 bool HasEndCallWithoutReason(const CallInfoList &callInfoList); 209 210 void UpdateCallDisconnectReason(int32_t callId, RilDisconnectedReason reason); 211 212 private: 213 /** 214 * Calculate International Roaming 215 * 216 * @param slotId 217 * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure. 218 */ 219 bool CalculateInternationalRoaming(int32_t slotId) const; 220 221 /** 222 * Report Incoming info 223 * 224 * @param CallInfoList 225 * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure. 226 */ 227 int32_t ReportIncomingInfo(int32_t slotId, const CallInfoList &list); 228 229 /** 230 * Report update info 231 * 232 * @param CallInfoList 233 * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure. 234 */ 235 int32_t ReportUpdateInfo(int32_t slotId, const CallInfoList &list); 236 237 /** 238 * Encapsulation CallReportInfo 239 * 240 * @param callInfo 241 * @return CallReportInfo 242 */ 243 CallReportInfo EncapsulationCallReportInfo(int32_t slotId, const CallInfo &callInfo); 244 245 /** 246 * DeleteConnection Connection send 247 * 248 * @param CallsReportInfo 249 * @param CallInfoList 250 */ 251 void DeleteConnection(CallsReportInfo &callsResponseInfo, const CallInfoList &callInfoList); 252 253 /** 254 * Dial Cdma 255 * 256 * @param CellularCallInfo 257 * @returns Error Code: Returns TELEPHONY_SUCCESS on success, others on failure. 258 */ 259 int32_t DialCdma(const CellularCallInfo &callInfo); 260 261 /** 262 * Dial Gsm 263 * 264 * @param CellularCallInfo 265 * @returns Error Code: Returns TELEPHONY_SUCCESS on success, others on failure. 266 */ 267 int32_t DialGsm(const CellularCallInfo &callInfo); 268 269 /** 270 * Encapsulate Dial Common 271 * 272 * @param std::string phoneNum 273 * @param CLIRMode clirMode 274 * @returns Error Code: Returns TELEPHONY_SUCCESS on success, others on failure. 275 */ 276 int32_t EncapsulateDialCommon(int32_t slotId, const std::string &phoneNum, CLIRMode &clirMode); 277 278 /** 279 * Check if active and holding call exist, hangup all holding call 280 * 281 */ 282 int32_t CheckAndHangupHoldingCall(); 283 284 private: 285 CsConnectionMap connectionMap_; // save callConnection map 286 std::string pendingPhoneNumber_; 287 const int32_t VOICE_CALL = 0; 288 ffrt::recursive_mutex connectionMapMutex_; 289 }; 290 } // namespace Telephony 291 } // namespace OHOS 292 293 #endif // CELLULAR_CALL_CONTROL_CS_H 294