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