public class RadioInfoManager extends Object
This class is a singleton class. Applications can use the getInstance method to obtain an instance
and then use the instance to invoke the method for obtaining WCN information and registering a listener.
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
addObserver(RadioStateObserver observer,
int mask) |
Registers an observer to receive notifications of changes in a specified radio state.
|
int |
getCsRadioTech(int slotId) |
Obtains RAT of the CS domain on the registered network.
|
String |
getImei(int slotId) |
Obtains the IMEI of a specified card slot of the device.
|
String |
getImeiSv(int slotId) |
Obtains the international mobile station equipment identity and software version (IMEISV) of a specified
card slot of the device.
|
static RadioInfoManager |
getInstance(Context context) |
Obtains an instance of RadioInfoManager.
|
String |
getIsoCountryCodeForNetwork(int slotId) |
Obtains the ISO-defined country code of the country where the registered network is deployed.
|
String |
getManufacturerCode(int slotId) |
Obtains the manufacturer code of a specified card slot of the device.
|
String |
getMeid(int slotId) |
Obtains the MEID of a specified card slot of the device.
|
int |
getNetworkSelectionMode(int slotId) |
Obtains the network search mode of the SIM card in a specified slot.
|
NetworkState |
getNetworkState(int slotId) |
Obtains the network state of the registered network.
|
String |
getOperatorName(int slotId) |
Obtains the operator name of the registered network.
|
String |
getPesn(int slotId) |
Obtains the pseudo-Electronic Serial Number (PESN) of the device based on a specified slot ID.
|
String |
getPlmnNumeric(int slotId) |
Obtains the public land mobile network (PLMN) code of the registered network.
|
int |
getPrimarySlotId() |
Obtains the index number of the card slot where the primary card is located if multiple SIM cards are inserted.
|
int |
getPsRadioTech(int slotId) |
Obtains RAT of the PS domain on the registered network.
|
int |
getRadioTech(int slotId) |
Obtains radio access technology (RAT) of the registered network.
|
String |
getRadioTechName(int radioTech) |
Obtains the radio access technology (RAT) name of the registered network.
|
List<SignalInformation> |
getSignalInfoList(int slotId) |
Obtains the list of signal strength information of the registered network corresponding to a specified SIM card.
|
String |
getTypeAllocationCode(int slotId) |
Obtains the type allocation code (TAC) of a specified card slot of the device.
|
String |
getUniqueDeviceId(int slotId) |
Obtains the unique device ID of a specified card slot of the device.
|
boolean |
isNrSupported() |
Checks whether the device supports 5G New Radio (NR).
|
boolean |
isNsaState() |
Checks whether the device is registered with a 5G non-standalone (NSA) network.
|
boolean |
isRoaming(int slotId) |
Checks whether the device is registered with a roaming network.
|
void |
removeObserver(RadioStateObserver observer) |
Unregisters an observer.
|
public static RadioInfoManager getInstance(Context context)
context - Indicates the context of the application.public int getRadioTech(int slotId)
Requires Permission: ohos.permission.GET_NETWORK_INFO.
slotId - Indicates the card slot index number,
ranging from 0 to the maximum card slot index number supported by the device.TelephonyConstants#RADIO_TECHNOLOGY_UNKNOWN
TelephonyConstants#RADIO_TECHNOLOGY_GSM
TelephonyConstants#RADIO_TECHNOLOGY_1XRTT
TelephonyConstants#RADIO_TECHNOLOGY_WCDMA
TelephonyConstants#RADIO_TECHNOLOGY_HSPA
TelephonyConstants#RADIO_TECHNOLOGY_HSPAP
TelephonyConstants#RADIO_TECHNOLOGY_TD_SCDMA
TelephonyConstants#RADIO_TECHNOLOGY_EVDO
TelephonyConstants#RADIO_TECHNOLOGY_EHRPD
TelephonyConstants#RADIO_TECHNOLOGY_LTE
TelephonyConstants#RADIO_TECHNOLOGY_LTE_CA
TelephonyConstants#RADIO_TECHNOLOGY_IWLAN
TelephonyConstants#RADIO_TECHNOLOGY_NR
public int getPsRadioTech(int slotId)
Requires Permission: ohos.permission.GET_NETWORK_INFO.
slotId - Indicates the card slot index number,
ranging from 0 to the maximum card slot index number supported by the device.getRadioTech(int).public int getCsRadioTech(int slotId)
Requires Permission: ohos.permission.GET_NETWORK_INFO.
slotId - Indicates the card slot index number,
ranging from 0 to the maximum card slot index number supported by the device.getRadioTech(int).public String getIsoCountryCodeForNetwork(int slotId)
slotId - Indicates the card slot index number,
ranging from 0 to the maximum card slot index number supported by the device.public NetworkState getNetworkState(int slotId)
Requires Permission: ohos.permission.GET_NETWORK_INFO.
slotId - Indicates the card slot index number,
ranging from 0 to the maximum card slot index number supported by the device.NetworkState object.public String getPlmnNumeric(int slotId)
slotId - Indicates the card slot index number,
ranging from 0 to the maximum card slot index number supported by the device.public String getOperatorName(int slotId)
slotId - Indicates the card slot index number,
ranging from 0 to the maximum card slot index number supported by the device.public boolean isRoaming(int slotId)
slotId - Indicates the card slot index number,
ranging from 0 to the maximum card slot index number supported by the device.true if the device is registered with a roaming network; returns false otherwise.public List<SignalInformation> getSignalInfoList(int slotId)
If the specified SIM card camps on one or more networks, the signal strength of these networks is reported, as listed below:
GsmSignalInformation
CdmaSignalInformation
TdscdmaSignalInformation
LteSignalInformation
WcdmaSignalInformation
NrSignalInformation
CdmaSignalInformation and
LteSignalInformation instances are returned. If an empty list is returned, there is no signal.
A device can use SignalInformation#getNetworkType() to obtain RAT of the signal instance
and then use the corresponding child class to obtain detailed signal information.
slotId - Indicates the card slot index number, ranging from 0 to the maximum card slot index number
supported by the device.SignalInformation.public String getUniqueDeviceId(int slotId)
If the device is registered with a 3GPP-compliant network, the international mobile equipment identity (IMEI) is returned. If the device is registered with a 3GPP2-compliant network, the mobile equipment identifier (MEID) is returned.
Requires Permission: ohos.permission.GET_TELEPHONY_STATE.
slotId - Indicates the card slot index number, ranging from 0 to the maximum card slot index number
supported by the device.public String getImei(int slotId)
Requires Permission: ohos.permission.GET_TELEPHONY_STATE.
slotId - Indicates the card slot index number, ranging from 0 to the maximum card slot index number
supported by the device.public String getImeiSv(int slotId)
Requires Permission: ohos.permission.GET_TELEPHONY_STATE.
slotId - Indicates the card slot index number, ranging from 0 to the maximum card slot index number
supported by the device.public String getTypeAllocationCode(int slotId)
slotId - Indicates the card slot index number, ranging from 0 to the maximum card slot index number
supported by the device.public String getMeid(int slotId)
Requires Permission: ohos.permission.GET_TELEPHONY_STATE.
slotId - Indicates the card slot index number, ranging from 0 to the maximum card slot index number
supported by the device.public String getManufacturerCode(int slotId)
slotId - Indicates the card slot index number, ranging from 0 to the maximum card slot index number
supported by the device.public int getPrimarySlotId()
The primary card is the SIM card inserted in the card slot that uses data services by default.
public boolean isNrSupported()
true if the device supports 5G NR; returns false otherwise.public boolean isNsaState()
Requires Permission: ohos.permission.GET_NETWORK_INFO.
true if the device is registered with a 5G NSA network; returns false otherwise.public void addObserver(RadioStateObserver observer, int mask)
To register an observer, pass a RadioStateObserver and an observer mask of the concerned state.
When the specified state changes, the callback method in RadioStateObserver is invoked.
It is also invoked upon the first registration of the observer.
NOTE: The slot ID that you want to observe is declared in RadioStateObserver.
Requires Permission: OBSERVE_MASK_SERVICE_STATE needs ohos.permission.GET_NETWORK_INFO and
OBSERVE_MASK_CELL_INFO needs ohos.permission.LOCATION.
observer - Indicates the RadioStateObserver to register.mask - Indicates the mask of the concerned state, as specified in RadioStateObserver.SecurityException - Throws this exception if the caller does not have the permission.public void removeObserver(RadioStateObserver observer)
To unregister an observer, pass the same RadioStateObserver
as in RadioInfoManager#addObserver.
observer - Indicates the RadioStateObserver to unregister.public String getRadioTechName(int radioTech)
radioTech - Indicates the RAT of the registered network.UNKNOWN if the name is not found.public int getNetworkSelectionMode(int slotId)
slotId - Indicates the ID of the SIM card slot.public String getPesn(int slotId)
Permissions: SystemPermission.GET_TELEPHONY_STATE
slotId - Indicates the ID of the specified slot.