1 /*
2  * Copyright (C) 2023 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 VOIP_CALL_MANAGER_INFO_H
17 #define VOIP_CALL_MANAGER_INFO_H
18 #include <cstdint>
19 #include <string>
20 #include <vector>
21 
22 namespace OHOS {
23 namespace Telephony {
24 /**
25  * @brief Indicates the call audio event.
26  */
27 enum class CallAudioEvent {
28     /**
29      * Indicates the event of muted.
30      */
31     AUDIO_EVENT_MUTED = 0,
32     /**
33      * Indicates the event of unmuted.
34      */
35     AUDIO_EVENT_UNMUTED = 1,
36     /**
37      * Indicates the event of speaker on.
38      */
39     AUDIO_EVENT_SPEAKER_ON = 2,
40     /**
41      * Indicates the event of speaker off.
42      */
43     AUDIO_EVENT_SPEAKER_OFF = 3,
44 };
45 
46 /**
47  * @brief Indicates the voip call state.
48  */
49 enum class VoipCallState {
50     /**
51      * Indicates the call state of idle.
52      */
53     VOIP_CALL_STATE_IDLE = 0,
54     /**
55      * Indicates the call state of incoming.
56      */
57     VOIP_CALL_STATE_INCOMING,
58     /**
59      * Indicates the call state of active.
60      */
61     VOIP_CALL_STATE_ACTIVE,
62     /**
63      * Indicates the call state is holding.
64      */
65     VOIP_CALL_STATE_HOLDING,
66     /**
67      * Indicates the call state of disconnected.
68      */
69     VOIP_CALL_STATE_DISCONNECTED,
70     /**
71      * Indicates the call state of dialing.
72      */
73     VOIP_CALL_STATE_DIALING,
74     /**
75      * Indicates the call is answered.
76      */
77     VOIP_CALL_STATE_ANSWERED,
78     /**
79      * Indicates the call is disconnecting.
80      */
81     VOIP_CALL_STATE_DISCONNECTING,
82 };
83 
84 /**
85  * @brief Indicates the voip call type.
86  */
87 enum class VoipCallType {
88     /**
89      * Indicates the type of voip voice call.
90      */
91     VOIP_CALL_VOICE = 0,
92     /**
93      * Indicates the type of voip video call.
94      */
95     VOIP_CALL_VIDEO,
96 };
97 
98 /**
99  * @brief Indicates the voip call attribute.
100  */
101 struct VoipCallAttribute {
102     /**
103      * Indicates the callid
104      */
105     std::string callId = "";
106     /**
107      * Indicates the bundleName.
108      */
109     std::string bundleName = "";
110     /**
111      * Indicates the type of voip call.
112      */
113     VoipCallType voipCallType = VoipCallType::VOIP_CALL_VOICE;
114     /**
115      * Indicates the userName.
116      */
117     std::string userName = "";
118     /**
119      * Indicates the user Porfile.
120      */
121     std::vector<uint8_t> userProfile = {};
122     /**
123      * Indicates the package Profile.
124      */
125     std::string abilityName = "";
126     /**
127      * Indicates the state of voip call.
128      */
129     VoipCallState voipCallState = VoipCallState::VOIP_CALL_STATE_IDLE;
130     /**
131      * Indicates the extensionId of voip call.
132      */
133     std::string extensionId = "";
134     /**
135      * Indicates the process mode of voip call. 1: main process mode; 0: sub process mode
136      */
137     std::string processMode = "1";
138     /**
139      * Indicates whether the VoIP incoming call default show live call banner. Default value is true.
140      */
141     bool showBannerForIncomingCall = true;
142     /**
143      * Indicates whether the VoIP incoming call is a conference. Default value is false.
144      */
145     bool isConferenceCall = false;
146     /**
147      * Indicates whether the VoIP incoming video call is support voice answer. Default value is true.
148      */
149     bool isVoiceAnswerSupported = true;
150     /**
151      * Indicates whether the app has the permission to use microphone. Default value is true.
152      */
153     bool hasMicPermission = true;
154     /**
155      * Indicates whether the VoIP call is from Push kit.
156     */
157     bool isCallByPushKit = true;
158     /**
159      * Indicates the uid of voip call.
160      */
161     int32_t uid = 0;
162     /**
163      * Indicates the fullTokenId of voip call.
164      */
165     uint64_t fullTokenId = 0;
166     /**
167      * Indicates the tokenId of voip call.
168      */
169     uint32_t tokenId = 0;
170 };
171 
172 /**
173  * @brief Indicates the voip call event.
174  */
175 enum class VoipCallEvent {
176     /**
177      * Indicates the click event of default.
178      */
179     VOIP_CALL_EVENT_NONE = 0,
180     /**
181      * Indicates the click event of answer voice.
182      */
183     VOIP_CALL_EVENT_ANSWER_VOICE,
184     /**
185      * Indicates the click event of answer video.
186      */
187     VOIP_CALL_EVENT_ANSWER_VIDEO,
188     /**
189      * Indicates the click event of reject.
190      */
191     VOIP_CALL_EVENT_REJECT,
192     /**
193      * Indicates the voip call was hung up by other cause.
194      */
195     VOIP_CALL_EVENT_HANGUP,
196     /**
197      * Indicates the user clicked muted.
198      */
199     VOIP_CALL_EVENT_MUTED,
200     /**
201      * Indicates the user clicked unmuted.
202      */
203     VOIP_CALL_EVENT_UNMUTED,
204     /**
205      * Indicates the user clicked speaker on.
206      */
207     VOIP_CALL_EVENT_SPEAKER_ON,
208     /**
209      * Indicates the user clicked speaker off.
210      */
211     VOIP_CALL_EVENT_SPEAKER_OFF,
212 };
213 
214 /**
215  * @brief Indicates the ErrorReason.
216  */
217 enum class ErrorReason {
218     /**
219      * Indicates there is no error.
220      */
221     ERROR_NONE = 0,
222 
223     /**
224      * Indicates there is already a cellular call.
225      */
226     CELLULAR_CALL_EXISTS = 1,
227 
228     /**
229      * Indicates there is already a voip call.
230      */
231     VOIP_CALL_EXISTS = 2,
232 
233     /**
234      * Indicates this is a invalid call.
235      */
236     INVALID_CALL = 3,
237 
238     /**
239      * Indicates the user answered the cellular call first.
240      */
241     USER_ANSWER_CELLULAR_FIRST = 4,
242 };
243 
244 /**
245  * @brief Indicates the voip call Events.
246  */
247 struct VoipCallEventInfo {
248     /**
249      * Indicates the callid
250      */
251     std::string voipCallId = "";
252     /**
253      * Indicates the bundleName.
254      */
255     std::string bundleName = "";
256     /**
257      * Indicates the uid.
258      */
259     int32_t uid = 0;
260     /**
261      * Indicates the click event of voip.
262      */
263     VoipCallEvent voipCallEvent = VoipCallEvent::VOIP_CALL_EVENT_NONE;
264     /**
265      * Indicates the error reason.
266      */
267     ErrorReason errorReason = ErrorReason::ERROR_NONE;
268 };
269 
270 /**
271  * @brief Indicates the ErrorReason.
272  */
273 enum class ReportVoipCallFailedCause {
274     /**
275      * Indicates other failed cause.
276      */
277     OTHER_CAUSED,
278     /**
279      * Indicates application line is busy.
280      */
281     ROUTE_BUSY,
282     /**
283      * Indicates application failed to establish connect.
284      */
285     CONNECT_FAILED,
286 };
287 
288 struct ReportVoIPCallParams {
289     std::string callId = "";
290     int32_t status;
291 };
292 
293 enum VoipCallErrorCode {
294     VOIP_ERR_CALLBACK_NOT_EXIST,
295 };
296 
297 enum class VoIPCallStatus : uint32_t {
298     ORIGINAL_STATE = 0,
299 
300     VOIP_EXTENSION_CONNECT_SUCCEED = 1,
301     VOIP_EXTENSION_CONNECT_FAILED = 2,
302     VOIP_EXTENSION_BUSY = 3,
303     VOIP_EXTENSION_CALLBACK_ILLEAGAL_PARAM = 4,
304     VOIP_EXTENSION_OTHER_REASON = 5,
305 
306     VOIP_MANAGER_BUSY = 6,
307     VOIP_MANAGER_OTHER_REASON = 7,
308 
309     EXTENSION_LOAD_SUCCEED = 20,
310     EXTENSION_LOAD_FAILED = 21,
311     REFUSE_ANSWER = 22,
312     DELETE_CALL_NOTIFICATION = 23,
313     HANG_UP_DURING_CALLING = 24,
314     LONGTIME_CALL_NOT_ANSWER = 25,
315     CALL_END_OTHER_REASON = 26,
316     ANSWERED_SUCCEED = 27,
317 
318     HANG_UP_DURING_ANSWERED = 40,
319     VOIP_MANAGER_DESTROYED = 41,
320     HANG_UP_DURING_ANSWERED_OTHER_REASON = 42,
321 
322     VOIP_MANAGER_INVALID_PARAM = 58,
323     VOIP_MANAGER_CALL_NOT_EXIST = 59,
324 
325     PUSH_MANAGER_SERVICE_LOAD_SUCCESS = 60,
326     PUSH_MANAGER_SERVICE_LOAD_FAILED_SYSTEM_ERROR = 61,
327     PUSH_MANAGER_SERVICE_LOAD_FAILED_ILLEGAL_EXTENSION = 62,
328     PUSH_MANAGER_SERVICE_LOAD_FAILED_CALLS_EXCEEDED = 63,
329     PUSH_MANAGER_SERVICE_LOAD_FAILED_VOIP_INTERNAL_ERROR = 64,
330     PUSH_MANAGER_SERVICE_LOAD_FAILED_ILLEGAL_CALL_ID = 65,
331     PUSH_MANAGER_SERVICE_LOAD_FAILED_OTHER_REASON = 66,
332 
333     VOIP_TIMER_TRIGGER = 70,
334 };
335 } // namespace Telephony
336 } // namespace OHOS
337 #endif
338