1/* 2* Copyright (C) 2021 Huawei Device Co., Ltd. 3* Licensed under the Apache License, Version 2.0 (the "License"); 4* you may not use this file except in compliance with the License. 5* You may obtain a copy of the License at 6* 7* http://www.apache.org/licenses/LICENSE-2.0 8* 9* Unless required by applicable law or agreed to in writing, software 10* distributed under the License is distributed on an "AS IS" BASIS, 11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12* See the License for the specific language governing permissions and 13* limitations under the License. 14*/ 15 16import {AsyncCallback} from "./basic"; 17 18/** 19 * Provides interfaces for applications to obtain the network state, cell information, signal information, 20 * and device ID of the wireless cellular network (WCN), and provides a callback registration mechanism to 21 * listen for changes of the network, cell, and signal status of the WCN. 22 * 23 * @since 6 24 * @sysCap SystemCapability.Telephony.Telephony 25 */ 26declare namespace radio { 27 /** 28 * Obtains radio access technology (RAT) of the registered network. The system 29 * returns RAT of the packet service (PS) and circuit service (CS) domain. 30 * 31 * <p>Requires Permission: {@code ohos.permission.GET_NETWORK_INFO}. 32 * 33 * @param slotId Indicates the card slot index number, 34 * ranging from 0 to the maximum card slot index number supported by the device. 35 * @param callback Returns an integer indicating the RAT in use. The values are as follows: 36 * <ul> 37 * <li>{@code RadioTechnology#RADIO_TECHNOLOGY_UNKNOWN} 38 * <li>{@code RadioTechnology#RADIO_TECHNOLOGY_GSM} 39 * <li>{@code RadioTechnology#RADIO_TECHNOLOGY_1XRTT} 40 * <li>{@code RadioTechnology#RADIO_TECHNOLOGY_WCDMA} 41 * <li>{@code RadioTechnology#RADIO_TECHNOLOGY_HSPA} 42 * <li>{@code RadioTechnology#RADIO_TECHNOLOGY_HSPAP} 43 * <li>{@code RadioTechnology#RADIO_TECHNOLOGY_TD_SCDMA} 44 * <li>{@code RadioTechnology#RADIO_TECHNOLOGY_EVDO} 45 * <li>{@code RadioTechnology#RADIO_TECHNOLOGY_EHRPD} 46 * <li>{@code RadioTechnology#RADIO_TECHNOLOGY_LTE} 47 * <li>{@code RadioTechnology#RADIO_TECHNOLOGY_LTE_CA} 48 * <li>{@code RadioTechnology#RADIO_TECHNOLOGY_IWLAN} 49 * <li>{@code RadioTechnology#RADIO_TECHNOLOGY_NR} 50 * </ul> 51 * @permission ohos.permission.GET_NETWORK_INFO 52 */ 53 function getRadioTech(slotId: number, 54 callback: AsyncCallback<{psRadioTech: RadioTechnology, csRadioTech: RadioTechnology}>): void; 55 function getRadioTech(slotId: number): Promise<{psRadioTech: RadioTechnology, csRadioTech: RadioTechnology}>; 56 57 /** 58 * Obtains the network state of the registered network. 59 * 60 * <p>Requires Permission: {@code ohos.permission.GET_NETWORK_INFO}. 61 * 62 * @param slotId Indicates the card slot index number, 63 * ranging from 0 to the maximum card slot index number supported by the device. 64 * @param callback Returns a {@code NetworkState} object. 65 * @permission ohos.permission.GET_NETWORK_INFO 66 */ 67 function getNetworkState(callback: AsyncCallback<NetworkState>): void; 68 function getNetworkState(slotId: number, callback: AsyncCallback<NetworkState>): void; 69 function getNetworkState(slotId?: number): Promise<NetworkState>; 70 71 /** 72 * Obtains the network search mode of the SIM card in a specified slot. 73 * 74 * @param slotId Indicates the ID of the SIM card slot. 75 * @param callback Returns the network search mode of the SIM card. Available values are as follows: 76 * <ul> 77 * <li>{@link NetworkSelectionMode#NETWORK_SELECTION_UNKNOWN} 78 * <li>{@link NetworkSelectionMode#NETWORK_SELECTION_AUTOMATIC} 79 * <li>{@link NetworkSelectionMode#NETWORK_SELECTION_MANUAL} 80 * <ul> 81 */ 82 function getNetworkSelectionMode(slotId: number, callback: AsyncCallback<NetworkSelectionMode>): void; 83 function getNetworkSelectionMode(slotId: number): Promise<NetworkSelectionMode>; 84 85 /** 86 * @permission ohos.permission.SET_TELEPHONY_STATE 87 * @systemapi Hide this for inner system use. 88 */ 89 function setNetworkSelectionMode(options: NetworkSelectionModeOptions, callback: AsyncCallback<void>): void; 90 function setNetworkSelectionMode(options: NetworkSelectionModeOptions): Promise<void>; 91 92 /** 93 * @permission ohos.permission.GET_TELEPHONY_STATE 94 * @systemapi Hide this for inner system use. 95 */ 96 function getNetworkSearchInformation(slotId: number, callback: AsyncCallback<NetworkSearchResult>): void; 97 function getNetworkSearchInformation(slotId: number): Promise<NetworkSearchResult>; 98 99 /** 100 * Obtains the ISO-defined country code of the country where the registered network is deployed. 101 * 102 * @param slotId Indicates the card slot index number, 103 * ranging from 0 to the maximum card slot index number supported by the device. 104 * @param callback Returns the country code defined in ISO 3166-2; 105 * returns an empty string if the device is not registered with any network. 106 * @since 7 107 */ 108 function getISOCountryCodeForNetwork(slotId: number, callback: AsyncCallback<string>): void; 109 function getISOCountryCodeForNetwork(slotId: number): Promise<string>; 110 111 /** 112 * Obtains the list of signal strength information of the registered network corresponding to a specified SIM card. 113 * 114 * @param slotId Indicates the card slot index number, ranging from 0 to the maximum card slot index number 115 * supported by the device. 116 * @param callback Returns the instance list of the child classes derived from {@link SignalInformation}. 117 * @since 7 118 */ 119 function getSignalInformation(slotId: number, callback: AsyncCallback<Array<SignalInformation>>): void; 120 function getSignalInformation(slotId: number): Promise<Array<SignalInformation>>; 121 122 /** 123 * @permission ohos.permission.GET_NETWORK_INFO 124 * @since 7 125 */ 126 function isRadioOn(callback: AsyncCallback<boolean>): void; 127 function isRadioOn(): Promise<boolean>; 128 129 /** 130 * @permission ohos.permission.SET_TELEPHONY_STATE 131 * @systemapi Hide this for inner system use. 132 * @since 7 133 */ 134 function turnOnRadio(callback: AsyncCallback<void>): void; 135 function turnOnRadio(): Promise<void>; 136 137 /** 138 * @permission ohos.permission.SET_TELEPHONY_STATE 139 * @systemapi Hide this for inner system use. 140 * @since 7 141 */ 142 function turnOffRadio(callback: AsyncCallback<void>): void; 143 function turnOffRadio(): Promise<void>; 144 145 /** 146 * Describes the radio access technology. 147 */ 148 export enum RadioTechnology { 149 /** 150 * Indicates unknown radio access technology (RAT). 151 */ 152 RADIO_TECHNOLOGY_UNKNOWN = 0, 153 154 /** 155 * Indicates that RAT is global system for mobile communications (GSM), including GSM, general packet 156 * radio system (GPRS), and enhanced data rates for GSM evolution (EDGE). 157 */ 158 RADIO_TECHNOLOGY_GSM = 1, 159 160 /** 161 * Indicates that RAT is code division multiple access (CDMA), including Interim Standard 95 (IS95) and 162 * Single-Carrier Radio Transmission Technology (1xRTT). 163 */ 164 RADIO_TECHNOLOGY_1XRTT = 2, 165 166 /** 167 * Indicates that RAT is wideband code division multiple address (WCDMA). 168 */ 169 RADIO_TECHNOLOGY_WCDMA = 3, 170 171 /** 172 * Indicates that RAT is high-speed packet access (HSPA), including HSPA, high-speed downlink packet 173 * access (HSDPA), and high-speed uplink packet access (HSUPA). 174 */ 175 RADIO_TECHNOLOGY_HSPA = 4, 176 177 /** 178 * Indicates that RAT is evolved high-speed packet access (HSPA+), including HSPA+ and dual-carrier 179 * HSPA+ (DC-HSPA+). 180 */ 181 RADIO_TECHNOLOGY_HSPAP = 5, 182 183 /** 184 * Indicates that RAT is time division-synchronous code division multiple access (TD-SCDMA). 185 */ 186 RADIO_TECHNOLOGY_TD_SCDMA = 6, 187 188 /** 189 * Indicates that RAT is evolution data only (EVDO), including EVDO Rev.0, EVDO Rev.A, and EVDO Rev.B. 190 */ 191 RADIO_TECHNOLOGY_EVDO = 7, 192 193 /** 194 * Indicates that RAT is evolved high rate packet data (EHRPD). 195 */ 196 RADIO_TECHNOLOGY_EHRPD = 8, 197 198 /** 199 * Indicates that RAT is long term evolution (LTE). 200 */ 201 RADIO_TECHNOLOGY_LTE = 9, 202 203 /** 204 * Indicates that RAT is LTE carrier aggregation (LTE-CA). 205 */ 206 RADIO_TECHNOLOGY_LTE_CA = 10, 207 208 /** 209 * Indicates that RAT is interworking WLAN (I-WLAN). 210 */ 211 RADIO_TECHNOLOGY_IWLAN = 11, 212 213 /** 214 * Indicates that RAT is 5G new radio (NR). 215 */ 216 RADIO_TECHNOLOGY_NR = 12 217 } 218 219 export interface SignalInformation { 220 /** 221 * Obtains the network type corresponding to the signal. 222 */ 223 signalType: NetworkType; 224 225 /** 226 * Obtains the signal level of the current network. 227 */ 228 signalLevel: number; 229 } 230 231 /** 232 * Describes the network type. 233 */ 234 export enum NetworkType { 235 /** 236 * Indicates unknown network type. 237 */ 238 NETWORK_TYPE_UNKNOWN, 239 240 /** 241 * Indicates that the network type is GSM. 242 */ 243 NETWORK_TYPE_GSM, 244 245 /** 246 * Indicates that the network type is CDMA. 247 */ 248 NETWORK_TYPE_CDMA, 249 250 /** 251 * Indicates that the network type is WCDMA. 252 */ 253 NETWORK_TYPE_WCDMA, 254 255 /** 256 * Indicates that the network type is TD-SCDMA. 257 */ 258 NETWORK_TYPE_TDSCDMA, 259 260 /** 261 * Indicates that the network type is LTE. 262 */ 263 NETWORK_TYPE_LTE, 264 265 /** 266 * Indicates that the network type is 5G NR. 267 */ 268 NETWORK_TYPE_NR 269 } 270 271 /** 272 * Describes the network registration state. 273 */ 274 export interface NetworkState { 275 /** 276 * Obtains the operator name in the long alphanumeric format of the registered network. 277 * 278 * @return Returns the operator name in the long alphanumeric format as a string; 279 * returns an empty string if no operator name is obtained. 280 */ 281 longOperatorName: string; 282 283 /** 284 * Obtains the operator name in the short alphanumeric format of the registered network. 285 * 286 * @return Returns the operator name in the short alphanumeric format as a string; 287 * returns an empty string if no operator name is obtained. 288 */ 289 shortOperatorName: string; 290 291 /** 292 * Obtains the PLMN code of the registered network. 293 * 294 * @return Returns the PLMN code as a string; returns an empty string if no operator name is obtained. 295 */ 296 plmnNumeric: string; 297 298 /** 299 * Checks whether the device is roaming. 300 * 301 * @return Returns {@code true} if the device is roaming; returns {@code false} otherwise. 302 */ 303 isRoaming: boolean; 304 305 /** 306 * Obtains the network registration status of the device. 307 * 308 * @return Returns the network registration status {@code RegState}. 309 */ 310 regState: RegState; 311 312 /** 313 * Obtains the NSA network registration status of the device. 314 * 315 * @return Returns the NSA network registration status {@code NsaState}. 316 */ 317 nsaState: NsaState; 318 319 /** 320 * Obtains the status of CA. 321 * 322 * @return Returns {@code true} if CA is actived; returns {@code false} otherwise. 323 */ 324 isCaActive: boolean; 325 326 /** 327 * Checks whether this device is allowed to make emergency calls only. 328 * 329 * @return Returns {@code true} if this device is allowed to make emergency calls only; 330 * returns {@code false} otherwise. 331 */ 332 isEmergency: boolean; 333 } 334 335 /** 336 * Describes the network registration state. 337 */ 338 export enum RegState { 339 /** 340 * Indicates a state in which a device cannot use any service. 341 */ 342 REG_STATE_NO_SERVICE = 0, 343 344 /** 345 * Indicates a state in which a device can use services properly. 346 */ 347 REG_STATE_IN_SERVICE = 1, 348 349 /** 350 * Indicates a state in which a device can use only the emergency call service. 351 */ 352 REG_STATE_EMERGENCY_CALL_ONLY = 2, 353 354 /** 355 * Indicates that the cellular radio is powered off. 356 */ 357 REG_STATE_POWER_OFF = 3 358 } 359 360 /** 361 * Describes the nsa state. 362 */ 363 export enum NsaState { 364 /** 365 * Indicates that a device is idle under or is connected to an LTE cell that does not support NSA. 366 */ 367 NSA_STATE_NOT_SUPPORT = 1, 368 369 /** 370 * Indicates that a device is idle under an LTE cell supporting NSA but not NR coverage detection. 371 */ 372 NSA_STATE_NO_DETECT = 2, 373 374 /** 375 * Indicates that a device is connected to an LTE network under an LTE cell 376 * that supports NSA and NR coverage detection. 377 */ 378 NSA_STATE_CONNECTED_DETECT = 3, 379 380 /** 381 * Indicates that a device is idle under an LTE cell supporting NSA and NR coverage detection. 382 */ 383 NSA_STATE_IDLE_DETECT = 4, 384 385 /** 386 * Indicates that a device is connected to an LTE + NR network under an LTE cell that supports NSA. 387 */ 388 NSA_STATE_DUAL_CONNECTED = 5, 389 390 /** 391 * Indicates that a device is idle under or is connected to an NG-RAN cell while being attached to 5GC. 392 */ 393 NSA_STATE_SA_ATTACHED = 6 394 } 395 396 /** 397 * @systemapi Hide this for inner system use. 398 */ 399 export interface NetworkSearchResult { 400 isNetworkSearchSuccess: boolean; 401 networkSearchResult: Array<NetworkInformation>; 402 } 403 404 /** 405 * @systemapi Hide this for inner system use. 406 */ 407 export interface NetworkInformation { 408 operatorName: string; 409 operatorNumeric: string; 410 state: NetworkInformationState; 411 radioTech: string; 412 } 413 414 /** 415 * @systemapi Hide this for inner system use. 416 */ 417 export enum NetworkInformationState { 418 /** Indicates that the network state is unknown. */ 419 NETWORK_UNKNOWN, 420 421 /** Indicates that the network is available for registration. */ 422 NETWORK_AVAILABLE, 423 424 /** Indicates that you have already registered with the network. */ 425 NETWORK_CURRENT, 426 427 /** Indicates that the network is unavailable for registration. */ 428 NETWORK_FORBIDDEN 429 } 430 431 /** 432 * @systemapi Hide this for inner system use. 433 */ 434 export interface NetworkSelectionModeOptions { 435 slotId: number; 436 selectMode: NetworkSelectionMode; 437 networkInformation: NetworkInformation; 438 resumeSelection: boolean; 439 } 440 441 export enum NetworkSelectionMode { 442 /** Unknown network selection modes. */ 443 NETWORK_SELECTION_UNKNOWN, 444 445 /** Automatic network selection modes. */ 446 NETWORK_SELECTION_AUTOMATIC, 447 448 /** Manual network selection modes. */ 449 NETWORK_SELECTION_MANUAL 450 } 451} 452 453export default radio;