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