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 CALL_MANAGER_BASE_H
17#define CALL_MANAGER_BASE_H
18
19#include <algorithm>
20#include <cstdio>
21#include <ctime>
22#include <string>
23#include <vector>
24
25namespace OHOS {
26namespace Telephony {
27/**
28 * @brief Indicates Maximum length of a string.
29 */
30constexpr int16_t kMaxNumberLen = 255;
31/**
32 * @brief Indicates Maximum length of a bundle name.
33 */
34constexpr int16_t kMaxBundleNameLen = 100;
35/**
36 * @brief Indicates Maximum length of a address.
37 */
38constexpr int16_t kMaxAddressLen = 225;
39/**
40 * @brief Indicates Maximum length of a sco device name.
41 */
42constexpr int16_t kMaxDeviceNameLen = 64;
43/**
44 * @brief Indicates Maximum length of a MMI code message.
45 */
46constexpr int16_t kMaxMessageLen = 500;
47/**
48 * @brief Indicates Maximum length of the reject call message.
49 */
50constexpr uint16_t REJECT_CALL_MSG_MAX_LEN = 300;
51/**
52 * @brief Indicates Maximum length of the account number.
53 */
54constexpr uint16_t ACCOUNT_NUMBER_MAX_LENGTH = 255;
55/**
56 * @brief Indicates Maximum duration(ms) when connect service.
57 */
58constexpr uint16_t CONNECT_SERVICE_WAIT_TIME = 1000;
59/**
60 * @brief Indicates the main call id is invalid.
61 */
62constexpr int16_t ERR_ID = -1;
63/**
64 * @brief Indicates the call id is invalid.
65 */
66constexpr int16_t INVALID_CALLID = 0;
67/**
68 * @brief Indicates one second duration.
69 */
70constexpr int16_t WAIT_TIME_ONE_SECOND = 1;
71/**
72 * @brief Indicates three second duration.
73 */
74constexpr int16_t WAIT_TIME_THREE_SECOND = 3;
75/**
76 * @brief Indicates two five duration.
77 */
78constexpr int16_t WAIT_TIME_FIVE_SECOND = 5;
79/**
80 * @brief Indicates No Call Exist.
81 */
82constexpr int16_t NO_CALL_EXIST = 0;
83/**
84 * @brief Indicates One Call Exist.
85 */
86constexpr int16_t ONE_CALL_EXIST = 1;
87/**
88 * @brief  The follow hour and minute was use to confirm the set
89 * call transfer beginning and ending time restriction.
90 *
91 * MIN_HOUR: the minimum hour value.
92 * MAX_HOUR: the maximum hour value.
93 * MIN_MINUTE: the minimum minute value.
94 * MAX_MINUTE: the maximum minute value.
95 * INVALID_TIME: the time value is invalid.
96 */
97constexpr int16_t MIN_HOUR = 0;
98constexpr int16_t MAX_HOUR = 24;
99constexpr int16_t MIN_MINUTE = 0;
100constexpr int16_t MAX_MINUTE = 60;
101constexpr int16_t INVALID_TIME = -1;
102
103/**
104 * @brief Indicates the type of call, includs CS, IMS, OTT, OTHER.
105 */
106enum class CallType {
107    /**
108     * Indicates the call type is CS.
109     */
110    TYPE_CS = 0,
111    /**
112     * Indicates the call type is IMS.
113     */
114    TYPE_IMS = 1,
115    /**
116     * Indicates the call type is OTT.
117     */
118    TYPE_OTT = 2,
119    /**
120     * Indicates the call type is OTHER.
121     */
122    TYPE_ERR_CALL = 3,
123    /**
124     * Indicates the call type is VoIP.
125     */
126    TYPE_VOIP = 4,
127    /**
128     * Indicates the call type is SATELLITE.
129     */
130    TYPE_SATELLITE = 5,
131    /**
132     * Indicates the call type is BLUETOOTH.
133     */
134    TYPE_BLUETOOTH = 6,
135};
136
137/**
138 * @brief Indicates the detailed state of call.
139 */
140enum class TelCallState {
141    /**
142     * Indicates the call is unknown.
143     */
144    CALL_STATUS_UNKNOWN = -1,
145    /**
146     * Indicates the call is active.
147     */
148    CALL_STATUS_ACTIVE = 0,
149    /**
150     * Indicates the call is holding.
151     */
152    CALL_STATUS_HOLDING,
153    /**
154     * Indicates the call is dialing.
155     */
156    CALL_STATUS_DIALING,
157    /**
158     * Indicates the call is alerting.
159     */
160    CALL_STATUS_ALERTING,
161    /**
162     * Indicates the call is incoming.
163     */
164    CALL_STATUS_INCOMING,
165    /**
166     * Indicates the call is waiting.
167     */
168    CALL_STATUS_WAITING,
169    /**
170     * Indicates the call is disconnected.
171     */
172    CALL_STATUS_DISCONNECTED,
173    /**
174     * Indicates the call is disconnecting.
175     */
176    CALL_STATUS_DISCONNECTING,
177    /**
178     * Indicates the call is idle.
179     */
180    CALL_STATUS_IDLE,
181    /**
182     * Indicates the call is answered.
183     */
184    CALL_STATUS_ANSWERED,
185};
186
187/**
188 * @brief Indicates the state of conference call.
189 */
190enum class TelConferenceState {
191    /**
192     * Indicates the state is idle.
193     */
194    TEL_CONFERENCE_IDLE = 0,
195    /**
196     * Indicates the state is active.
197     */
198    TEL_CONFERENCE_ACTIVE,
199    /**
200     * Indicates the state is hold.
201     */
202    TEL_CONFERENCE_HOLDING,
203    /**
204     * Indicates the state is disconnecting.
205     */
206    TEL_CONFERENCE_DISCONNECTING,
207    /**
208     * Indicates the state is disconnected.
209     */
210    TEL_CONFERENCE_DISCONNECTED,
211};
212
213/**
214 * @brief Indicates the Network type.
215 */
216enum class PhoneNetType {
217    /**
218     * Indicates the Network type is GSM.
219     */
220    PHONE_TYPE_GSM = 1,
221    /**
222     * Indicates the Network type is CDMA.
223     */
224    PHONE_TYPE_CDMA = 2,
225};
226
227/**
228 * @brief Indicates the type of video state.
229 */
230enum class VideoStateType {
231    /**
232     * Indicates the call is in voice state.
233     */
234    TYPE_VOICE = 0,
235    /**
236     * Indicates the call is in send only state.
237     */
238    TYPE_SEND_ONLY,
239    /**
240     * Indicates the call is in send only state.
241     */
242    TYPE_RECEIVE_ONLY,
243    /**
244     * Indicates the call is in video state.
245     */
246    TYPE_VIDEO,
247};
248
249/**
250 * @brief Indicates the scenarios of the call to be made.
251 */
252enum class DialScene {
253    /**
254     * Indicates this is a common call.
255     */
256    CALL_NORMAL = 0,
257    /**
258     * Indicates this is a privileged call.
259     */
260    CALL_PRIVILEGED,
261    /**
262     * Indicates this is an emergency call.
263     */
264    CALL_EMERGENCY,
265};
266
267/**
268 * @brief Indicates the call is MO or MT.
269 */
270enum class CallDirection {
271    /**
272     * Indicates the call is a incoming call.
273     */
274    CALL_DIRECTION_IN = 0,
275    /**
276     * Indicates the call is a outgoing call.
277     */
278    CALL_DIRECTION_OUT,
279    /**
280     * Indicates the call is unknown.
281     */
282    CALL_DIRECTION_UNKNOW,
283};
284
285/**
286 * @brief Indicates the call state in progress.
287 */
288enum class CallRunningState {
289    /**
290     * Indicates to create a new call session.
291     */
292    CALL_RUNNING_STATE_CREATE = 0,
293    /**
294     * Indicates the call state is in connecting.
295     */
296    CALL_RUNNING_STATE_CONNECTING,
297    /**
298     * Indicates the call state is in dialing.
299     */
300    CALL_RUNNING_STATE_DIALING,
301    /**
302     * Indicates the call state is in ringing.
303     */
304    CALL_RUNNING_STATE_RINGING,
305    /**
306     * Indicates the call state is in active.
307     */
308    CALL_RUNNING_STATE_ACTIVE,
309    /**
310     * Indicates the call state is in hold.
311     */
312    CALL_RUNNING_STATE_HOLD,
313    /**
314     * Indicates the call state is ended.
315     */
316    CALL_RUNNING_STATE_ENDED,
317    /**
318     * Indicates the call state is in ending.
319     */
320    CALL_RUNNING_STATE_ENDING,
321};
322
323/**
324 * @brief Indicates the cause of the ended call.
325 */
326enum class CallEndedType {
327    /**
328     * Indicates the cause is unknown.
329     */
330    UNKNOWN = 0,
331    /**
332     * Indicates the cause is phone busy.
333     */
334    PHONE_IS_BUSY,
335    /**
336     * Indicates the cause is invalid phone number.
337     */
338    INVALID_NUMBER,
339    /**
340     * Indicates the call is ended normally.
341     */
342    CALL_ENDED_NORMALLY,
343};
344
345/**
346 * @brief Indicates the information of SIM card.
347 */
348struct SIMCardInfo {
349    /**
350     * Indicates the SIM ICC id.
351     */
352    int32_t simId = 0;
353    /**
354     * Indicated the country to which the SIM card belongs.
355     */
356    int32_t country = 0;
357    /**
358     * Indicates wether the SIM card is active.
359     */
360    int32_t state = 0;
361    /**
362     * Indicates the Network type.
363     */
364    PhoneNetType phoneNetType = PhoneNetType::PHONE_TYPE_GSM;
365};
366
367/**
368 * @brief Indicates the dialing call type.
369 */
370enum class DialType {
371    /**
372     * Indicates the dialing call type is normal cellular call.
373     */
374    DIAL_CARRIER_TYPE = 0,
375    /**
376     * Indicates the dialing call type is voice mail.
377     */
378    DIAL_VOICE_MAIL_TYPE,
379    /**
380     * Indicates the dialing call type is OTT.
381     */
382    DIAL_OTT_TYPE,
383};
384
385/**
386 * @brief Indicates the call state which will report to APP.
387 */
388enum class CallStateToApp {
389    /**
390     * Indicates an invalid state, which is used when the call state
391     * fails to be obtained.
392     */
393    CALL_STATE_UNKNOWN = -1,
394
395    /**
396     * Indicates that there is no ongoing call.
397     */
398    CALL_STATE_IDLE = 0,
399
400    /**
401     * Indicates that an incoming call is ringing or waiting.
402     */
403    CALL_STATE_RINGING = 1,
404
405    /**
406     * Indicates that a least one call is in the dialing, active, or hold
407     * state, and there is no new incoming call ringing or waiting.
408     */
409    CALL_STATE_OFFHOOK = 2,
410
411    CALL_STATE_ANSWERED = 3
412};
413
414/**
415 * @brief Indicates the cause when the call is answered.
416 */
417enum class CallAnswerType {
418    /**
419     * Indicates the call answer is call missed.
420     */
421    CALL_ANSWER_MISSED = 0,
422    /**
423     * Indicates the call answer is call active.
424     */
425    CALL_ANSWER_ACTIVED,
426    /**
427     * Indicates the call answer is call rejected.
428     */
429    CALL_ANSWER_REJECT,
430    /**
431     * Indicates the call answer is call blocked.
432     */
433    CALL_ANSWER_BLOCKED = 6,
434};
435
436/**
437 * @brief Indicates the event ID of call ability.
438 */
439enum class CallAbilityEventId {
440    /**
441     * Indicates that there is no available carrier during dialing.
442     */
443    EVENT_DIAL_NO_CARRIER = 1,
444    /**
445     * Indicates that FDN is invalid.
446     */
447    EVENT_INVALID_FDN_NUMBER = 2,
448    /**
449     * Indicates hold call fail.
450     */
451    EVENT_HOLD_CALL_FAILED = 3,
452    /**
453     * Indicates swap call fail.
454     */
455    EVENT_SWAP_CALL_FAILED = 4,
456    /**
457     * Indicates that the combine call failed.
458     */
459    EVENT_COMBINE_CALL_FAILED = 5,
460    /**
461     * Indicates that the split call failed.
462     */
463    EVENT_SPLIT_CALL_FAILED = 6,
464    /**
465     * Indicates that call is muted.
466     */
467    EVENT_CALL_MUTED = 7,
468    /**
469     * Indicates that the call is unmuted.
470     */
471    EVENT_CALL_UNMUTED = 8,
472    /**
473     * Indicates that call is speaker on.
474     */
475    EVENT_CALL_SPEAKER_ON = 9,
476    /**
477     * Indicates that call is speaker off.
478     */
479    EVENT_CALL_SPEAKER_OFF = 10,
480    /**
481     * Indicates that the OTT is not supported.
482     */
483    EVENT_OTT_FUNCTION_UNSUPPORTED = 11,
484    /**
485     * Indicates show full screen.
486     */
487    EVENT_SHOW_FULL_SCREEN = 12,
488    /**
489     * Indicates show float window.
490     */
491    EVENT_SHOW_FLOAT_WINDOW = 13,
492    /**
493     * Indicates that the super privacy mode ON.
494     */
495    EVENT_IS_SUPER_PRIVACY_MODE_ON = 20,
496	  /**
497     * Indicates that the super privacy mode OFF.
498     */
499    EVENT_IS_SUPER_PRIVACY_MODE_OFF = 21,
500    /**
501     * Indicates that the mute ring.
502     */
503    EVENT_MUTE_RING = 22,
504    /**
505     * Indicates that the local alerting.
506     */
507    EVENT_LOCAL_ALERTING = 23,
508};
509
510/**
511 * @brief Indicates the event ID of call ability.
512 */
513enum class CallSessionEventId {
514    /**
515     * Indicates the camera event failure type.
516     */
517    EVENT_CAMERA_FAILURE = 0,
518    /**
519     * Indicates the camera event ready type.
520     */
521    EVENT_CAMERA_READY,
522    /**
523     * Indicates the display surface release type.
524     */
525    EVENT_RELEASE_DISPLAY_SURFACE = 100,
526    /**
527     * Indicates the preview surface release type.
528     */
529    EVENT_RELEASE_PREVIEW_SURFACE,
530};
531
532/**
533 * @brief Indicates the type of device direction.
534 */
535enum DeviceDirection {
536    /**
537     * Indicates the device direction is 0 degree.
538     */
539    DEVICE_DIRECTION_0 = 0,
540    /**
541     * Indicates the device direction is 90 degree.
542     */
543    DEVICE_DIRECTION_90 = 90,
544    /**
545     * Indicates the device direction is 180 degree.
546     */
547    DEVICE_DIRECTION_180 = 180,
548    /**
549     * Indicates the device direction is 270 degree.
550     */
551    DEVICE_DIRECTION_270 = 270,
552};
553
554/**
555 * @brief Indicates the what the Audio device type is used.
556 */
557enum class AudioDeviceType {
558    /**
559     * Indicates the device type is a earphone speaker.
560     */
561    DEVICE_EARPIECE = 0,
562    /**
563     * Indicates the device type is the speaker system (i.e. a mono speaker or
564     * stereo speakers) built in a device.
565     */
566    DEVICE_SPEAKER,
567    /**
568     * Indicates the device type is a headset, which is the combination of a
569     * headphones and microphone.
570     */
571    DEVICE_WIRED_HEADSET,
572    /**
573     * Indicates the device type is a Bluetooth device typically used for
574     * telephony.
575     */
576    DEVICE_BLUETOOTH_SCO,
577    /**
578     * Indicates the audio device is disabled.
579     */
580    DEVICE_DISABLE,
581    /**
582     * Indicates the device type is an unknown or uninitialized.
583     */
584    DEVICE_UNKNOWN,
585    /**
586     * Indicates the device type is a distributed car device.
587     */
588    DEVICE_DISTRIBUTED_AUTOMOTIVE,
589    /**
590     * Indicates the device type is a distributed phone device.
591     */
592    DEVICE_DISTRIBUTED_PHONE,
593    /**
594     * Indicates the device type is a distributed pad device.
595     */
596    DEVICE_DISTRIBUTED_PAD,
597    /**
598     * Indicates the device type is a distributed pc device.
599     */
600    DEVICE_DISTRIBUTED_PC,
601};
602
603/**
604 * @brief Indicates the type of the number mark..
605 */
606enum class MarkType {
607    /**
608     * Indicates the mark is none.
609     */
610    MARK_TYPE_NONE = 0,
611    /**
612     * Indicates the mark is crank.
613     */
614    MARK_TYPE_CRANK,
615    /**
616     * Indicates the mark is fraud.
617     */
618    MARK_TYPE_FRAUD,
619    /**
620     * Indicates the mark is express.
621     */
622    MARK_TYPE_EXPRESS,
623    /**
624     * Indicates the mark is promote sales.
625     */
626    MARK_TYPE_PROMOTE_SALES,
627    /**
628     * Indicates the mark is house agent.
629     */
630    MARK_TYPE_HOUSE_AGENT,
631    /**
632     * Indicates the mark is insurance.
633     */
634    MARK_TYPE_INSURANCE,
635    /**
636     * Indicates the mark is taxi.
637     */
638    MARK_TYPE_TAXI,
639    /**
640     * Indicates the mark is custom.
641     */
642    MARK_TYPE_CUSTOM,
643    /**
644     * Indicates the mark is others.
645     */
646    MARK_TYPE_OTHERS,
647    /**
648     * Indicates the mark is yellow page.
649     */
650    MARK_TYPE_YELLOW_PAGE,
651    /**
652     * Indicates the mark is enterprise.
653     */
654    MARK_TYPE_ENTERPRISE,
655};
656
657/**
658 * @brief Indicates the call event type.
659 */
660enum class CellularCallEventType {
661    EVENT_REQUEST_RESULT_TYPE = 0,
662};
663
664/**
665 * @brief Indicates the call event id, one id corresponds to one request.
666 */
667enum class RequestResultEventId {
668    INVALID_REQUEST_RESULT_EVENT_ID = -1,
669    RESULT_DIAL_SEND_FAILED = 0,
670    RESULT_DIAL_NO_CARRIER,
671    RESULT_END_SEND_FAILED,
672    RESULT_REJECT_SEND_FAILED,
673    RESULT_ACCEPT_SEND_FAILED,
674    RESULT_HOLD_SEND_FAILED,
675    RESULT_ACTIVE_SEND_FAILED,
676    RESULT_SWAP_SEND_FAILED,
677    RESULT_COMBINE_SEND_FAILED,
678    RESULT_JOIN_SEND_FAILED,
679    RESULT_SPLIT_SEND_FAILED,
680    RESULT_SUPPLEMENT_SEND_FAILED,
681    RESULT_INVITE_TO_CONFERENCE_SUCCESS,
682    RESULT_INVITE_TO_CONFERENCE_FAILED,
683    RESULT_KICK_OUT_FROM_CONFERENCE_SUCCESS,
684    RESULT_KICK_OUT_FROM_CONFERENCE_FAILED,
685
686    RESULT_SEND_DTMF_SUCCESS,
687    RESULT_SEND_DTMF_FAILED,
688
689    RESULT_GET_CURRENT_CALLS_FAILED,
690
691    RESULT_SET_CALL_PREFERENCE_MODE_SUCCESS,
692    RESULT_SET_CALL_PREFERENCE_MODE_FAILED,
693    RESULT_GET_IMS_CALLS_DATA_FAILED,
694
695    RESULT_GET_CALL_WAITING_SUCCESS,
696    RESULT_GET_CALL_WAITING_FAILED,
697    RESULT_SET_CALL_WAITING_SUCCESS,
698    RESULT_SET_CALL_WAITING_FAILED,
699    RESULT_GET_CALL_RESTRICTION_SUCCESS,
700    RESULT_GET_CALL_RESTRICTION_FAILED,
701    RESULT_SET_CALL_RESTRICTION_SUCCESS,
702    RESULT_SET_CALL_RESTRICTION_FAILED,
703    RESULT_GET_CALL_TRANSFER_SUCCESS,
704    RESULT_GET_CALL_TRANSFER_FAILED,
705    RESULT_SET_CALL_TRANSFER_SUCCESS,
706    RESULT_SET_CALL_TRANSFER_FAILED,
707    RESULT_SEND_USSD_SUCCESS,
708    RESULT_SEND_USSD_FAILED,
709
710    RESULT_SET_MUTE_SUCCESS,
711    RESULT_SET_MUTE_FAILED,
712
713    RESULT_CTRL_CAMERA_SUCCESS,
714    RESULT_CTRL_CAMERA_FAILED,
715    RESULT_SET_PREVIEW_WINDOW_SUCCESS,
716    RESULT_SET_PREVIEW_WINDOW_FAILED,
717    RESULT_SET_DISPLAY_WINDOW_SUCCESS,
718    RESULT_SET_DISPLAY_WINDOW_FAILED,
719    RESULT_SET_CAMERA_ZOOM_SUCCESS,
720    RESULT_SET_CAMERA_ZOOM_FAILED,
721    RESULT_SET_PAUSE_IMAGE_SUCCESS,
722    RESULT_SET_PAUSE_IMAGE_FAILED,
723    RESULT_SET_DEVICE_DIRECTION_SUCCESS,
724    RESULT_SET_DEVICE_DIRECTION_FAILED,
725};
726
727/**
728 * @brief Indicates the call result report id in callback,
729 * one id corresponds to one request.
730 */
731enum class CallResultReportId {
732    START_DTMF_REPORT_ID = 0,
733    STOP_DTMF_REPORT_ID,
734    SEND_USSD_REPORT_ID,
735    GET_IMS_CALL_DATA_REPORT_ID,
736    GET_CALL_WAITING_REPORT_ID,
737    SET_CALL_WAITING_REPORT_ID,
738    GET_CALL_RESTRICTION_REPORT_ID,
739    SET_CALL_RESTRICTION_REPORT_ID,
740    GET_CALL_TRANSFER_REPORT_ID,
741    SET_CALL_TRANSFER_REPORT_ID,
742    GET_CALL_CLIP_ID,
743    GET_CALL_CLIR_ID,
744    SET_CALL_CLIR_ID,
745    START_RTT_REPORT_ID,
746    STOP_RTT_REPORT_ID,
747    GET_IMS_CONFIG_REPORT_ID,
748    SET_IMS_CONFIG_REPORT_ID,
749    GET_IMS_FEATURE_VALUE_REPORT_ID,
750    SET_IMS_FEATURE_VALUE_REPORT_ID,
751    INVITE_TO_CONFERENCE_REPORT_ID,
752    UPDATE_MEDIA_MODE_REPORT_ID,
753    CLOSE_UNFINISHED_USSD_REPORT_ID,
754    SET_CALL_RESTRICTION_PWD_REPORT_ID,
755};
756
757/**
758 * @brief Indicates the temperature level for satellite call.
759 */
760enum class SatCommTempLevel {
761    /*
762     *  Indicates the low temperature level.(< 51 degressCelsius)
763     */
764    TEMP_LEVEL_LOW = 0,
765    /*
766     *  Indicates the middle temperature level.(>= 51 degressCelsius  && < 53 degressCelsius)
767     */
768    TEMP_LEVEL_MIDDLE,
769    /*
770     *  Indicates the high temperature level.(>= 53 degressCelsius)
771     */
772    TEMP_LEVEL_HIGH,
773};
774
775/**
776 * @brief Indicates the super privacy mode for  call.
777 */
778enum class CallSuperPrivacyModeType {
779    /*
780     *  Indicates the super privacy mode for  OFF.
781     */
782    OFF = 0,
783    /*
784     *  Indicates the super privacy mode for  ON_WHEN_FOLDED.
785     */
786    ON_WHEN_FOLDED = 1,
787    /*
788     *  Indicates the super privacy mode for  ALWAYS_ON.
789     */
790    ALWAYS_ON = 2,
791};
792
793} // namespace Telephony
794} // namespace OHOS
795#endif // CALL_MANAGER_BASE_H