openharmony 鸿蒙 js-apis-observer

2025-06-12 浏览 (1)

@ohos.telephony.observer (Observer)

The 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.

NOTE

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.

Modules to Import

import { observer } from '@kit.TelephonyKit';

NetworkState

type NetworkState = radio.NetworkState

Defines the network status.

System capability: SystemCapability.Telephony.StateRegistry

TypeDescription
radio.NetworkStateNetwork status.

SignalInformation

type SignalInformation = radio.SignalInformation

Defines the signal strength.

System capability: SystemCapability.Telephony.StateRegistry

TypeDescription
radio.SignalInformationSignal strength.

DataConnectState

type DataConnectState = data.DataConnectState

Describes the connection status of a cellular data link.

System capability: SystemCapability.Telephony.StateRegistry

TypeDescription
data.DataConnectStateConnection status of a cellular data link.

RatType

type RatType = radio.RadioTechnology

Enumerates the radio access technologies.

System capability: SystemCapability.Telephony.StateRegistry

TypeDescription
radio.RadioTechnologyRadio access technology.

DataFlowType

type DataFlowType = data.DataFlowType

Defines the cellular data flow type.

System capability: SystemCapability.Telephony.StateRegistry

TypeDescription
data.DataFlowTypeCellular data flow type.

CallState

type CallState = call.CallState

Enumerates call states.

System capability: SystemCapability.Telephony.StateRegistry

TypeDescription
call.CallStateCall state.

CardType

type CardType = sim.CardType

Enumerates SIM card types.

System capability: SystemCapability.Telephony.StateRegistry

TypeDescription
sim.CardTypeSIM card type.

SimState

type SimState = sim.SimState

SIM card state.

System capability: SystemCapability.Telephony.StateRegistry

TypeDescription
sim.SimStateSIM card state.

observer.on('networkStateChange')

on(type: 'networkStateChange', callback: Callback<NetworkState>): void

Registers an observer for network status change events. This API uses an asynchronous callback to return the execution result.

Required permission: ohos.permission.GET_NETWORK_INFO

System capability: SystemCapability.Telephony.StateRegistry

Parameters

NameTypeMandatoryDescription
typestringYesNetwork status change event. This field has a fixed value of networkStateChange.
callbackCallback<NetworkState>YesCallback used to return the result. For details, see NetworkState.

Error codes

For details about the error codes, see Universal Error Codes and Telephony Error Codes.

IDError Message
201Permission denied.
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
8300001Invalid parameter value.
8300002Service connection failed.
8300003System internal error.
8300999Unknown error.

Example

observer.on('networkStateChange', (data: observer.NetworkState) => {
    console.log("on networkStateChange, data:" + JSON.stringify(data));
});

observer.on('networkStateChange')

on(type: 'networkStateChange', options: ObserverOptions, callback: Callback<NetworkState>): void

Registers 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.

Required permission: ohos.permission.GET_NETWORK_INFO

System capability: SystemCapability.Telephony.StateRegistry

Parameters

NameTypeMandatoryDescription
typestringYesNetwork status change event. This field has a fixed value of networkStateChange.
optionsObserverOptionsYesEvent subscription parameters.
callbackCallback<NetworkState>YesCallback used to return the result. For details, see NetworkState.

Error codes

For details about the error codes, see Universal Error Codes and Telephony Error Codes.

IDError Message
201Permission denied.
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
8300001Invalid parameter value.
8300002Service connection failed.
8300003System internal error.
8300999Unknown error.

Example

let options: observer.ObserverOptions = {
    slotId: 0
}
observer.on('networkStateChange', options, (data: observer.NetworkState) => {
    console.log("on networkStateChange, data:" + JSON.stringify(data));
});

observer.off('networkStateChange')

off(type: 'networkStateChange', callback?: Callback<NetworkState>): void

Unregisters the observer for network status change events. This API uses an asynchronous callback to return the execution result.

NOTE

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.

System capability: SystemCapability.Telephony.StateRegistry

Parameters

NameTypeMandatoryDescription
typestringYesNetwork status change event. This field has a fixed value of networkStateChange.
callbackCallback<NetworkState>NoCallback used to return the result. For details, see NetworkState.

Error codes

For details about the error codes, see Universal Error Codes and Telephony Error Codes.

IDError Message
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
8300001Invalid parameter value.
8300002Service connection failed.
8300003System internal error.
8300999Unknown error.

Example

let callback: (data: observer.NetworkState) => void = (data: observer.NetworkState) => {
    console.log("on networkStateChange, data:" + JSON.stringify(data));
}
observer.on('networkStateChange', callback);
// 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.
observer.off('networkStateChange', callback);
observer.off('networkStateChange');

observer.on('signalInfoChange')

on(type: 'signalInfoChange', callback: Callback<Array<SignalInformation>>): void

Registers an observer for signal status change events. This API uses an asynchronous callback to return the execution result.

System capability: SystemCapability.Telephony.StateRegistry

Parameters

NameTypeMandatoryDescription
typestringYesSignal status change event. This field has a fixed value of signalInfoChange.
callbackCallback<Array<SignalInformation>>YesCallback used to return the result. For details, see SignalInformation.

Error codes

For details about the error codes, see Universal Error Codes and Telephony Error Codes.

IDError Message
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
8300001Invalid parameter value.
8300002Service connection failed.
8300003System internal error.
8300999Unknown error.

Example

import { radio } from '@kit.TelephonyKit';

observer.on('signalInfoChange', (data: Array<radio.SignalInformation>) => {
    console.log("on signalInfoChange, data:" + JSON.stringify(data));
});

observer.on('signalInfoChange')

on(type: 'signalInfoChange', options: ObserverOptions, callback: Callback<Array<SignalInformation>>): void

Registers 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.

System capability: SystemCapability.Telephony.StateRegistry

Parameters

NameTypeMandatoryDescription
typestringYesSignal status change event. This field has a fixed value of signalInfoChange.
optionsObserverOptionsYesEvent subscription parameters.
callbackCallback<Array<SignalInformation>>YesCallback used to return the result. For details, see SignalInformation.

Error codes

For details about the error codes, see Universal Error Codes and Telephony Error Codes.

IDError Message
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
8300001Invalid parameter value.
8300002Service connection failed.
8300003System internal error.
8300999Unknown error.

Example

import { radio } from '@kit.TelephonyKit';

let options: observer.ObserverOptions = {
    slotId: 0
}
observer.on('signalInfoChange', options, (data: Array<radio.SignalInformation>) => {
    console.log("on signalInfoChange, data:" + JSON.stringify(data));
});

observer.off('signalInfoChange')

off(type: 'signalInfoChange', callback?: Callback<Array<SignalInformation>>): void

Unregisters the observer for signal status change events. This API uses an asynchronous callback to return the execution result.

NOTE

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.

System capability: SystemCapability.Telephony.StateRegistry

Parameters

NameTypeMandatoryDescription
typestringYesSignal status change event. This field has a fixed value of signalInfoChange.
callbackCallback<Array<SignalInformation>>NoCallback used to return the result. For details, see SignalInformation.

Error codes

For details about the error codes, see Universal Error Codes and Telephony Error Codes.

IDError Message
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
8300001Invalid parameter value.
8300002Service connection failed.
8300003System internal error.
8300999Unknown error.

Example

import { radio } from '@kit.TelephonyKit';

let callback: (data: Array<radio.SignalInformation>) => void = (data: Array<radio.SignalInformation>) => {
    console.log("on signalInfoChange, data:" + JSON.stringify(data));
}
observer.on('signalInfoChange', callback);
// 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.
observer.off('signalInfoChange', callback);
observer.off('signalInfoChange');

observer.on('callStateChange')

on(type: 'callStateChange', callback: Callback<CallStateInfo>): void

Registers an observer for call status change events. This API uses an asynchronous callback to return the execution result.

NOTE

Before using this API, you must declare the ohos.permission.READ_CALL_LOG permission (a system permission).

System capability: SystemCapability.Telephony.StateRegistry

Parameters

NameTypeMandatoryDescription
typestringYesCall status change event. This field has a fixed value of callStateChange.
callbackCallback<CallStateInfo>YesCallback used to return the result. For details, see CallState.
number: phone number.

Error codes

For details about the error codes, see Universal Error Codes and Telephony Error Codes.

IDError Message
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
8300001Invalid parameter value.
8300002Service connection failed.
8300003System internal error.
8300999Unknown error.

Example

observer.on('callStateChange', (data: observer.CallStateInfo) => {
    console.log("on callStateChange, data:" + JSON.stringify(data));
});

observer.on('callStateChange')

on(type: 'callStateChange', options: ObserverOptions, callback: Callback<CallStateInfo>): void

Registers an observer for call status change events. This API uses an asynchronous callback to return the execution result.

NOTE

Before using this API, you must declare the ohos.permission.READ_CALL_LOG permission (a system permission).

System capability: SystemCapability.Telephony.StateRegistry

Parameters

NameTypeMandatoryDescription
typestringYesCall status change event. This field has a fixed value of callStateChange.
optionsObserverOptionsYesEvent subscription parameters.
callbackCallback<CallStateInfo>YesCallback used to return the result. For details, see CallState.
number: phone number.

Error codes

For details about the error codes, see Universal Error Codes and Telephony Error Codes.

IDError Message
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
8300001Invalid parameter value.
8300002Service connection failed.
8300003System internal error.
8300999Unknown error.

Example

let options: observer.ObserverOptions = {
    slotId: 0
}
observer.on('callStateChange', options, (data: observer.CallStateInfo) => {
    console.log("on callStateChange, data:" + JSON.stringify(data));
});

observer.off('callStateChange')

off(type: 'callStateChange', callback?: Callback<CallStateInfo>): void

Unregisters the observer for call status change events. This API uses an asynchronous callback to return the execution result.

NOTE

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.

System capability: SystemCapability.Telephony.StateRegistry

Parameters

NameTypeMandatoryDescription
typestringYesCall status change event. This field has a fixed value of callStateChange.
callbackCallback<CallStateInfo>NoCallback used to return the result. For details, see CallState.
number: phone number.

Error codes

For details about the error codes, see Universal Error Codes and Telephony Error Codes.

IDError Message
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
8300001Invalid parameter value.
8300002Service connection failed.
8300003System internal error.
8300999Unknown error.

Example

let callback: (data: observer.CallStateInfo) => void = (data: observer.CallStateInfo) => {
    console.log("on callStateChange, data:" + JSON.stringify(data));
}
observer.on('callStateChange', callback);
// 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.
observer.off('callStateChange', callback);
observer.off('callStateChange');

observer.on('cellularDataConnectionStateChange')7+

on(type: 'cellularDataConnectionStateChange', callback: Callback<DataConnectionStateInfo>): void

Registers an observer for connection status change events of the cellular data link. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.Telephony.StateRegistry

Parameters

NameTypeMandatoryDescription
typestringYesCellular data connection status event. This field has a fixed value of cellularDataConnectionStateChange.
callbackCallback<DataConnectionStateInfo>YesCallback used to return the result. For details, see DataConnectState and RadioTechnology.

Error codes

For details about the error codes, see Universal Error Codes and Telephony Error Codes.

IDError Message
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
8300001Invalid parameter value.
8300002Service connection failed.
8300003System internal error.
8300999Unknown error.

Example

observer.on('cellularDataConnectionStateChange', (data: observer.DataConnectionStateInfo) => {
    console.log("on cellularDataConnectionStateChange, data:" + JSON.stringify(data));
});

observer.on('cellularDataConnectionStateChange')7+

on(type: 'cellularDataConnectionStateChange', options: ObserverOptions, callback: Callback<DataConnectionStateInfo>): void

Registers 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.

System capability: SystemCapability.Telephony.StateRegistry

Parameters

NameTypeMandatoryDescription
typestringYesCellular data connection status event. This field has a fixed value of cellularDataConnectionStateChange.
optionsObserverOptionsYesEvent subscription parameters.
callbackCallback<DataConnectionStateInfo>YesCallback used to return the result. For details, see DataConnectState and RadioTechnology.

Error codes

For details about the error codes, see Universal Error Codes and Telephony Error Codes.

IDError Message
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
8300001Invalid parameter value.
8300002Service connection failed.
8300003System internal error.
8300999Unknown error.

Example

let options: observer.ObserverOptions = {
    slotId: 0
}
observer.on('cellularDataConnectionStateChange', options, (data: observer.DataConnectionStateInfo) => {
    console.log("on cellularDataConnectionStateChange, data:" + JSON.stringify(data));
});

observer.off('cellularDataConnectionStateChange')7+

off(type: 'cellularDataConnectionStateChange', callback?: Callback<DataConnectionStateInfo>): void

Unregisters the observer for connection status change events of the cellular data link. This API uses an asynchronous callback to return the result.

NOTE

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.

System capability: SystemCapability.Telephony.StateRegistry

Parameters

NameTypeMandatoryDescription
typestringYesCellular data connection status event. This field has a fixed value of cellularDataConnectionStateChange.
callbackCallback<DataConnectionStateInfo>NoCallback used to return the result. For details, see DataConnectState and RadioTechnology.

Error codes

For details about the error codes, see Universal Error Codes and Telephony Error Codes.

IDError Message
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
8300001Invalid parameter value.
8300002Service connection failed.
8300003System internal error.
8300999Unknown error.

Example

let callback: (data: observer.DataConnectionStateInfo) => void = (data: observer.DataConnectionStateInfo) => {
    console.log("on cellularDataConnectionStateChange, data:" + JSON.stringify(data));
}
observer.on('cellularDataConnectionStateChange', callback);
// 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.
observer.off('cellularDataConnectionStateChange', callback);
observer.off('cellularDataConnectionStateChange');

observer.on('cellularDataFlowChange')7+

on(type: 'cellularDataFlowChange', callback: Callback<DataFlowType>): void

Registers 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.

System capability: SystemCapability.Telephony.StateRegistry

Parameters

NameTypeMandatoryDescription
typestringYesCellular data flow change event. This field has a fixed value of cellularDataFlowChange.
callbackCallback<DataFlowType>YesCallback used to return the result. For details, see DataFlowType.

Error codes

For details about the error codes, see Universal Error Codes and Telephony Error Codes.

IDError Message
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
8300001Invalid parameter value.
8300002Service connection failed.
8300003System internal error.
8300999Unknown error.

Example

import { data } from '@kit.TelephonyKit';

observer.on('cellularDataFlowChange', (data: data.DataFlowType) => {
    console.log("on cellularDataFlowChange, data:" + JSON.stringify(data));
});

observer.on('cellularDataFlowChange')7+

on(type: 'cellularDataFlowChange', options: ObserverOptions, callback: Callback<DataFlowType>): void

Registers 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.

System capability: SystemCapability.Telephony.StateRegistry

Parameters

NameTypeMandatoryDescription
typestringYesCellular data flow change event. This field has a fixed value of cellularDataFlowChange.
optionsObserverOptionsYesEvent subscription parameters.
callbackCallback<DataFlowType>YesCallback used to return the result. For details, see DataFlowType.

Error codes

For details about the error codes, see Universal Error Codes and Telephony Error Codes.

IDError Message
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
8300001Invalid parameter value.
8300002Service connection failed.
8300003System internal error.
8300999Unknown error.

Example

import { data } from '@kit.TelephonyKit';

let options: observer.ObserverOptions = {
    slotId: 0
}
observer.on('cellularDataFlowChange', options, (data: data.DataFlowType) => {
    console.log("on cellularDataFlowChange, data:" + JSON.stringify(data));
});

observer.off('cellularDataFlowChange')7+

off(type: 'cellularDataFlowChange', callback?: Callback<DataFlowType>): void

Unregisters 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.

NOTE

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.

System capability: SystemCapability.Telephony.StateRegistry

Parameters

NameTypeMandatoryDescription
typestringYesCellular data flow change event. This field has a fixed value of cellularDataFlowChange.
callbackCallback<DataFlowType>NoCallback used to return the result. For details, see DataFlowType.

Error codes

For details about the error codes, see Universal Error Codes and Telephony Error Codes.

IDError Message
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
8300001Invalid parameter value.
8300002Service connection failed.
8300003System internal error.
8300999Unknown error.

Example

import { data } from '@kit.TelephonyKit';

let callback: (data: data.DataFlowType) => void = (data: data.DataFlowType) => {
    console.log("on cellularDataFlowChange, data:" + JSON.stringify(data));
}
observer.on('cellularDataFlowChange', callback);
// 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.
observer.off('cellularDataFlowChange', callback);
observer.off('cellularDataFlowChange');

observer.on('simStateChange')7+

on(type: 'simStateChange', callback: Callback<SimStateData>): void

Registers an observer for SIM card status change events. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.Telephony.StateRegistry

Parameters

NameTypeMandatoryDescription
typestringYesSIM status change event. This field has a fixed value of simStateChange.
callbackCallback<SimStateData>YesCallback used to return the result.

Error codes

For details about the error codes, see Universal Error Codes and Telephony Error Codes.

IDError Message
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
8300001Invalid parameter value.
8300002Service connection failed.
8300003System internal error.
8300999Unknown error.

Example

observer.on('simStateChange', (data: observer.SimStateData) => {
    console.log("on simStateChange, data:" + JSON.stringify(data));
});

observer.on('simStateChange')7+

on(type: 'simStateChange', options: ObserverOptions, callback: Callback<SimStateData>): void

Registers an observer for status change events of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.Telephony.StateRegistry

Parameters

NameTypeMandatoryDescription
typestringYesSIM status change event. This field has a fixed value of simStateChange.
optionsObserverOptionsYesEvent subscription parameters.
callbackCallback<SimStateData>YesCallback used to return the result.

Error codes

For details about the error codes, see Universal Error Codes and Telephony Error Codes.

IDError Message
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
8300001Invalid parameter value.
8300002Service connection failed.
8300003System internal error.
8300999Unknown error.

Example

let options: observer.ObserverOptions = {
    slotId: 0
}
observer.on('simStateChange', options, (data: observer.SimStateData) => {
    console.log("on simStateChange, data:" + JSON.stringify(data));
});

observer.off('simStateChange')7+

off(type: 'simStateChange', callback?: Callback<SimStateData>): void

Unregisters the observer for SIM card status change events. This API uses an asynchronous callback to return the result.

NOTE

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.

System capability: SystemCapability.Telephony.StateRegistry

Parameters

NameTypeMandatoryDescription
typestringYesSIM status change event. This field has a fixed value of simStateChange.
callbackCallback<SimStateData>NoCallback used to return the result.

Error codes

For details about the error codes, see Universal Error Codes and Telephony Error Codes.

IDError Message
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
8300001Invalid parameter value.
8300002Service connection failed.
8300003System internal error.
8300999Unknown error.

Example

let callback: (data: observer.SimStateData) => void = (data: observer.SimStateData) => {
    console.log("on simStateChange, data:" + JSON.stringify(data));
}
observer.on('simStateChange', callback);
// 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.
observer.off('simStateChange', callback);
observer.off('simStateChange');

observer.on('iccAccountInfoChange')10+

on(type: 'iccAccountInfoChange', callback: Callback<void>): void

Registers an observer for account information change events of the SIM card. This API uses an asynchronous callback to return the result.

System capability: SystemCapability.Telephony.StateRegistry

Parameters

NameTypeMandatoryDescription
typestringYesAccount information change event. This field has a fixed value of iccAccountInfoChange.
callbackCallback<void>YesCallback used to return the result.

Error codes

For details about the error codes, see Universal Error Codes and Telephony Error Codes.

IDError Message
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
8300001Invalid parameter value.
8300002Service connection failed.
8300003System internal error.
8300999Unknown error.

Example

observer.on('iccAccountInfoChange', () => {
    console.log("on iccAccountInfoChange success");
});

observer.off('iccAccountInfoChange')10+

off(type: 'iccAccountInfoChange', callback?: Callback<void>): void

Unregisters the observer for account information change events of the SIM card. This API uses an asynchronous callback to return the result.

NOTE

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.

System capability: SystemCapability.Telephony.StateRegistry

Parameters

NameTypeMandatoryDescription
typestringYesAccount information change event. This field has a fixed value of iccAccountInfoChange.
callbackCallback<void>NoCallback used to return the result.

Error codes

For details about the error codes, see Universal Error Codes and Telephony Error Codes.

IDError Message
401Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.
8300001Invalid parameter value.
8300002Service connection failed.
8300003System internal error.
8300999Unknown error.

Example

let callback: () => void = () => {
    console.log("on iccAccountInfoChange success");
}
observer.on('iccAccountInfoChange', callback);
// 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.
observer.off('iccAccountInfoChange', callback);
observer.off('iccAccountInfoChange');

LockReason8+

Enumerates SIM card lock types.

System capability: SystemCapability.Telephony.StateRegistry

NameValueDescription
SIM_NONE0No lock.
SIM_PIN1PIN lock.
SIM_PUK2PUK lock.
SIM_PN_PIN3Network PIN lock.
SIM_PN_PUK4Network PUK lock.
SIM_PU_PIN5Subnet PIN lock.
SIM_PU_PUK6Subnet PUK lock.
SIM_PP_PIN7Service provider PIN lock.
SIM_PP_PUK8Service provider PUK lock.
SIM_PC_PIN9Organization PIN lock.
SIM_PC_PUK10Organization PUK lock.
SIM_SIM_PIN11SIM PIN lock.
SIM_SIM_PUK12SIM PUK lock.

SimStateData7+

Enumerates SIM card types and states.

System capability: SystemCapability.Telephony.StateRegistry

NameTypeMandatoryDescription
typeCardTypeYesSIM card type.
stateSimStateYesSIM card state.
reason8+LockReasonYesSIM card lock type.

CallStateInfo11+

Defines information about the call status.

System capability: SystemCapability.Telephony.StateRegistry

NameTypeMandatoryDescription
stateCallStateYesCall type.
numberstringYesPhone number.

DataConnectionStateInfo11+

Defines information about the data connection status.

System capability: SystemCapability.Telephony.StateRegistry

NameTypeMandatoryDescription
stateDataConnectStateYesData connection status.
networkRatTypeYesNetwork type.

ObserverOptions11+

Defines event subscription parameters.

System capability: SystemCapability.Telephony.StateRegistry

NameTypeMandatoryDescription
slotIdnumberYesCard slot ID.
- 0: card slot 1.
- 1: card slot 2.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Telephony Kit

harmony 鸿蒙Telephony_NetworkState

harmony 鸿蒙Telephony Error Codes

harmony 鸿蒙js-apis-call-sys

harmony 鸿蒙@ohos.telephony.call (Call)

harmony 鸿蒙@ohos.telephony.esim (eSIM Management) (System API)

harmony 鸿蒙@ohos.telephony.esim (eSIM Management)

harmony 鸿蒙@ohos.telephony.observer (Observer) (System API)

harmony 鸿蒙@ohos.telephony.radio (Radio) (System API)

harmony 鸿蒙@ohos.telephony.radio (Network Search)

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/qasVeU