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