1/* 2* Copyright (C) 2021 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.DCall 23 */ 24declare namespace call { 25 /** 26 * Makes a call. 27 * 28 * <p>Applications must have the {@code ohos.permission.PLACE_CALL} permission to call this method. 29 * 30 * @param phoneNumber Indicates the called number. 31 * @param options Indicates additional information carried in the call. 32 * @param callback Returns {@code true} if the call request is successful; returns {@code false} otherwise. 33 * Note that the value {@code true} indicates only the successful processing of the request; it does not mean 34 * that the call is or can be connected. 35 * @permission ohos.permission.PLACE_CALL 36 */ 37 function dial(phoneNumber: string, callback: AsyncCallback<boolean>): void; 38 function dial(phoneNumber: string, options: DialOptions, callback: AsyncCallback<boolean>): void; 39 function dial(phoneNumber: string, options?: DialOptions): Promise<boolean>; 40 41 /** 42 * Checks whether a call is ongoing. 43 * 44 * @param callback Returns {@code true} if at least one call is not in the {@link CallState#CALL_STATE_IDLE} 45 * state; returns {@code false} otherwise. 46 */ 47 function hasCall(callback: AsyncCallback<boolean>): void; 48 function hasCall(): Promise<boolean>; 49 50 /** 51 * Obtains the call state. 52 * 53 * <p>If an incoming call is ringing or waiting, the system returns {@code CallState#CALL_STATE_RINGING}. 54 * If at least one call is in the active, hold, or dialing state, the system returns 55 * {@code CallState#CALL_STATE_OFFHOOK}. 56 * In other cases, the system returns {@code CallState#CALL_STATE_IDLE}. 57 * 58 * @param callback Returns the call state. 59 */ 60 function getCallState(callback: AsyncCallback<CallState>): void; 61 function getCallState(): Promise<CallState>; 62 63 /** 64 * Checks whether a phone number is on the emergency number list. 65 * 66 * @param phoneNumber Indicates the phone number to check. 67 * @param callback Returns {@code true} if the phone number is on the emergency number list; 68 * returns {@code false} otherwise. 69 * @since 7 70 */ 71 function isEmergencyPhoneNumber(phoneNumber: string, callback: AsyncCallback<boolean>): void; 72 function isEmergencyPhoneNumber(phoneNumber: string, options: EmergencyNumberOptions, callback: AsyncCallback<boolean>): void; 73 function isEmergencyPhoneNumber(phoneNumber: string, options?: EmergencyNumberOptions): Promise<boolean>; 74 75 /** 76 * Formats a phone number according to the Chinese Telephone Code Plan. Before the formatting, 77 * a phone number is in the format of country code (if any) + 3-digit service provider code 78 * + 4-digit area code + 4-digit subscriber number. After the formatting, 79 * each part is separated by a space. 80 * 81 * @param phoneNumber Indicates the phone number to format. 82 * @param callback Returns the phone number after being formatted; returns an empty string 83 * if the input phone number is invalid. 84 * @since 7 85 */ 86 function formatPhoneNumber(phoneNumber: string, callback: AsyncCallback<string>): void; 87 function formatPhoneNumber(phoneNumber: string, options: NumberFormatOptions, callback: AsyncCallback<string>): void; 88 function formatPhoneNumber(phoneNumber: string, options?: NumberFormatOptions): Promise<string>; 89 90 /** 91 * Formats a phone number into an E.164 representation. 92 * 93 * @param phoneNumber Indicates the phone number to format. 94 * @param countryCode Indicates a two-digit country code defined in ISO 3166-1. 95 * @param callback Returns an E.164 number; returns an empty string if the input phone number is invalid. 96 * @since 7 97 */ 98 function formatPhoneNumberToE164(phoneNumber: string, countryCode: string, callback: AsyncCallback<string>): void; 99 function formatPhoneNumberToE164(phoneNumber: string, countryCode: string): Promise<string>; 100 101 /** 102 * @systemapi Hide this for inner system use. 103 * @since 7 104 */ 105 function answer(callId: number, callback: AsyncCallback<void>): void; 106 function answer(callId: number): Promise<void>; 107 108 /** 109 * @systemapi Hide this for inner system use. 110 * @since 7 111 */ 112 function hangup(callId: number, callback: AsyncCallback<void>): void; 113 function hangup(callId: number): Promise<void>; 114 115 /** 116 * @systemapi Hide this for inner system use. 117 * @since 7 118 */ 119 function reject(callId: number, callback: AsyncCallback<void>): void; 120 function reject(callId: number, options: RejectMessageOptions, callback: AsyncCallback<void>): void; 121 function reject(callId: number, options?: RejectMessageOptions): Promise<void>; 122 123 /** 124 * @systemapi Hide this for inner system use. 125 */ 126 function holdCall(callId: number, callback: AsyncCallback<void>): void; 127 function holdCall(callId: number): Promise<void>; 128 129 /** 130 * @systemapi Hide this for inner system use. 131 */ 132 function unHoldCall(callId: number, callback: AsyncCallback<void>): void; 133 function unHoldCall(callId: number): Promise<void>; 134 135 /** 136 * @systemapi Hide this for inner system use. 137 */ 138 function switchCall(callId: number, callback: AsyncCallback<void>): void; 139 function switchCall(callId: number): Promise<void>; 140 141 /** 142 * @systemapi Hide this for inner system use. 143 * @since 7 144 */ 145 function combineConference(callId: number, callback: AsyncCallback<void>): void; 146 function combineConference(callId: number): Promise<void>; 147 148 /** 149 * @systemapi Hide this for inner system use. 150 * @since 7 151 */ 152 function getMainCallId(callId: number, callback: AsyncCallback<number>): void; 153 function getMainCallId(callId: number): Promise<number>; 154 155 /** 156 * @systemapi Hide this for inner system use. 157 * @since 7 158 */ 159 function getSubCallIdList(callId: number, callback: AsyncCallback<Array<string>>): void; 160 function getSubCallIdList(callId: number): Promise<Array<string>>; 161 162 /** 163 * @systemapi Hide this for inner system use. 164 * @since 7 165 */ 166 function getCallIdListForConference(callId: number, callback: AsyncCallback<Array<string>>): void; 167 function getCallIdListForConference(callId: number): Promise<Array<string>>; 168 169 /** 170 * @systemapi Hide this for inner system use. 171 * @since 7 172 */ 173 function getCallWaitingStatus(slotId: number, callback: AsyncCallback<CallWaitingStatus>): void; 174 function getCallWaitingStatus(slotId: number): Promise<CallWaitingStatus>; 175 176 /** 177 * @systemapi Hide this for inner system use. 178 * @since 7 179 */ 180 function setCallWaiting(slotId: number, activate: boolean, callback: AsyncCallback<void>): void; 181 function setCallWaiting(slotId: number, activate: boolean): Promise<void>; 182 183 /** 184 * @systemapi Hide this for inner system use. 185 * @since 7 186 */ 187 function startDTMF(callId: number, character: string, callback: AsyncCallback<void>): void; 188 function startDTMF(callId: number, character: string): Promise<void>; 189 190 /** 191 * @systemapi Hide this for inner system use. 192 * @since 7 193 */ 194 function stopDTMF(callId: number, callback: AsyncCallback<void>): void; 195 function stopDTMF(callId: number): Promise<void>; 196 197 /** 198 * @permission ohos.permission.SET_TELEPHONY_STATE 199 * @systemapi Hide this for inner system use. 200 * @since 7 201 */ 202 function isInEmergencyCall(callback: AsyncCallback<boolean>): void; 203 function isInEmergencyCall(): Promise<boolean>; 204 205 /** 206 * @systemapi Hide this for inner system use. 207 * @since 7 208 */ 209 function on(type: 'callDetailsChange', callback: Callback<CallAttributeOptions>): void; 210 function off(type: 'callDetailsChange', callback?: Callback<CallAttributeOptions>): void; 211 212 /** 213 * @systemapi Hide this for inner system use. 214 * @since 7 215 */ 216 export interface CallAttributeOptions { 217 accountNumber: string, 218 speakerphoneOn: boolean, 219 accountId: number, 220 videoState: VideoStateType, 221 startTime: number, 222 isEcc: boolean, 223 callType: CallType, 224 callId: number, 225 callState: DetailedCallState, 226 conferenceState: ConferenceState, 227 } 228 229 /** 230 * @systemapi Hide this for inner system use. 231 * @since 7 232 */ 233 export enum ConferenceState { 234 TEL_CONFERENCE_IDLE = 0, 235 TEL_CONFERENCE_ACTIVE, 236 TEL_CONFERENCE_DISCONNECTING, 237 TEL_CONFERENCE_DISCONNECTED, 238 } 239 240 /** 241 * @systemapi Hide this for inner system use. 242 * @since 7 243 */ 244 export enum CallType { 245 TYPE_CS = 0, // CS 246 TYPE_IMS = 1, // IMS 247 TYPE_OTT = 2, // OTT 248 TYPE_ERR_CALL = 3, // OTHER 249 } 250 251 /** 252 * @systemapi Hide this for inner system use. 253 * @since 7 254 */ 255 export enum VideoStateType { 256 TYPE_VOICE = 0, // Voice 257 TYPE_VIDEO, // Video 258 } 259 260 /** 261 * @systemapi Hide this for inner system use. 262 * @since 7 263 */ 264 export enum DetailedCallState { 265 CALL_STATUS_ACTIVE = 0, 266 CALL_STATUS_HOLDING, 267 CALL_STATUS_DIALING, 268 CALL_STATUS_ALERTING, 269 CALL_STATUS_INCOMING, 270 CALL_STATUS_WAITING, 271 CALL_STATUS_DISCONNECTED, 272 CALL_STATUS_DISCONNECTING, 273 CALL_STATUS_IDLE, 274 } 275 276 export enum CallState { 277 /** 278 * Indicates an invalid state, which is used when the call state fails to be obtained. 279 */ 280 CALL_STATE_UNKNOWN = -1, 281 282 /** 283 * Indicates that there is no ongoing call. 284 */ 285 CALL_STATE_IDLE = 0, 286 287 /** 288 * Indicates that an incoming call is ringing or waiting. 289 */ 290 CALL_STATE_RINGING = 1, 291 292 /** 293 * Indicates that a least one call is in the dialing, active, or hold state, and there is no new incoming call 294 * ringing or waiting. 295 */ 296 CALL_STATE_OFFHOOK = 2 297 } 298 299 export interface DialOptions { 300 /** 301 * boolean means whether the call to be made is a video call. The value {@code false} indicates a voice call. 302 */ 303 extras?: boolean; 304 } 305 306 /** 307 * @systemapi Hide this for inner system use. 308 * @since 7 309 */ 310 export interface RejectMessageOptions { 311 messageContent: string, 312 } 313 314 /** 315 * @systemapi Hide this for inner system use. 316 * @since 7 317 */ 318 export enum CallWaitingStatus { 319 CALL_WAITING_DISABLE = 0, 320 CALL_WAITING_ENABLE = 1 321 } 322 323 /** 324 * @since 7 325 */ 326 export interface EmergencyNumberOptions { 327 slotId?: number; 328 } 329 330 /** 331 * @since 7 332 */ 333 export interface NumberFormatOptions { 334 countryCode?: string; 335 } 336} 337 338export default call;