1# @ohos.telephony.radio (Network Search) 2 3The **radio** module provides basic network search management functions. Using the APIs provided by this module, you can obtain the radio access technology (RAT) used in the CS and PS domains, network status, current network selection mode, ISO country code of the registered network, ID of the slot in which the primary card is located, list of signal strengths of the registered network for the SIM card in the specified slot, and carrier name. Besides, you can check whether the current device supports New Radio \(NR\) and whether the radio service is enabled on the primary SIM card. 4 5> **NOTE** 6> 7> 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. 8 9 10## Modules to Import 11 12```ts 13import { radio } from '@kit.TelephonyKit'; 14``` 15 16## radio.getRadioTech 17 18getRadioTech\(slotId: number, callback: AsyncCallback<[NetworkRadioTech](#networkradiotech11)\>\): void 19 20Obtains the RAT used in the CS and PS domains for the SIM card in the specified slot. This API uses an asynchronous callback to return the result. 21 22**Required permission**: ohos.permission.GET_NETWORK_INFO 23 24**System capability**: SystemCapability.Telephony.CoreService 25 26**Parameters** 27 28| Name | Type | Mandatory| Description | 29| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- | 30| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1.<br>- **1**: card slot 2| 31| callback | AsyncCallback\<[NetworkRadioTech](#networkradiotech11)\> | Yes | Callback used to return the result. | 32 33**Error codes** 34 35For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Telephony Error Codes](errorcode-telephony.md). 36 37| ID| Error Message | 38| -------- | -------------------------------------------- | 39| 201 | Permission denied. | 40| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 41| 8300001 | Invalid parameter value. | 42| 8300002 | Service connection failed. | 43| 8300003 | System internal error. | 44| 8300999 | Unknown error. | 45 46**Example** 47 48```ts 49import { BusinessError } from '@kit.BasicServicesKit'; 50 51let slotId: number = 0; 52radio.getRadioTech(slotId, (err: BusinessError, data: radio.NetworkRadioTech) => { 53 if (err) { 54 console.error(`getRadioTech failed, callback: err->${JSON.stringify(err)}`); 55 return; 56 } 57 console.log(`getRadioTech success, callback: data->${JSON.stringify(data)}`); 58}); 59``` 60 61 62## radio.getRadioTech 63 64getRadioTech\(slotId: number\): Promise\<[NetworkRadioTech](#networkradiotech11)\> 65 66Obtains the RAT used in the CS and PS domains for the SIM card in the specified slot. This API uses a promise to return the result. 67 68**Required permission**: ohos.permission.GET_NETWORK_INFO 69 70**System capability**: SystemCapability.Telephony.CoreService 71 72**Parameters** 73 74| Name| Type | Mandatory| Description | 75| ------ | ------ | ---- | -------------------------------------- | 76| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1.<br>- **1**: card slot 2| 77 78**Return value** 79 80| Type | Description | 81| ------------------------------------------------------------ | ----------------------------------------------- | 82| Promise\<[NetworkRadioTech](#networkradiotech11)\> | Promise used to return the result.| 83 84**Error codes** 85 86For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Telephony Error Codes](errorcode-telephony.md). 87 88| ID| Error Message | 89| -------- | -------------------------------------------- | 90| 201 | Permission denied. | 91| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 92| 8300001 | Invalid parameter value. | 93| 8300002 | Service connection failed. | 94| 8300003 | System internal error. | 95| 8300999 | Unknown error. | 96 97**Example** 98 99```ts 100import { BusinessError } from '@kit.BasicServicesKit'; 101 102let slotId: number = 0; 103radio.getRadioTech(slotId).then((data: radio.NetworkRadioTech) => { 104 console.log(`getRadioTech success, promise: data->${JSON.stringify(data)}`); 105}).catch((err: BusinessError) => { 106 console.error(`getRadioTech failed, promise: err->${JSON.stringify(err)}`); 107}); 108``` 109 110 111## radio.getRadioTechSync<sup>18+</sup> 112 113getRadioTechSync\(slotId: number\): [NetworkRadioTech](#networkradiotech11) 114 115Obtains the RAT used in the CS and PS domains for the SIM card in the specified slot. 116 117**Required permission**: ohos.permission.GET_NETWORK_INFO 118 119**System capability**: SystemCapability.Telephony.CoreService 120 121**Parameters** 122 123| Name| Type | Mandatory| Description | 124| ------ | ------ | ---- | -------------------------------------- | 125| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1.<br>- **1**: card slot 2| 126 127**Return value** 128 129| Type | Description | 130| ------------------------------------------------------------ | ----------------------------------------------- | 131| [NetworkRadioTech](#networkradiotech11) | RAT used in the CS and PS domains.| 132 133**Example** 134 135```ts 136let slotId: number = 0; 137let networkRadioTech: radio.NetworkRadioTech = radio.getRadioTechSync(slotId); 138console.info(`getRadioTechSync success, NetworkRadioTech->${JSON.stringify(networkRadioTech)}`); 139``` 140 141 142## radio.getNetworkState 143 144getNetworkState\(callback: AsyncCallback\<NetworkState\>\): void 145 146Obtains the network status. This API uses an asynchronous callback to return the result. 147 148**Required permission**: ohos.permission.GET_NETWORK_INFO 149 150**System capability**: SystemCapability.Telephony.CoreService 151 152**Parameters** 153 154| Name | Type | Mandatory| Description | 155| -------- | ---------------------------------------------- | ---- | ---------- | 156| callback | AsyncCallback\<[NetworkState](#networkstate)\> | Yes | Callback used to return the result. | 157 158**Error codes** 159 160For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Telephony Error Codes](errorcode-telephony.md). 161 162| ID| Error Message | 163| -------- | -------------------------------------------- | 164| 201 | Permission denied. | 165| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 166| 8300001 | Invalid parameter value. | 167| 8300002 | Service connection failed. | 168| 8300003 | System internal error. | 169| 8300999 | Unknown error. | 170 171**Example** 172 173```ts 174import { BusinessError } from '@kit.BasicServicesKit'; 175 176radio.getNetworkState((err: BusinessError, data: radio.NetworkState) => { 177 if (err) { 178 console.error(`getNetworkState failed, callback: err->${JSON.stringify(err)}`); 179 return; 180 } 181 console.log(`getNetworkState success, callback: data->${JSON.stringify(data)}`); 182}); 183``` 184 185 186## radio.getNetworkState 187 188getNetworkState\(slotId: number, callback: AsyncCallback\<NetworkState\>\): void 189 190Obtains the network status of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. 191 192**Required permission**: ohos.permission.GET_NETWORK_INFO 193 194**System capability**: SystemCapability.Telephony.CoreService 195 196**Parameters** 197 198| Name | Type | Mandatory| Description | 199| -------- | ---------------------------------------------- | ---- | -------------------------------------- | 200| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1.<br>- **1**: card slot 2| 201| callback | AsyncCallback\<[NetworkState](#networkstate)\> | Yes | Callback used to return the result. | 202 203**Error codes** 204 205For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Telephony Error Codes](errorcode-telephony.md). 206 207| ID| Error Message | 208| -------- | -------------------------------------------- | 209| 201 | Permission denied. | 210| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 211| 8300001 | Invalid parameter value. | 212| 8300002 | Service connection failed. | 213| 8300003 | System internal error. | 214| 8300999 | Unknown error. | 215 216**Example** 217 218```ts 219import { BusinessError } from '@kit.BasicServicesKit'; 220 221let slotId: number = 0; 222radio.getNetworkState(slotId, (err: BusinessError, data: radio.NetworkState) => { 223 if (err) { 224 console.error(`getNetworkState failed, callback: err->${JSON.stringify(err)}`); 225 return; 226 } 227 console.log(`getNetworkState success, callback: data->${JSON.stringify(data)}`); 228}); 229``` 230 231 232## radio.getNetworkState 233 234getNetworkState\(slotId?: number\): Promise\<NetworkState\> 235 236Obtains the network status of the SIM card in the specified slot. This API uses a promise to return the result. 237 238**Required permission**: ohos.permission.GET_NETWORK_INFO 239 240**System capability**: SystemCapability.Telephony.CoreService 241 242**Parameters** 243 244| Name| Type | Mandatory| Description | 245| ------ | ------ | ---- | -------------------------------------- | 246| slotId | number | No | Card slot ID.<br>- **0**: card slot 1.<br>- **1**: card slot 2<br> If no card slot is specified, card slot 1 is used by default.| 247 248**Return value** 249 250| Type | Description | 251| ---------------------------------------- | --------------------------- | 252| Promise\<[NetworkState](#networkstate)\> | Promise used to return the result.| 253 254**Error codes** 255 256For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Telephony Error Codes](errorcode-telephony.md). 257 258| ID| Error Message | 259| -------- | -------------------------------------------- | 260| 201 | Permission denied. | 261| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 262| 8300001 | Invalid parameter value. | 263| 8300002 | Service connection failed. | 264| 8300003 | System internal error. | 265| 8300999 | Unknown error. | 266 267**Example** 268 269```ts 270import { BusinessError } from '@kit.BasicServicesKit'; 271 272let slotId: number = 0; 273radio.getNetworkState(slotId).then((data: radio.NetworkState) => { 274 console.log(`getNetworkState success, promise: data->${JSON.stringify(data)}`); 275}).catch((err: BusinessError) => { 276 console.error(`getNetworkState failed, promise: err->${JSON.stringify(err)}`); 277}); 278``` 279 280 281## radio.getNetworkSelectionMode 282 283getNetworkSelectionMode\(slotId: number, callback: AsyncCallback\<NetworkSelectionMode\>\): void 284 285Obtains the network selection mode of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. 286 287**System capability**: SystemCapability.Telephony.CoreService 288 289**Parameters** 290 291| Name | Type | Mandatory| Description | 292| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- | 293| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1.<br>- **1**: card slot 2| 294| callback | AsyncCallback\<[NetworkSelectionMode](#networkselectionmode)\> | Yes | Callback used to return the result. | 295 296**Error codes** 297 298For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Telephony Error Codes](errorcode-telephony.md). 299 300| ID| Error Message | 301| -------- | -------------------------------------------- | 302| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 303| 8300001 | Invalid parameter value. | 304| 8300002 | Service connection failed. | 305| 8300003 | System internal error. | 306| 8300999 | Unknown error. | 307 308**Example** 309 310```ts 311import { BusinessError } from '@kit.BasicServicesKit'; 312 313let slotId: number = 0; 314radio.getNetworkSelectionMode(slotId, (err: BusinessError, data: radio.NetworkSelectionMode) => { 315 if (err) { 316 console.error(`getNetworkSelectionMode failed, callback: err->${JSON.stringify(err)}`); 317 return; 318 } 319 console.log(`getNetworkSelectionMode success, callback: data->${JSON.stringify(data)}`); 320}); 321``` 322 323 324## radio.getNetworkSelectionMode 325 326getNetworkSelectionMode\(slotId: number\): Promise\<NetworkSelectionMode\> 327 328Obtains the network selection mode of the SIM card in the specified slot. This API uses a promise to return the result. 329 330**System capability**: SystemCapability.Telephony.CoreService 331 332**Parameters** 333 334| Name| Type | Mandatory| Description | 335| ------ | ------ | ---- | -------------------------------------- | 336| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1.<br>- **1**: card slot 2| 337 338**Return value** 339 340| Type | Description | 341| -------------------------------------------------------- | ------------------------------- | 342| Promise\<[NetworkSelectionMode](#networkselectionmode)\> | Promise used to return the result.| 343 344**Error codes** 345 346For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Telephony Error Codes](errorcode-telephony.md). 347 348| ID| Error Message | 349| -------- | -------------------------------------------- | 350| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 351| 8300001 | Invalid parameter value. | 352| 8300002 | Service connection failed. | 353| 8300003 | System internal error. | 354| 8300999 | Unknown error. | 355 356**Example** 357 358```ts 359import { BusinessError } from '@kit.BasicServicesKit'; 360 361let slotId: number = 0; 362radio.getNetworkSelectionMode(slotId).then((data: radio.NetworkSelectionMode) => { 363 console.log(`getNetworkSelectionMode success, promise: data->${JSON.stringify(data)}`); 364}).catch((err: BusinessError) => { 365 console.error(`getNetworkSelectionMode failed, promise: err->${JSON.stringify(err)}`); 366}); 367``` 368 369 370## radio.getISOCountryCodeForNetwork<sup>7+</sup> 371 372getISOCountryCodeForNetwork\(slotId: number, callback: AsyncCallback\<string\>\): void 373 374Obtains 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. 375 376**System capability**: SystemCapability.Telephony.CoreService 377 378**Parameters** 379 380| Name | Type | Mandatory| Description | 381| -------- | ----------------------- | ---- | ---------------------------------------- | 382| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1.<br>- **1**: card slot 2 | 383| callback | AsyncCallback\<string\> | Yes | Callback used to return the result. which is a country code, for example, **CN** (China). If the device is not registered with any network, an empty string is returned.| 384 385**Error codes** 386 387For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Telephony Error Codes](errorcode-telephony.md). 388 389| ID| Error Message | 390| -------- | -------------------------------------------- | 391| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 392| 8300001 | Invalid parameter value. | 393| 8300002 | Service connection failed. | 394| 8300003 | System internal error. | 395| 8300999 | Unknown error. | 396 397**Example** 398 399```ts 400import { BusinessError } from '@kit.BasicServicesKit'; 401 402let slotId: number = 0; 403radio.getISOCountryCodeForNetwork(slotId, (err: BusinessError, data: string) => { 404 if (err) { 405 console.error(`getISOCountryCodeForNetwork failed, callback: err->${JSON.stringify(err)}`); 406 return; 407 } 408 console.log(`getISOCountryCodeForNetwork success, callback: data->${JSON.stringify(data)}`); 409}); 410``` 411 412 413## radio.getISOCountryCodeForNetwork<sup>7+</sup> 414 415getISOCountryCodeForNetwork\(slotId: number\): Promise\<string\> 416 417Obtains 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. 418 419**System capability**: SystemCapability.Telephony.CoreService 420 421**Parameters** 422 423| Name| Type | Mandatory| Description | 424| ------ | ------ | ---- | -------------------------------------- | 425| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1.<br>- **1**: card slot 2| 426 427**Return value** 428 429| Type | Description | 430| ----------------- | ------------------------------------------------------------ | 431| Promise\<string\> | Promise used to return the result, which is an ISO country code, for example, **CN** (China). If the device is not registered with any network, an empty string is returned.| 432 433**Error codes** 434 435For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Telephony Error Codes](errorcode-telephony.md). 436 437| ID| Error Message | 438| -------- | -------------------------------------------- | 439| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 440| 8300001 | Invalid parameter value. | 441| 8300002 | Service connection failed. | 442| 8300003 | System internal error. | 443| 8300999 | Unknown error. | 444 445**Example** 446 447```ts 448import { BusinessError } from '@kit.BasicServicesKit'; 449 450let slotId: number = 0; 451radio.getISOCountryCodeForNetwork(slotId).then((data: string) => { 452 console.log(`getISOCountryCodeForNetwork success, promise: data->${JSON.stringify(data)}`); 453}).catch((err: BusinessError) => { 454 console.error(`getISOCountryCodeForNetwork failed, promise: err->${JSON.stringify(err)}`); 455}); 456``` 457 458## radio.getISOCountryCodeForNetworkSync<sup>10+</sup> 459 460getISOCountryCodeForNetworkSync\(slotId: number\): string 461 462Obtains the ISO country code of the network with which the SIM card in the specified slot is registered. 463 464**System capability**: SystemCapability.Telephony.CoreService 465 466**Parameters** 467 468| Name| Type | Mandatory| Description | 469| ------ | ------ | ---- | -------------------------------------- | 470| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1.<br>- **1**: card slot 2| 471 472**Return value** 473 474| Type | Description | 475| ----------------- | ------------------------------------------------------------ | 476| string | ISO country code of the network, for example, **CN** (China). If the device is not registered with any network, an empty string is returned.| 477 478**Example** 479 480```ts 481let slotId: number = 0; 482let countryISO: string = radio.getISOCountryCodeForNetworkSync(slotId); 483console.log(`the country ISO is:` + countryISO); 484``` 485 486 487 488## radio.getPrimarySlotId<sup>7+</sup> 489 490getPrimarySlotId\(callback: AsyncCallback\<number\>\): void 491 492Obtains the ID of the slot in which the primary card is located. This API uses an asynchronous callback to return the result. 493 494**System capability**: SystemCapability.Telephony.CoreService 495 496**Parameters** 497 498| Name | Type | Mandatory| Description | 499| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 500| callback | AsyncCallback\<number\> | Yes | Callback used to return the result. | 501 502**Error codes** 503 504For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Telephony Error Codes](errorcode-telephony.md). 505 506| ID| Error Message | 507| -------- | -------------------------------------------- | 508| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 509| 8300001 | Invalid parameter value. | 510| 8300002 | Service connection failed. | 511| 8300003 | System internal error. | 512| 8300999 | Unknown error. | 513 514**Example** 515 516```ts 517import { BusinessError } from '@kit.BasicServicesKit'; 518 519radio.getPrimarySlotId((err: BusinessError, data: number) => { 520 if (err) { 521 console.error(`getPrimarySlotId failed, callback: err->${JSON.stringify(err)}`); 522 return; 523 } 524 console.log(`getPrimarySlotId success, callback: data->${JSON.stringify(data)}`); 525}); 526``` 527 528 529## radio.getPrimarySlotId<sup>7+</sup> 530 531getPrimarySlotId\(\): Promise\<number\> 532 533Obtains the ID of the slot in which the primary card is located. This API uses a promise to return the result. 534 535**System capability**: SystemCapability.Telephony.CoreService 536 537**Return value** 538 539| Type | Description | 540| ----------------------------------------------------------- | ------------------------------------------------------------ | 541| Promise\<number\> | Promise used to return the result.| 542 543**Error codes** 544 545For details about the error codes, see[ohos.telephony (Telephony) Error Codes](errorcode-telephony.md). 546 547| ID| Error Message | 548| -------- | -------------------------------------------- | 549| 8300002 | Service connection failed. | 550| 8300003 | System internal error. | 551| 8300999 | Unknown error. | 552 553**Example** 554 555```ts 556import { BusinessError } from '@kit.BasicServicesKit'; 557 558radio.getPrimarySlotId().then((data: number) => { 559 console.log(`getPrimarySlotId success, promise: data->${JSON.stringify(data)}`); 560}).catch((err: BusinessError) => { 561 console.error(`getPrimarySlotId failed, promise: err->${JSON.stringify(err)}`); 562}); 563``` 564 565 566## radio.getSignalInformation<sup>7+</sup> 567 568getSignalInformation\(slotId: number, callback: AsyncCallback\<Array\<SignalInformation\>\>\): void 569 570Obtains 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. 571 572**System capability**: SystemCapability.Telephony.CoreService 573 574**Parameters** 575 576| Name | Type | Mandatory| Description | 577| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 578| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1.<br>- **1**: card slot 2 | 579| callback | AsyncCallback\<Array\<[SignalInformation](#signalinformation)\>\> | Yes | Callback used to return the result, which is an array of child class objects derived from [SignalInformation](#signalinformation).| 580 581**Error codes** 582 583For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Telephony Error Codes](errorcode-telephony.md). 584 585| ID| Error Message | 586| -------- | -------------------------------------------- | 587| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 588| 8300001 | Invalid parameter value. | 589| 8300002 | Service connection failed. | 590| 8300003 | System internal error. | 591| 8300999 | Unknown error. | 592 593**Example** 594 595```ts 596import { BusinessError } from '@kit.BasicServicesKit'; 597 598let slotId: number = 0; 599radio.getSignalInformation(slotId, (err: BusinessError, data: Array<radio.SignalInformation>) => { 600 if (err) { 601 console.error(`getSignalInformation failed, callback: err->${JSON.stringify(err)}`); 602 return; 603 } 604 console.log(`getSignalInformation success, callback: data->${JSON.stringify(data)}`); 605}); 606``` 607 608 609## radio.getSignalInformation<sup>7+</sup> 610 611getSignalInformation\(slotId: number\): Promise\<Array\<SignalInformation\>\> 612 613Obtains 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. 614 615**System capability**: SystemCapability.Telephony.CoreService 616 617**Parameters** 618 619| Name| Type | Mandatory| Description | 620| ------ | ------ | ---- | -------------------------------------- | 621| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1.<br>- **1**: card slot 2| 622 623**Return value** 624 625| Type | Description | 626| ----------------------------------------------------------- | ------------------------------------------------------------ | 627| Promise\<Array\<[SignalInformation](#signalinformation)\>\> | Promise used to return the result, which is a list of child class objects derived from [SignalInformation](#signalinformation).| 628 629**Error codes** 630 631For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Telephony Error Codes](errorcode-telephony.md). 632 633| ID| Error Message | 634| -------- | -------------------------------------------- | 635| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 636| 8300001 | Invalid parameter value. | 637| 8300002 | Service connection failed. | 638| 8300003 | System internal error. | 639| 8300999 | Unknown error. | 640 641**Example** 642 643```ts 644import { BusinessError } from '@kit.BasicServicesKit'; 645 646let slotId: number = 0; 647radio.getSignalInformation(slotId).then((data: Array<radio.SignalInformation>) => { 648 console.log(`getSignalInformation success, promise: data->${JSON.stringify(data)}`); 649}).catch((err: BusinessError) => { 650 console.error(`getSignalInformation failed, promise: err->${JSON.stringify(err)}`); 651}); 652``` 653 654## radio.getSignalInformationSync<sup>10+</sup> 655 656getSignalInformationSync\(slotId: number\): Array\<SignalInformation\> 657 658Obtains a list of signal strengths of the network with which the SIM card in the specified slot is registered. 659 660**System capability**: SystemCapability.Telephony.CoreService 661 662**Parameters** 663 664| Name| Type | Mandatory| Description | 665| ------ | ------ | ---- | -------------------------------------- | 666| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1.<br>- **1**: card slot 2| 667 668**Return value** 669 670| Type | Description | 671| ----------------------------------------------------------- | ------------------------------------------------------------ | 672| Array\<[SignalInformation](#signalinformation)\>| Array of child class objects derived from [SignalInformation](#signalinformation).| 673 674 675**Example** 676 677```ts 678let slotId: number = 0; 679let signalInfo: Array<radio.SignalInformation> = radio.getSignalInformationSync(slotId); 680console.log(`signal information size is:` + signalInfo.length); 681``` 682 683## radio.isNrSupported<sup>8+(deprecated)</sup> 684 685isNrSupported\(\): boolean 686 687Check whether the current device supports NR. 688 689> **NOTE** 690> 691> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [isNRSupported](#radioisnrsupported9). 692 693**System capability**: SystemCapability.Telephony.CoreService 694 695**Return value** 696 697| Type | Description | 698| ------- | -------------------------------- | 699| boolean | - **true**: supported<br>- **false**: not supported| 700 701**Example** 702 703```ts 704let result: boolean = radio.isNrSupported(); 705console.log("Result: "+ result); 706``` 707 708## radio.isNrSupported<sup>(deprecated)</sup> 709 710isNrSupported\(slotId: number\): boolean 711 712Check whether the SIM card in the specified slot supports NR. 713 714> **NOTE** 715> 716> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [isNRSupported](#radioisnrsupported9-1). 717 718**System capability**: SystemCapability.Telephony.CoreService 719 720**Parameters** 721 722| Name| Type | Mandatory| Description | 723| ------ | ------ | ---- | -------------------------------------- | 724| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1.<br>- **1**: card slot 2| 725 726**Return value** 727 728| Type | Description | 729| ------------------ | ------------------------------------------------------------ | 730| boolean | - **true**: supported<br>- **false**: not supported| 731 732**Example** 733 734```ts 735let slotId: number = 0; 736let result: boolean = radio.isNrSupported(slotId); 737console.log("Result: "+ result); 738``` 739 740 741## radio.isNRSupported<sup>9+</sup> 742 743isNRSupported\(\): boolean 744 745Check whether the current device supports NR. 746 747**System capability**: SystemCapability.Telephony.CoreService 748 749**Return value** 750 751| Type | Description | 752| ------- | -------------------------------- | 753| boolean | - **true**: supported<br>- **false**: not supported| 754 755**Example** 756 757```ts 758let result: boolean = radio.isNRSupported(); 759console.log("Result: "+ result); 760``` 761 762 763## radio.isNRSupported<sup>9+</sup> 764 765isNRSupported\(slotId: number\): boolean 766 767Check whether the SIM card in the specified slot supports NR. 768 769**System capability**: SystemCapability.Telephony.CoreService 770 771**Parameters** 772 773| Name| Type | Mandatory| Description | 774| ------ | ------ | ---- | -------------------------------------- | 775| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1.<br>- **1**: card slot 2| 776 777**Return value** 778 779| Type | Description | 780| ------------------ | ------------------------------------------------------------ | 781| boolean | - **true**: supported<br>- **false**: not supported| 782 783**Example** 784 785```ts 786let slotId: number = 0; 787let result: boolean = radio.isNRSupported(slotId); 788console.log("Result: "+ result); 789``` 790 791 792## radio.isRadioOn<sup>7+</sup> 793 794isRadioOn\(callback: AsyncCallback\<boolean\>\): void 795 796Checks whether the radio service is enabled on the primary SIM card. This API uses an asynchronous callback to return the result. 797 798**Required permission**: ohos.permission.GET_NETWORK_INFO 799 800**System capability**: SystemCapability.Telephony.CoreService 801 802**Parameters** 803 804| Name | Type | Mandatory| Description | 805| -------- | ------------------------ | ---- | ------------------------------------------------------- | 806| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result. <br>- **true**: The radio service is enabled.<br>- **false**: The radio service is disabled.| 807 808**Error codes** 809 810For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Telephony Error Codes](errorcode-telephony.md). 811 812| ID| Error Message | 813| -------- | -------------------------------------------- | 814| 201 | Permission denied. | 815| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 816| 8300001 | Invalid parameter value. | 817| 8300002 | Service connection failed. | 818| 8300003 | System internal error. | 819| 8300999 | Unknown error. | 820 821**Example** 822 823```ts 824import { BusinessError } from '@kit.BasicServicesKit'; 825 826radio.isRadioOn((err: BusinessError, data: boolean) => { 827 if (err) { 828 console.error(`isRadioOn failed, callback: err->${JSON.stringify(err)}`); 829 return; 830 } 831 console.log(`isRadioOn success, callback: data->${JSON.stringify(data)}`); 832}); 833``` 834 835 836## radio.isRadioOn<sup>7+</sup> 837 838isRadioOn\(slotId: number, callback: AsyncCallback\<boolean\>\): void 839 840Checks whether the radio service is enabled on the SIM card in the specified slot. This API uses an asynchronous callback to return the result. 841 842**Required permission**: ohos.permission.GET_NETWORK_INFO 843 844**System capability**: SystemCapability.Telephony.CoreService 845 846**Parameters** 847 848| Name | Type | Mandatory| Description | 849| -------- | ------------------------ | ---- | ------------------------------------------------------- | 850| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1.<br>- **1**: card slot 2 | 851| callback | AsyncCallback\<boolean\> | Yes | Callback used to return the result. <br>- **true**: The radio service is enabled.<br>- **false**: The radio service is disabled.| 852 853**Error codes** 854 855For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Telephony Error Codes](errorcode-telephony.md). 856 857| ID| Error Message | 858| -------- | -------------------------------------------- | 859| 201 | Permission denied. | 860| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 861| 8300001 | Invalid parameter value. | 862| 8300002 | Service connection failed. | 863| 8300003 | System internal error. | 864| 8300999 | Unknown error. | 865 866**Example** 867 868```ts 869import { BusinessError } from '@kit.BasicServicesKit'; 870 871let slotId: number = 0; 872radio.isRadioOn(slotId, (err: BusinessError, data: boolean) => { 873 if (err) { 874 console.error(`isRadioOn failed, callback: err->${JSON.stringify(err)}`); 875 return; 876 } 877 console.log(`isRadioOn success, callback: data->${JSON.stringify(data)}`); 878}); 879``` 880 881 882## radio.isRadioOn<sup>7+</sup> 883 884isRadioOn\(slotId?: number\): Promise\<boolean\> 885 886Checks whether the radio service is enabled on the SIM card in the specified slot. This API uses a promise to return the result. 887 888**Required permission**: ohos.permission.GET_NETWORK_INFO 889 890**System capability**: SystemCapability.Telephony.CoreService 891 892**Parameters** 893 894| Name| Type | Mandatory| Description | 895| ------ | ------ | ---- | -------------------------------------- | 896| 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.| 897 898**Return value** 899 900| Type | Description | 901| ------------------ | ------------------------------------------------------------ | 902| Promise\<boolean\> | Promise used to return the result.<br>- **true**: The radio service is enabled.<br>- **false**: The radio service is disabled.| 903 904**Error codes** 905 906For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Telephony Error Codes](errorcode-telephony.md). 907 908| ID| Error Message | 909| -------- | -------------------------------------------- | 910| 201 | Permission denied. | 911| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 912| 8300001 | Invalid parameter value. | 913| 8300002 | Service connection failed. | 914| 8300003 | System internal error. | 915| 8300999 | Unknown error. | 916 917**Example** 918 919```ts 920import { BusinessError } from '@kit.BasicServicesKit'; 921 922let slotId: number = 0; 923radio.isRadioOn(slotId).then((data: boolean) => { 924 console.log(`isRadioOn success, promise: data->${JSON.stringify(data)}`); 925}).catch((err: BusinessError) => { 926 console.error(`isRadioOn failed, promise: err->${JSON.stringify(err)}`); 927}); 928``` 929 930 931## radio.getOperatorName<sup>7+</sup> 932 933getOperatorName\(slotId: number, callback: AsyncCallback\<string\>\): void 934 935Obtains the carrier name of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. 936 937**System capability**: SystemCapability.Telephony.CoreService 938 939**Parameters** 940 941| Name | Type | Mandatory| Description | 942| -------- | ----------------------- | ---- | ------------------------------------------ | 943| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1.<br>- **1**: card slot 2 | 944| callback | AsyncCallback\<string\> | Yes | Callback used to return the carrier name, for example, China Mobile.| 945 946**Error codes** 947 948For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Telephony Error Codes](errorcode-telephony.md). 949 950| ID| Error Message | 951| -------- | -------------------------------------------- | 952| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 953| 8300001 | Invalid parameter value. | 954| 8300002 | Service connection failed. | 955| 8300003 | System internal error. | 956| 8300999 | Unknown error. | 957 958**Example** 959 960```ts 961import { BusinessError } from '@kit.BasicServicesKit'; 962 963let slotId: number = 0; 964radio.getOperatorName(slotId, (err: BusinessError, data: string) => { 965 if (err) { 966 console.error(`getOperatorName failed, callback: err->${JSON.stringify(err)}`); 967 return; 968 } 969 console.log(`getOperatorName success, callback: data->${JSON.stringify(data)}`); 970}); 971``` 972 973 974## radio.getOperatorName<sup>7+</sup> 975 976getOperatorName\(slotId: number\): Promise\<string\> 977 978Obtains the carrier name of the SIM card in the specified slot. This API uses a promise to return the result. 979 980**System capability**: SystemCapability.Telephony.CoreService 981 982**Parameters** 983 984| Name| Type | Mandatory| Description | 985| ------ | ------ | ---- | -------------------------------------- | 986| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1.<br>- **1**: card slot 2| 987 988**Return value** 989 990| Type | Description | 991| ----------------- | ------------------------------------------------------------ | 992| Promise\<string\> | Promise used to return the result, for example, China Mobile. | 993 994**Error codes** 995 996For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Telephony Error Codes](errorcode-telephony.md). 997 998| ID| Error Message | 999| -------- | -------------------------------------------- | 1000| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. | 1001| 8300001 | Invalid parameter value. | 1002| 8300002 | Service connection failed. | 1003| 8300003 | System internal error. | 1004| 8300999 | Unknown error. | 1005 1006**Example** 1007 1008```ts 1009import { BusinessError } from '@kit.BasicServicesKit'; 1010 1011let slotId: number = 0; 1012radio.getOperatorName(slotId).then((data: string) => { 1013 console.log(`getOperatorName success, promise: data->${JSON.stringify(data)}`); 1014}).catch((err: BusinessError) => { 1015 console.error(`getOperatorName failed, promise: err->${JSON.stringify(err)}`); 1016}); 1017``` 1018 1019## radio.getOperatorNameSync<sup>10+</sup> 1020 1021getOperatorNameSync\(slotId: number\): string 1022 1023Obtains the carrier name of the SIM card in the specified slot. 1024 1025**System capability**: SystemCapability.Telephony.CoreService 1026 1027**Parameters** 1028 1029| Name| Type | Mandatory| Description | 1030| ------ | ------ | ---- | -------------------------------------- | 1031| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1.<br>- **1**: card slot 2| 1032 1033**Return value** 1034 1035| Type | Description | 1036| ----------------- | ------------------------------------------------------------ | 1037| string | Carrier name, for example, China Mobile. | 1038 1039 1040**Example** 1041 1042```ts 1043let slotId: number = 0; 1044let operatorName: string = radio.getOperatorNameSync(slotId); 1045console.log(`operator name is:` + operatorName); 1046``` 1047 1048 1049## NetworkRadioTech<sup>11+</sup> 1050 1051Defines the radio access technology for the packet switched (PS) or circuit switched (CS) network. 1052 1053**System capability**: SystemCapability.Telephony.CoreService 1054 1055| Name | Type | Mandatory| Description | 1056| --------------- | --------------------------- | ---- | ------------------ | 1057| psRadioTech | [RadioTechnology](#radiotechnology) | Yes | PS.| 1058| csRadioTech | [RadioTechnology](#radiotechnology) | Yes | CS.| 1059 1060## RadioTechnology 1061 1062Enumerates radio access technologies. 1063 1064**System capability**: SystemCapability.Telephony.CoreService 1065 1066| Name | Value | Description | 1067| ------------------------- | ---- | ------------------------------------------------------------ | 1068| RADIO_TECHNOLOGY_UNKNOWN | 0 | Unknown RAT | 1069| RADIO_TECHNOLOGY_GSM | 1 | Global System for Mobile Communication (GSM) | 1070| RADIO_TECHNOLOGY_1XRTT | 2 | Single-Carrier Radio Transmission Technology (1XRTT)| 1071| RADIO_TECHNOLOGY_WCDMA | 3 | Wideband Code Division Multiple Access (WCDMA)| 1072| RADIO_TECHNOLOGY_HSPA | 4 | High Speed Packet Access (HSPA) | 1073| RADIO_TECHNOLOGY_HSPAP | 5 | Evolved High Speed Packet Access (HSPA+) | 1074| RADIO_TECHNOLOGY_TD_SCDMA | 6 | TD-SCDMA.| 1075| RADIO_TECHNOLOGY_EVDO | 7 | Evolution-Data Optimized (EVDO) | 1076| RADIO_TECHNOLOGY_EHRPD | 8 | Evolved High Rate Package Data (EHRPD) | 1077| RADIO_TECHNOLOGY_LTE | 9 | Long Term Evolution (LTE) | 1078| RADIO_TECHNOLOGY_LTE_CA | 10 | Long Term Evolution_Carrier Aggregation (LTE_CA)| 1079| RADIO_TECHNOLOGY_IWLAN | 11 | Industrial Wireless LAN (IWLAN) | 1080| RADIO_TECHNOLOGY_NR | 12 | New Radio (NR) | 1081 1082 1083## SignalInformation 1084 1085Defines the signal strength. 1086 1087**System capability**: SystemCapability.Telephony.CoreService 1088 1089| Name | Type | Mandatory| Description | 1090| --------------- | --------------------------- | ---- | ------------------ | 1091| signalType | [NetworkType](#networktype) | Yes | Signal strength type.| 1092| signalLevel | number | Yes | Signal strength level.| 1093| dBm<sup>9+</sup>| number | Yes | Signal strength, in dBm. | 1094 1095## NetworkType 1096 1097Enumerates network types. 1098 1099**System capability**: SystemCapability.Telephony.CoreService 1100 1101| Name | Value | Description | 1102| -------------------- | ---- | ------------------------------------------------------------ | 1103| NETWORK_TYPE_UNKNOWN | 0 | Unknown network. | 1104| NETWORK_TYPE_GSM | 1 | GSM network. | 1105| NETWORK_TYPE_CDMA | 2 | CDMA network. | 1106| NETWORK_TYPE_WCDMA | 3 | WCDMA network. | 1107| NETWORK_TYPE_TDSCDMA | 4 | TD-SCDMA network.| 1108| NETWORK_TYPE_LTE | 5 | LTE network. | 1109| NETWORK_TYPE_NR | 6 | NR network. | 1110 1111## NetworkState 1112 1113Defines the network status. 1114 1115**System capability**: SystemCapability.Telephony.CoreService 1116 1117| Name | Type | Mandatory| Description | 1118| -------------------- | ----------------------------------- | ---- | ------------------------------------------------------------ | 1119| longOperatorName | string | Yes | Long carrier name of the registered network. | 1120| shortOperatorName | string | Yes | Short carrier name of the registered network. | 1121| plmnNumeric | string | Yes | PLMN code of the registered network. | 1122| isRoaming | boolean | Yes | Whether the user is roaming. | 1123| regState | [RegState](#regstate) | Yes | Network registration status of the device. | 1124| cfgTech<sup>8+</sup> | [RadioTechnology](#radiotechnology) | Yes | RAT of the device. | 1125| nsaState | [NsaState](#nsastate) | Yes | NSA network registration status of the device. | 1126| isCaActive | boolean | Yes | CA status. | 1127| isEmergency | boolean | Yes | Whether only emergency calls are allowed. | 1128 1129 1130## RegState 1131 1132Defines the network registration status of the device. 1133 1134**System capability**: SystemCapability.Telephony.CoreService 1135 1136| Name | Value | Description | 1137| ----------------------------- | ---- | -------------------------- | 1138| REG_STATE_NO_SERVICE | 0 | The device cannot use any services, including data, SMS, and call services. | 1139| REG_STATE_IN_SERVICE | 1 | The device can use services properly, including data, SMS, and call services. | 1140| REG_STATE_EMERGENCY_CALL_ONLY | 2 | The device can use only the emergency call service.| 1141| REG_STATE_POWER_OFF | 3 | The device cannot communicate with the network because the cellular radio service is disabled or the modem is powered off. | 1142 1143 1144## NsaState 1145 1146Enumerates NSA network states. 1147 1148**System capability**: SystemCapability.Telephony.CoreService 1149 1150| Name | Value | Description | 1151| -------------------------- | ---- | ---------------------------------------------------------- | 1152| NSA_STATE_NOT_SUPPORT | 1 | The device is in idle or connected state in an LTE cell that does not support NSA. | 1153| NSA_STATE_NO_DETECT | 2 | The device is in the idle state in an LTE cell that supports NSA but not NR coverage detection.| 1154| NSA_STATE_CONNECTED_DETECT | 3 | The device is connected to the LTE network in an LTE cell that supports NSA and NR coverage detection. | 1155| NSA_STATE_IDLE_DETECT | 4 | The device is in the idle state in an LTE cell that supports NSA and NR coverage detection. | 1156| NSA_STATE_DUAL_CONNECTED | 5 | The device is connected to the LTE/NR network in an LTE cell that supports NSA. | 1157| NSA_STATE_SA_ATTACHED | 6 | The device is idle or connected to the NG-RAN cell when being attached to the 5G Core. | 1158 1159 1160## NetworkSelectionMode 1161 1162Enumerates network selection modes. 1163 1164**System capability**: SystemCapability.Telephony.CoreService 1165 1166| Name | Value | Description | 1167| --------------------------- | ---- | -------------- | 1168| NETWORK_SELECTION_UNKNOWN | 0 | Unknown network selection mode.| 1169| NETWORK_SELECTION_AUTOMATIC | 1 | Automatic network selection mode.| 1170| NETWORK_SELECTION_MANUAL | 2 | Manual network selection mode.| 1171 1172 1173## CellInformation<sup>8+</sup> 1174 1175Defines the cell information. 1176 1177**System capability**: SystemCapability.Telephony.CoreService 1178 1179| Name | Type | Mandatory| Description | 1180| ----------------- | --------------------------------------- | ---- | ------------------------------------------------------------ | 1181| networkType | [NetworkType](#networktype) | Yes | Network type of the cell. | 1182| signalInformation | [SignalInformation](#signalinformation) | Yes | Signal information. | 1183