• 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
16import {AsyncCallback, Callback} from "./basic";
17
18/**
19 * Provides methods related to call management.
20 *
21 * @since 6
22 * @syscap SystemCapability.Telephony.CallManager
23 */
24declare namespace call {
25  /**
26   * Makes a call.
27   *
28   * @param phoneNumber Indicates the called number.
29   * @param options Indicates additional information carried in the call.
30   * @param callback Returns {@code true} if the call request is successful; returns {@code false} otherwise.
31   * Note that the value {@code true} indicates only the successful processing of the request; it does not mean
32   * that the call is or can be connected.
33   * @permission ohos.permission.PLACE_CALL
34   */
35  function dial(phoneNumber: string, callback: AsyncCallback<boolean>): void;
36  function dial(phoneNumber: string, options: DialOptions, callback: AsyncCallback<boolean>): void;
37  function dial(phoneNumber: string, options?: DialOptions): Promise<boolean>;
38
39  /**
40   * Go to the dial screen and the called number is displayed.
41   *
42   * @param phoneNumber Indicates the called number.
43   * @syscap SystemCapability.Applications.Contacts
44   * @since 7
45   */
46  function makeCall(phoneNumber: string, callback: AsyncCallback<void>): void;
47  function makeCall(phoneNumber: string): Promise<void>;
48
49  /**
50   * Checks whether a call is ongoing.
51   *
52   * @param callback Returns {@code true} if at least one call is not in the {@link CallState#CALL_STATE_IDLE}
53   * state; returns {@code false} otherwise.
54   */
55  function hasCall(callback: AsyncCallback<boolean>): void;
56  function hasCall(): Promise<boolean>;
57
58  /**
59   * Obtains the call state.
60   *
61   * <p>If an incoming call is ringing or waiting, the system returns {@code CallState#CALL_STATE_RINGING}.
62   * If at least one call is in the active, hold, or dialing state, the system returns
63   * {@code CallState#CALL_STATE_OFFHOOK}.
64   * In other cases, the system returns {@code CallState#CALL_STATE_IDLE}.
65   *
66   * @param callback Returns the call state.
67   */
68  function getCallState(callback: AsyncCallback<CallState>): void;
69  function getCallState(): Promise<CallState>;
70
71  /**
72   * Stops the ringtone.
73   *
74   * <p>If an incoming call is ringing, the phone stops ringing. Otherwise, this method does not function.
75   *
76   * @permission ohos.permission.SET_TELEPHONY_STATE
77   * @systemapi Hide this for inner system use.
78   * @since 8
79   */
80  function muteRinger(callback: AsyncCallback<void>): void;
81  function muteRinger(): Promise<void>;
82
83  /**
84   * Checks whether a device supports voice calls.
85   *
86   * <p>The system checks whether the device has the capability to initiate a circuit switching (CS) or IP multimedia
87   * subsystem domain (IMS) call on a telephone service network. If the device supports only packet switching
88   * (even if the device supports OTT calls), {@code false} is returned.
89   *
90   * @return Returns {@code true} if the device supports voice calls; returns {@code false} otherwise.
91   * @since 7
92   */
93  function hasVoiceCapability(): boolean;
94
95  /**
96   * Checks whether a phone number is on the emergency number list.
97   *
98   * @param phoneNumber Indicates the phone number to check.
99   * @param callback Returns {@code true} if the phone number is on the emergency number list;
100   * returns {@code false} otherwise.
101   * @since 7
102   */
103  function isEmergencyPhoneNumber(phoneNumber: string, callback: AsyncCallback<boolean>): void;
104  function isEmergencyPhoneNumber(phoneNumber: string, options: EmergencyNumberOptions, callback: AsyncCallback<boolean>): void;
105  function isEmergencyPhoneNumber(phoneNumber: string, options?: EmergencyNumberOptions): Promise<boolean>;
106
107  /**
108   * Formats a phone number according to the Chinese Telephone Code Plan. Before the formatting,
109   * a phone number is in the format of country code (if any) + 3-digit service provider code
110   * + 4-digit area code + 4-digit subscriber number. After the formatting,
111   * each part is separated by a space.
112   *
113   * @param phoneNumber Indicates the phone number to format.
114   * @param callback Returns the phone number after being formatted; returns an empty string
115   * if the input phone number is invalid.
116   * @since 7
117   */
118  function formatPhoneNumber(phoneNumber: string, callback: AsyncCallback<string>): void;
119  function formatPhoneNumber(phoneNumber: string, options: NumberFormatOptions, callback: AsyncCallback<string>): void;
120  function formatPhoneNumber(phoneNumber: string, options?: NumberFormatOptions): Promise<string>;
121
122  /**
123   * Formats a phone number into an E.164 representation.
124   *
125   * @param phoneNumber Indicates the phone number to format.
126   * @param countryCode Indicates a two-digit country code defined in ISO 3166-1.
127   * @param callback Returns an E.164 number; returns an empty string if the input phone number is invalid.
128   * @since 7
129   */
130  function formatPhoneNumberToE164(phoneNumber: string, countryCode: string, callback: AsyncCallback<string>): void;
131  function formatPhoneNumberToE164(phoneNumber: string, countryCode: string): Promise<string>;
132
133  /**
134   * @systemapi Hide this for inner system use.
135   * @permission ohos.permission.ANSWER_CALL
136   * @since 7
137   */
138  function answer(callId: number, callback: AsyncCallback<void>): void;
139  function answer(callId: number): Promise<void>;
140
141  /**
142   * @systemapi Hide this for inner system use.
143   * @since 7
144   */
145  function hangup(callId: number, callback: AsyncCallback<void>): void;
146  function hangup(callId: number): Promise<void>;
147
148  /**
149   * @systemapi Hide this for inner system use.
150   * @since 7
151   */
152  function reject(callId: number, callback: AsyncCallback<void>): void;
153  function reject(callId: number, options: RejectMessageOptions, callback: AsyncCallback<void>): void;
154  function reject(callId: number, options?: RejectMessageOptions): Promise<void>;
155
156  /**
157   * @systemapi Hide this for inner system use.
158   * @since 7
159   */
160  function holdCall(callId: number, callback: AsyncCallback<void>): void;
161  function holdCall(callId: number): Promise<void>;
162
163  /**
164   * @systemapi Hide this for inner system use.
165   * @since 7
166   */
167  function unHoldCall(callId: number, callback: AsyncCallback<void>): void;
168  function unHoldCall(callId: number): Promise<void>;
169
170  /**
171   * @systemapi Hide this for inner system use.
172   * @since 7
173   */
174  function switchCall(callId: number, callback: AsyncCallback<void>): void;
175  function switchCall(callId: number): Promise<void>;
176
177  /**
178   * @systemapi Hide this for inner system use.
179   * @since 7
180   */
181  function combineConference(callId: number, callback: AsyncCallback<void>): void;
182  function combineConference(callId: number): Promise<void>;
183
184  /**
185   * @systemapi Hide this for inner system use.
186   * @since 7
187   */
188  function getMainCallId(callId: number, callback: AsyncCallback<number>): void;
189  function getMainCallId(callId: number): Promise<number>;
190
191  /**
192   * @systemapi Hide this for inner system use.
193   * @since 7
194   */
195  function getSubCallIdList(callId: number, callback: AsyncCallback<Array<string>>): void;
196  function getSubCallIdList(callId: number): Promise<Array<string>>;
197
198  /**
199   * @systemapi Hide this for inner system use.
200   * @since 7
201   */
202  function getCallIdListForConference(callId: number, callback: AsyncCallback<Array<string>>): void;
203  function getCallIdListForConference(callId: number): Promise<Array<string>>;
204
205  /**
206   * @systemapi Hide this for inner system use.
207   * @since 7
208   */
209  function getCallWaitingStatus(slotId: number, callback: AsyncCallback<CallWaitingStatus>): void;
210  function getCallWaitingStatus(slotId: number): Promise<CallWaitingStatus>;
211
212  /**
213   * @systemapi Hide this for inner system use.
214   * @since 7
215   */
216  function setCallWaiting(slotId: number, activate: boolean, callback: AsyncCallback<void>): void;
217  function setCallWaiting(slotId: number, activate: boolean): Promise<void>;
218
219  /**
220   * @systemapi Hide this for inner system use.
221   * @since 7
222   */
223  function startDTMF(callId: number, character: string, callback: AsyncCallback<void>): void;
224  function startDTMF(callId: number, character: string): Promise<void>;
225
226  /**
227   * @systemapi Hide this for inner system use.
228   * @since 7
229   */
230  function stopDTMF(callId: number, callback: AsyncCallback<void>): void;
231  function stopDTMF(callId: number): Promise<void>;
232
233  /**
234   * @permission ohos.permission.SET_TELEPHONY_STATE
235   * @systemapi Hide this for inner system use.
236   * @since 7
237   */
238  function isInEmergencyCall(callback: AsyncCallback<boolean>): void;
239  function isInEmergencyCall(): Promise<boolean>;
240
241  /**
242   * @systemapi Hide this for inner system use.
243   * @since 7
244   */
245  function on(type: 'callDetailsChange', callback: Callback<CallAttributeOptions>): void;
246
247  /**
248   * @systemapi Hide this for inner system use.
249   * @since 7
250   */
251  function off(type: 'callDetailsChange', callback?: Callback<CallAttributeOptions>): void;
252
253  /**
254   * @systemapi Hide this for inner system use.
255   * @since 8
256   */
257  function on(type: 'callEventChange', callback: Callback<CallEventOptions>): void;
258
259  /**
260   * @systemapi Hide this for inner system use.
261   * @since 8
262   */
263  function off(type: 'callEventChange', callback?: Callback<CallEventOptions>): void;
264
265  /**
266   * @systemapi Hide this for inner system use.
267   * @since 8
268   */
269  function on(type: 'callDisconnectedCause', callback: Callback<DisconnectedDetails>): void;
270
271  /**
272   * @systemapi Hide this for inner system use.
273   * @since 8
274   */
275  function off(type: 'callDisconnectedCause', callback?: Callback<DisconnectedDetails>): void;
276
277  /**
278   * @systemapi Hide this for inner system use.
279   * @since 8
280   */
281  function isNewCallAllowed(callback: AsyncCallback<boolean>): void;
282  function isNewCallAllowed(): Promise<boolean>;
283
284  /**
285   * @systemapi Hide this for inner system use.
286   * @since 8
287   */
288  function separateConference(callId: number, callback: AsyncCallback<void>): void;
289  function separateConference(callId: number): Promise<void>;
290
291  /**
292   * @systemapi Hide this for inner system use.
293   * @since 8
294   */
295  function getCallRestrictionStatus(slotId: number, type: CallRestrictionType, callback: AsyncCallback<RestrictionStatus>): void;
296  function getCallRestrictionStatus(slotId: number, type: CallRestrictionType): Promise<RestrictionStatus>;
297
298  /**
299   * @systemapi Hide this for inner system use.
300   * @since 8
301   */
302  function setCallRestriction(slotId: number, info: CallRestrictionInfo, callback: AsyncCallback<void>): void;
303  function setCallRestriction(slotId: number, info: CallRestrictionInfo): Promise<void>;
304
305  /**
306   * @systemapi Hide this for inner system use.
307   * @since 8
308   */
309  function getCallTransferInfo(slotId: number, type: CallTransferType, callback: AsyncCallback<CallTransferResult>): void;
310  function getCallTransferInfo(slotId: number, type: CallTransferType): Promise<CallTransferResult>;
311
312  /**
313   * @systemapi Hide this for inner system use.
314   * @since 8
315   */
316  function setCallTransfer(slotId: number, info: CallTransferInfo, callback: AsyncCallback<void>): void;
317  function setCallTransfer(slotId: number, info: CallTransferInfo): Promise<void>;
318
319  /**
320   * @permission ohos.permission.SET_TELEPHONY_STATE
321   * @systemapi Hide this for inner system use.
322   * @since 8
323   */
324  function isRinging(callback: AsyncCallback<boolean>): void;
325  function isRinging(): Promise<boolean>;
326
327  /**
328   * @systemapi Hide this for inner system use.
329   * @since 8
330   */
331  function setMuted(callback: AsyncCallback<void>): void;
332  function setMuted(): Promise<void>;
333
334  /**
335   * @systemapi Hide this for inner system use.
336   * @since 8
337   */
338  function cancelMuted(callback: AsyncCallback<void>): void;
339  function cancelMuted(): Promise<void>;
340
341  /**
342   * @systemapi Hide this for inner system use.
343   * @since 8
344   */
345  function setAudioDevice(device: AudioDevice, callback: AsyncCallback<void>): void;
346  function setAudioDevice(device: AudioDevice): Promise<void>;
347
348  /**
349   * @systemapi Hide this for inner system use.
350   * @since 8
351   */
352  function joinConference(mainCallId: number, callNumberList: Array<string>, callback: AsyncCallback<void>): void;
353  function joinConference(mainCallId: number, callNumberList: Array<string>): Promise<void>;
354
355  /**
356   * @systemapi Hide this for inner system use.
357   * @since 8
358   */
359  function updateImsCallMode(callId: number, mode: ImsCallMode, callback: AsyncCallback<void>): void;
360  function updateImsCallMode(callId: number, mode: ImsCallMode): Promise<void>;
361
362  /**
363   * @systemapi Hide this for inner system use.
364   * @since 8
365   */
366  function enableImsSwitch(slotId: number, callback: AsyncCallback<void>): void;
367  function enableImsSwitch(slotId: number): Promise<void>;
368
369  /**
370   * @systemapi Hide this for inner system use.
371   * @since 8
372   */
373  function disableImsSwitch(slotId: number, callback: AsyncCallback<void>): void;
374  function disableImsSwitch(slotId: number): Promise<void>;
375
376  /**
377   * @systemapi Hide this for inner system use.
378   * @since 8
379   */
380  function isImsSwitchEnabled(slotId: number, callback: AsyncCallback<boolean>): void;
381  function isImsSwitchEnabled(slotId: number): Promise<boolean>;
382
383  /**
384   * @systemapi Hide this for inner system use.
385   * @since 8
386   */
387  export enum ImsCallMode {
388    CALL_MODE_AUDIO_ONLY = 0,
389    CALL_MODE_SEND_ONLY,
390    CALL_MODE_RECEIVE_ONLY,
391    CALL_MODE_SEND_RECEIVE,
392    CALL_MODE_VIDEO_PAUSED,
393  }
394
395  /**
396   * @systemapi Hide this for inner system use.
397   * @since 8
398   */
399  export enum AudioDevice {
400    DEVICE_MIC,
401    DEVICE_SPEAKER,
402    DEVICE_WIRED_HEADSET,
403    DEVICE_BLUETOOTH_SCO
404  }
405
406  /**
407   * @systemapi Hide this for inner system use.
408   * @since 8
409   */
410  export enum CallRestrictionType {
411    RESTRICTION_TYPE_ALL_INCOMING = 0,
412    RESTRICTION_TYPE_ALL_OUTGOING,
413    RESTRICTION_TYPE_INTERNATIONAL,
414    RESTRICTION_TYPE_INTERNATIONAL_EXCLUDING_HOME,
415    RESTRICTION_TYPE_ROAMING_INCOMING,
416    RESTRICTION_TYPE_ALL_CALLS,
417    RESTRICTION_TYPE_OUTGOING_SERVICES,
418    RESTRICTION_TYPE_INCOMING_SERVICES,
419  }
420
421  /**
422   * @systemapi Hide this for inner system use.
423   * @since 8
424   */
425  export interface CallTransferInfo {
426    transferNum: string;
427    type: CallTransferType;
428    settingType: CallTransferSettingType;
429  }
430
431  /**
432   * @systemapi Hide this for inner system use.
433   * @since 8
434   */
435  export enum CallTransferType {
436    TRANSFER_TYPE_UNCONDITIONAL = 0,
437    TRANSFER_TYPE_BUSY,
438    TRANSFER_TYPE_NO_REPLY,
439    TRANSFER_TYPE_NOT_REACHABLE,
440  }
441
442  /**
443   * @systemapi Hide this for inner system use.
444   * @since 8
445   */
446  export enum CallTransferSettingType {
447    CALL_TRANSFER_DISABLE = 0,
448    CALL_TRANSFER_ENABLE = 1,
449    CALL_TRANSFER_REGISTRATION = 3,
450    CALL_TRANSFER_ERASURE = 4,
451  }
452
453  /**
454   * @systemapi Hide this for inner system use.
455   * @since 7
456   */
457  export interface CallAttributeOptions {
458    accountNumber: string;
459    speakerphoneOn: boolean;
460    accountId: number;
461    videoState: VideoStateType;
462    startTime: number;
463    isEcc: boolean;
464    callType: CallType;
465    callId: number;
466    callState: DetailedCallState;
467    conferenceState: ConferenceState;
468  }
469
470  /**
471   * @systemapi Hide this for inner system use.
472   * @since 7
473   */
474  export enum ConferenceState {
475    TEL_CONFERENCE_IDLE = 0,
476    TEL_CONFERENCE_ACTIVE,
477    TEL_CONFERENCE_DISCONNECTING,
478    TEL_CONFERENCE_DISCONNECTED,
479  }
480
481  /**
482   * @systemapi Hide this for inner system use.
483   * @since 7
484   */
485  export enum CallType {
486    TYPE_CS = 0, // CS
487    TYPE_IMS = 1, // IMS
488    TYPE_OTT = 2, // OTT
489    TYPE_ERR_CALL = 3, // OTHER
490  }
491
492  /**
493   * @systemapi Hide this for inner system use.
494   * @since 7
495   */
496  export enum VideoStateType {
497    TYPE_VOICE = 0, // Voice
498    TYPE_VIDEO, // Video
499  }
500
501  /**
502   * @systemapi Hide this for inner system use.
503   * @since 7
504   */
505  export enum DetailedCallState {
506    CALL_STATUS_ACTIVE = 0,
507    CALL_STATUS_HOLDING,
508    CALL_STATUS_DIALING,
509    CALL_STATUS_ALERTING,
510    CALL_STATUS_INCOMING,
511    CALL_STATUS_WAITING,
512    CALL_STATUS_DISCONNECTED,
513    CALL_STATUS_DISCONNECTING,
514    CALL_STATUS_IDLE,
515  }
516
517  /**
518   * @systemapi Hide this for inner system use.
519   * @since 8
520   */
521  export interface CallRestrictionInfo {
522    type: CallRestrictionType;
523    password: string;
524    mode: CallRestrictionMode;
525  }
526
527  /**
528   * @systemapi Hide this for inner system use.
529   * @since 8
530   */
531  export enum CallRestrictionMode {
532    RESTRICTION_MODE_DEACTIVATION = 0,
533    RESTRICTION_MODE_ACTIVATION,
534  }
535
536  /**
537   * @systemapi Hide this for inner system use.
538   * @since 8
539   */
540  export interface CallEventOptions {
541    eventId: CallAbilityEventId,
542  }
543
544  /**
545   * @systemapi Hide this for inner system use.
546   * @since 8
547   */
548  export enum CallAbilityEventId {
549    EVENT_DIAL_NO_CARRIER = 1,
550    EVENT_INVALID_FDN_NUMBER,
551  }
552
553  export enum CallState {
554    /**
555     * Indicates an invalid state, which is used when the call state fails to be obtained.
556     */
557    CALL_STATE_UNKNOWN = -1,
558
559    /**
560     * Indicates that there is no ongoing call.
561     */
562    CALL_STATE_IDLE = 0,
563
564    /**
565     * Indicates that an incoming call is ringing or waiting.
566     */
567    CALL_STATE_RINGING = 1,
568
569    /**
570     * Indicates that a least one call is in the dialing, active, or hold state, and there is no new incoming call
571     * ringing or waiting.
572     */
573    CALL_STATE_OFFHOOK = 2
574  }
575
576  export interface DialOptions {
577    /**
578     * boolean means whether the call to be made is a video call. The value {@code false} indicates a voice call.
579     */
580    extras?: boolean;
581    /**
582     * @systemapi Hide this for inner system use.
583     * @since 8
584     */
585    accountId?: number;
586    /**
587     * @systemapi Hide this for inner system use.
588     * @since 8
589     */
590    videoState?: VideoStateType;
591    /**
592     * @systemapi Hide this for inner system use.
593     * @since 8
594     */
595    dialScene?: DialScene;
596    /**
597     * @systemapi Hide this for inner system use.
598     * @since 8
599     */
600    dialType?: DialType;
601  }
602
603  /**
604   * @systemapi Hide this for inner system use.
605   * @since 8
606   */
607  export enum DialScene {
608    CALL_NORMAL = 0,
609    CALL_PRIVILEGED = 1,
610    CALL_EMERGENCY = 2,
611  }
612
613  /**
614   * @systemapi Hide this for inner system use.
615   * @since 8
616   */
617  export enum DialType {
618    DIAL_CARRIER_TYPE = 0,
619    DIAL_VOICE_MAIL_TYPE = 1,
620    DIAL_OTT_TYPE = 2,
621  }
622
623  /**
624   * @systemapi Hide this for inner system use.
625   * @since 7
626   */
627  export interface RejectMessageOptions {
628    messageContent: string;
629  }
630
631  /**
632   * @systemapi Hide this for inner system use.
633   * @since 8
634   */
635  export interface CallTransferResult {
636    status: TransferStatus;
637    number: string;
638  }
639
640  /**
641   * @systemapi Hide this for inner system use.
642   * @since 7
643   */
644  export enum CallWaitingStatus {
645    CALL_WAITING_DISABLE = 0,
646    CALL_WAITING_ENABLE = 1
647  }
648
649  /**
650   * @systemapi Hide this for inner system use.
651   * @since 8
652   */
653  export enum RestrictionStatus {
654    RESTRICTION_DISABLE = 0,
655    RESTRICTION_ENABLE = 1
656  }
657
658  /**
659   * @systemapi Hide this for inner system use.
660   * @since 8
661   */
662  export enum TransferStatus {
663    TRANSFER_DISABLE = 0,
664    TRANSFER_ENABLE = 1
665  }
666
667  /**
668   * @since 7
669   */
670  export interface EmergencyNumberOptions {
671    slotId?: number;
672  }
673
674  /**
675   * @since 7
676   */
677  export interface NumberFormatOptions {
678    countryCode?: string;
679  }
680
681  /**
682   * @systemapi Hide this for inner system use.
683   * @since 8
684   */
685  export enum DisconnectedDetails {
686    UNASSIGNED_NUMBER = 1,
687    NO_ROUTE_TO_DESTINATION = 3,
688    CHANNEL_UNACCEPTABLE = 6,
689    OPERATOR_DETERMINED_BARRING = 8,
690    NORMAL_CALL_CLEARING = 16,
691    USER_BUSY = 17,
692    NO_USER_RESPONDING = 18,
693    USER_ALERTING_NO_ANSWER = 19,
694    CALL_REJECTED = 21,
695    NUMBER_CHANGED = 22,
696    DESTINATION_OUT_OF_ORDER = 27,
697    INVALID_NUMBER_FORMAT = 28,
698    NETWORK_OUT_OF_ORDER = 38,
699    TEMPORARY_FAILURE = 41,
700    INVALID_PARAMETER = 1025,
701    SIM_NOT_EXIT = 1026,
702    SIM_PIN_NEED = 1027,
703    CALL_NOT_ALLOW = 1029,
704    SIM_INVALID = 1045,
705    UNKNOWN = 1279,
706  }
707}
708
709export default call;