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