js-apis-radio.md 25.8 KB
Newer Older
S
shawn_he 已提交
1 2
# Radio

S
shawn_he 已提交
3
>**NOTE**
S
shawn_he 已提交
4
>
Z
zengyawen 已提交
5
>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.
S
shawn_he 已提交
6 7 8 9


## Modules to Import

S
shawn_he 已提交
10
```js
S
shawn_he 已提交
11 12 13
import radio from '@ohos.telephony.radio'
```

S
shawn_he 已提交
14
## radio.getRadioTech
S
shawn_he 已提交
15 16 17

getRadioTech\(slotId: number, callback: AsyncCallback<\{psRadioTech: RadioTechnology, csRadioTech: RadioTechnology\}\>\): void

S
shawn_he 已提交
18
Obtains the radio access technology (RAT) used by the CS and PS domains. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
19

S
shawn_he 已提交
20 21 22
**Required permission**: ohos.permission.GET_NETWORK_INFO

**System capability**: SystemCapability.Telephony.CoreService
S
shawn_he 已提交
23

S
shawn_he 已提交
24
**Parameters**
S
shawn_he 已提交
25

S
shawn_he 已提交
26
| Name  | Type                                                        | Mandatory| Description                                  |
S
shawn_he 已提交
27
| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- |
S
shawn_he 已提交
28
| slotId   | number                                                       | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
29
| callback | AsyncCallback\<{psRadioTech: [RadioTechnology](#radiotechnology), csRadioTech:[RadioTechnology](#radiotechnology)}\> | Yes  | Callback used to return the result.                            |
S
shawn_he 已提交
30

S
shawn_he 已提交
31
**Example**
S
shawn_he 已提交
32

S
shawn_he 已提交
33
```js
S
shawn_he 已提交
34 35 36 37 38
let slotId = 0;
radio.getRadioTech(slotId, (err, data) =>{ 
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
S
shawn_he 已提交
39 40


S
shawn_he 已提交
41
## radio.getRadioTech
S
shawn_he 已提交
42 43 44

getRadioTech\(slotId: number\): Promise<\{psRadioTech: RadioTechnology, csRadioTech: RadioTechnology\}\>

S
shawn_he 已提交
45
Obtains the RAT used by the CS and PS domains. This API uses a promise to return the result. 
S
shawn_he 已提交
46

S
shawn_he 已提交
47 48 49
**Required permission**: ohos.permission.GET_NETWORK_INFO

**System capability**: SystemCapability.Telephony.CoreService
S
shawn_he 已提交
50

S
shawn_he 已提交
51
**Parameters**
S
shawn_he 已提交
52

S
shawn_he 已提交
53
| Name| Type  | Mandatory| Description                                  |
S
shawn_he 已提交
54
| ------ | ------ | ---- | -------------------------------------- |
S
shawn_he 已提交
55
| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
56

S
shawn_he 已提交
57
**Return value**
S
shawn_he 已提交
58

S
shawn_he 已提交
59
| Type                                                        | Description                                           |
S
shawn_he 已提交
60
| ------------------------------------------------------------ | ----------------------------------------------- |
S
shawn_he 已提交
61
| Promise<{psRadioTech: [RadioTechnology](#radiotechnology), csRadioTech: [RadioTechnology](#radiotechnology)}> | Promise used to return the result.|
S
shawn_he 已提交
62

S
shawn_he 已提交
63
**Example**
S
shawn_he 已提交
64

S
shawn_he 已提交
65
```js
S
shawn_he 已提交
66 67 68 69 70 71 72 73
let slotId = 0;
let promise = radio.getRadioTech(slotId);
promise.then(data => {
    console.log(`getRadioTech success, data->${JSON.stringify(data)}`);
}).catch(err => {
    console.log(`getRadioTech fail, err->${JSON.stringify(err)}`);
});
```
S
shawn_he 已提交
74 75


S
shawn_he 已提交
76
## radio.getNetworkState
S
shawn_he 已提交
77 78 79

getNetworkState\(callback: AsyncCallback<NetworkState\>\): void

S
shawn_he 已提交
80
Obtains the network status. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
81

S
shawn_he 已提交
82 83 84
**Required permission**: ohos.permission.GET_NETWORK_INFO

**System capability**: SystemCapability.Telephony.CoreService
S
shawn_he 已提交
85

S
shawn_he 已提交
86
**Parameters**
S
shawn_he 已提交
87

S
shawn_he 已提交
88
| Name  | Type                                          | Mandatory| Description      |
S
shawn_he 已提交
89
| -------- | ---------------------------------------------- | ---- | ---------- |
S
shawn_he 已提交
90
| callback | AsyncCallback\<[NetworkState](#networkstate)\> | Yes  | Callback used to return the result.|
S
shawn_he 已提交
91

S
shawn_he 已提交
92
**Example**
S
shawn_he 已提交
93

S
shawn_he 已提交
94
```js
S
shawn_he 已提交
95 96 97 98
radio.getNetworkState((err, data) =>{
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
S
shawn_he 已提交
99 100


S
shawn_he 已提交
101
## radio.getNetworkState
S
shawn_he 已提交
102 103 104

getNetworkState\(slotId: number, callback: AsyncCallback<NetworkState\>\): void

S
shawn_he 已提交
105
Obtains the network status. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
106

S
shawn_he 已提交
107 108 109
**Required permission**: ohos.permission.GET_NETWORK_INFO

**System capability**: SystemCapability.Telephony.CoreService
S
shawn_he 已提交
110

S
shawn_he 已提交
111
**Parameters**
S
shawn_he 已提交
112

S
shawn_he 已提交
113
| Name  | Type                                          | Mandatory| Description                                  |
S
shawn_he 已提交
114
| -------- | ---------------------------------------------- | ---- | -------------------------------------- |
S
shawn_he 已提交
115
| slotId   | number                                         | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
116
| callback | AsyncCallback\<[NetworkState](#networkstate)\> | Yes  | Callback used to return the result.                            |
S
shawn_he 已提交
117

S
shawn_he 已提交
118
**Example**
S
shawn_he 已提交
119

S
shawn_he 已提交
120
```js
S
shawn_he 已提交
121 122 123 124 125
let slotId = 0;
radio.getNetworkState(slotId, (err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
S
shawn_he 已提交
126 127


S
shawn_he 已提交
128
## radio.getNetworkState
S
shawn_he 已提交
129 130 131

getNetworkState\(slotId?: number\): Promise<NetworkState\>

S
shawn_he 已提交
132
Obtains the network status of the SIM card in the specified slot. This API uses a promise to return the result.
S
shawn_he 已提交
133

S
shawn_he 已提交
134 135 136
**Required permission**: ohos.permission.GET_NETWORK_INFO

**System capability**: SystemCapability.Telephony.CoreService
S
shawn_he 已提交
137

S
shawn_he 已提交
138
**Parameters**
S
shawn_he 已提交
139

S
shawn_he 已提交
140
| Name| Type  | Mandatory| Description                                  |
S
shawn_he 已提交
141
| ------ | ------ | ---- | -------------------------------------- |
S
shawn_he 已提交
142
| slotId | number | No  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
143

S
shawn_he 已提交
144
**Return value**
S
shawn_he 已提交
145

S
shawn_he 已提交
146
| Type                                    | Description                       |
S
shawn_he 已提交
147
| ---------------------------------------- | --------------------------- |
S
shawn_he 已提交
148
| Promise\<[NetworkState](#networkstate)\> | Promise used to return the result.|
S
shawn_he 已提交
149

S
shawn_he 已提交
150
**Example**
S
shawn_he 已提交
151

S
shawn_he 已提交
152
```js
S
shawn_he 已提交
153 154 155 156 157 158 159 160
let slotId = 0;
let promise = radio.getNetworkState(slotId);
promise.then(data => {
    console.log(`getNetworkState success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
    console.log(`getNetworkState fail, promise: err->${JSON.stringify(err)}`);
});
```
S
shawn_he 已提交
161 162


S
shawn_he 已提交
163
## radio.getNetworkSelectionMode
S
shawn_he 已提交
164 165 166

getNetworkSelectionMode\(slotId: number, callback: AsyncCallback<NetworkSelectionMode\>\): void

S
shawn_he 已提交
167
Obtains the network selection mode of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
168

S
shawn_he 已提交
169 170
**System capability**: SystemCapability.Telephony.CoreService

S
shawn_he 已提交
171
**Parameters**
S
shawn_he 已提交
172

S
shawn_he 已提交
173
| Name  | Type                                                        | Mandatory| Description                                  |
S
shawn_he 已提交
174
| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- |
S
shawn_he 已提交
175
| slotId   | number                                                       | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
176
| callback | AsyncCallback\<[NetworkSelectionMode](#networkselectionmode)\> | Yes  | Callback used to return the result.                            |
S
shawn_he 已提交
177

S
shawn_he 已提交
178
**Example**
S
shawn_he 已提交
179

S
shawn_he 已提交
180
```js
S
shawn_he 已提交
181 182 183 184 185
let slotId = 0;
radio.getNetworkSelectionMode(slotId, (err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
S
shawn_he 已提交
186 187


S
shawn_he 已提交
188
## radio.getNetworkSelectionMode
S
shawn_he 已提交
189 190 191

getNetworkSelectionMode\(slotId: number\): Promise<NetworkSelectionMode\>

S
shawn_he 已提交
192
Obtains the network selection mode of the SIM card in the specified slot. This API uses a promise to return the result.
S
shawn_he 已提交
193

S
shawn_he 已提交
194 195
**System capability**: SystemCapability.Telephony.CoreService

S
shawn_he 已提交
196
**Parameters**
S
shawn_he 已提交
197

S
shawn_he 已提交
198
| Name| Type  | Mandatory| Description                                  |
S
shawn_he 已提交
199
| ------ | ------ | ---- | -------------------------------------- |
S
shawn_he 已提交
200
| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
201

S
shawn_he 已提交
202
**Return value**
S
shawn_he 已提交
203

S
shawn_he 已提交
204
| Type                                                    | Description                           |
S
shawn_he 已提交
205
| -------------------------------------------------------- | ------------------------------- |
S
shawn_he 已提交
206
| Promise\<[NetworkSelectionMode](#networkselectionmode)\> | Promise used to return the result.|
S
shawn_he 已提交
207

S
shawn_he 已提交
208
**Example**
S
shawn_he 已提交
209

S
shawn_he 已提交
210
```js
S
shawn_he 已提交
211 212 213 214 215 216 217 218
let slotId = 0;
let promise = radio.getNetworkSelectionMode(slotId);
promise.then(data => {
    console.log(`getNetworkSelectionMode success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
    console.log(`getNetworkSelectionMode fail, promise: err->${JSON.stringify(err)}`);
});
```
S
shawn_he 已提交
219 220


S
shawn_he 已提交
221
## radio.getISOCountryCodeForNetwork<sup>7+</sup>
S
shawn_he 已提交
222 223 224

getISOCountryCodeForNetwork\(slotId: number, callback: AsyncCallback<string\>\): void

S
shawn_he 已提交
225
Obtains the ISO country code of the network with which the SIM card in the specified slot is registered. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
226

S
shawn_he 已提交
227 228
**System capability**: SystemCapability.Telephony.CoreService

S
shawn_he 已提交
229
**Parameters**
S
shawn_he 已提交
230

S
shawn_he 已提交
231
| Name  | Type                   | Mandatory| Description                                    |
S
shawn_he 已提交
232
| -------- | ----------------------- | ---- | ---------------------------------------- |
S
shawn_he 已提交
233
| slotId   | number                  | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2  |
S
shawn_he 已提交
234
| callback | AsyncCallback\<string\> | Yes  | Callback used to return the result. which is a country code, for example, **CN** (China).|
S
shawn_he 已提交
235

S
shawn_he 已提交
236
**Example**
S
shawn_he 已提交
237

S
shawn_he 已提交
238
```js
S
shawn_he 已提交
239 240 241 242 243
let slotId = 0;
radio.getISOCountryCodeForNetwork(slotId, (err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
S
shawn_he 已提交
244 245


S
shawn_he 已提交
246
## radio.getISOCountryCodeForNetwork<sup>7+</sup>
S
shawn_he 已提交
247 248 249

getISOCountryCodeForNetwork\(slotId: number\): Promise<string\>

S
shawn_he 已提交
250
Obtains the ISO country code of the network with which the SIM card in the specified slot is registered. This API uses a promise to return the result.
S
shawn_he 已提交
251

S
shawn_he 已提交
252 253
**System capability**: SystemCapability.Telephony.CoreService

S
shawn_he 已提交
254
**Parameters**
S
shawn_he 已提交
255

S
shawn_he 已提交
256
| Name| Type  | Mandatory| Description                                  |
S
shawn_he 已提交
257
| ------ | ------ | ---- | -------------------------------------- |
S
shawn_he 已提交
258
| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
259

S
shawn_he 已提交
260
**Return value**
S
shawn_he 已提交
261

S
shawn_he 已提交
262
| Type             | Description                                                        |
S
shawn_he 已提交
263 264
| ----------------- | ------------------------------------------------------------ |
| Promise\<string\> | Promise used to return the result, which is an ISO country code, for example, **CN** (China).|
S
shawn_he 已提交
265

S
shawn_he 已提交
266
**Example**
S
shawn_he 已提交
267

S
shawn_he 已提交
268
```js
S
shawn_he 已提交
269 270 271 272 273 274 275 276
let slotId = 0;
let promise = radio.getISOCountryCodeForNetwork(slotId);
promise.then(data => {
    console.log(`getISOCountryCodeForNetwork success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
    console.log(`getISOCountryCodeForNetwork fail, promise: err->${JSON.stringify(err)}`);
});
```
S
shawn_he 已提交
277 278


S
shawn_he 已提交
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294
## radio.getPrimarySlotId<sup>7+</sup>

getPrimarySlotId\(callback: AsyncCallback\<number\>\): void

Obtains the ID of the slot in which the primary card is located. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name  | Type                                                        | Mandatory| Description                                                        |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback\<number\> | Yes  | Callback used to return the result.|

**Example**

S
shawn_he 已提交
295
```js
S
shawn_he 已提交
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317
radio.getPrimarySlotId((err, data) => {
   console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```


## radio.getPrimarySlotId<sup>7+</sup>

getPrimarySlotId\(\): Promise\<number\>

Obtains the ID of the slot in which the primary card is located. This API uses a promise to return the result.

**System capability**: SystemCapability.Telephony.CoreService

**Return value**

| Type                                                       | Description                                                        |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<number\> | Promise used to return the result.|

**Example**

S
shawn_he 已提交
318
```js
S
shawn_he 已提交
319 320 321 322 323 324 325 326 327 328
let promise = radio.getPrimarySlotId();
promise.then(data => {
    console.log(`getPrimarySlotId success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
    console.error(`getPrimarySlotId fail, promise: err->${JSON.stringify(err)}`);
});
```


## radio.getSignalInformation<sup>7+</sup>
S
shawn_he 已提交
329 330 331

getSignalInformation\(slotId: number, callback: AsyncCallback<Array<SignalInformation\>\>\): void

S
shawn_he 已提交
332
Obtains a list of signal strengths of the network with which the SIM card in the specified slot is registered. This API uses an asynchronous callback to return the result. 
S
shawn_he 已提交
333

S
shawn_he 已提交
334 335
**System capability**: SystemCapability.Telephony.CoreService

S
shawn_he 已提交
336
**Parameters**
S
shawn_he 已提交
337

S
shawn_he 已提交
338
| Name  | Type                                                        | Mandatory| Description                                                        |
S
shawn_he 已提交
339
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
S
shawn_he 已提交
340
| slotId   | number                                                       | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2                      |
S
shawn_he 已提交
341
| callback | AsyncCallback\<Array\<[SignalInformation](#signalinformation)\>\> | Yes  | Callback used to return the result, which is a list of [SignalInformation](#signalinformation) objects.|
S
shawn_he 已提交
342

S
shawn_he 已提交
343
**Example**
S
shawn_he 已提交
344

S
shawn_he 已提交
345
```js
S
shawn_he 已提交
346 347 348 349 350
let slotId = 0;
radio.getSignalInformation(slotId, (err, data) => {
   console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
S
shawn_he 已提交
351 352


S
shawn_he 已提交
353
## radio.getSignalInformation<sup>7+</sup>
S
shawn_he 已提交
354 355 356

getSignalInformation\(slotId: number\): Promise<Array<SignalInformation\>\>

S
shawn_he 已提交
357
Obtains a list of signal strengths of the network with which the SIM card in the specified slot is registered. This API uses a promise to return the result. 
S
shawn_he 已提交
358

S
shawn_he 已提交
359 360
**System capability**: SystemCapability.Telephony.CoreService

S
shawn_he 已提交
361
**Parameters**
S
shawn_he 已提交
362

S
shawn_he 已提交
363
| Name| Type  | Mandatory| Description                                  |
S
shawn_he 已提交
364
| ------ | ------ | ---- | -------------------------------------- |
S
shawn_he 已提交
365
| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
366

S
shawn_he 已提交
367
**Return value**
S
shawn_he 已提交
368

S
shawn_he 已提交
369
| Type                                                       | Description                                                        |
S
shawn_he 已提交
370
| ----------------------------------------------------------- | ------------------------------------------------------------ |
S
shawn_he 已提交
371
| Promise\<Array\<[SignalInformation](#signalinformation)\>\> | Promise used to return the result, which is a list of [SignalInformation](#signalinformation) objects.|
S
shawn_he 已提交
372

S
shawn_he 已提交
373
**Example**
S
shawn_he 已提交
374

S
shawn_he 已提交
375
```js
S
shawn_he 已提交
376 377 378 379 380 381 382 383
let slotId = 0;
let promise = radio.getSignalInformation(slotId);
promise.then(data => {
    console.log(`getSignalInformation success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
    console.error(`getSignalInformation fail, promise: err->${JSON.stringify(err)}`);
});
```
S
shawn_he 已提交
384 385


S
shawn_he 已提交
386 387 388 389 390 391 392 393 394 395 396 397
## radio.isNrSupported<sup>8+</sup>

isNrSupported\(slotId: number\): boolean

Checks whether the current device supports 5G \(NR\).

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

| Name| Type  | Mandatory| Description                                  |
| ------ | ------ | ---- | -------------------------------------- |
S
shawn_he 已提交
398
| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
399 400 401 402 403 404 405 406 407

**Return value**

| Type              | Description                                                        |
| ------------------ | ------------------------------------------------------------ |
| boolean | - **true**: The current device supports 5G \(NR\).<br>- **false**: The current device does not support 5G \(NR\).|

**Example**

S
shawn_he 已提交
408
```js
S
shawn_he 已提交
409 410
let slotId = 0;
let result = radio.isNrSupported(slotId);
S
shawn_he 已提交
411
console.log("Result: "+ result);
S
shawn_he 已提交
412 413 414 415
```


## radio.isRadioOn<sup>7+</sup>
S
shawn_he 已提交
416 417 418

isRadioOn\(callback: AsyncCallback<boolean\>\): void

S
shawn_he 已提交
419
Checks whether the radio service is enabled on the primary SIM card. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
420 421

**Required permission**: ohos.permission.GET_NETWORK_INFO
S
shawn_he 已提交
422

S
shawn_he 已提交
423
**System capability**: SystemCapability.Telephony.CoreService
S
shawn_he 已提交
424

S
shawn_he 已提交
425
**Parameters**
S
shawn_he 已提交
426

S
shawn_he 已提交
427
| Name  | Type                    | Mandatory| Description                                                   |
S
shawn_he 已提交
428
| -------- | ------------------------ | ---- | ------------------------------------------------------- |
S
shawn_he 已提交
429
| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.<br>- **true**: The radio service is enabled.<br>- **false**: The radio service is disabled.|
S
shawn_he 已提交
430

S
shawn_he 已提交
431
**Example**
S
shawn_he 已提交
432

S
shawn_he 已提交
433
```js
S
shawn_he 已提交
434 435 436 437
radio.isRadioOn((err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
S
shawn_he 已提交
438 439


S
shawn_he 已提交
440
## radio.isRadioOn<sup>7+</sup>
S
shawn_he 已提交
441 442 443

isRadioOn\(slotId: number, callback: AsyncCallback<boolean\>\): void

S
shawn_he 已提交
444
Checks whether the radio service is enabled on the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
445 446 447 448 449 450 451

**Required permission**: ohos.permission.GET_NETWORK_INFO

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

S
shawn_he 已提交
452
| Name  | Type                    | Mandatory| Description                                                   |
S
shawn_he 已提交
453
| -------- | ------------------------ | ---- | ------------------------------------------------------- |
S
shawn_he 已提交
454
| slotId   | number                   | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2                 |
S
shawn_he 已提交
455
| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result.<br>- **true**: The radio service is enabled.<br>- **false**: The radio service is disabled.|
S
shawn_he 已提交
456 457 458

**Example**

S
shawn_he 已提交
459
```js
S
shawn_he 已提交
460 461 462 463 464 465 466
let slotId = 0;
radio.isRadioOn(slotId, (err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```


S
shawn_he 已提交
467
## radio.isRadioOn<sup>7+</sup>
S
shawn_he 已提交
468

S
shawn_he 已提交
469
isRadioOn\(slotId?: number\): Promise<boolean\>
S
shawn_he 已提交
470

S
shawn_he 已提交
471
Checks whether the radio service is enabled. This API uses a promise to return the result.
S
shawn_he 已提交
472

S
shawn_he 已提交
473 474 475 476 477 478
**Required permission**: ohos.permission.GET_NETWORK_INFO

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

S
shawn_he 已提交
479
| Name| Type  | Mandatory| Description                                  |
S
shawn_he 已提交
480
| ------ | ------ | ---- | -------------------------------------- |
S
shawn_he 已提交
481
| slotId | number | No  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2<br>If the slot ID is not specified, this API is defaulted to check whether the radio service is enabled on the primary SIM card.|
S
shawn_he 已提交
482

S
shawn_he 已提交
483
**Return value**
S
shawn_he 已提交
484

S
shawn_he 已提交
485
| Type              | Description                                                        |
S
shawn_he 已提交
486
| ------------------ | ------------------------------------------------------------ |
S
shawn_he 已提交
487
| Promise\<boolean\> | Promise used to return the result.<br>- **true**: The radio service is enabled.<br>- **false**: The radio service is disabled.|
S
shawn_he 已提交
488

S
shawn_he 已提交
489
**Example**
S
shawn_he 已提交
490

S
shawn_he 已提交
491
```js
S
shawn_he 已提交
492 493
let slotId = 0;
let promise = radio.isRadioOn(slotId);
S
shawn_he 已提交
494 495 496 497 498 499
promise.then(data => {
    console.log(`isRadioOn success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
    console.error(`isRadioOn fail, promise: err->${JSON.stringify(err)}`);
});
```
S
shawn_he 已提交
500 501


S
shawn_he 已提交
502
## radio.getOperatorName<sup>7+</sup>
S
shawn_he 已提交
503 504 505

getOperatorName\(slotId: number, callback: AsyncCallback<string\>\): void

S
shawn_he 已提交
506
Obtains the carrier name. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
507 508 509 510 511

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

S
shawn_he 已提交
512
| Name  | Type                   | Mandatory| Description                                      |
S
shawn_he 已提交
513
| -------- | ----------------------- | ---- | ------------------------------------------ |
S
shawn_he 已提交
514
| slotId   | number                  | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2    |
S
shawn_he 已提交
515
| callback | AsyncCallback\<string\> | Yes  | Callback used to return the result, which is the carrier name, for example, China Mobile.|
S
shawn_he 已提交
516 517 518

**Example**

S
shawn_he 已提交
519
```js
S
shawn_he 已提交
520 521 522 523 524 525 526
let slotId = 0;
radio.getOperatorName(slotId, (err, data) => {
    console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```


S
shawn_he 已提交
527
## radio.getOperatorName<sup>7+</sup>
S
shawn_he 已提交
528 529 530

getOperatorName\(slotId: number\): Promise<string\>

S
shawn_he 已提交
531
Obtains the carrier name. This API uses a promise to return the result.
S
shawn_he 已提交
532 533 534 535 536

**System capability**: SystemCapability.Telephony.CoreService

**Parameters**

S
shawn_he 已提交
537
| Name| Type  | Mandatory| Description                                  |
S
shawn_he 已提交
538
| ------ | ------ | ---- | -------------------------------------- |
S
shawn_he 已提交
539
| slotId | number | Yes  | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
S
shawn_he 已提交
540 541 542

**Return value**

S
shawn_he 已提交
543
| Type             | Description                                                        |
S
shawn_he 已提交
544
| ----------------- | ------------------------------------------------------------ |
S
shawn_he 已提交
545
| Promise\<string\> | Promise used t return the result, which is the carrier name, for example, China Mobile.               |
S
shawn_he 已提交
546 547 548

**Example**

S
shawn_he 已提交
549
```js
S
shawn_he 已提交
550 551 552 553 554 555 556 557 558 559
let slotId = 0;
let promise = radio.getOperatorName(slotId);
promise.then(data => {
    console.log(`getOperatorName success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
    console.log(`getOperatorName fail, promise: err->${JSON.stringify(err)}`);
});
```


S
shawn_he 已提交
560
## RadioTechnology
S
shawn_he 已提交
561 562 563

Enumerates the RATs.

S
shawn_he 已提交
564 565 566
**System capability**: SystemCapability.Telephony.CoreService

| Name                     | Value  | Description                                                        |
S
shawn_he 已提交
567
| ------------------------- | ---- | ------------------------------------------------------------ |
S
shawn_he 已提交
568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583
| RADIO_TECHNOLOGY_UNKNOWN  | 0    | Unknown RAT                                   |
| RADIO_TECHNOLOGY_GSM      | 1    | Global System for Mobile Communication (GSM) |
| RADIO_TECHNOLOGY_1XRTT    | 2    | Single-Carrier Radio Transmission Technology (1XRTT)|
| RADIO_TECHNOLOGY_WCDMA    | 3    | Wideband Code Division Multiple Access (WCDMA)|
| RADIO_TECHNOLOGY_HSPA     | 4    | High Speed Packet Access (HSPA)              |
| RADIO_TECHNOLOGY_HSPAP    | 5    | Evolved High Speed Packet Access (HSPA+)    |
| RADIO_TECHNOLOGY_TD_SCDMA | 6    | Time Division Synchronous Code Division Multiple Access (TD-SCDMA)|
| RADIO_TECHNOLOGY_EVDO     | 7    | Evolution-Data Optimized (EVDO)                  |
| RADIO_TECHNOLOGY_EHRPD    | 8    | Evolved High Rate Package Data (EHRPD)       |
| RADIO_TECHNOLOGY_LTE      | 9    | Long Term Evolution (LTE)                    |
| RADIO_TECHNOLOGY_LTE_CA   | 10   | Long Term Evolution_Carrier Aggregation (LTE_CA)|
| RADIO_TECHNOLOGY_IWLAN    | 11   | Industrial Wireless LAN (IWLAN)              |
| RADIO_TECHNOLOGY_NR       | 12   | New Radio (NR)                               |


## SignalInformation
S
shawn_he 已提交
584 585 586

Defines the signal strength.

S
shawn_he 已提交
587 588 589 590 591 592
**System capability**: SystemCapability.Telephony.CoreService

| Name     | Type                       | Description              |
| ----------- | --------------------------- | ------------------ |
| signalType  | [NetworkType](#networktype) | Signal strength type.|
| signalLevel | number                      | Signal strength level.|
S
shawn_he 已提交
593 594


S
shawn_he 已提交
595
## NetworkType
S
shawn_he 已提交
596

S
shawn_he 已提交
597
Defines the network type.
S
shawn_he 已提交
598

S
shawn_he 已提交
599 600 601
**System capability**: SystemCapability.Telephony.CoreService

| Name                | Value  | Description                                                        |
S
shawn_he 已提交
602
| -------------------- | ---- | ------------------------------------------------------------ |
S
shawn_he 已提交
603 604 605 606 607 608 609
| NETWORK_TYPE_UNKNOWN | 0    | Unknown network.                                              |
| NETWORK_TYPE_GSM     | 1    | GSM network.   |
| NETWORK_TYPE_CDMA    | 2    | CDMA network.           |
| NETWORK_TYPE_WCDMA   | 3    | WCDMA network. |
| NETWORK_TYPE_TDSCDMA | 4    | TD-SCDMA network.|
| NETWORK_TYPE_LTE     | 5    | LTE network.                      |
| NETWORK_TYPE_NR      | 6    | 5G NR network.                              |
S
shawn_he 已提交
610

S
shawn_he 已提交
611
## NetworkState
S
shawn_he 已提交
612 613 614

Defines the network registration status.

S
shawn_he 已提交
615 616 617
**System capability**: SystemCapability.Telephony.CoreService

| Name           | Type                 | Description                                                        |
S
shawn_he 已提交
618
| ----------------- | --------------------- | ------------------------------------------------------------ |
S
shawn_he 已提交
619 620 621 622 623 624
| longOperatorName  | string                | Long carrier name of the registered network.|
| shortOperatorName | string                | Short carrier name of the registered network.|
| plmnNumeric       | string                | PLMN code of the registered network.|
| isRoaming         | boolean               | Whether the user is roaming.|
| regState          | [RegState](#regstate) | Network registration status of the device.|
| cfgTech<sup>8+</sup> | [RadioTechnology](#radiotechnology) | RAT of the device.|
S
shawn_he 已提交
625
| nsaState          | [NsaState](#nsastate) | NSA network registration status of the device.|
S
shawn_he 已提交
626 627
| isCaActive        | boolean               | CA status.|
| isEmergency       | boolean               | Whether only emergency calls are allowed.|
S
shawn_he 已提交
628 629


S
shawn_he 已提交
630
## RegState
S
shawn_he 已提交
631

S
shawn_he 已提交
632
Defines the network registration status.
S
shawn_he 已提交
633

S
shawn_he 已提交
634 635 636 637 638 639 640 641
**System capability**: SystemCapability.Telephony.CoreService

| Name                         | Value  | Description                      |
| ----------------------------- | ---- | -------------------------- |
| REG_STATE_NO_SERVICE          | 0    | The device cannot use any service.    |
| REG_STATE_IN_SERVICE          | 1    | The device can use services normally.     |
| REG_STATE_EMERGENCY_CALL_ONLY | 2    | The device can use only the emergency call service.|
| REG_STATE_POWER_OFF           | 3    | The cellular radio service is disabled.        |
S
shawn_he 已提交
642 643


S
shawn_he 已提交
644
## NsaState
S
shawn_he 已提交
645 646 647

Enumerates NSA network states.

S
shawn_he 已提交
648 649 650 651 652 653 654 655 656 657
**System capability**: SystemCapability.Telephony.CoreService

| Name                      | Value  | Description                                                      |
| -------------------------- | ---- | ---------------------------------------------------------- |
| NSA_STATE_NOT_SUPPORT      | 1    | The device is in idle or connected state in an LTE cell that does not support NSA.        |
| NSA_STATE_NO_DETECT        | 2    | The device is in the idle state in an LTE cell that supports NSA but not NR coverage detection.|
| NSA_STATE_CONNECTED_DETECT | 3    | The device is connected to the LTE network in an LTE cell that supports NSA and NR coverage detection.         |
| NSA_STATE_IDLE_DETECT      | 4    | The device is in the idle state in an LTE cell that supports NSA and NR coverage detection.          |
| NSA_STATE_DUAL_CONNECTED   | 5    | The device is connected to the LTE/NR network in an LTE cell that supports NSA.              |
| NSA_STATE_SA_ATTACHED      | 6    | The device is idle or connected to the NG-RAN cell when being attached to the 5G Core.     |
S
shawn_he 已提交
658 659


S
shawn_he 已提交
660
## NetworkSelectionMode
S
shawn_he 已提交
661 662 663

Enumerates network selection modes.

S
shawn_he 已提交
664 665 666 667 668 669 670
**System capability**: SystemCapability.Telephony.CoreService

| Name                       | Value  | Description          |
| --------------------------- | ---- | -------------- |
| NETWORK_SELECTION_UNKNOWN   | 0    | Unknown network selection mode.|
| NETWORK_SELECTION_AUTOMATIC | 1    | Automatic network selection mode.|
| NETWORK_SELECTION_MANUAL    | 2    | Manual network selection mode.|