1/* 2 * Copyright (C) 2021-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/** 17 * @file 18 * @kit TelephonyKit 19 */ 20 21import type { Callback } from './@ohos.base'; 22import type radio from './@ohos.telephony.radio'; 23import type data from './@ohos.telephony.data'; 24import type call from './@ohos.telephony.call'; 25import type sim from './@ohos.telephony.sim'; 26 27/** 28 * Monitors telephony state updates of a device, including updates of the network state, 29 * signal strength, call state, the data link connection state and others. 30 * 31 * @namespace observer 32 * @syscap SystemCapability.Telephony.StateRegistry 33 * @since 6 34 */ 35declare namespace observer { 36 /** 37 * Describes the network registration state. 38 * 39 * @typedef NetworkState 40 * @syscap SystemCapability.Telephony.StateRegistry 41 * @since 6 42 */ 43 type NetworkState = radio.NetworkState; 44 45 /** 46 * Describes the signal strength information. 47 * 48 * @typedef SignalInformation 49 * @syscap SystemCapability.Telephony.StateRegistry 50 * @since 6 51 */ 52 type SignalInformation = radio.SignalInformation; 53 54 /** 55 * Describes current cell information. 56 * 57 * @typedef CellInformation 58 * @syscap SystemCapability.Telephony.StateRegistry 59 * @systemapi Hide this for inner system use. 60 * @since 6 61 */ 62 type CellInformation = radio.CellInformation; 63 64 /** 65 * Describes the cellular data link connection state. 66 * 67 * @typedef DataConnectState 68 * @syscap SystemCapability.Telephony.StateRegistry 69 * @since 6 70 */ 71 type DataConnectState = data.DataConnectState; 72 73 /** 74 * Describes the radio access technology. 75 * 76 * @typedef RatType 77 * @syscap SystemCapability.Telephony.StateRegistry 78 * @since 6 79 */ 80 type RatType = radio.RadioTechnology; 81 82 /** 83 * Describes the cellular data flow type. 84 * 85 * @typedef DataFlowType 86 * @syscap SystemCapability.Telephony.StateRegistry 87 * @since 6 88 */ 89 type DataFlowType = data.DataFlowType; 90 91 /** 92 * Indicates the states of call. 93 * 94 * @typedef CallState 95 * @syscap SystemCapability.Telephony.StateRegistry 96 * @since 6 97 */ 98 type CallState = call.CallState; 99 100 /** 101 * Indicates the SIM card types. 102 * 103 * @typedef CardType 104 * @syscap SystemCapability.Telephony.StateRegistry 105 * @since 6 106 */ 107 type CardType = sim.CardType; 108 109 /** 110 * Indicates the SIM card states. 111 * 112 * @typedef SimState 113 * @syscap SystemCapability.Telephony.StateRegistry 114 * @since 6 115 */ 116 type SimState = sim.SimState; 117 118 /** 119 * Callback when the network state corresponding to the default sim card is updated. 120 * 121 * @permission ohos.permission.GET_NETWORK_INFO 122 * @param { 'networkStateChange' } type - Event type. Indicates the networkStateChange event to be subscribed to. 123 * @param { Callback<NetworkState> } callback - Indicates the callback for 124 * getting an instance of the {@code NetworkState} class. 125 * @throws { BusinessError } 201 - Permission denied. 126 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified. 127 * 2. Incorrect parameter types. 128 * @throws { BusinessError } 8300001 - Invalid parameter value. 129 * @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service. 130 * @throws { BusinessError } 8300003 - System internal error. 131 * @throws { BusinessError } 8300999 - Unknown error code. 132 * @syscap SystemCapability.Telephony.StateRegistry 133 * @since 6 134 */ 135 function on(type: 'networkStateChange', callback: Callback<NetworkState>): void; 136 137 /** 138 * Callback when the network state corresponding to the monitored {@code slotId} is updated. 139 * 140 * @permission ohos.permission.GET_NETWORK_INFO 141 * @param { 'networkStateChange' } type - Event type. Indicates the networkStateChange event to be subscribed to. 142 * @param { object } options - Indicates the ID of the target card slot. 143 * The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2. 144 * @param { Callback<NetworkState> } callback - Indicates the callback for getting 145 * an instance of the {@code NetworkState} class. 146 * @throws { BusinessError } 201 - Permission denied. 147 * @throws { BusinessError } 401 - Parameter error. 148 * @throws { BusinessError } 8300001 - Invalid parameter value. 149 * @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service. 150 * @throws { BusinessError } 8300003 - System internal error. 151 * @throws { BusinessError } 8300999 - Unknown error code. 152 * @syscap SystemCapability.Telephony.StateRegistry 153 * @since 6 154 */ 155 /** 156 * Callback when the network state corresponding to the monitored {@code slotId} is updated. 157 * 158 * @permission ohos.permission.GET_NETWORK_INFO 159 * @param { 'networkStateChange' } type - Event type. Indicates the networkStateChange event to be subscribed to. 160 * @param { ObserverOptions } options - Indicates the options for observer. 161 * @param { Callback<NetworkState> } callback - Indicates the callback for getting 162 * an instance of the {@code NetworkState} class. 163 * @throws { BusinessError } 201 - Permission denied. 164 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified. 165 * 2. Incorrect parameter types. 166 * @throws { BusinessError } 8300001 - Invalid parameter value. 167 * @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service. 168 * @throws { BusinessError } 8300003 - System internal error. 169 * @throws { BusinessError } 8300999 - Unknown error code. 170 * @syscap SystemCapability.Telephony.StateRegistry 171 * @since 11 172 */ 173 function on(type: 'networkStateChange', options: ObserverOptions, callback: Callback<NetworkState>): void; 174 175 /** 176 * Cancel callback when the network state is updated. 177 * 178 * @param { 'networkStateChange' } type - Event type. Indicates the networkStateChange event to unsubscribe from. 179 * @param { Callback<NetworkState> } callback - Indicates the callback for getting 180 * an instance of the {@code NetworkState} class. 181 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified. 182 * 2. Incorrect parameter types. 183 * @throws { BusinessError } 8300001 - Invalid parameter value. 184 * @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service. 185 * @throws { BusinessError } 8300003 - System internal error. 186 * @throws { BusinessError } 8300999 - Unknown error code. 187 * @syscap SystemCapability.Telephony.StateRegistry 188 * @since 6 189 */ 190 function off(type: 'networkStateChange', callback?: Callback<NetworkState>): void; 191 192 /** 193 * Callback when the signal strength corresponding to the default sim card is updated. 194 * 195 * @param { 'signalInfoChange' } type - Event type. Indicates the signalInfoChange event to be subscribed to. 196 * @param { Callback<Array<SignalInformation>> } callback - Indicates the callback for getting 197 * an array of instances of the classes derived from {@link SignalInformation}. 198 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified. 199 * 2. Incorrect parameter types. 200 * @throws { BusinessError } 8300001 - Invalid parameter value. 201 * @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service. 202 * @throws { BusinessError } 8300003 - System internal error. 203 * @throws { BusinessError } 8300999 - Unknown error code. 204 * @syscap SystemCapability.Telephony.StateRegistry 205 * @since 6 206 */ 207 function on(type: 'signalInfoChange', callback: Callback<Array<SignalInformation>>): void; 208 209 /** 210 * Callback when the signal strength corresponding to a monitored {@code slotId} is updated. 211 * 212 * @param { 'signalInfoChange' } type - Event type. Indicates the signalInfoChange event to be subscribed to. 213 * @param { object } options - Indicates the ID of the target card slot. 214 * The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2. 215 * @param { Callback<Array<SignalInformation>> } callback - Indicates the callback for getting 216 * an array of instances of the classes derived from {@link SignalInformation}. 217 * @throws { BusinessError } 401 - Parameter error. 218 * @throws { BusinessError } 8300001 - Invalid parameter value. 219 * @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service. 220 * @throws { BusinessError } 8300003 - System internal error. 221 * @throws { BusinessError } 8300999 - Unknown error code. 222 * @syscap SystemCapability.Telephony.StateRegistry 223 * @since 6 224 */ 225 /** 226 * Callback when the signal strength corresponding to a monitored {@code slotId} is updated. 227 * 228 * @param { 'signalInfoChange' } type - Event type. Indicates the signalInfoChange event to be subscribed to. 229 * @param { ObserverOptions } options - Indicates the options for observer. 230 * @param { Callback<Array<SignalInformation>> } callback - Indicates the callback for getting 231 * an array of instances of the classes derived from {@link SignalInformation}. 232 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified. 233 * 2. Incorrect parameter types. 234 * @throws { BusinessError } 8300001 - Invalid parameter value. 235 * @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service. 236 * @throws { BusinessError } 8300003 - System internal error. 237 * @throws { BusinessError } 8300999 - Unknown error code. 238 * @syscap SystemCapability.Telephony.StateRegistry 239 * @since 11 240 */ 241 function on(type: 'signalInfoChange', options: ObserverOptions, callback: Callback<Array<SignalInformation>>): void; 242 243 /** 244 * Cancel callback when the signal strength is updated. 245 * 246 * @param { 'signalInfoChange' } type - Event type. Indicates the signalInfoChange event to unsubscribe from. 247 * @param { Callback<Array<SignalInformation>> } callback - Indicates the callback to unsubscribe from 248 * the signalInfoChange event. 249 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified. 250 * 2. Incorrect parameter types. 251 * @throws { BusinessError } 8300001 - Invalid parameter value. 252 * @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service. 253 * @throws { BusinessError } 8300003 - System internal error. 254 * @throws { BusinessError } 8300999 - Unknown error code. 255 * @syscap SystemCapability.Telephony.StateRegistry 256 * @since 6 257 */ 258 function off(type: 'signalInfoChange', callback?: Callback<Array<SignalInformation>>): void; 259 260 /** 261 * Callback when the cell information corresponding to the default sim card is updated. 262 * 263 * @permission ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION 264 * @param { 'cellInfoChange' } type - Event type. Indicates the cellInfoChange event to be subscribed to. 265 * @param { Callback<Array<CellInformation>> } callback - Indicates the callback for getting 266 * an array of instances of the classes derived from {@link CellInformation}. 267 * @throws { BusinessError } 201 - Permission denied. 268 * @throws { BusinessError } 202 - Non-system applications use system APIs. 269 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified. 270 * 2. Incorrect parameter types. 271 * @throws { BusinessError } 8300001 - Invalid parameter value. 272 * @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service. 273 * @throws { BusinessError } 8300003 - System internal error. 274 * @throws { BusinessError } 8300999 - Unknown error code. 275 * @syscap SystemCapability.Telephony.StateRegistry 276 * @systemapi Hide this for inner system use. 277 * @since 8 278 */ 279 function on(type: 'cellInfoChange', callback: Callback<Array<CellInformation>>): void; 280 281 /** 282 * Callback when the cell information corresponding to a monitored {@code slotId} is updated. 283 * 284 * @permission ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION 285 * @param { 'cellInfoChange' } type - Event type. Indicates the cellInfoChange event to be subscribed to. 286 * @param { object } options - Indicates the ID of the target card slot. 287 * The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2. 288 * @param { Callback<Array<CellInformation>> } callback - Indicates the callback for getting 289 * an array of instances of the classes derived from {@link CellInformation}. 290 * @throws { BusinessError } 201 - Permission denied. 291 * @throws { BusinessError } 202 - Non-system applications use system APIs. 292 * @throws { BusinessError } 401 - Parameter error. 293 * @throws { BusinessError } 8300001 - Invalid parameter value. 294 * @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service. 295 * @throws { BusinessError } 8300003 - System internal error. 296 * @throws { BusinessError } 8300999 - Unknown error code. 297 * @syscap SystemCapability.Telephony.StateRegistry 298 * @systemapi Hide this for inner system use. 299 * @since 8 300 */ 301 /** 302 * Callback when the cell information corresponding to a monitored {@code slotId} is updated. 303 * 304 * @permission ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION 305 * @param { 'cellInfoChange' } type - Event type. Indicates the cellInfoChange event to be subscribed to. 306 * @param { ObserverOptions } options - Indicates the options for observer. 307 * @param { Callback<Array<CellInformation>> } callback - Indicates the callback for getting 308 * an array of instances of the classes derived from {@link CellInformation}. 309 * @throws { BusinessError } 201 - Permission denied. 310 * @throws { BusinessError } 202 - Non-system applications use system APIs. 311 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified. 312 * 2. Incorrect parameter types. 313 * @throws { BusinessError } 8300001 - Invalid parameter value. 314 * @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service. 315 * @throws { BusinessError } 8300003 - System internal error. 316 * @throws { BusinessError } 8300999 - Unknown error code. 317 * @syscap SystemCapability.Telephony.StateRegistry 318 * @systemapi Hide this for inner system use. 319 * @since 11 320 */ 321 function on(type: 'cellInfoChange', options: ObserverOptions, callback: Callback<Array<CellInformation>>): void; 322 323 /** 324 * Cancel callback when the cell information is updated. 325 * 326 * @param { 'cellInfoChange' } type - Event type. Indicates the cellInfoChange event to unsubscribe from. 327 * @param { Callback<Array<CellInformation>> } callback - Indicates the callback to unsubscribe from 328 * the cellInfoChange event. 329 * @throws { BusinessError } 202 - Non-system applications use system APIs. 330 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified. 331 * 2. Incorrect parameter types. 332 * @throws { BusinessError } 8300001 - Invalid parameter value. 333 * @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service. 334 * @throws { BusinessError } 8300003 - System internal error. 335 * @throws { BusinessError } 8300999 - Unknown error code. 336 * @syscap SystemCapability.Telephony.StateRegistry 337 * @systemapi Hide this for inner system use. 338 * @since 8 339 */ 340 function off(type: 'cellInfoChange', callback?: Callback<Array<CellInformation>>): void; 341 342 /** 343 * Callback when the cellular data link connection state corresponding to the default sim card is updated. 344 * 345 * @param { 'cellularDataConnectionStateChange' } type - Event type. Indicates the cellularDataConnectionStateChange 346 * event to be subscribed to. 347 * @param { Callback<{ state: DataConnectState, network: RatType }> } callback - Indicates the callback for 348 * getting the cellular data link connection state, and networkType Indicates the radio access technology 349 * for cellular data services. 350 * @throws { BusinessError } 401 - Parameter error. 351 * @throws { BusinessError } 8300001 - Invalid parameter value. 352 * @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service. 353 * @throws { BusinessError } 8300003 - System internal error. 354 * @throws { BusinessError } 8300999 - Unknown error code. 355 * @syscap SystemCapability.Telephony.StateRegistry 356 * @since 7 357 */ 358 /** 359 * Callback when the cellular data link connection state corresponding to the default sim card is updated. 360 * 361 * @param { 'cellularDataConnectionStateChange' } type - Event type. Indicates the cellularDataConnectionStateChange 362 * event to be subscribed to. 363 * @param { Callback<DataConnectionStateInfo> } callback - Indicates the callback for 364 * getting the cellular data link connection state, and networkType Indicates the radio access technology 365 * for cellular data services. 366 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified. 367 * 2. Incorrect parameter types. 368 * @throws { BusinessError } 8300001 - Invalid parameter value. 369 * @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service. 370 * @throws { BusinessError } 8300003 - System internal error. 371 * @throws { BusinessError } 8300999 - Unknown error code. 372 * @syscap SystemCapability.Telephony.StateRegistry 373 * @since 11 374 */ 375 function on(type: 'cellularDataConnectionStateChange', callback: Callback<DataConnectionStateInfo>): void; 376 377 /** 378 * Callback when the cellular data link connection state corresponding to the monitored {@code slotId} is updated. 379 * 380 * @param { 'cellularDataConnectionStateChange' } type - Event type. Indicates the cellularDataConnectionStateChange 381 * event to be subscribed to. 382 * @param { object } options - Indicates the ID of the target card slot. 383 * The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2. 384 * @param { Callback<{ state: DataConnectState, network: RatType }> } callback - Indicates the callback for 385 * getting the cellular data link connection state, and networkType Indicates the radio access technology for 386 * cellular data services. 387 * @throws { BusinessError } 401 - Parameter error. 388 * @throws { BusinessError } 8300001 - Invalid parameter value. 389 * @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service. 390 * @throws { BusinessError } 8300003 - System internal error. 391 * @throws { BusinessError } 8300999 - Unknown error code. 392 * @syscap SystemCapability.Telephony.StateRegistry 393 * @since 7 394 */ 395 /** 396 * Callback when the cellular data link connection state corresponding to the monitored {@code slotId} is updated. 397 * 398 * @param { 'cellularDataConnectionStateChange' } type - Event type. Indicates the cellularDataConnectionStateChange 399 * event to be subscribed to. 400 * @param { ObserverOptions } options - Indicates the options for observer. 401 * @param { Callback<DataConnectionStateInfo> } callback - Indicates the callback for 402 * getting the cellular data link connection state, and networkType Indicates the radio access technology for 403 * cellular data services. 404 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified. 405 * 2. Incorrect parameter types. 406 * @throws { BusinessError } 8300001 - Invalid parameter value. 407 * @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service. 408 * @throws { BusinessError } 8300003 - System internal error. 409 * @throws { BusinessError } 8300999 - Unknown error code. 410 * @syscap SystemCapability.Telephony.StateRegistry 411 * @since 11 412 */ 413 function on(type: 'cellularDataConnectionStateChange', options: ObserverOptions, 414 callback: Callback<DataConnectionStateInfo>): void; 415 416 /** 417 * Cancel callback when the cellular data link connection state is updated. 418 * 419 * @param { 'cellularDataConnectionStateChange' } type - Event type. Indicates the cellularDataConnectionStateChange 420 * event to unsubscribe from. 421 * @param { Callback<{ state: DataConnectState, network: RatType }> } callback - Indicates the callback to unsubscribe 422 * from the cellularDataConnectionStateChange event. 423 * @throws { BusinessError } 401 - Parameter error. 424 * @throws { BusinessError } 8300001 - Invalid parameter value. 425 * @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service. 426 * @throws { BusinessError } 8300003 - System internal error. 427 * @throws { BusinessError } 8300999 - Unknown error code. 428 * @syscap SystemCapability.Telephony.StateRegistry 429 * @since 7 430 */ 431 /** 432 * Cancel callback when the cellular data link connection state is updated. 433 * 434 * @param { 'cellularDataConnectionStateChange' } type - Event type. Indicates the cellularDataConnectionStateChange 435 * event to unsubscribe from. 436 * @param { Callback<DataConnectionStateInfo> } callback - Indicates the callback to unsubscribe 437 * from the cellularDataConnectionStateChange event. 438 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified. 439 * 2. Incorrect parameter types. 440 * @throws { BusinessError } 8300001 - Invalid parameter value. 441 * @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service. 442 * @throws { BusinessError } 8300003 - System internal error. 443 * @throws { BusinessError } 8300999 - Unknown error code. 444 * @syscap SystemCapability.Telephony.StateRegistry 445 * @since 11 446 */ 447 function off(type: 'cellularDataConnectionStateChange', callback?: Callback<DataConnectionStateInfo>): void; 448 449 /** 450 * Callback when the uplink and downlink data flow state of cellular data services 451 * corresponding to the default sim card is updated. 452 * 453 * @param { 'cellularDataFlowChange' } type - Event type. Indicates the cellularDataFlowChange event to be subscribed to. 454 * @param { Callback<DataFlowType> } callback - Indicates the callback for getting the cellular data flow state. 455 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified. 456 * 2. Incorrect parameter types. 457 * @throws { BusinessError } 8300001 - Invalid parameter value. 458 * @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service. 459 * @throws { BusinessError } 8300003 - System internal error. 460 * @throws { BusinessError } 8300999 - Unknown error code. 461 * @syscap SystemCapability.Telephony.StateRegistry 462 * @since 7 463 */ 464 function on(type: 'cellularDataFlowChange', callback: Callback<DataFlowType>): void; 465 466 /** 467 * Callback when the uplink and downlink data flow state of cellular data services 468 * corresponding to the monitored {@code slotId} is updated. 469 * 470 * @param { 'cellularDataFlowChange' } type - Event type. Indicates the cellularDataFlowChange event to be subscribed to. 471 * @param { object } options - Indicates the ID of the target card slot. 472 * The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2. 473 * @param { Callback<DataFlowType> } callback - Indicates the callback for getting the cellular data flow state. 474 * @throws { BusinessError } 401 - Parameter error. 475 * @throws { BusinessError } 8300001 - Invalid parameter value. 476 * @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service. 477 * @throws { BusinessError } 8300003 - System internal error. 478 * @throws { BusinessError } 8300999 - Unknown error code. 479 * @syscap SystemCapability.Telephony.StateRegistry 480 * @since 7 481 */ 482 /** 483 * Callback when the uplink and downlink data flow state of cellular data services 484 * corresponding to the monitored {@code slotId} is updated. 485 * 486 * @param { 'cellularDataFlowChange' } type - Event type. Indicates the cellularDataFlowChange event to be subscribed to. 487 * @param { ObserverOptions } options - Indicates the options for observer. 488 * @param { Callback<DataFlowType> } callback - Indicates the callback for getting the cellular data flow state. 489 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified. 490 * 2. Incorrect parameter types. 491 * @throws { BusinessError } 8300001 - Invalid parameter value. 492 * @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service. 493 * @throws { BusinessError } 8300003 - System internal error. 494 * @throws { BusinessError } 8300999 - Unknown error code. 495 * @syscap SystemCapability.Telephony.StateRegistry 496 * @since 11 497 */ 498 function on(type: 'cellularDataFlowChange', options: ObserverOptions, callback: Callback<DataFlowType>): void; 499 500 /** 501 * Cancel callback when the uplink and downlink data flow state of cellular data services is updated. 502 * 503 * @param { 'cellularDataFlowChange' } type - Event type. Indicates the cellularDataFlowChange event to unsubscribe from. 504 * @param { Callback<DataFlowType> } callback - Indicates the callback to unsubscribe from 505 * the cellularDataFlowChange event. 506 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified. 507 * 2. Incorrect parameter types. 508 * @throws { BusinessError } 8300001 - Invalid parameter value. 509 * @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service. 510 * @throws { BusinessError } 8300003 - System internal error. 511 * @throws { BusinessError } 8300999 - Unknown error code. 512 * @syscap SystemCapability.Telephony.StateRegistry 513 * @since 7 514 */ 515 function off(type: 'cellularDataFlowChange', callback?: Callback<DataFlowType>): void; 516 517 /** 518 * Callback when the call state corresponding to the default sim card is updated. 519 * 520 * @param { 'callStateChange' } type - Event type. Indicates the callStateChange event to be subscribed to. 521 * @param { Callback<{ state: CallState, number: string }> } callback - Indicates the callback for 522 * getting the call state and the called number. 523 * @throws { BusinessError } 401 - Parameter error. 524 * @throws { BusinessError } 8300001 - Invalid parameter value. 525 * @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service. 526 * @throws { BusinessError } 8300003 - System internal error. 527 * @throws { BusinessError } 8300999 - Unknown error code. 528 * @syscap SystemCapability.Telephony.StateRegistry 529 * @since 6 530 */ 531 /** 532 * Callback when the call state corresponding to the default sim card is updated. 533 * 534 * @param { 'callStateChange' } type - Event type. Indicates the callStateChange event to be subscribed to. 535 * @param { Callback<CallStateInfo> } callback - Indicates the callback for 536 * getting the call state and the called number. 537 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified. 538 * 2. Incorrect parameter types. 539 * @throws { BusinessError } 8300001 - Invalid parameter value. 540 * @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service. 541 * @throws { BusinessError } 8300003 - System internal error. 542 * @throws { BusinessError } 8300999 - Unknown error code. 543 * @syscap SystemCapability.Telephony.StateRegistry 544 * @since 11 545 */ 546 function on(type: 'callStateChange', callback: Callback<CallStateInfo>): void; 547 548 /** 549 * Callback when the call state corresponding to the monitored {@code slotId} is updated. 550 * 551 * @param { 'callStateChange' } type - Event type. Indicates the callStateChange event to be subscribed to. 552 * @param { object } options - Indicates the ID of the target card slot. 553 * The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2. 554 * @param { Callback<{ state: CallState, number: string }> } callback - Indicates the callback for 555 * getting the call state and the called number. 556 * @throws { BusinessError } 401 - Parameter error. 557 * @throws { BusinessError } 8300001 - Invalid parameter value. 558 * @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service. 559 * @throws { BusinessError } 8300003 - System internal error. 560 * @throws { BusinessError } 8300999 - Unknown error code. 561 * @syscap SystemCapability.Telephony.StateRegistry 562 * @since 6 563 */ 564 /** 565 * Callback when the call state corresponding to the monitored {@code slotId} is updated. 566 * 567 * @param { 'callStateChange' } type - Event type. Indicates the callStateChange event to be subscribed to. 568 * @param { ObserverOptions } options - Indicates the options for observer. 569 * @param { Callback<CallStateInfo> } callback - Indicates the callback for 570 * getting the call state and the called number. 571 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified. 572 * 2. Incorrect parameter types. 573 * @throws { BusinessError } 8300001 - Invalid parameter value. 574 * @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service. 575 * @throws { BusinessError } 8300003 - System internal error. 576 * @throws { BusinessError } 8300999 - Unknown error code. 577 * @syscap SystemCapability.Telephony.StateRegistry 578 * @since 11 579 */ 580 function on(type: 'callStateChange', options: ObserverOptions, callback: Callback<CallStateInfo>): void; 581 582 /** 583 * Cancel callback when the call state is updated. 584 * 585 * @param { 'callStateChange' } type - Event type. Indicates the callStateChange event to unsubscribe from. 586 * @param { Callback<{ state: CallState, number: string }> } callback - Indicates the callback to 587 * unsubscribe from the callStateChange event. 588 * @throws { BusinessError } 401 - Parameter error. 589 * @throws { BusinessError } 8300001 - Invalid parameter value. 590 * @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service. 591 * @throws { BusinessError } 8300003 - System internal error. 592 * @throws { BusinessError } 8300999 - Unknown error code. 593 * @syscap SystemCapability.Telephony.StateRegistry 594 * @since 6 595 */ 596 /** 597 * Cancel callback when the call state is updated. 598 * 599 * @param { 'callStateChange' } type - Event type. Indicates the callStateChange event to unsubscribe from. 600 * @param { Callback<CallStateInfo> } callback - Indicates the callback to 601 * unsubscribe from the callStateChange event. 602 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified. 603 * 2. Incorrect parameter types. 604 * @throws { BusinessError } 8300001 - Invalid parameter value. 605 * @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service. 606 * @throws { BusinessError } 8300003 - System internal error. 607 * @throws { BusinessError } 8300999 - Unknown error code. 608 * @syscap SystemCapability.Telephony.StateRegistry 609 * @since 11 610 */ 611 function off(type: 'callStateChange', callback?: Callback<CallStateInfo>): void; 612 613 /** 614 * Callback when the sim state corresponding to the default sim card is updated. 615 * 616 * @param { 'simStateChange' } type - Event type. Indicates the simStateChange event to be subscribed to. 617 * @param { Callback<SimStateData> } callback - Indicates the callback for getting the SimStateData object. 618 * including state Indicates the sim state, and reason Indicates the cause of the change. 619 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified. 620 * 2. Incorrect parameter types. 621 * @throws { BusinessError } 8300001 - Invalid parameter value. 622 * @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service. 623 * @throws { BusinessError } 8300003 - System internal error. 624 * @throws { BusinessError } 8300999 - Unknown error code. 625 * @syscap SystemCapability.Telephony.StateRegistry 626 * @since 7 627 */ 628 function on(type: 'simStateChange', callback: Callback<SimStateData>): void; 629 630 /** 631 * Callback when the sim state corresponding to the monitored {@code slotId} is updated. 632 * 633 * @param { 'simStateChange' } type - Event type. Indicates the simStateChange event to be subscribed to. 634 * @param { object } options - Indicates the ID of the target card slot. 635 * The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2. 636 * @param { Callback<SimStateData> } callback - Indicates the callback for getting the SimStateData object. 637 * @throws { BusinessError } 401 - Parameter error. 638 * @throws { BusinessError } 8300001 - Invalid parameter value. 639 * @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service. 640 * @throws { BusinessError } 8300003 - System internal error. 641 * @throws { BusinessError } 8300999 - Unknown error code. 642 * @syscap SystemCapability.Telephony.StateRegistry 643 * @since 7 644 */ 645 /** 646 * Callback when the sim state corresponding to the monitored {@code slotId} is updated. 647 * 648 * @param { 'simStateChange' } type - Event type. Indicates the simStateChange event to be subscribed to. 649 * @param { ObserverOptions } options - Indicates the options for observer. 650 * @param { Callback<SimStateData> } callback - Indicates the callback for getting the SimStateData object. 651 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified. 652 * 2. Incorrect parameter types. 653 * @throws { BusinessError } 8300001 - Invalid parameter value. 654 * @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service. 655 * @throws { BusinessError } 8300003 - System internal error. 656 * @throws { BusinessError } 8300999 - Unknown error code. 657 * @syscap SystemCapability.Telephony.StateRegistry 658 * @since 11 659 */ 660 function on(type: 'simStateChange', options: ObserverOptions, callback: Callback<SimStateData>): void; 661 662 /** 663 * Cancel callback when the sim state is updated. 664 * 665 * @param { 'simStateChange' } type - Event type. Indicates the simStateChange event to unsubscribe from. 666 * @param { Callback<SimStateData> } callback - Indicates the callback to unsubscribe from the simStateChange event. 667 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified. 668 * 2. Incorrect parameter types. 669 * @throws { BusinessError } 8300001 - Invalid parameter value. 670 * @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service. 671 * @throws { BusinessError } 8300003 - System internal error. 672 * @throws { BusinessError } 8300999 - Unknown error code. 673 * @syscap SystemCapability.Telephony.StateRegistry 674 * @since 7 675 */ 676 function off(type: 'simStateChange', callback?: Callback<SimStateData>): void; 677 678 /** 679 * Receives an ICC account change. This callback is invoked when the ICC account updates 680 * and the observer is added to monitor the updates. 681 * 682 * @param { 'iccAccountInfoChange' } type - iccAccountInfoChange 683 * @param { Callback<void> } callback - including state Indicates the ICC account information, 684 * and reason Indicates the cause of the change. 685 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified. 686 * 2. Incorrect parameter types. 687 * @throws { BusinessError } 8300001 - Invalid parameter value. 688 * @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service. 689 * @throws { BusinessError } 8300003 - System internal error. 690 * @throws { BusinessError } 8300999 - Unknown error code. 691 * @syscap SystemCapability.Telephony.StateRegistry 692 * @since 10 693 */ 694 function on(type: 'iccAccountInfoChange', callback: Callback<void>): void; 695 696 /** 697 * Cancel to receive an ICC account change. 698 * 699 * @param { 'iccAccountInfoChange' } type - iccAccountInfoChange 700 * @param { Callback<void> } callback - including state Indicates the ICC account information, 701 * and reason Indicates the cause of the change. 702 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified. 703 * 2. Incorrect parameter types. 704 * @throws { BusinessError } 8300001 - Invalid parameter value. 705 * @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service. 706 * @throws { BusinessError } 8300003 - System internal error. 707 * @throws { BusinessError } 8300999 - Unknown error code. 708 * @syscap SystemCapability.Telephony.StateRegistry 709 * @since 10 710 */ 711 function off(type: 'iccAccountInfoChange', callback?: Callback<void>): void; 712 713 /** 714 * Indicates SIM card type and status. 715 * 716 * @interface SimStateData 717 * @syscap SystemCapability.Telephony.StateRegistry 718 * @since 7 719 */ 720 export interface SimStateData { 721 /** 722 * Indicates the SIM card type. 723 * 724 * @type { CardType } 725 * @syscap SystemCapability.Telephony.StateRegistry 726 * @since 7 727 */ 728 type: CardType; 729 730 /** 731 * Indicates the SIM card states. 732 * 733 * @type { SimState } 734 * @syscap SystemCapability.Telephony.StateRegistry 735 * @since 7 736 */ 737 state: SimState; 738 739 /** 740 * Indicates the SIM card lock type. 741 * 742 * @type { LockReason } 743 * @syscap SystemCapability.Telephony.StateRegistry 744 * @since 8 745 */ 746 reason: LockReason; 747 } 748 749 /** 750 * Indicates call state and number. 751 * 752 * @interface CallStateInfo 753 * @syscap SystemCapability.Telephony.StateRegistry 754 * @since 11 755 */ 756 export interface CallStateInfo { 757 /** 758 * Indicates call state. 759 * 760 * @type { CallState } 761 * @syscap SystemCapability.Telephony.StateRegistry 762 * @since 11 763 */ 764 state: CallState; 765 766 /** 767 * Indicates call number. 768 * 769 * @type { string } 770 * @syscap SystemCapability.Telephony.StateRegistry 771 * @since 11 772 */ 773 number: string; 774 } 775 776 /** 777 * Indicates cellular data connect state and technology type. 778 * 779 * @interface DataConnectionStateInfo 780 * @syscap SystemCapability.Telephony.StateRegistry 781 * @since 11 782 */ 783 export interface DataConnectionStateInfo { 784 /** 785 * Indicates cellular data connect state. 786 * 787 * @type { DataConnectState } 788 * @syscap SystemCapability.Telephony.StateRegistry 789 * @since 11 790 */ 791 state: DataConnectState; 792 793 /** 794 * Indicates technology type. 795 * 796 * @type { RatType } 797 * @syscap SystemCapability.Telephony.StateRegistry 798 * @since 11 799 */ 800 network: RatType; 801 } 802 803 /** 804 * Indicates observer options. 805 * 806 * @interface ObserverOptions 807 * @syscap SystemCapability.Telephony.StateRegistry 808 * @since 11 809 */ 810 export interface ObserverOptions { 811 /** 812 * Indicates the ID of the target card slot. 813 * 814 * @type { number } 815 * @syscap SystemCapability.Telephony.StateRegistry 816 * @since 11 817 */ 818 slotId: number; 819 } 820 821 /** 822 * Enum for SIM card lock type. 823 * 824 * @enum { number } 825 * @syscap SystemCapability.Telephony.StateRegistry 826 * @since 8 827 */ 828 export enum LockReason { 829 /** 830 * Indicates no SIM lock. 831 * 832 * @syscap SystemCapability.Telephony.StateRegistry 833 * @since 8 834 */ 835 SIM_NONE, 836 837 /** 838 * Indicates the PIN lock. 839 * 840 * @syscap SystemCapability.Telephony.StateRegistry 841 * @since 8 842 */ 843 SIM_PIN, 844 845 /** 846 * Indicates the PUK lock. 847 * 848 * @syscap SystemCapability.Telephony.StateRegistry 849 * @since 8 850 */ 851 SIM_PUK, 852 853 /** 854 * Indicates network personalization of PIN lock(refer 3GPP TS 22.022 [33]). 855 * 856 * @syscap SystemCapability.Telephony.StateRegistry 857 * @since 8 858 */ 859 SIM_PN_PIN, 860 861 /** 862 * Indicates network personalization of PUK lock(refer 3GPP TS 22.022 [33]). 863 * 864 * @syscap SystemCapability.Telephony.StateRegistry 865 * @since 8 866 */ 867 SIM_PN_PUK, 868 869 /** 870 * Indicates network subset personalization of PIN lock(refer 3GPP TS 22.022 [33]). 871 * 872 * @syscap SystemCapability.Telephony.StateRegistry 873 * @since 8 874 */ 875 SIM_PU_PIN, 876 877 /** 878 * Indicates network subset personalization of PUK lock(refer 3GPP TS 22.022 [33]). 879 * 880 * @syscap SystemCapability.Telephony.StateRegistry 881 * @since 8 882 */ 883 SIM_PU_PUK, 884 885 /** 886 * Indicates service provider personalization of PIN lock(refer 3GPP TS 22.022 [33]). 887 * 888 * @syscap SystemCapability.Telephony.StateRegistry 889 * @since 8 890 */ 891 SIM_PP_PIN, 892 893 /** 894 * Indicates service provider personalization of PUK lock(refer 3GPP TS 22.022 [33]). 895 * 896 * @syscap SystemCapability.Telephony.StateRegistry 897 * @since 8 898 */ 899 SIM_PP_PUK, 900 901 /** 902 * Indicates corporate personalization of PIN lock(refer 3GPP TS 22.022 [33]). 903 * 904 * @syscap SystemCapability.Telephony.StateRegistry 905 * @since 8 906 */ 907 SIM_PC_PIN, 908 909 /** 910 * Indicates corporate personalization of PUK lock(refer 3GPP TS 22.022 [33]). 911 * 912 * @syscap SystemCapability.Telephony.StateRegistry 913 * @since 8 914 */ 915 SIM_PC_PUK, 916 917 /** 918 * Indicates SIM/USIM personalization of PIN lock(refer 3GPP TS 22.022 [33]). 919 * 920 * @syscap SystemCapability.Telephony.StateRegistry 921 * @since 8 922 */ 923 SIM_SIM_PIN, 924 925 /** 926 * Indicates SIM/USIM personalization of PUK lock(refer 3GPP TS 22.022 [33]). 927 * 928 * @syscap SystemCapability.Telephony.StateRegistry 929 * @since 8 930 */ 931 SIM_SIM_PUK, 932 } 933} 934 935export default observer; 936