From 74797620d307ebe092833a2f2e1f2ef5f84c89b7 Mon Sep 17 00:00:00 2001 From: clevercong Date: Fri, 18 Feb 2022 16:45:55 +0800 Subject: [PATCH 1/2] update telephony and net js api. Signed-off-by: clevercong --- api/@ohos.net.connection.d.ts | 292 +++++++ api/@ohos.net.http.d.ts | 152 ++++ api/@ohos.net.socket.d.ts | 319 ++++++++ api/@ohos.net.statistics.d.ts | 157 ++++ api/@ohos.telephony.call.d.ts | 1021 ++++++++++++++++-------- api/@ohos.telephony.data.d.ts | 196 +++++ api/@ohos.telephony.observer.d.ts | 113 +++ api/@ohos.telephony.radio.d.ts | 1226 ++++++++++++++++++----------- api/@ohos.telephony.sim.d.ts | 883 +++++++++++++++------ api/@ohos.telephony.sms.d.ts | 947 +++++++++++++++------- 10 files changed, 3979 insertions(+), 1327 deletions(-) create mode 100644 api/@ohos.net.connection.d.ts create mode 100644 api/@ohos.net.http.d.ts create mode 100644 api/@ohos.net.socket.d.ts create mode 100644 api/@ohos.net.statistics.d.ts create mode 100644 api/@ohos.telephony.data.d.ts diff --git a/api/@ohos.net.connection.d.ts b/api/@ohos.net.connection.d.ts new file mode 100644 index 000000000..0014fd3e2 --- /dev/null +++ b/api/@ohos.net.connection.d.ts @@ -0,0 +1,292 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {AsyncCallback, Callback} from "./basic"; +import http from "./@ohos.net.http"; +import socket from "./@ohos.net.socket"; + +/** + * Provides interfaces to manage and use data networks. + * + * @since 8 + * @sysCap SystemCapability.Communication.NetManager.Core + */ +declare namespace connection { + type HttpRequest = http.HttpRequest; + type TCPSocket = socket.TCPSocket; + type UDPSocket = socket.UDPSocket; + + /** + * Create a network connection with optional netSpefifier and timeout. + * + * @param netSpecifier Indicates the network specifier. See {@link NetSpecifier}. + * @param timeout The time in milliseconds to attempt looking for a suitable network before + * {@link NetConnection#netUnavailable} is called. + */ + function createNetConnection(netSpecifier?: NetSpecifier, timeout?: number): NetConnection; + + /** + * Obtains the data network that is activated by default. + * + *

To call this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission. + * + * @param callback Returns the {@link NetHandle} object; + * returns {@code null} if the default network is not activated. + * @permission ohos.permission.GET_NETWORK_INFO + */ + function getDefaultNet(callback: AsyncCallback): void; + function getDefaultNet(): Promise; + + /** + * Obtains the list of data networks that are activated. + * + *

To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission. + * + * @param callback Returns the {@link NetHandle} object; returns {@code null} if no network is activated. + * @permission ohos.permission.GET_NETWORK_INFO + */ + function getAllNets(callback: AsyncCallback>): void; + function getAllNets(): Promise>; + + /** + * Queries the connection properties of a network. + * + *

This method requires the {@code ohos.permission.GET_NETWORK_INFO} permission. + * + * @param netHandle Indicates the network to be queried. + * @param callback Returns the {@link ConnectionProperties} object. + * @permission ohos.permission.GET_NETWORK_INFO + */ + function getConnectionProperties(netHandle: NetHandle, callback: AsyncCallback): void; + function getConnectionProperties(netHandle: NetHandle): Promise; + + /** + * Obtains {@link NetCapabilities} of a {@link NetHandle} object. + * + *

To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission. + * + * @param netHandle Indicates the handle. See {@link NetHandle}. + * @param callback Returns {@link NetCapabilities}; returns {@code null} if {@code handle} is invalid. + * @permission ohos.permission.GET_NETWORK_INFO + */ + function getNetCapabilities(netHandle: NetHandle, callback: AsyncCallback): void; + function getNetCapabilities(netHandle: NetHandle): Promise; + + /** + * Checks whether the default data network is activated. + * + * @param callback Returns {@code true} if the default data network is activated; returns {@code false} otherwise. + */ + function hasDefaultNet(callback: AsyncCallback): void; + function hasDefaultNet(): Promise; + + /** + * Enables the airplane mode for a device. + * + * @systemapi Hide this for inner system use. Only used for system app. + */ + function enableAirplaneMode(callback: AsyncCallback): void; + function enableAirplaneMode(): Promise; + + /** + * Disables the airplane mode for a device. + * + * @systemapi Hide this for inner system use. Only used for system app. + */ + function disableAirplaneMode(callback: AsyncCallback): void; + function disableAirplaneMode(): Promise; + + /** + * Reports the network state is connected. + * + * @param netHandle Indicates the network whose state is to be reported. + * @permission ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET + */ + function reportNetConnected(netHandle: NetHandle, callback: AsyncCallback): void; + function reportNetConnected(netHandle: NetHandle): Promise; + + /** + * Reports the network state is disconnected. + * + * @param netHandle Indicates the network whose state is to be reported. + * @permission ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET + */ + function reportNetDisconnected(netHandle: NetHandle, callback: AsyncCallback): void; + function reportNetDisconnected(netHandle: NetHandle): Promise; + + /** + * Resolves the host name to obtain all IP addresses based on the default data network. + * + * @param host Indicates the host name or the domain. + * @param callback Returns the NetAddress list. + * @permission ohos.permission.GET_NETWORK_INFO + */ + function getAddressesByName(host: string, callback: AsyncCallback>): void; + function getAddressesByName(host: string): Promise>; + + export interface NetConnection { + on(type: 'netAvailable', callback: Callback): void; + + on(type: 'netBlockStatusChange', callback: Callback<{ netHandle: NetHandle, blocked: boolean }>): void; + + on(type: 'netCapabilitiesChange', callback: Callback<{ netHandle: NetHandle, netCap: NetCapabilities }>): void; + + on(type: 'netConnectionPropertiesChange', callback: Callback<{ netHandle: NetHandle, connectionProperties: ConnectionProperties }>): void; + + on(type: 'netLost', callback: Callback): void; + + on(type: 'netUnavailable', callback: Callback): void; + + /** + * Receives status change notifications of a specified network. + * + * @permission ohos.permission.GET_NETWORK_INFO + */ + register(callback: AsyncCallback): void; + + /** + * Cancels listening for network status changes. + */ + unregister(callback: AsyncCallback): void; + } + + export interface NetSpecifier { + netCapabilities: NetCapabilities; + bearerPrivateIdentifier?: string; + } + + export interface NetHandle { + netId: number; + + /** + * Binds a TCPSocket or UDPSocket to the current network. All data flows from + * the socket will use this network, without being subject to {@link setAppNet}. + * Before using this method, ensure that the socket is disconnected. + * + * @param socketParam Indicates the TCPSocket or UDPSocket object. + */ + bindSocket(socketParam: TCPSocket | UDPSocket, callback: AsyncCallback): void; + bindSocket(socketParam: TCPSocket | UDPSocket): Promise; + + /** + * Resolves a host name to obtain all IP addresses based on the specified NetHandle. + * + * @param host Indicates the host name or the domain. + * @param callback Returns the NetAddress list. + */ + getAddressesByName(host: string, callback: AsyncCallback>): void; + getAddressesByName(host: string): Promise>; + + /** + * Resolves a host name to obtain the first IP address based on the specified NetHandle. + * + * @param host Indicates the host name or the domain. + * @return Returns the first NetAddress. + */ + getAddressByName(host: string, callback: AsyncCallback): void; + getAddressByName(host: string): Promise; + } + + export interface NetCapabilities { + linkUpBandwidthKbps?: number; + linkDownBandwidthKbps?: number; + networkCap?: Array; + bearerTypes: Array; + } + + export enum NetCap { + /** + * Indicates that the network can access the carrier's MMSC to send and receive multimedia messages. + */ + NET_CAPABILITY_MMS = 0, + + + /** + * Indicates that the network traffic is not metered. + */ + NET_CAPABILITY_NOT_METERED = 11, + + /** + * Indicates that the network can access the Internet. + */ + NET_CAPABILITY_INTERNET = 12, + + + /** + * Indicates that the network does not use a VPN. + */ + NET_CAPABILITY_NOT_VPN = 15, + + /** + * Indicates that the network is available. + */ + NET_CAPABILITY_VALIDATED = 16, + + } + + export enum NetBearType { + /** + * Indicates that the network is based on a cellular network. + */ + BEARER_CELLULAR = 0, + + /** + * Indicates that the network is based on a Wi-Fi network. + */ + BEARER_WIFI = 1, + + /** + * Indicates that the network is an Ethernet network. + */ + BEARER_ETHERNET = 3, + + } + + export interface ConnectionProperties { + interfaceName: string; + domains: string; + linkAddresses: Array; + dnses: Array; + routes: Array; + mtu: number; + } + + + export interface RouteInfo { + interface: string; + destination: LinkAddress; + gateway: NetAddress; + hasGateway: boolean; + isDefaultRoute: boolean; + } + + export interface LinkAddress { + address: NetAddress; + prefixLength: number; + } + + /** + * @since 7 + */ + export interface NetAddress { + address: string; + family?: number; // IPv4 = 1; IPv6 = 2, default is IPv4 + port?: number; // [0, 65535] + } + + +} + +export default connection; \ No newline at end of file diff --git a/api/@ohos.net.http.d.ts b/api/@ohos.net.http.d.ts new file mode 100644 index 000000000..8e5a182da --- /dev/null +++ b/api/@ohos.net.http.d.ts @@ -0,0 +1,152 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {AsyncCallback, Callback} from "./basic"; + +/** + * Provides http related APIs. + * + * @since 6 + * @sysCap SystemCapability.Communication.NetStack + */ +declare namespace http { + /** + * Creates an HTTP request task. + */ + function createHttp(): HttpRequest; + + export interface HttpRequestOptions { + /** + * Request method. + */ + method?: RequestMethod; // default is GET + /** + * Additional data of the request. + * extraData can be a string or an Object (API 6) or an ArrayBuffer(API 8). + */ + extraData?: string | Object | ArrayBuffer; + /** + * HTTP request header. + */ + header?: Object; // default is 'content-type': 'application/json' + /** + * Read timeout period. The default value is 60,000, in ms. + */ + readTimeout?: number; // default is 60s + /** + * Connection timeout interval. The default value is 60,000, in ms. + */ + connectTimeout?: number; // default is 60s. + } + + export interface HttpRequest { + /** + * Initiates an HTTP request to a given URL. + * + * @param url URL for initiating an HTTP request. + * @param options Optional parameters {@link HttpRequestOptions}. + * @param callback Returns {@link HttpResponse}. + * @permission ohos.permission.INTERNET + */ + request(url: string, callback: AsyncCallback): void; + request(url: string, options: HttpRequestOptions, callback: AsyncCallback): void; + request(url: string, options?: HttpRequestOptions): Promise; + + /** + * Destroys an HTTP request. + */ + destroy(): void; + + /** + * Registers an observer for HTTP Response Header events. + */ + on(type: "headerReceive", callback: AsyncCallback): void; + + /** + * Unregisters the observer for HTTP Response Header events. + */ + off(type: "headerReceive", callback?: AsyncCallback): void; + } + + export enum RequestMethod { + OPTIONS = "OPTIONS", + GET = "GET", + HEAD = "HEAD", + POST = "POST", + PUT = "PUT", + DELETE = "DELETE", + TRACE = "TRACE", + CONNECT = "CONNECT" + } + + export enum ResponseCode { + OK = 200, + CREATED, + ACCEPTED, + NOT_AUTHORITATIVE, + NO_CONTENT, + RESET, + PARTIAL, + MULT_CHOICE = 300, + MOVED_PERM, + MOVED_TEMP, + SEE_OTHER, + NOT_MODIFIED, + USE_PROXY, + BAD_REQUEST = 400, + UNAUTHORIZED, + PAYMENT_REQUIRED, + FORBIDDEN, + NOT_FOUND, + BAD_METHOD, + NOT_ACCEPTABLE, + PROXY_AUTH, + CLIENT_TIMEOUT, + CONFLICT, + GONE, + LENGTH_REQUIRED, + PRECON_FAILED, + ENTITY_TOO_LARGE, + REQ_TOO_LONG, + UNSUPPORTED_TYPE, + INTERNAL_ERROR = 500, + NOT_IMPLEMENTED, + BAD_GATEWAY, + UNAVAILABLE, + GATEWAY_TIMEOUT, + VERSION + } + + export interface HttpResponse { + /** + * result can be a string or an Object (API 6) or an ArrayBuffer(API 8). + */ + result: string | Object | ArrayBuffer; + /** + * Server status code. + */ + responseCode: ResponseCode | number; + /** + * All headers in the response from the server. + */ + header: Object; + /** + * @since 8 + */ + cookies: string; + } +} + +export default http; \ No newline at end of file diff --git a/api/@ohos.net.socket.d.ts b/api/@ohos.net.socket.d.ts new file mode 100644 index 000000000..61d4ea416 --- /dev/null +++ b/api/@ohos.net.socket.d.ts @@ -0,0 +1,319 @@ +/* +* Copyright (C) 2021 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import {AsyncCallback, Callback, ErrorCallback} from "./basic"; +import connection from "./@ohos.net.connection"; + +/** + * Provides TCP and UDP Socket APIs. + * + * @since 7 + * @sysCap SystemCapability.Communication.NetStack + */ +declare namespace socket { + export import NetAddress = connection.NetAddress; + + /** + * Creates a UDPSocket object. + */ + function constructUDPSocketInstance(): UDPSocket; + + /** + * Creates a TCPSocket object. + */ + function constructTCPSocketInstance(): TCPSocket; + + export interface UDPSendOptions { + /** + * Data to send. + */ + data: string | ArrayBuffer; + /** + * Destination address. + */ + address: NetAddress; + } + + export interface ExtraOptionsBase { + /** + * Size of the receive buffer, in MBS. + */ + receiveBufferSize?: number; + /** + * Size of the send buffer, in MBS. + */ + sendBufferSize?: number; + /** + * Whether to reuse addresses. The default value is false. + */ + reuseAddress?: boolean; + /** + * Timeout duration of the UDPSocket connection, in milliseconds. + */ + socketTimeout?: number; + } + + export interface UDPExtraOptions extends ExtraOptionsBase { + /** + * Whether to send broadcast messages. The default value is false. + */ + broadcast?: boolean; + } + + export interface SocketStateBase { + /** + * Whether the connection is in the bound state. + */ + isBound: boolean; + /** + * Whether the connection is in the closed state. + */ + isClose: boolean; + /** + * Whether the connection is in the connected state. + */ + isConnected: boolean; + } + + export interface SocketRemoteInfo { + /** + * Bound IP address. + */ + address: string; + /** + * Network protocol type. The options are as follows: IPv4, IPv6. + */ + family: 'IPv4' | 'IPv6'; + /** + * Port number. The value ranges from 0 to 65535. + */ + port: number; + /** + * Length of the server response message, in bytes. + */ + size: number; + } + + export interface UDPSocket { + /** + * Binds the IP address and port number. The port number can be specified or randomly allocated by the system. + * + * @param address Destination address. {@link NetAddress} + * @permission ohos.permission.INTERNET + */ + bind(address: NetAddress, callback: AsyncCallback): void; + bind(address: NetAddress): Promise; + + /** + * Sends data over a UDPSocket connection. + * + * @param options Optional parameters {@link UDPSendOptions}. + * @permission ohos.permission.INTERNET + */ + send(options: UDPSendOptions, callback: AsyncCallback): void; + send(options: UDPSendOptions): Promise; + + /** + * Closes a UDPSocket connection. + * @permission ohos.permission.INTERNET + */ + close(callback: AsyncCallback): void; + close(): Promise; + + /** + * Obtains the status of the UDPSocket connection. + * + * @param callback Callback used to return the result. {@link SocketStateBase}. + * @permission ohos.permission.INTERNET + */ + getState(callback: AsyncCallback): void; + getState(): Promise; + + /** + * Sets other attributes of the UDPSocket connection. + * + * @param options Optional parameters {@link UDPExtraOptions}. + * @permission ohos.permission.INTERNET + */ + setExtraOptions(options: UDPExtraOptions, callback: AsyncCallback): void; + setExtraOptions(options: UDPExtraOptions): Promise; + + /** + * Listens for message receiving events of the UDPSocket connection. + */ + on(type: 'message', callback: Callback<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}>): void; + + /** + * Cancels listening for message receiving events of the UDPSocket connection. + */ + off(type: 'message', callback?: Callback<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}>): void; + + /** + * Listens for data packet message events or close events of the UDPSocket connection. + */ + on(type: 'listening' | 'close', callback: Callback): void; + + /** + * Cancels listening for data packet message events or close events of the UDPSocket connection. + */ + off(type: 'listening' | 'close', callback?: Callback): void; + + /** + * Listens for error events of the UDPSocket connection. + */ + on(type: 'error', callback: ErrorCallback): void; + + /** + * Cancels listening for error events of the UDPSocket connection. + */ + off(type: 'error', callback?: ErrorCallback): void; + } + + export interface TCPConnectOptions { + /** + * Bound IP address and port number. + */ + address: NetAddress; + /** + * Timeout duration of the TCPSocket connection, in milliseconds. + */ + timeout?: number; + } + + export interface TCPSendOptions { + /** + * Data to send. + */ + data: string | ArrayBuffer; + /** + * Character encoding format. + */ + encoding?: string; + } + + export interface TCPExtraOptions extends ExtraOptionsBase { + /** + * Whether to keep the connection alive. The default value is false. + */ + keepAlive?: boolean; + /** + * Whether to enable OOBInline. The default value is false. + */ + OOBInline?: boolean; + /** + * Whether to enable no-delay on the TCPSocket connection. The default value is false. + */ + TCPNoDelay?: boolean; + /** + * Socket linger. + */ + socketLinger: {on: boolean, linger: number}; + } + + export interface TCPSocket { + /** + * Binds the IP address and port number. The port number can be specified or randomly allocated by the system. + * + * @param address Destination address. {@link NetAddress} + * @permission ohos.permission.INTERNET + */ + bind(address: NetAddress, callback: AsyncCallback): void; + bind(address: NetAddress): Promise; + + /** + * Sets up a connection to the specified IP address and port number. + * + * @param options Optional parameters {@link TCPConnectOptions}. + * @permission ohos.permission.INTERNET + */ + connect(options: TCPConnectOptions, callback: AsyncCallback): void; + connect(options: TCPConnectOptions): Promise; + + /** + * Sends data over a TCPSocket connection. + * + * @param options Optional parameters {@link TCPSendOptions}. + * @permission ohos.permission.INTERNET + */ + send(options: TCPSendOptions, callback: AsyncCallback): void; + send(options: TCPSendOptions): Promise; + + /** + * Closes a TCPSocket connection. + * @permission ohos.permission.INTERNET + */ + close(callback: AsyncCallback): void; + close(): Promise; + + /** + * Obtains the peer address of a TCPSocket connection. + * + * @param callback Callback used to return the result. {@link NetAddress} + * @permission ohos.permission.INTERNET + */ + getRemoteAddress(callback: AsyncCallback): void; + getRemoteAddress(): Promise; + + /** + * Obtains the status of the TCPSocket connection. + * + * @param callback Callback used to return the result. {@link SocketStateBase} + * @permission ohos.permission.INTERNET + */ + getState(callback: AsyncCallback): void; + getState(): Promise; + + /** + * Sets other attributes of the TCPSocket connection. + * + * @param options Optional parameters {@link TCPExtraOptions}. + * @permission ohos.permission.INTERNET + */ + setExtraOptions(options: TCPExtraOptions, callback: AsyncCallback): void; + setExtraOptions(options: TCPExtraOptions): Promise; + + /** + * Listens for message receiving events of the TCPSocket connection. + */ + on(type: 'message', callback: Callback<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}>): void; + + /** + * Cancels listening for message receiving events of the TCPSocket connection. + */ + off(type: 'message', callback?: Callback<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}>): void; + + /** + * Listens for connection or close events of the TCPSocket connection. + */ + on(type: 'connect' | 'close', callback: Callback): void; + + /** + * Cancels listening for connection or close events of the TCPSocket connection. + */ + off(type: 'connect' | 'close', callback?: Callback): void; + + /** + * Listens for error events of the TCPSocket connection. + */ + on(type: 'error', callback: ErrorCallback): void; + + /** + * Cancels listening for error events of the TCPSocket connection. + */ + off(type: 'error', callback?: ErrorCallback): void; + } +} + +export default socket; \ No newline at end of file diff --git a/api/@ohos.net.statistics.d.ts b/api/@ohos.net.statistics.d.ts new file mode 100644 index 000000000..3b53cec6a --- /dev/null +++ b/api/@ohos.net.statistics.d.ts @@ -0,0 +1,157 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {AsyncCallback, Callback} from "./basic"; + +/** + * Obtains traffic statistics. + * + * @since 8 + * @sysCap SystemCapability.Communication.NetManager.Core + */ +declare namespace statistics { + /** + * Queries the data traffic (including all TCP and UDP data packets) received through a specified NIC. + * + * @param nic Indicates the NIC name. + * @param callback Returns the data traffic received through the specified NIC. + */ + function getIfaceRxBytes(nic: string, callback: AsyncCallback): void; + function getIfaceRxBytes(nic: string): Promise; + + /** + * Queries the data traffic (including all TCP and UDP data packets) sent through a specified NIC. + * + * @param nic Indicates the NIC name. + * @param callback Returns the data traffic sent through the specified NIC. + */ + function getIfaceTxBytes(nic: string, callback: AsyncCallback): void; + function getIfaceTxBytes(nic: string): Promise; + + /** + * Queries the data traffic (including all TCP and UDP data packets) received through the cellular network. + * + * @param callback Returns the data traffic received through the cellular network. + */ + function getCellularRxBytes(callback: AsyncCallback): void; + function getCellularRxBytes(): Promise; + + /** + * Queries the data traffic (including all TCP and UDP data packets) sent through the cellular network. + * + * @param callback Returns the data traffic sent through the cellular network. + */ + function getCellularTxBytes(callback: AsyncCallback): void; + function getCellularTxBytes(): Promise; + + /** + * Queries the data traffic (including all TCP and UDP data packets) sent through all NICs. + * + * @param callback Returns the data traffic sent through all NICs. + */ + function getAllTxBytes(callback: AsyncCallback): void; + function getAllTxBytes(): Promise; + + /** + * Queries the data traffic (including all TCP and UDP data packets) received through all NICs. + * + * @param callback Returns the data traffic received through all NICs. + */ + function getAllRxBytes(callback: AsyncCallback): void; + function getAllRxBytes(): Promise; + + /** + * Queries the data traffic (including all TCP and UDP data packets) received by a specified application. + * This method applies only to system applications and your own applications. + * + * @param uid Indicates the process ID of the application. + * @param callback Returns the data traffic received by the specified application. + */ + function getUidRxBytes(uid: number, callback: AsyncCallback): void; + function getUidRxBytes(uid: number): Promise; + + /** + * Queries the data traffic (including all TCP and UDP data packets) sent by a specified application. + * This method applies only to system applications and your own applications. + * + * @param uid Indicates the process ID of the application. + * @param callback Returns the data traffic sent by the specified application. + */ + function getUidTxBytes(uid: number, callback: AsyncCallback): void; + function getUidTxBytes(uid: number): Promise; + + /** + * Register notifications of network traffic updates, restrictions, and warnings. + * + * @permission ohos.permission.GET_NETSTATS_SUMMARY + * @systemapi Hide this for inner system use. + */ + function on(type: 'netStatsChange', callback: Callback<{ iface: string, uid?: number }>): void; + + /** + * @systemapi Hide this for inner system use. + */ + function off(type: 'netStatsChange', callback?: Callback<{ iface: string, uid?: number }>): void; + + /** + * Get the traffic usage details of the network interface in the specified time period. + * + * @param IfaceInfo Indicates the handle. See {@link IfaceInfo}. + * @permission ohos.permission.GET_NETSTATS_SUMMARY + * @systemapi Hide this for inner system use. + */ + function getIfaceStats(ifaceInfo: IfaceInfo, callback: AsyncCallback): void; + function getIfaceStats(ifaceInfo: IfaceInfo): Promise; + + /** + * Get the traffic usage details of the specified time period of the application. + * + * @param UidStatsInfo Indicates the handle. See {@link UidStatsInfo}. + * @permission ohos.permission.GET_NETSTATS_SUMMARY + * @systemapi Hide this for inner system use. + */ + function getIfaceUidStats(uidStatsInfo: UidStatsInfo, callback: AsyncCallback): void; + function getIfaceUidStats(uidStatsInfo: UidStatsInfo): Promise; + + /** + * @systemapi Hide this for inner system use. + */ + export interface IfaceInfo { + iface: string; + startTime: number; + endTime: number; + } + + /** + * @systemapi Hide this for inner system use. + */ + export interface UidStatsInfo { + /*See {@link IfaceInfo}*/ + ifaceInfo: IfaceInfo; + uid: number; + } + + /** + * @systemapi Hide this for inner system use. + */ + export interface NetStatsInfo { + rxBytes: number; + txBytes: number; + rxPackets: number; + txPackets: number; + } +} + +export default statistics; \ No newline at end of file diff --git a/api/@ohos.telephony.call.d.ts b/api/@ohos.telephony.call.d.ts index 25680a731..e2d30005e 100644 --- a/api/@ohos.telephony.call.d.ts +++ b/api/@ohos.telephony.call.d.ts @@ -1,338 +1,685 @@ -/* -* Copyright (C) 2021 Huawei Device Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import {AsyncCallback, Callback} from "./basic"; - -/** - * Provides methods related to call management. - * - * @since 6 - * @sysCap SystemCapability.Telephony.DCall - */ -declare namespace call { - /** - * Makes a call. - * - *

Applications must have the {@code ohos.permission.PLACE_CALL} permission to call this method. - * - * @param phoneNumber Indicates the called number. - * @param options Indicates additional information carried in the call. - * @param callback Returns {@code true} if the call request is successful; returns {@code false} otherwise. - * Note that the value {@code true} indicates only the successful processing of the request; it does not mean - * that the call is or can be connected. - * @permission ohos.permission.PLACE_CALL - */ - function dial(phoneNumber: string, callback: AsyncCallback): void; - function dial(phoneNumber: string, options: DialOptions, callback: AsyncCallback): void; - function dial(phoneNumber: string, options?: DialOptions): Promise; - - /** - * Checks whether a call is ongoing. - * - * @param callback Returns {@code true} if at least one call is not in the {@link CallState#CALL_STATE_IDLE} - * state; returns {@code false} otherwise. - */ - function hasCall(callback: AsyncCallback): void; - function hasCall(): Promise; - - /** - * Obtains the call state. - * - *

If an incoming call is ringing or waiting, the system returns {@code CallState#CALL_STATE_RINGING}. - * If at least one call is in the active, hold, or dialing state, the system returns - * {@code CallState#CALL_STATE_OFFHOOK}. - * In other cases, the system returns {@code CallState#CALL_STATE_IDLE}. - * - * @param callback Returns the call state. - */ - function getCallState(callback: AsyncCallback): void; - function getCallState(): Promise; - - /** - * Checks whether a phone number is on the emergency number list. - * - * @param phoneNumber Indicates the phone number to check. - * @param callback Returns {@code true} if the phone number is on the emergency number list; - * returns {@code false} otherwise. - * @since 7 - */ - function isEmergencyPhoneNumber(phoneNumber: string, callback: AsyncCallback): void; - function isEmergencyPhoneNumber(phoneNumber: string, options: EmergencyNumberOptions, callback: AsyncCallback): void; - function isEmergencyPhoneNumber(phoneNumber: string, options?: EmergencyNumberOptions): Promise; - - /** - * Formats a phone number according to the Chinese Telephone Code Plan. Before the formatting, - * a phone number is in the format of country code (if any) + 3-digit service provider code - * + 4-digit area code + 4-digit subscriber number. After the formatting, - * each part is separated by a space. - * - * @param phoneNumber Indicates the phone number to format. - * @param callback Returns the phone number after being formatted; returns an empty string - * if the input phone number is invalid. - * @since 7 - */ - function formatPhoneNumber(phoneNumber: string, callback: AsyncCallback): void; - function formatPhoneNumber(phoneNumber: string, options: NumberFormatOptions, callback: AsyncCallback): void; - function formatPhoneNumber(phoneNumber: string, options?: NumberFormatOptions): Promise; - - /** - * Formats a phone number into an E.164 representation. - * - * @param phoneNumber Indicates the phone number to format. - * @param countryCode Indicates a two-digit country code defined in ISO 3166-1. - * @param callback Returns an E.164 number; returns an empty string if the input phone number is invalid. - * @since 7 - */ - function formatPhoneNumberToE164(phoneNumber: string, countryCode: string, callback: AsyncCallback): void; - function formatPhoneNumberToE164(phoneNumber: string, countryCode: string): Promise; - - /** - * @systemapi Hide this for inner system use. - * @since 7 - */ - function answer(callId: number, callback: AsyncCallback): void; - function answer(callId: number): Promise; - - /** - * @systemapi Hide this for inner system use. - * @since 7 - */ - function hangup(callId: number, callback: AsyncCallback): void; - function hangup(callId: number): Promise; - - /** - * @systemapi Hide this for inner system use. - * @since 7 - */ - function reject(callId: number, callback: AsyncCallback): void; - function reject(callId: number, options: RejectMessageOptions, callback: AsyncCallback): void; - function reject(callId: number, options?: RejectMessageOptions): Promise; - - /** - * @systemapi Hide this for inner system use. - */ - function holdCall(callId: number, callback: AsyncCallback): void; - function holdCall(callId: number): Promise; - - /** - * @systemapi Hide this for inner system use. - */ - function unHoldCall(callId: number, callback: AsyncCallback): void; - function unHoldCall(callId: number): Promise; - - /** - * @systemapi Hide this for inner system use. - */ - function switchCall(callId: number, callback: AsyncCallback): void; - function switchCall(callId: number): Promise; - - /** - * @systemapi Hide this for inner system use. - * @since 7 - */ - function combineConference(callId: number, callback: AsyncCallback): void; - function combineConference(callId: number): Promise; - - /** - * @systemapi Hide this for inner system use. - * @since 7 - */ - function getMainCallId(callId: number, callback: AsyncCallback): void; - function getMainCallId(callId: number): Promise; - - /** - * @systemapi Hide this for inner system use. - * @since 7 - */ - function getSubCallIdList(callId: number, callback: AsyncCallback>): void; - function getSubCallIdList(callId: number): Promise>; - - /** - * @systemapi Hide this for inner system use. - * @since 7 - */ - function getCallIdListForConference(callId: number, callback: AsyncCallback>): void; - function getCallIdListForConference(callId: number): Promise>; - - /** - * @systemapi Hide this for inner system use. - * @since 7 - */ - function getCallWaitingStatus(slotId: number, callback: AsyncCallback): void; - function getCallWaitingStatus(slotId: number): Promise; - - /** - * @systemapi Hide this for inner system use. - * @since 7 - */ - function setCallWaiting(slotId: number, activate: boolean, callback: AsyncCallback): void; - function setCallWaiting(slotId: number, activate: boolean): Promise; - - /** - * @systemapi Hide this for inner system use. - * @since 7 - */ - function startDTMF(callId: number, character: string, callback: AsyncCallback): void; - function startDTMF(callId: number, character: string): Promise; - - /** - * @systemapi Hide this for inner system use. - * @since 7 - */ - function stopDTMF(callId: number, callback: AsyncCallback): void; - function stopDTMF(callId: number): Promise; - - /** - * @permission ohos.permission.SET_TELEPHONY_STATE - * @systemapi Hide this for inner system use. - * @since 7 - */ - function isInEmergencyCall(callback: AsyncCallback): void; - function isInEmergencyCall(): Promise; - - /** - * @systemapi Hide this for inner system use. - * @since 7 - */ - function on(type: 'callDetailsChange', callback: Callback): void; - function off(type: 'callDetailsChange', callback?: Callback): void; - - /** - * @systemapi Hide this for inner system use. - * @since 7 - */ - export interface CallAttributeOptions { - accountNumber: string, - speakerphoneOn: boolean, - accountId: number, - videoState: VideoStateType, - startTime: number, - isEcc: boolean, - callType: CallType, - callId: number, - callState: DetailedCallState, - conferenceState: ConferenceState, - } - - /** - * @systemapi Hide this for inner system use. - * @since 7 - */ - export enum ConferenceState { - TEL_CONFERENCE_IDLE = 0, - TEL_CONFERENCE_ACTIVE, - TEL_CONFERENCE_DISCONNECTING, - TEL_CONFERENCE_DISCONNECTED, - } - - /** - * @systemapi Hide this for inner system use. - * @since 7 - */ - export enum CallType { - TYPE_CS = 0, // CS - TYPE_IMS = 1, // IMS - TYPE_OTT = 2, // OTT - TYPE_ERR_CALL = 3, // OTHER - } - - /** - * @systemapi Hide this for inner system use. - * @since 7 - */ - export enum VideoStateType { - TYPE_VOICE = 0, // Voice - TYPE_VIDEO, // Video - } - - /** - * @systemapi Hide this for inner system use. - * @since 7 - */ - export enum DetailedCallState { - CALL_STATUS_ACTIVE = 0, - CALL_STATUS_HOLDING, - CALL_STATUS_DIALING, - CALL_STATUS_ALERTING, - CALL_STATUS_INCOMING, - CALL_STATUS_WAITING, - CALL_STATUS_DISCONNECTED, - CALL_STATUS_DISCONNECTING, - CALL_STATUS_IDLE, - } - - export enum CallState { - /** - * Indicates an invalid state, which is used when the call state fails to be obtained. - */ - CALL_STATE_UNKNOWN = -1, - - /** - * Indicates that there is no ongoing call. - */ - CALL_STATE_IDLE = 0, - - /** - * Indicates that an incoming call is ringing or waiting. - */ - CALL_STATE_RINGING = 1, - - /** - * Indicates that a least one call is in the dialing, active, or hold state, and there is no new incoming call - * ringing or waiting. - */ - CALL_STATE_OFFHOOK = 2 - } - - export interface DialOptions { - /** - * boolean means whether the call to be made is a video call. The value {@code false} indicates a voice call. - */ - extras?: boolean; - } - - /** - * @systemapi Hide this for inner system use. - * @since 7 - */ - export interface RejectMessageOptions { - messageContent: string, - } - - /** - * @systemapi Hide this for inner system use. - * @since 7 - */ - export enum CallWaitingStatus { - CALL_WAITING_DISABLE = 0, - CALL_WAITING_ENABLE = 1 - } - - /** - * @since 7 - */ - export interface EmergencyNumberOptions { - slotId?: number; - } - - /** - * @since 7 - */ - export interface NumberFormatOptions { - countryCode?: string; - } -} - +/* +* Copyright (C) 2021 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import {AsyncCallback, Callback} from "./basic"; + +/** + * Provides methods related to call management. + * + * @since 6 + * @sysCap SystemCapability.Telephony.CallManager + */ +declare namespace call { + /** + * Makes a call. + * + *

Applications must have the {@code ohos.permission.PLACE_CALL} permission to call this method. + * + * @param phoneNumber Indicates the called number. + * @param options Indicates additional information carried in the call. + * @param callback Returns {@code true} if the call request is successful; returns {@code false} otherwise. + * Note that the value {@code true} indicates only the successful processing of the request; it does not mean + * that the call is or can be connected. + * @permission ohos.permission.PLACE_CALL + */ + function dial(phoneNumber: string, callback: AsyncCallback): void; + function dial(phoneNumber: string, options: DialOptions, callback: AsyncCallback): void; + function dial(phoneNumber: string, options?: DialOptions): Promise; + + /** + * Checks whether a call is ongoing. + * + * @param callback Returns {@code true} if at least one call is not in the {@link CallState#CALL_STATE_IDLE} + * state; returns {@code false} otherwise. + */ + function hasCall(callback: AsyncCallback): void; + function hasCall(): Promise; + + /** + * Obtains the call state. + * + *

If an incoming call is ringing or waiting, the system returns {@code CallState#CALL_STATE_RINGING}. + * If at least one call is in the active, hold, or dialing state, the system returns + * {@code CallState#CALL_STATE_OFFHOOK}. + * In other cases, the system returns {@code CallState#CALL_STATE_IDLE}. + * + * @param callback Returns the call state. + */ + function getCallState(callback: AsyncCallback): void; + function getCallState(): Promise; + + /** + * Stops the ringtone. + * + *

If an incoming call is ringing, the phone stops ringing. Otherwise, this method does not function. + * + * @permission ohos.permission.SET_TELEPHONY_STATE or System App + * @systemapi Hide this for inner system use. + * @since 8 + */ + function muteRinger(callback: AsyncCallback): void; + function muteRinger(): Promise; + + /** + * Checks whether a phone number is on the emergency number list. + * + * @param phoneNumber Indicates the phone number to check. + * @param callback Returns {@code true} if the phone number is on the emergency number list; + * returns {@code false} otherwise. + * @since 7 + */ + function isEmergencyPhoneNumber(phoneNumber: string, callback: AsyncCallback): void; + function isEmergencyPhoneNumber(phoneNumber: string, options: EmergencyNumberOptions, callback: AsyncCallback): void; + function isEmergencyPhoneNumber(phoneNumber: string, options?: EmergencyNumberOptions): Promise; + + /** + * Formats a phone number according to the Chinese Telephone Code Plan. Before the formatting, + * a phone number is in the format of country code (if any) + 3-digit service provider code + * + 4-digit area code + 4-digit subscriber number. After the formatting, + * each part is separated by a space. + * + * @param phoneNumber Indicates the phone number to format. + * @param callback Returns the phone number after being formatted; returns an empty string + * if the input phone number is invalid. + * @since 7 + */ + function formatPhoneNumber(phoneNumber: string, callback: AsyncCallback): void; + function formatPhoneNumber(phoneNumber: string, options: NumberFormatOptions, callback: AsyncCallback): void; + function formatPhoneNumber(phoneNumber: string, options?: NumberFormatOptions): Promise; + + /** + * Formats a phone number into an E.164 representation. + * + * @param phoneNumber Indicates the phone number to format. + * @param countryCode Indicates a two-digit country code defined in ISO 3166-1. + * @param callback Returns an E.164 number; returns an empty string if the input phone number is invalid. + * @since 7 + */ + function formatPhoneNumberToE164(phoneNumber: string, countryCode: string, callback: AsyncCallback): void; + function formatPhoneNumberToE164(phoneNumber: string, countryCode: string): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function answer(callId: number, callback: AsyncCallback): void; + function answer(callId: number): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function hangup(callId: number, callback: AsyncCallback): void; + function hangup(callId: number): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function reject(callId: number, callback: AsyncCallback): void; + function reject(callId: number, options: RejectMessageOptions, callback: AsyncCallback): void; + function reject(callId: number, options?: RejectMessageOptions): Promise; + + /** + * @systemapi Hide this for inner system use. + */ + function holdCall(callId: number, callback: AsyncCallback): void; + function holdCall(callId: number): Promise; + + /** + * @systemapi Hide this for inner system use. + */ + function unHoldCall(callId: number, callback: AsyncCallback): void; + function unHoldCall(callId: number): Promise; + + /** + * @systemapi Hide this for inner system use. + */ + function switchCall(callId: number, callback: AsyncCallback): void; + function switchCall(callId: number): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function combineConference(callId: number, callback: AsyncCallback): void; + function combineConference(callId: number): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function getMainCallId(callId: number, callback: AsyncCallback): void; + function getMainCallId(callId: number): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function getSubCallIdList(callId: number, callback: AsyncCallback>): void; + function getSubCallIdList(callId: number): Promise>; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function getCallIdListForConference(callId: number, callback: AsyncCallback>): void; + function getCallIdListForConference(callId: number): Promise>; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function getCallWaitingStatus(slotId: number, callback: AsyncCallback): void; + function getCallWaitingStatus(slotId: number): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function setCallWaiting(slotId: number, activate: boolean, callback: AsyncCallback): void; + function setCallWaiting(slotId: number, activate: boolean): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function startDTMF(callId: number, character: string, callback: AsyncCallback): void; + function startDTMF(callId: number, character: string): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function stopDTMF(callId: number, callback: AsyncCallback): void; + function stopDTMF(callId: number): Promise; + + /** + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 7 + */ + function isInEmergencyCall(callback: AsyncCallback): void; + function isInEmergencyCall(): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function on(type: 'callDetailsChange', callback: Callback): void; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function off(type: 'callDetailsChange', callback?: Callback): void; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function on(type: 'callEventChange', callback: Callback): void; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function off(type: 'callEventChange', callback?: Callback): void; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function on(type: 'callDisconnectedCause', callback: Callback): void; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function off(type: 'callDisconnectedCause', callback?: Callback): void; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function isNewCallAllowed(callback: AsyncCallback): void; + function isNewCallAllowed(): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function separateConference(callId: number, callback: AsyncCallback): void; + function separateConference(callId: number): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function getCallRestrictionStatus(slotId: number, type: CallRestrictionType, callback: AsyncCallback): void; + function getCallRestrictionStatus(slotId: number, type: CallRestrictionType): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function setCallRestriction(slotId: number, info: CallRestrictionInfo, callback: AsyncCallback): void; + function setCallRestriction(slotId: number, info: CallRestrictionInfo): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function getCallTransferInfo(slotId: number, type: CallTransferType, callback: AsyncCallback): void; + function getCallTransferInfo(slotId: number, type: CallTransferType): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function setCallTransfer(slotId: number, info: CallTransferInfo, callback: AsyncCallback): void; + function setCallTransfer(slotId: number, info: CallTransferInfo): Promise; + + /** + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 8 + */ + function isRinging(callback: AsyncCallback): void; + function isRinging(): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function setMuted(callback: AsyncCallback): void; + function setMuted(): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function cancelMuted(callback: AsyncCallback): void; + function cancelMuted(): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function setAudioDevice(device: AudioDevice, callback: AsyncCallback): void; + function setAudioDevice(device: AudioDevice): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function joinConference(mainCallId: number, callNumberList: Array, callback: AsyncCallback): void; + function joinConference(mainCallId: number, callNumberList: Array): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function updateImsCallMode(callId: number, mode: ImsCallMode, callback: AsyncCallback): void; + function updateImsCallMode(callId: number, mode: ImsCallMode): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function enableImsSwitch(slotId: number, callback: AsyncCallback): void; + function enableImsSwitch(slotId: number): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function disableImsSwitch(slotId: number, callback: AsyncCallback): void; + function disableImsSwitch(slotId: number): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function isImsSwitchEnabled(slotId: number, callback: AsyncCallback): void; + function isImsSwitchEnabled(slotId: number): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum ImsCallMode { + CALL_MODE_AUDIO_ONLY = 0, + CALL_MODE_SEND_ONLY, + CALL_MODE_RECEIVE_ONLY, + CALL_MODE_SEND_RECEIVE, + CALL_MODE_VIDEO_PAUSED, + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum AudioDevice { + DEVICE_MIC, + DEVICE_SPEAKER, + DEVICE_WIRED_HEADSET, + DEVICE_BLUETOOTH_SCO + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum CallRestrictionType { + RESTRICTION_TYPE_ALL_INCOMING = 0, + RESTRICTION_TYPE_ALL_OUTGOING, + RESTRICTION_TYPE_INTERNATIONAL, + RESTRICTION_TYPE_INTERNATIONAL_EXCLUDING_HOME, + RESTRICTION_TYPE_ROAMING_INCOMING, + RESTRICTION_TYPE_ALL_CALLS, + RESTRICTION_TYPE_OUTGOING_SERVICES, + RESTRICTION_TYPE_INCOMING_SERVICES, + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export interface CallTransferInfo { + transferNum: string, + type: CallTransferType, + settingType: CallTransferSettingType + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum CallTransferType { + TRANSFER_TYPE_UNCONDITIONAL = 0, + TRANSFER_TYPE_BUSY, + TRANSFER_TYPE_NO_REPLY, + TRANSFER_TYPE_NOT_REACHABLE, + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum CallTransferSettingType { + CALL_TRANSFER_DISABLE = 0, + CALL_TRANSFER_ENABLE = 1, + CALL_TRANSFER_REGISTRATION = 3, + CALL_TRANSFER_ERASURE = 4, + } + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + export interface CallAttributeOptions { + accountNumber: string, + speakerphoneOn: boolean, + accountId: number, + videoState: VideoStateType, + startTime: number, + isEcc: boolean, + callType: CallType, + callId: number, + callState: DetailedCallState, + conferenceState: ConferenceState, + } + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + export enum ConferenceState { + TEL_CONFERENCE_IDLE = 0, + TEL_CONFERENCE_ACTIVE, + TEL_CONFERENCE_DISCONNECTING, + TEL_CONFERENCE_DISCONNECTED, + } + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + export enum CallType { + TYPE_CS = 0, // CS + TYPE_IMS = 1, // IMS + TYPE_OTT = 2, // OTT + TYPE_ERR_CALL = 3, // OTHER + } + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + export enum VideoStateType { + TYPE_VOICE = 0, // Voice + TYPE_VIDEO, // Video + } + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + export enum DetailedCallState { + CALL_STATUS_ACTIVE = 0, + CALL_STATUS_HOLDING, + CALL_STATUS_DIALING, + CALL_STATUS_ALERTING, + CALL_STATUS_INCOMING, + CALL_STATUS_WAITING, + CALL_STATUS_DISCONNECTED, + CALL_STATUS_DISCONNECTING, + CALL_STATUS_IDLE, + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export interface CallRestrictionInfo { + type: CallRestrictionType, + password: string + mode: CallRestrictionMode + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum CallRestrictionMode { + RESTRICTION_MODE_DEACTIVATION = 0, + RESTRICTION_MODE_ACTIVATION, + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export interface CallEventOptions { + eventId: CallAbilityEventId, + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum CallAbilityEventId { + EVENT_DIAL_NO_CARRIER = 1, + EVENT_INVALID_FDN_NUMBER, + } + + export enum CallState { + /** + * Indicates an invalid state, which is used when the call state fails to be obtained. + */ + CALL_STATE_UNKNOWN = -1, + + /** + * Indicates that there is no ongoing call. + */ + CALL_STATE_IDLE = 0, + + /** + * Indicates that an incoming call is ringing or waiting. + */ + CALL_STATE_RINGING = 1, + + /** + * Indicates that a least one call is in the dialing, active, or hold state, and there is no new incoming call + * ringing or waiting. + */ + CALL_STATE_OFFHOOK = 2 + } + + export interface DialOptions { + /** + * boolean means whether the call to be made is a video call. The value {@code false} indicates a voice call. + */ + extras?: boolean; + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + accountId?: number; + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + videoState?: VideoStateType; + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + dialScene?: DialScene; + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + dialType?: DialType; + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum DialScene { + CALL_NORMAL = 0, + CALL_PRIVILEGED = 1, + CALL_EMERGENCY = 2, + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum DialType { + DIAL_CARRIER_TYPE = 0, + DIAL_VOICE_MAIL_TYPE = 1, + DIAL_OTT_TYPE = 2, + } + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + export interface RejectMessageOptions { + messageContent: string; + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export interface CallTransferResult { + status: TransferStatus; + number: string; + } + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + export enum CallWaitingStatus { + CALL_WAITING_DISABLE = 0, + CALL_WAITING_ENABLE = 1 + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum RestrictionStatus { + RESTRICTION_DISABLE = 0, + RESTRICTION_ENABLE = 1 + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum TransferStatus { + TRANSFER_DISABLE = 0, + TRANSFER_ENABLE = 1 + } + + /** + * @since 7 + */ + export interface EmergencyNumberOptions { + slotId?: number; + } + + /** + * @since 7 + */ + export interface NumberFormatOptions { + countryCode?: string; + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum DisconnectedDetails { + UNASSIGNED_NUMBER = 1, + NO_ROUTE_TO_DESTINATION = 3, + CHANNEL_UNACCEPTABLE = 6, + OPERATOR_DETERMINED_BARRING = 8, + NORMAL_CALL_CLEARING = 16, + USER_BUSY = 17, + NO_USER_RESPONDING = 18, + USER_ALERTING_NO_ANSWER = 19, + CALL_REJECTED = 21, + NUMBER_CHANGED = 22, + DESTINATION_OUT_OF_ORDER = 27, + INVALID_NUMBER_FORMAT = 28, + NETWORK_OUT_OF_ORDER = 38, + TEMPORARY_FAILURE = 41, + INVALID_PARAMETER = 1025, + SIM_NOT_EXIT = 1026, + SIM_PIN_NEED = 1027, + CALL_NOT_ALLOW = 1029, + SIM_INVALID = 1045, + UNKNOWN = 1279, + }; +} + export default call; \ No newline at end of file diff --git a/api/@ohos.telephony.data.d.ts b/api/@ohos.telephony.data.d.ts new file mode 100644 index 000000000..e589ee35d --- /dev/null +++ b/api/@ohos.telephony.data.d.ts @@ -0,0 +1,196 @@ +/* +* Copyright (C) 2021 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import {AsyncCallback} from "./basic"; + +/** + * Provides methods related to cellular data services. + * + * @since 7 + * @sysCap SystemCapability.Telephony.CellularData + */ +declare namespace data { + /** + * Checks whether cellular data services are enabled. + * + *

Requires Permission: {@code ohos.permission.GET_NETWORK_INFO}. + * + * @return Returns {@code true} if cellular data services are enabled; returns {@code false} otherwise. + * @permission ohos.permission.GET_NETWORK_INFO + */ + function getDefaultCellularDataSlotId(callback: AsyncCallback): void; + function getDefaultCellularDataSlotId(): Promise; + + /** + * Switches cellular data services to another card, without changing the default settings. + * + * @param slotId Indicates the ID of the target card slot. + * The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2. + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + */ + function setDefaultCellularDataSlotId(slotId: number, callback: AsyncCallback): void; + function setDefaultCellularDataSlotId(slotId: number): Promise; + + /** + * Indicates that there is no uplink or downlink data. + * + *

It is a return value of service state query of cellular data services. + */ + function getCellularDataFlowType(callback: AsyncCallback): void; + function getCellularDataFlowType(): Promise; + + /** + * Obtains the connection state of the PS domain. + * + * @param slotId Indicates the ID of a card slot. + * The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2. + * @param callback Returns the connection state, which can be any of the following: + *

    + *
  • {@code DataConnectState#DATA_STATE_UNKNOWN} + *
  • {@code DataConnectState#DATA_STATE_DISCONNECTED} + *
  • {@code DataConnectState#DATA_STATE_CONNECTING} + *
  • {@code DataConnectState#DATA_STATE_CONNECTED} + *
  • {@code DataConnectState#DATA_STATE_SUSPENDED} + *
+ */ + function getCellularDataState(callback: AsyncCallback): void; + function getCellularDataState(): Promise; + + /** + * Checks whether cellular data services are enabled. + * + *

Requires Permission: {@code ohos.permission.GET_NETWORK_INFO}. + * + * @param callback Returns {@code true} if cellular data services are enabled; returns {@code false} otherwise. + */ + function isCellularDataEnabled(callback: AsyncCallback): void; + function isCellularDataEnabled(): Promise; + + /** + * Enables cellular data services. + * + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + */ + function enableCellularData(callback: AsyncCallback): void; + function enableCellularData(): Promise; + + /** + * Diables cellular data services. + * + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + */ + function disableCellularData(callback: AsyncCallback): void; + function disableCellularData(): Promise; + + /** + * Checks whether roaming is enabled for cellular data services. + * + *

Requires Permission: {@code ohos.permission.GET_NETWORK_INFO}. + * + * @param slotId Indicates the ID of a card slot. + * The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2. + * @param callback Returns {@code true} if roaming is enabled for cellular data services; returns {@code false} otherwise. + * @permission ohos.permission.GET_NETWORK_INFO + */ + function isCellularDataRoamingEnabled(slotId: number, callback: AsyncCallback): void; + function isCellularDataRoamingEnabled(slotId: number): Promise; + + /** + * Enables cellular data roaming. + * + * @param slotId Indicates the ID of a card slot. + * The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2. + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + */ + function enableCellularDataRoaming(slotId: number, callback: AsyncCallback): void; + function enableCellularDataRoaming(slotId: number): Promise; + + /** + * Disables cellular data roaming. + * + * @param slotId Indicates the ID of a card slot. + * The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2. + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + */ + function disableCellularDataRoaming(slotId: number, callback: AsyncCallback): void; + function disableCellularDataRoaming(slotId: number): Promise; + + /** + * Describes the cellular data flow type. + */ + export enum DataFlowType { + /** + * Indicates that there is no uplink or downlink data. + */ + DATA_FLOW_TYPE_NONE = 0, + + /** + * Indicates that there is only downlink data. + */ + DATA_FLOW_TYPE_DOWN = 1, + + /** + * Indicates that there is only uplink data. + */ + DATA_FLOW_TYPE_UP = 2, + + /** + * Indicates that there is uplink and downlink data. + */ + DATA_FLOW_TYPE_UP_DOWN = 3, + + /** + * Indicates that there is no uplink or downlink data, and the bottom-layer link is in the dormant state. + */ + DATA_FLOW_TYPE_DORMANT = 4 + } + + /** + * Describes the cellular data link connection state. + */ + export enum DataConnectState { + /** + * Indicates that a cellular data link is unknown. + */ + DATA_STATE_UNKNOWN = -1, + + /** + * Indicates that a cellular data link is disconnected. + */ + DATA_STATE_DISCONNECTED = 0, + + /** + * Indicates that a cellular data link is being connected. + */ + DATA_STATE_CONNECTING = 1, + + /** + * Indicates that a cellular data link is connected. + */ + DATA_STATE_CONNECTED = 2, + + /** + * Indicates that a cellular data link is suspended. + */ + DATA_STATE_SUSPENDED = 3 + } +} + +export default data; \ No newline at end of file diff --git a/api/@ohos.telephony.observer.d.ts b/api/@ohos.telephony.observer.d.ts index 6e4fbce5d..7a99d89d0 100644 --- a/api/@ohos.telephony.observer.d.ts +++ b/api/@ohos.telephony.observer.d.ts @@ -15,18 +15,27 @@ import {Callback} from "./basic"; import radio from "./@ohos.telephony.radio"; +import data from "./@ohos.telephony.data"; import call from "./@ohos.telephony.call"; +import sim from "./@ohos.telephony.sim"; /** * Monitors telephony state updates of a device, including updates of the network state, * signal strength, call state, the data link connection state and others. * * @since 6 + * @sysCap SystemCapability.Telephony.StateRegistry */ declare namespace observer { type NetworkState = radio.NetworkState; type SignalInformation = radio.SignalInformation; + type CellInformation = radio.CellInformation; + type DataConnectState = data.DataConnectState; + type RatType = radio.RadioTechnology; + type DataFlowType = data.DataFlowType; type CallState = call.CallState; + type CardType = sim.CardType; + type SimState = sim.SimState; /** * Called when the network state corresponding to a monitored {@code slotId} updates. @@ -59,6 +68,63 @@ declare namespace observer { function off(type: 'signalInfoChange', callback?: Callback>): void; + /** + * Called back when the cell information corresponding to a monitored {@code slotId} updates. + * + *

Applications must have the {@code ohos.permission.LOCATION} permission + * to register this event. + * + * @param type cellInfoChange + * @param options including slotId Indicates the ID of the target card slot. + * The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2. + * @param callback including an array of instances of the classes derived from {@link CellInformation}. + * @permission ohos.permission.LOCATION + * @systemapi Hide this for inner system use. + * @since 8 + */ + function on(type: 'cellInfoChange', callback: Callback>): void; + function on(type: 'cellInfoChange', options: { slotId: number }, + callback: Callback>): void; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function off(type: 'cellInfoChange', callback?: Callback>): void; + + /** + * Called when the cellular data link connection state updates. + * + * @param type cellularDataConnectionStateChange + * @param options including slotId Indicates the ID of the target card slot. + * The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2. + * @param callback including state Indicates the cellular data link connection state, + * and networkType Indicates the radio access technology for cellular data services. + * @since 7 + */ + function on(type: 'cellularDataConnectionStateChange', + callback: Callback<{ state: DataConnectState, network: RatType }>): void; + function on(type: 'cellularDataConnectionStateChange', options: { slotId: number }, + callback: Callback<{ state: DataConnectState, network: RatType }>): void; + + function off(type: 'cellularDataConnectionStateChange', + callback?: Callback<{ state: DataConnectState, network: RatType }>): void; + + /** + * Called when the uplink and downlink data flow state of cellular data services updates. + * + * @param type cellularDataFlowChange + * @param options including slotId Indicates the ID of the target card slot. + * The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2. + * @param callback including the cellular data flow state. + * @since 7 + */ + function on(type: 'cellularDataFlowChange', callback: Callback): void; + function on(type: 'cellularDataFlowChange', options: { slotId: number }, + callback: Callback): void; + + function off(type: 'cellularDataFlowChange', callback?: Callback): void; + /** * Receives a call state change. This callback is invoked when the call state of a specified card updates * and the observer is added to monitor the updates. @@ -75,6 +141,53 @@ declare namespace observer { callback: Callback<{ state: CallState, number: string }>): void; function off(type: 'callStateChange', callback?: Callback<{ state: CallState, number: string }>): void; + + /** + * Receives a sim state change. This callback is invoked when the sim state of a specified card updates + * and the observer is added to monitor the updates. + * + * @param type simStateChange + * @param options including slotId Indicates the ID of the target card slot. + * The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2. + * @param callback including state Indicates the sim state, and reason Indicates the cause of the change. + * The value of reason is an empty string if the application does not have + * @since 7 + */ + function on(type: 'simStateChange', callback: Callback): void; + function on(type: 'simStateChange', options: { slotId: number }, callback: Callback): void; + + function off(type: 'simStateChange', callback?: Callback): void; + + /** + * @since 7 + */ + export interface SimStateData { + type: CardType, + state: SimState, + /** + * @since 8 + */ + reason: LockReason + } + + /** + * @since 8 + */ + export enum LockReason { + SIM_NONE, + SIM_PIN, + SIM_PUK, + SIM_PN_PIN, //Network Personalization (refer 3GPP TS 22.022 [33]) + SIM_PN_PUK, + SIM_PU_PIN, //network sUbset Personalization (refer 3GPP TS 22.022 [33]) + SIM_PU_PUK, + SIM_PP_PIN, //service Provider Personalization (refer 3GPP TS 22.022 [33]) + SIM_PP_PUK, + SIM_PC_PIN, //Corporate Personalization (refer 3GPP TS 22.022 [33]) + SIM_PC_PUK, + SIM_SIM_PIN, //SIM/USIM personalisation (refer 3GPP TS 22.022 [33]) + SIM_SIM_PUK, + } } export default observer; \ No newline at end of file diff --git a/api/@ohos.telephony.radio.d.ts b/api/@ohos.telephony.radio.d.ts index bbc4dcfc7..e0377c032 100644 --- a/api/@ohos.telephony.radio.d.ts +++ b/api/@ohos.telephony.radio.d.ts @@ -1,453 +1,775 @@ -/* -* Copyright (C) 2021 Huawei Device Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import {AsyncCallback} from "./basic"; - -/** - * Provides interfaces for applications to obtain the network state, cell information, signal information, - * and device ID of the wireless cellular network (WCN), and provides a callback registration mechanism to - * listen for changes of the network, cell, and signal status of the WCN. - * - * @since 6 - * @sysCap SystemCapability.Telephony.Telephony - */ -declare namespace radio { - /** - * Obtains radio access technology (RAT) of the registered network. The system - * returns RAT of the packet service (PS) and circuit service (CS) domain. - * - *

Requires Permission: {@code ohos.permission.GET_NETWORK_INFO}. - * - * @param slotId Indicates the card slot index number, - * ranging from 0 to the maximum card slot index number supported by the device. - * @param callback Returns an integer indicating the RAT in use. The values are as follows: - *

    - *
  • {@code RadioTechnology#RADIO_TECHNOLOGY_UNKNOWN} - *
  • {@code RadioTechnology#RADIO_TECHNOLOGY_GSM} - *
  • {@code RadioTechnology#RADIO_TECHNOLOGY_1XRTT} - *
  • {@code RadioTechnology#RADIO_TECHNOLOGY_WCDMA} - *
  • {@code RadioTechnology#RADIO_TECHNOLOGY_HSPA} - *
  • {@code RadioTechnology#RADIO_TECHNOLOGY_HSPAP} - *
  • {@code RadioTechnology#RADIO_TECHNOLOGY_TD_SCDMA} - *
  • {@code RadioTechnology#RADIO_TECHNOLOGY_EVDO} - *
  • {@code RadioTechnology#RADIO_TECHNOLOGY_EHRPD} - *
  • {@code RadioTechnology#RADIO_TECHNOLOGY_LTE} - *
  • {@code RadioTechnology#RADIO_TECHNOLOGY_LTE_CA} - *
  • {@code RadioTechnology#RADIO_TECHNOLOGY_IWLAN} - *
  • {@code RadioTechnology#RADIO_TECHNOLOGY_NR} - *
- * @permission ohos.permission.GET_NETWORK_INFO - */ - function getRadioTech(slotId: number, - callback: AsyncCallback<{psRadioTech: RadioTechnology, csRadioTech: RadioTechnology}>): void; - function getRadioTech(slotId: number): Promise<{psRadioTech: RadioTechnology, csRadioTech: RadioTechnology}>; - - /** - * Obtains the network state of the registered network. - * - *

Requires Permission: {@code ohos.permission.GET_NETWORK_INFO}. - * - * @param slotId Indicates the card slot index number, - * ranging from 0 to the maximum card slot index number supported by the device. - * @param callback Returns a {@code NetworkState} object. - * @permission ohos.permission.GET_NETWORK_INFO - */ - function getNetworkState(callback: AsyncCallback): void; - function getNetworkState(slotId: number, callback: AsyncCallback): void; - function getNetworkState(slotId?: number): Promise; - - /** - * Obtains the network search mode of the SIM card in a specified slot. - * - * @param slotId Indicates the ID of the SIM card slot. - * @param callback Returns the network search mode of the SIM card. Available values are as follows: - *

    - *
  • {@link NetworkSelectionMode#NETWORK_SELECTION_UNKNOWN} - *
  • {@link NetworkSelectionMode#NETWORK_SELECTION_AUTOMATIC} - *
  • {@link NetworkSelectionMode#NETWORK_SELECTION_MANUAL} - *
      - */ - function getNetworkSelectionMode(slotId: number, callback: AsyncCallback): void; - function getNetworkSelectionMode(slotId: number): Promise; - - /** - * @permission ohos.permission.SET_TELEPHONY_STATE - * @systemapi Hide this for inner system use. - */ - function setNetworkSelectionMode(options: NetworkSelectionModeOptions, callback: AsyncCallback): void; - function setNetworkSelectionMode(options: NetworkSelectionModeOptions): Promise; - - /** - * @permission ohos.permission.GET_TELEPHONY_STATE - * @systemapi Hide this for inner system use. - */ - function getNetworkSearchInformation(slotId: number, callback: AsyncCallback): void; - function getNetworkSearchInformation(slotId: number): Promise; - - /** - * Obtains the ISO-defined country code of the country where the registered network is deployed. - * - * @param slotId Indicates the card slot index number, - * ranging from 0 to the maximum card slot index number supported by the device. - * @param callback Returns the country code defined in ISO 3166-2; - * returns an empty string if the device is not registered with any network. - * @since 7 - */ - function getISOCountryCodeForNetwork(slotId: number, callback: AsyncCallback): void; - function getISOCountryCodeForNetwork(slotId: number): Promise; - - /** - * Obtains the list of signal strength information of the registered network corresponding to a specified SIM card. - * - * @param slotId Indicates the card slot index number, ranging from 0 to the maximum card slot index number - * supported by the device. - * @param callback Returns the instance list of the child classes derived from {@link SignalInformation}. - * @since 7 - */ - function getSignalInformation(slotId: number, callback: AsyncCallback>): void; - function getSignalInformation(slotId: number): Promise>; - - /** - * @permission ohos.permission.GET_NETWORK_INFO - * @since 7 - */ - function isRadioOn(callback: AsyncCallback): void; - function isRadioOn(): Promise; - - /** - * @permission ohos.permission.SET_TELEPHONY_STATE - * @systemapi Hide this for inner system use. - * @since 7 - */ - function turnOnRadio(callback: AsyncCallback): void; - function turnOnRadio(): Promise; - - /** - * @permission ohos.permission.SET_TELEPHONY_STATE - * @systemapi Hide this for inner system use. - * @since 7 - */ - function turnOffRadio(callback: AsyncCallback): void; - function turnOffRadio(): Promise; - - /** - * Describes the radio access technology. - */ - export enum RadioTechnology { - /** - * Indicates unknown radio access technology (RAT). - */ - RADIO_TECHNOLOGY_UNKNOWN = 0, - - /** - * Indicates that RAT is global system for mobile communications (GSM), including GSM, general packet - * radio system (GPRS), and enhanced data rates for GSM evolution (EDGE). - */ - RADIO_TECHNOLOGY_GSM = 1, - - /** - * Indicates that RAT is code division multiple access (CDMA), including Interim Standard 95 (IS95) and - * Single-Carrier Radio Transmission Technology (1xRTT). - */ - RADIO_TECHNOLOGY_1XRTT = 2, - - /** - * Indicates that RAT is wideband code division multiple address (WCDMA). - */ - RADIO_TECHNOLOGY_WCDMA = 3, - - /** - * Indicates that RAT is high-speed packet access (HSPA), including HSPA, high-speed downlink packet - * access (HSDPA), and high-speed uplink packet access (HSUPA). - */ - RADIO_TECHNOLOGY_HSPA = 4, - - /** - * Indicates that RAT is evolved high-speed packet access (HSPA+), including HSPA+ and dual-carrier - * HSPA+ (DC-HSPA+). - */ - RADIO_TECHNOLOGY_HSPAP = 5, - - /** - * Indicates that RAT is time division-synchronous code division multiple access (TD-SCDMA). - */ - RADIO_TECHNOLOGY_TD_SCDMA = 6, - - /** - * Indicates that RAT is evolution data only (EVDO), including EVDO Rev.0, EVDO Rev.A, and EVDO Rev.B. - */ - RADIO_TECHNOLOGY_EVDO = 7, - - /** - * Indicates that RAT is evolved high rate packet data (EHRPD). - */ - RADIO_TECHNOLOGY_EHRPD = 8, - - /** - * Indicates that RAT is long term evolution (LTE). - */ - RADIO_TECHNOLOGY_LTE = 9, - - /** - * Indicates that RAT is LTE carrier aggregation (LTE-CA). - */ - RADIO_TECHNOLOGY_LTE_CA = 10, - - /** - * Indicates that RAT is interworking WLAN (I-WLAN). - */ - RADIO_TECHNOLOGY_IWLAN = 11, - - /** - * Indicates that RAT is 5G new radio (NR). - */ - RADIO_TECHNOLOGY_NR = 12 - } - - export interface SignalInformation { - /** - * Obtains the network type corresponding to the signal. - */ - signalType: NetworkType; - - /** - * Obtains the signal level of the current network. - */ - signalLevel: number; - } - - /** - * Describes the network type. - */ - export enum NetworkType { - /** - * Indicates unknown network type. - */ - NETWORK_TYPE_UNKNOWN, - - /** - * Indicates that the network type is GSM. - */ - NETWORK_TYPE_GSM, - - /** - * Indicates that the network type is CDMA. - */ - NETWORK_TYPE_CDMA, - - /** - * Indicates that the network type is WCDMA. - */ - NETWORK_TYPE_WCDMA, - - /** - * Indicates that the network type is TD-SCDMA. - */ - NETWORK_TYPE_TDSCDMA, - - /** - * Indicates that the network type is LTE. - */ - NETWORK_TYPE_LTE, - - /** - * Indicates that the network type is 5G NR. - */ - NETWORK_TYPE_NR - } - - /** - * Describes the network registration state. - */ - export interface NetworkState { - /** - * Obtains the operator name in the long alphanumeric format of the registered network. - * - * @return Returns the operator name in the long alphanumeric format as a string; - * returns an empty string if no operator name is obtained. - */ - longOperatorName: string; - - /** - * Obtains the operator name in the short alphanumeric format of the registered network. - * - * @return Returns the operator name in the short alphanumeric format as a string; - * returns an empty string if no operator name is obtained. - */ - shortOperatorName: string; - - /** - * Obtains the PLMN code of the registered network. - * - * @return Returns the PLMN code as a string; returns an empty string if no operator name is obtained. - */ - plmnNumeric: string; - - /** - * Checks whether the device is roaming. - * - * @return Returns {@code true} if the device is roaming; returns {@code false} otherwise. - */ - isRoaming: boolean; - - /** - * Obtains the network registration status of the device. - * - * @return Returns the network registration status {@code RegState}. - */ - regState: RegState; - - /** - * Obtains the NSA network registration status of the device. - * - * @return Returns the NSA network registration status {@code NsaState}. - */ - nsaState: NsaState; - - /** - * Obtains the status of CA. - * - * @return Returns {@code true} if CA is actived; returns {@code false} otherwise. - */ - isCaActive: boolean; - - /** - * Checks whether this device is allowed to make emergency calls only. - * - * @return Returns {@code true} if this device is allowed to make emergency calls only; - * returns {@code false} otherwise. - */ - isEmergency: boolean; - } - - /** - * Describes the network registration state. - */ - export enum RegState { - /** - * Indicates a state in which a device cannot use any service. - */ - REG_STATE_NO_SERVICE = 0, - - /** - * Indicates a state in which a device can use services properly. - */ - REG_STATE_IN_SERVICE = 1, - - /** - * Indicates a state in which a device can use only the emergency call service. - */ - REG_STATE_EMERGENCY_CALL_ONLY = 2, - - /** - * Indicates that the cellular radio is powered off. - */ - REG_STATE_POWER_OFF = 3 - } - - /** - * Describes the nsa state. - */ - export enum NsaState { - /** - * Indicates that a device is idle under or is connected to an LTE cell that does not support NSA. - */ - NSA_STATE_NOT_SUPPORT = 1, - - /** - * Indicates that a device is idle under an LTE cell supporting NSA but not NR coverage detection. - */ - NSA_STATE_NO_DETECT = 2, - - /** - * Indicates that a device is connected to an LTE network under an LTE cell - * that supports NSA and NR coverage detection. - */ - NSA_STATE_CONNECTED_DETECT = 3, - - /** - * Indicates that a device is idle under an LTE cell supporting NSA and NR coverage detection. - */ - NSA_STATE_IDLE_DETECT = 4, - - /** - * Indicates that a device is connected to an LTE + NR network under an LTE cell that supports NSA. - */ - NSA_STATE_DUAL_CONNECTED = 5, - - /** - * Indicates that a device is idle under or is connected to an NG-RAN cell while being attached to 5GC. - */ - NSA_STATE_SA_ATTACHED = 6 - } - - /** - * @systemapi Hide this for inner system use. - */ - export interface NetworkSearchResult { - isNetworkSearchSuccess: boolean; - networkSearchResult: Array; - } - - /** - * @systemapi Hide this for inner system use. - */ - export interface NetworkInformation { - operatorName: string; - operatorNumeric: string; - state: NetworkInformationState; - radioTech: string; - } - - /** - * @systemapi Hide this for inner system use. - */ - export enum NetworkInformationState { - /** Indicates that the network state is unknown. */ - NETWORK_UNKNOWN, - - /** Indicates that the network is available for registration. */ - NETWORK_AVAILABLE, - - /** Indicates that you have already registered with the network. */ - NETWORK_CURRENT, - - /** Indicates that the network is unavailable for registration. */ - NETWORK_FORBIDDEN - } - - /** - * @systemapi Hide this for inner system use. - */ - export interface NetworkSelectionModeOptions { - slotId: number; - selectMode: NetworkSelectionMode; - networkInformation: NetworkInformation; - resumeSelection: boolean; - } - - export enum NetworkSelectionMode { - /** Unknown network selection modes. */ - NETWORK_SELECTION_UNKNOWN, - - /** Automatic network selection modes. */ - NETWORK_SELECTION_AUTOMATIC, - - /** Manual network selection modes. */ - NETWORK_SELECTION_MANUAL - } -} - +/* +* Copyright (C) 2021 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import {AsyncCallback} from "./basic"; + +/** + * Provides interfaces for applications to obtain the network state, cell information, signal information, + * and device ID of the wireless cellular network (WCN), and provides a callback registration mechanism to + * listen for changes of the network, cell, and signal status of the WCN. + * + * @since 6 + * @sysCap SystemCapability.Telephony.CoreService + */ +declare namespace radio { + /** + * Obtains radio access technology (RAT) of the registered network. The system + * returns RAT of the packet service (PS) and circuit service (CS) domain. + * + *

      Requires Permission: {@code ohos.permission.GET_NETWORK_INFO}. + * + * @param slotId Indicates the card slot index number, + * ranging from 0 to the maximum card slot index number supported by the device. + * @param callback Returns an integer indicating the RAT in use. The values are as follows: + *

        + *
      • {@code RadioTechnology#RADIO_TECHNOLOGY_UNKNOWN} + *
      • {@code RadioTechnology#RADIO_TECHNOLOGY_GSM} + *
      • {@code RadioTechnology#RADIO_TECHNOLOGY_1XRTT} + *
      • {@code RadioTechnology#RADIO_TECHNOLOGY_WCDMA} + *
      • {@code RadioTechnology#RADIO_TECHNOLOGY_HSPA} + *
      • {@code RadioTechnology#RADIO_TECHNOLOGY_HSPAP} + *
      • {@code RadioTechnology#RADIO_TECHNOLOGY_TD_SCDMA} + *
      • {@code RadioTechnology#RADIO_TECHNOLOGY_EVDO} + *
      • {@code RadioTechnology#RADIO_TECHNOLOGY_EHRPD} + *
      • {@code RadioTechnology#RADIO_TECHNOLOGY_LTE} + *
      • {@code RadioTechnology#RADIO_TECHNOLOGY_LTE_CA} + *
      • {@code RadioTechnology#RADIO_TECHNOLOGY_IWLAN} + *
      • {@code RadioTechnology#RADIO_TECHNOLOGY_NR} + *
      + * @permission ohos.permission.GET_NETWORK_INFO + */ + function getRadioTech(slotId: number, + callback: AsyncCallback<{psRadioTech: RadioTechnology, csRadioTech: RadioTechnology}>): void; + function getRadioTech(slotId: number): Promise<{psRadioTech: RadioTechnology, csRadioTech: RadioTechnology}>; + + /** + * Obtains the network state of the registered network. + * + *

      Requires Permission: {@code ohos.permission.GET_NETWORK_INFO}. + * + * @param slotId Indicates the card slot index number, + * ranging from 0 to the maximum card slot index number supported by the device. + * @param callback Returns a {@code NetworkState} object. + * @permission ohos.permission.GET_NETWORK_INFO + */ + function getNetworkState(callback: AsyncCallback): void; + function getNetworkState(slotId: number, callback: AsyncCallback): void; + function getNetworkState(slotId?: number): Promise; + + /** + * Proactively requests to update location information. + * + * @systemapi Hide this for inner system use. + * @since 8 + */ + function sendUpdateCellLocationRequest(callback: AsyncCallback): void; + function sendUpdateCellLocationRequest(): Promise; + + /** + * @permission ohos.permission.LOCATION + * @systemapi Hide this for inner system use. + * @since 8 + */ + function getCellInformation(callback: AsyncCallback>): void; + function getCellInformation(slotId: number, callback: AsyncCallback>): void; + function getCellInformation(slotId?: number): Promise>; + + /** + * Obtains the network search mode of the SIM card in a specified slot. + * + * @param slotId Indicates the ID of the SIM card slot. + * @param callback Returns the network search mode of the SIM card. Available values are as follows: + *

        + *
      • {@link NetworkSelectionMode#NETWORK_SELECTION_UNKNOWN} + *
      • {@link NetworkSelectionMode#NETWORK_SELECTION_AUTOMATIC} + *
      • {@link NetworkSelectionMode#NETWORK_SELECTION_MANUAL} + *
          + */ + function getNetworkSelectionMode(slotId: number, callback: AsyncCallback): void; + function getNetworkSelectionMode(slotId: number): Promise; + + /** + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + */ + function setNetworkSelectionMode(options: NetworkSelectionModeOptions, callback: AsyncCallback): void; + function setNetworkSelectionMode(options: NetworkSelectionModeOptions): Promise; + + /** + * @permission ohos.permission.GET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + */ + function getNetworkSearchInformation(slotId: number, callback: AsyncCallback): void; + function getNetworkSearchInformation(slotId: number): Promise; + + /** + * Obtains the ISO-defined country code of the country where the registered network is deployed. + * + * @param slotId Indicates the card slot index number, + * ranging from 0 to the maximum card slot index number supported by the device. + * @param callback Returns the country code defined in ISO 3166-2; + * returns an empty string if the device is not registered with any network. + * @since 7 + */ + function getISOCountryCodeForNetwork(slotId: number, callback: AsyncCallback): void; + function getISOCountryCodeForNetwork(slotId: number): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function getNrOptionMode(callback: AsyncCallback): void; + function getNrOptionMode(slotId: number, callback: AsyncCallback): void; + function getNrOptionMode(slotId?: number): Promise; + + /** + * Obtains the IMEI of a specified card slot of the device. + * + *

          Requires Permission: {@code ohos.permission.GET_TELEPHONY_STATE}. + * + * @param slotId Indicates the card slot index number, ranging from 0 to the maximum card slot index number + * supported by the device. + * @param callback Returns the IMEI; returns an empty string if the IMEI does not exist. + * @permission ohos.permission.GET_TELEPHONY_STATE + * @since 8 + */ + function getIMEI(callback: AsyncCallback): void; + function getIMEI(slotId: number, callback: AsyncCallback): void; + function getIMEI(slotId?: number): Promise; + + /** + * Obtains the MEID of a specified card slot of the device. + * + *

          Requires Permission: {@code ohos.permission.GET_TELEPHONY_STATE}. + * + * @param slotId Indicates the card slot index number, ranging from 0 to the maximum card slot index number + * supported by the device. + * @param callback Returns the MEID; returns an empty string if the MEID does not exist. + * @permission ohos.permission.GET_TELEPHONY_STATE + * @since 8 + */ + function getMEID(callback: AsyncCallback): void; + function getMEID(slotId: number, callback: AsyncCallback): void; + function getMEID(slotId?: number): Promise; + + /** + * Obtains the unique device ID of a specified card slot of the device. + * + *

          If the device is registered with a 3GPP-compliant network, the international mobile equipment identity + * (IMEI) is returned. If the device is registered with a 3GPP2-compliant network, the mobile equipment identifier + * (MEID) is returned. + * + *

          Requires Permission: {@code ohos.permission.GET_TELEPHONY_STATE}. + * + * @param slotId Indicates the card slot index number, ranging from 0 to the maximum card slot index number + * supported by the device. + * @param callback Returns the unique device ID; returns an empty string if the unique device ID does not exist. + * @permission ohos.permission.GET_TELEPHONY_STATE + * @since 8 + */ + function getUniqueDeviceId(callback: AsyncCallback): void; + function getUniqueDeviceId(slotId: number, callback: AsyncCallback): void; + function getUniqueDeviceId(slotId?: number): Promise; + + /** + * Obtains the index number of the card slot where the primary card is located if multiple SIM cards are inserted. + * + *

          The primary card is the SIM card inserted in the card slot that uses data services by default. + * + * @param callback Returns the index number of the primary card slot. + * @since 7 + */ + function getPrimarySlotId(callback: AsyncCallback): void; + function getPrimarySlotId(): Promise; + + /** + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 8 + */ + function setPrimarySlotId(slotId: number, callback: AsyncCallback): void; + function setPrimarySlotId(slotId: number): Promise; + + /** + * Obtains the list of signal strength information of the registered network corresponding to a specified SIM card. + * + * @param slotId Indicates the card slot index number, ranging from 0 to the maximum card slot index number + * supported by the device. + * @param callback Returns the instance list of the child classes derived from {@link SignalInformation}. + * @since 7 + */ + function getSignalInformation(slotId: number, callback: AsyncCallback>): void; + function getSignalInformation(slotId: number): Promise>; + + /** + * Checks whether the device supports 5G New Radio (NR). + * + * @return Returns {@code true} if the device supports 5G NR; returns {@code false} otherwise. + * @deprecated Advised to use isNrSupported(slotId: number) instead. + * @since 7 + */ + function isNrSupported(): boolean; + + /** + * Checks whether the device supports 5G New Radio (NR) by according card slot. + * + * @param slotId Indicates the card slot index number, ranging from 0 to the maximum card slot index number + * supported by the device. + * @return Returns {@code true} if the device supports 5G NR; returns {@code false} otherwise. + * @since 8 + */ + function isNrSupported(slotId: number): boolean; + + /** + * @permission ohos.permission.GET_NETWORK_INFO + * @since 7 + */ + function isRadioOn(callback: AsyncCallback): void; + function isRadioOn(): Promise; + + /** + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 7 + */ + function turnOnRadio(callback: AsyncCallback): void; + function turnOnRadio(): Promise; + + /** + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 7 + */ + function turnOffRadio(callback: AsyncCallback): void; + function turnOffRadio(): Promise; + + /** + * @since 7 + */ + function getOperatorName(slotId: number, callback: AsyncCallback): void; + function getOperatorName(slotId: number): Promise; + + /** + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 8 + */ + function setPreferredNetwork(slotId: number, networkMode: PreferredNetworkMode, callback: AsyncCallback): void; + function setPreferredNetwork(slotId: number, networkMode: PreferredNetworkMode): Promise; + + /** + * @permission ohos.permission.GET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 8 + */ + function getPreferredNetwork(slotId: number, callback: AsyncCallback): void; + function getPreferredNetwork(slotId: number): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum PreferredNetworkMode { + PREFERRED_NETWORK_MODE_GSM = 1, + PREFERRED_NETWORK_MODE_WCDMA = 2, + PREFERRED_NETWORK_MODE_LTE = 3, + PREFERRED_NETWORK_MODE_LTE_WCDMA = 4, + PREFERRED_NETWORK_MODE_LTE_WCDMA_GSM = 5, + PREFERRED_NETWORK_MODE_WCDMA_GSM = 6, + PREFERRED_NETWORK_MODE_CDMA = 7, + PREFERRED_NETWORK_MODE_EVDO = 8, + PREFERRED_NETWORK_MODE_EVDO_CDMA = 9, + PREFERRED_NETWORK_MODE_WCDMA_GSM_EVDO_CDMA = 10, + PREFERRED_NETWORK_MODE_LTE_EVDO_CDMA = 11, + PREFERRED_NETWORK_MODE_LTE_WCDMA_GSM_EVDO_CDMA = 12, + PREFERRED_NETWORK_MODE_TDSCDMA = 13, + PREFERRED_NETWORK_MODE_TDSCDMA_GSM = 14, + PREFERRED_NETWORK_MODE_TDSCDMA_WCDMA = 15, + PREFERRED_NETWORK_MODE_TDSCDMA_WCDMA_GSM = 16, + PREFERRED_NETWORK_MODE_LTE_TDSCDMA = 17, + PREFERRED_NETWORK_MODE_LTE_TDSCDMA_GSM = 18, + PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA = 19, + PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA_GSM = 20, + PREFERRED_NETWORK_MODE_TDSCDMA_WCDMA_GSM_EVDO_CDMA = 21, + PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA_GSM_EVDO_CDMA = 22, + PREFERRED_NETWORK_MODE_NR = 31, + PREFERRED_NETWORK_MODE_NR_LTE = 32, + PREFERRED_NETWORK_MODE_NR_LTE_WCDMA = 33, + PREFERRED_NETWORK_MODE_NR_LTE_WCDMA_GSM = 34, + PREFERRED_NETWORK_MODE_NR_LTE_EVDO_CDMA = 35, + PREFERRED_NETWORK_MODE_NR_LTE_WCDMA_GSM_EVDO_CDMA = 36, + PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA = 37, + PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA_GSM = 38, + PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA = 39, + PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA_GSM = 40, + PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA_GSM_EVDO_CDMA = 41, + PREFERRED_NETWORK_MODE_MAX_VALUE = 99, + } + + /** + * Describes the radio access technology. + */ + export enum RadioTechnology { + /** + * Indicates unknown radio access technology (RAT). + */ + RADIO_TECHNOLOGY_UNKNOWN = 0, + + /** + * Indicates that RAT is global system for mobile communications (GSM), including GSM, general packet + * radio system (GPRS), and enhanced data rates for GSM evolution (EDGE). + */ + RADIO_TECHNOLOGY_GSM = 1, + + /** + * Indicates that RAT is code division multiple access (CDMA), including Interim Standard 95 (IS95) and + * Single-Carrier Radio Transmission Technology (1xRTT). + */ + RADIO_TECHNOLOGY_1XRTT = 2, + + /** + * Indicates that RAT is wideband code division multiple address (WCDMA). + */ + RADIO_TECHNOLOGY_WCDMA = 3, + + /** + * Indicates that RAT is high-speed packet access (HSPA), including HSPA, high-speed downlink packet + * access (HSDPA), and high-speed uplink packet access (HSUPA). + */ + RADIO_TECHNOLOGY_HSPA = 4, + + /** + * Indicates that RAT is evolved high-speed packet access (HSPA+), including HSPA+ and dual-carrier + * HSPA+ (DC-HSPA+). + */ + RADIO_TECHNOLOGY_HSPAP = 5, + + /** + * Indicates that RAT is time division-synchronous code division multiple access (TD-SCDMA). + */ + RADIO_TECHNOLOGY_TD_SCDMA = 6, + + /** + * Indicates that RAT is evolution data only (EVDO), including EVDO Rev.0, EVDO Rev.A, and EVDO Rev.B. + */ + RADIO_TECHNOLOGY_EVDO = 7, + + /** + * Indicates that RAT is evolved high rate packet data (EHRPD). + */ + RADIO_TECHNOLOGY_EHRPD = 8, + + /** + * Indicates that RAT is long term evolution (LTE). + */ + RADIO_TECHNOLOGY_LTE = 9, + + /** + * Indicates that RAT is LTE carrier aggregation (LTE-CA). + */ + RADIO_TECHNOLOGY_LTE_CA = 10, + + /** + * Indicates that RAT is interworking WLAN (I-WLAN). + */ + RADIO_TECHNOLOGY_IWLAN = 11, + + /** + * Indicates that RAT is 5G new radio (NR). + */ + RADIO_TECHNOLOGY_NR = 12 + } + + export interface SignalInformation { + /** + * Obtains the network type corresponding to the signal. + */ + signalType: NetworkType; + + /** + * Obtains the signal level of the current network. + */ + signalLevel: number; + } + + /** + * Describes the network type. + */ + export enum NetworkType { + /** + * Indicates unknown network type. + */ + NETWORK_TYPE_UNKNOWN, + + /** + * Indicates that the network type is GSM. + */ + NETWORK_TYPE_GSM, + + /** + * Indicates that the network type is CDMA. + */ + NETWORK_TYPE_CDMA, + + /** + * Indicates that the network type is WCDMA. + */ + NETWORK_TYPE_WCDMA, + + /** + * Indicates that the network type is TD-SCDMA. + */ + NETWORK_TYPE_TDSCDMA, + + /** + * Indicates that the network type is LTE. + */ + NETWORK_TYPE_LTE, + + /** + * Indicates that the network type is 5G NR. + */ + NETWORK_TYPE_NR + } + + /** + * Describes the network registration state. + */ + export interface NetworkState { + /** + * Obtains the operator name in the long alphanumeric format of the registered network. + * + * @return Returns the operator name in the long alphanumeric format as a string; + * returns an empty string if no operator name is obtained. + */ + longOperatorName: string; + + /** + * Obtains the operator name in the short alphanumeric format of the registered network. + * + * @return Returns the operator name in the short alphanumeric format as a string; + * returns an empty string if no operator name is obtained. + */ + shortOperatorName: string; + + /** + * Obtains the PLMN code of the registered network. + * + * @return Returns the PLMN code as a string; returns an empty string if no operator name is obtained. + */ + plmnNumeric: string; + + /** + * Checks whether the device is roaming. + * + * @return Returns {@code true} if the device is roaming; returns {@code false} otherwise. + */ + isRoaming: boolean; + + /** + * Obtains the network registration status of the device. + * + * @return Returns the network registration status {@code RegState}. + */ + regState: RegState; + + /** + * Obtains the radio Access technology after config conversion. + * + * @return Returns the radio Access technology {@code RadioTechnology}. + * @since 8 + */ + cfgTech: RadioTechnology; + + /** + * Obtains the NSA network registration status of the device. + * + * @return Returns the NSA network registration status {@code NsaState}. + */ + nsaState: NsaState; + + /** + * Obtains the status of CA. + * + * @return Returns {@code true} if CA is actived; returns {@code false} otherwise. + */ + isCaActive: boolean; + + /** + * Checks whether this device is allowed to make emergency calls only. + * + * @return Returns {@code true} if this device is allowed to make emergency calls only; + * returns {@code false} otherwise. + */ + isEmergency: boolean; + } + + /** + * Describes the network registration state. + */ + export enum RegState { + /** + * Indicates a state in which a device cannot use any service. + */ + REG_STATE_NO_SERVICE = 0, + + /** + * Indicates a state in which a device can use services properly. + */ + REG_STATE_IN_SERVICE = 1, + + /** + * Indicates a state in which a device can use only the emergency call service. + */ + REG_STATE_EMERGENCY_CALL_ONLY = 2, + + /** + * Indicates that the cellular radio is powered off. + */ + REG_STATE_POWER_OFF = 3 + } + + /** + * Describes the nsa state. + */ + export enum NsaState { + /** + * Indicates that a device is idle under or is connected to an LTE cell that does not support NSA. + */ + NSA_STATE_NOT_SUPPORT = 1, + + /** + * Indicates that a device is idle under an LTE cell supporting NSA but not NR coverage detection. + */ + NSA_STATE_NO_DETECT = 2, + + /** + * Indicates that a device is connected to an LTE network under an LTE cell + * that supports NSA and NR coverage detection. + */ + NSA_STATE_CONNECTED_DETECT = 3, + + /** + * Indicates that a device is idle under an LTE cell supporting NSA and NR coverage detection. + */ + NSA_STATE_IDLE_DETECT = 4, + + /** + * Indicates that a device is connected to an LTE + NR network under an LTE cell that supports NSA. + */ + NSA_STATE_DUAL_CONNECTED = 5, + + /** + * Indicates that a device is idle under or is connected to an NG-RAN cell while being attached to 5GC. + */ + NSA_STATE_SA_ATTACHED = 6 + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export interface CellInformation { + /** + * Obtains the network type of the serving cell. + * + *

          An application can call this method to determine the network type that the child class uses. + * + * @return Returns the the network type of the serving cell. + */ + networkType: NetworkType; + + /** + * Obtains the camp-on status of the serving cell. + * + * @return Returns {@code true} if the user equipment (UE) is camped on the cell; returns + * {@code false} otherwise. + */ + isCamped: boolean; + + /** + * Obtains the timestamp when the cell information is obtained. + * + * @return Returns a timestamp since boot, in nanoseconds. + */ + timeStamp: number; + + /** + * An abstract method of the parent class whose implementation depends on the child classes. + * Returned child class objects vary according to the network type. + * + * @return Returns child class objects specific to the network type. + */ + signalInformation: SignalInformation; + + data: CdmaCellInformation | GsmCellInformation | LteCellInformation | NrCellInformation | TdscdmaCellInformation + | WcdmaCellInformation; + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export interface CdmaCellInformation { + baseId: number, + latitude: number, + longitude: number, + nid: number, + sid: number, + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export interface GsmCellInformation { + lac: number; + cellId: number; + arfcn: number; + bsic: number; + mcc: string; + mnc: string; + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export interface LteCellInformation { + cgi: number; + pci: number; + tac: number; + earfcn: number; + bandwidth: number; + mcc: string; + mnc: string; + isSupportEndc: boolean; + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export interface NrCellInformation { + nrArfcn: number; + pci: number; + tac: number; + nci: number; + mcc: string; + mnc: string; + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export interface TdscdmaCellInformation { + lac: number; + cellId: number; + cpid: number; + uarfcn: number; + mcc: string; + mnc: string; + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export interface WcdmaCellInformation { + lac: number; + cellId: number; + psc: number; + uarfcn: number; + mcc: string; + mnc: string; + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum NrOptionMode { + /** Indicates unknown NR networking mode. */ + NR_OPTION_UNKNOWN, + + /** Indicates that the NR networking mode is NSA only. */ + NR_OPTION_NSA_ONLY, + + /** Indicates that the NR networking mode is SA only. */ + NR_OPTION_SA_ONLY, + + /** Indicates that the NR networking mode is NSA and SA. */ + NR_OPTION_NSA_AND_SA, + } + + /** + * @systemapi Hide this for inner system use. + */ + export interface NetworkSearchResult { + isNetworkSearchSuccess: boolean; + networkSearchResult: Array; + } + + /** + * @systemapi Hide this for inner system use. + */ + export interface NetworkInformation { + operatorName: string; + operatorNumeric: string; + state: NetworkInformationState; + radioTech: string; + } + + /** + * @systemapi Hide this for inner system use. + */ + export enum NetworkInformationState { + /** Indicates that the network state is unknown. */ + NETWORK_UNKNOWN, + + /** Indicates that the network is available for registration. */ + NETWORK_AVAILABLE, + + /** Indicates that you have already registered with the network. */ + NETWORK_CURRENT, + + /** Indicates that the network is unavailable for registration. */ + NETWORK_FORBIDDEN + } + + /** + * @systemapi Hide this for inner system use. + */ + export interface NetworkSelectionModeOptions { + slotId: number; + selectMode: NetworkSelectionMode; + networkInformation: NetworkInformation; + resumeSelection: boolean; + } + + export enum NetworkSelectionMode { + /** Unknown network selection modes. */ + NETWORK_SELECTION_UNKNOWN, + + /** Automatic network selection modes. */ + NETWORK_SELECTION_AUTOMATIC, + + /** Manual network selection modes. */ + NETWORK_SELECTION_MANUAL + } +} + export default radio; \ No newline at end of file diff --git a/api/@ohos.telephony.sim.d.ts b/api/@ohos.telephony.sim.d.ts index ed9652a51..5cd23a729 100644 --- a/api/@ohos.telephony.sim.d.ts +++ b/api/@ohos.telephony.sim.d.ts @@ -1,235 +1,648 @@ -/* -* Copyright (C) 2021 Huawei Device Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import {AsyncCallback} from "./basic"; - -/** - * Provides applications with APIs for obtaining SIM card status, card file information, and card specifications. - * SIM cards include SIM, USIM, and CSIM cards. - * - * @since 6 - * @sysCap SystemCapability.Telephony.Telephony - */ -declare namespace sim { - /** - * Obtains the default card slot for the voice service. - * - * @param callback Returns {@code 0} if card 1 is used as the default card slot for the voice service; - * returns {@code 1} if card 2 is used as the default card slot for the voice service; - * returns {@code -1} if no card is available for the voice service. - * @since 7 - */ - function getDefaultVoiceSlotId(callback: AsyncCallback): void; - function getDefaultVoiceSlotId(): Promise; - - /** - * Obtains the ISO country code of the SIM card in a specified slot. - * - * @param slotId Indicates the card slot index number, - * ranging from 0 to the maximum card slot index number supported by the device. - * @param callback Returns the country code defined in ISO 3166-2; returns an empty string if no SIM card is inserted. - */ - function getISOCountryCodeForSim(slotId: number, callback: AsyncCallback): void; - function getISOCountryCodeForSim(slotId: number): Promise; - - /** - * Obtains the home PLMN number of the SIM card in a specified slot. - * - *

          The value is recorded in the SIM card and is irrelevant to the network - * with which the SIM card is currently registered. - * - * @param slotId Indicates the card slot index number, - * ranging from 0 to the maximum card slot index number supported by the device. - * @param callback Returns the PLMN number; returns an empty string if no SIM card is inserted. - */ - function getSimOperatorNumeric(slotId: number, callback: AsyncCallback): void; - function getSimOperatorNumeric(slotId: number): Promise; - - /** - * Obtains the service provider name (SPN) of the SIM card in a specified slot. - * - *

          The value is recorded in the EFSPN file of the SIM card and is irrelevant to the network - * with which the SIM card is currently registered. - * - * @param slotId Indicates the card slot index number, - * ranging from 0 to the maximum card slot index number supported by the device. - * @param callback Returns the SPN; returns an empty string if no SIM card is inserted or - * no EFSPN file in the SIM card. - */ - function getSimSpn(slotId: number, callback: AsyncCallback): void; - function getSimSpn(slotId: number): Promise; - - /** - * Obtains the state of the SIM card in a specified slot. - * - * @param slotId Indicates the card slot index number, - * ranging from {@code 0} to the maximum card slot index number supported by the device. - * @param callback Returns one of the following SIM card states: - *

            - *
          • {@code SimState#SIM_STATE_UNKNOWN} - *
          • {@code SimState#SIM_STATE_NOT_PRESENT} - *
          • {@code SimState#SIM_STATE_LOCKED} - *
          • {@code SimState#SIM_STATE_NOT_READY} - *
          • {@code SimState#SIM_STATE_READY} - *
          • {@code SimState#SIM_STATE_LOADED} - *
          - */ - function getSimState(slotId: number, callback: AsyncCallback): void; - function getSimState(slotId: number): Promise; - - /** - * Obtains the ICCID of the SIM card in a specified slot. - * - *

          The ICCID is a unique identifier of a SIM card. It consists of 20 digits - * and is recorded in the EFICCID file of the SIM card. - * - *

          Requires Permission: {@code ohos.permission.GET_TELEPHONY_STATE}. - * - * @param slotId Indicates the card slot index number, - * ranging from 0 to the maximum card slot index number supported by the device. - * @param callback Returns the ICCID; returns an empty string if no SIM card is inserted. - * @permission ohos.permission.GET_TELEPHONY_STATE - */ - function getSimIccId(slotId: number, callback: AsyncCallback): void; - function getSimIccId(slotId: number): Promise; - - /** - * Obtains the Group Identifier Level 1 (GID1) of the SIM card in a specified slot. - * The GID1 is recorded in the EFGID1 file of the SIM card. - * - *

          Requires Permission: {@code ohos.permission.GET_TELEPHONY_STATE}. - * - * @param slotId Indicates the card slot index number, - * ranging from 0 to the maximum card slot index number supported by the device. - * @param callback Returns the GID1; returns an empty string if no SIM card is inserted or - * no GID1 in the SIM card. - * @permission ohos.permission.GET_TELEPHONY_STATE - */ - function getSimGid1(slotId: number, callback: AsyncCallback): void; - function getSimGid1(slotId: number): Promise; - - /** - * @permission ohos.permission.GET_TELEPHONY_STATE - * @systemapi Hide this for inner system use. - */ - function getIMSI(slotId: number, callback: AsyncCallback): void; - function getIMSI(slotId: number): Promise; - - /** - * @permission ohos.permission.GET_TELEPHONY_STATE - * @systemapi Hide this for inner system use. - * @since 7 - */ - function getSimAccountInfo(slotId: number, callback: AsyncCallback): void; - function getSimAccountInfo(slotId: number): Promise; - - /** - * @permission ohos.permission.SET_TELEPHONY_STATE - * @systemapi Hide this for inner system use. - * @since 7 - */ - function setDefaultVoiceSlotId(slotId: number, callback: AsyncCallback): void; - function setDefaultVoiceSlotId(slotId: number): Promise; - - /** - * @permission ohos.permission.SET_TELEPHONY_STATE - * @systemapi Hide this for inner system use. - * @since 7 - */ - function unlockPin(slotId: number, pin: string, callback: AsyncCallback): void; - function unlockPin(slotId: number, pin: string): Promise; - - /** - * @permission ohos.permission.SET_TELEPHONY_STATE - * @systemapi Hide this for inner system use. - * @since 7 - */ - function unlockPuk(slotId: number, newPin: string, puk: string, callback: AsyncCallback): void; - function unlockPuk(slotId: number, newPin: string, puk: string): Promise; - - /** - * @permission ohos.permission.SET_TELEPHONY_STATE - * @systemapi Hide this for inner system use. - * @since 7 - */ - function alterPin(slotId: number, newPin: string, oldPin: string, callback: AsyncCallback): void; - function alterPin(slotId: number, newPin: string, oldPin: string): Promise; - - /** - * @permission ohos.permission.SET_TELEPHONY_STATE - * @systemapi Hide this for inner system use. - * @since 7 - */ - function setLockState(slotId: number, pin: string, enable: number, callback: AsyncCallback): void; - function setLockState(slotId: number, pin: string, enable: number): Promise; - - /** - * @systemapi Hide this for inner system use. - * @since 7 - */ - export interface IccAccountInfo { - slotIndex: number, /* slot id */ - showName: string, /* display name for card */ - showNumber: string, /* display number for card */ - } - - /** - * @systemapi Hide this for inner system use. - * @since 7 - */ - export interface LockStatusResponse { - result: number, /* Current operation result */ - remain?: number, /* Operations remaining */ - } - - export enum SimState { - /** - * Indicates unknown SIM card state, that is, the accurate status cannot be obtained. - */ - SIM_STATE_UNKNOWN, - - /** - * Indicates that the SIM card is in the not present state, that is, no SIM card is inserted - * into the card slot. - */ - SIM_STATE_NOT_PRESENT, - - /** - * Indicates that the SIM card is in the locked state, that is, the SIM card is locked by the - * personal identification number (PIN)/PIN unblocking key (PUK) or network. - */ - SIM_STATE_LOCKED, - - /** - * Indicates that the SIM card is in the not ready state, that is, the SIM card is in position - * but cannot work properly. - */ - SIM_STATE_NOT_READY, - - /** - * Indicates that the SIM card is in the ready state, that is, the SIM card is in position and - * is working properly. - */ - SIM_STATE_READY, - - /** - * Indicates that the SIM card is in the loaded state, that is, the SIM card is in position and - * is working properly. - */ - SIM_STATE_LOADED - } -} - -export default sim; \ No newline at end of file +/* +* Copyright (C) 2021 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import {AsyncCallback} from "./basic"; + +/** + * Provides applications with APIs for obtaining SIM card status, card file information, and card specifications. + * SIM cards include SIM, USIM, and CSIM cards. + * + * @since 6 + * @sysCap SystemCapability.Telephony.CoreService + */ +declare namespace sim { + /** + * Checks whether the SIM card in a specified slot is activated. + * + * @param slotId Indicates the card slot index number, + * ranging from {@code 0} to the maximum card slot index number supported by the device. + * @param callback Returns {@code true} if the SIM card is activated; returns {@code false} otherwise. + * @since 7 + */ + function isSimActive(slotId: number, callback: AsyncCallback): void; + function isSimActive(slotId: number): Promise; + + /** + * Obtains the default card slot for the voice service. + * + * @param callback Returns {@code 0} if card 1 is used as the default card slot for the voice service; + * returns {@code 1} if card 2 is used as the default card slot for the voice service; + * returns {@code -1} if no card is available for the voice service. + * @since 7 + */ + function getDefaultVoiceSlotId(callback: AsyncCallback): void; + function getDefaultVoiceSlotId(): Promise; + + /** + * Checks whether your application (the caller) has been granted the operator permissions. + * + * @param slotId Indicates the ID of the SIM card slot. + * @param callback Returns {@code true} if your application has been granted the operator permissions; + * returns {@code false} otherwise. + * @since 7 + */ + function hasOperatorPrivileges(slotId: number, callback: AsyncCallback): void; + function hasOperatorPrivileges(slotId: number): Promise; + + /** + * Obtains the ISO country code of the SIM card in a specified slot. + * + * @param slotId Indicates the card slot index number, + * ranging from 0 to the maximum card slot index number supported by the device. + * @param callback Returns the country code defined in ISO 3166-2; returns an empty string if no SIM card is inserted. + */ + function getISOCountryCodeForSim(slotId: number, callback: AsyncCallback): void; + function getISOCountryCodeForSim(slotId: number): Promise; + + /** + * Obtains the home PLMN number of the SIM card in a specified slot. + * + *

          The value is recorded in the SIM card and is irrelevant to the network + * with which the SIM card is currently registered. + * + * @param slotId Indicates the card slot index number, + * ranging from 0 to the maximum card slot index number supported by the device. + * @param callback Returns the PLMN number; returns an empty string if no SIM card is inserted. + */ + function getSimOperatorNumeric(slotId: number, callback: AsyncCallback): void; + function getSimOperatorNumeric(slotId: number): Promise; + + /** + * Obtains the service provider name (SPN) of the SIM card in a specified slot. + * + *

          The value is recorded in the EFSPN file of the SIM card and is irrelevant to the network + * with which the SIM card is currently registered. + * + * @param slotId Indicates the card slot index number, + * ranging from 0 to the maximum card slot index number supported by the device. + * @param callback Returns the SPN; returns an empty string if no SIM card is inserted or + * no EFSPN file in the SIM card. + */ + function getSimSpn(slotId: number, callback: AsyncCallback): void; + function getSimSpn(slotId: number): Promise; + + /** + * Obtains the state of the SIM card in a specified slot. + * + * @param slotId Indicates the card slot index number, + * ranging from {@code 0} to the maximum card slot index number supported by the device. + * @param callback Returns one of the following SIM card states: + *

            + *
          • {@code SimState#SIM_STATE_UNKNOWN} + *
          • {@code SimState#SIM_STATE_NOT_PRESENT} + *
          • {@code SimState#SIM_STATE_LOCKED} + *
          • {@code SimState#SIM_STATE_NOT_READY} + *
          • {@code SimState#SIM_STATE_READY} + *
          • {@code SimState#SIM_STATE_LOADED} + *
          + */ + function getSimState(slotId: number, callback: AsyncCallback): void; + function getSimState(slotId: number): Promise; + + /** + * Obtains the type of the SIM card installed in a specified slot. + * + * @param slotId Indicates the ID of the specified slot. + * @param callback Returns the SIM card type. + * @since 7 + */ + function getCardType(slotId: number, callback: AsyncCallback): void; + function getCardType(slotId: number): Promise; + + /** + * Obtains the ICCID of the SIM card in a specified slot. + * + *

          The ICCID is a unique identifier of a SIM card. It consists of 20 digits + * and is recorded in the EFICCID file of the SIM card. + * + *

          Requires Permission: {@code ohos.permission.GET_TELEPHONY_STATE}. + * + * @param slotId Indicates the card slot index number, + * ranging from 0 to the maximum card slot index number supported by the device. + * @param callback Returns the ICCID; returns an empty string if no SIM card is inserted. + * @permission ohos.permission.GET_TELEPHONY_STATE + */ + function getSimIccId(slotId: number, callback: AsyncCallback): void; + function getSimIccId(slotId: number): Promise; + + /** + * Obtains the alpha identifier of the voice mailbox of the SIM card in a specified slot. + * + *

          Only applications with the {@code ohos.permission.GET_TELEPHONY_STATE} permission can call this method. + * + * @param slotId Indicates the card slot index number, + * ranging from {@code 0} to the maximum card slot index number supported by the device. + * @param callback Returns the voice mailbox alpha identifier; + * returns an empty string if no voice mailbox alpha identifier is written into the SIM card. + * @permission ohos.permission.GET_TELEPHONY_STATE + * @since 8 + */ + function getVoiceMailIdentifier(slotId: number, callback: AsyncCallback): void; + function getVoiceMailIdentifier(slotId: number): Promise; + + /** + * Obtains the voice mailbox number of the SIM card in a specified slot. + * + *

          Only applications with the {@code ohos.permission.GET_TELEPHONY_STATE} permission can call this method. + * + * @param slotId Indicates the card slot index number, + * ranging from {@code 0} to the maximum card slot index number supported by the device. + * @param callback Returns the voice mailbox number; + * returns an empty string if no voice mailbox number is written into the SIM card. + * @permission ohos.permission.GET_TELEPHONY_STATE + * @since 8 + */ + function getVoiceMailNumber(slotId: number, callback: AsyncCallback): void; + function getVoiceMailNumber(slotId: number): Promise; + + /** + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 8 + */ + function setVoiceMailInfo(slotId: number, mailName: string, mailNumber: string, callback: AsyncCallback): void; + function setVoiceMailInfo(slotId: number, mailName: string, mailNumber: string): Promise; + + /** + * Obtains the MSISDN of the SIM card in a specified slot. + * The MSISDN is recorded in the EFMSISDN file of the SIM card. + * + *

          Requires Permission: {@code ohos.permission.GET_TELEPHONY_STATE}. + * + * @param slotId Indicates the card slot index number, + * ranging from 0 to the maximum card slot index number supported by the device. + * @param callback Returns the MSISDN; returns an empty string if no SIM card is inserted or + * no MSISDN is recorded in the EFMSISDN file. + * @permission ohos.permission.GET_TELEPHONY_STATE + * @since 8 + */ + function getSimTelephoneNumber(slotId: number, callback: AsyncCallback): void; + function getSimTelephoneNumber(slotId: number): Promise; + + /** + * Obtains the Group Identifier Level 1 (GID1) of the SIM card in a specified slot. + * The GID1 is recorded in the EFGID1 file of the SIM card. + * + *

          Requires Permission: {@code ohos.permission.GET_TELEPHONY_STATE}. + * + * @param slotId Indicates the card slot index number, + * ranging from 0 to the maximum card slot index number supported by the device. + * @param callback Returns the GID1; returns an empty string if no SIM card is inserted or + * no GID1 in the SIM card. + * @permission ohos.permission.GET_TELEPHONY_STATE + * @since 8 + */ + function getSimGid1(slotId: number, callback: AsyncCallback): void; + function getSimGid1(slotId: number): Promise; + + /** + * Obtains the maximum number of SIM cards that can be used simultaneously on the device, + * that is, the maximum number of SIM card slots. + * + * @return Returns the maximum number of SIM card slots. + * @since 7 + */ + function getMaxSimCount(): number; + + /** + * @permission ohos.permission.GET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + */ + function getIMSI(slotId: number, callback: AsyncCallback): void; + function getIMSI(slotId: number): Promise; + + /** + * Checks whether a SIM card is inserted in a specified slot. + * + * @param slotId Indicates the card slot index number, + * ranging from 0 to the maximum card slot index number supported by the device. + * @param callback Returns true if a SIM card is inserted; return false otherwise. + * @since 7 + */ + function hasSimCard(slotId: number, callback: AsyncCallback): void; + function hasSimCard(slotId: number): Promise; + + /** + * @permission ohos.permission.GET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 7 + */ + function getSimAccountInfo(slotId: number, callback: AsyncCallback): void; + function getSimAccountInfo(slotId: number): Promise; + + /** + * @permission ohos.permission.GET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 8 + */ + function getActiveSimAccountInfoList(callback: AsyncCallback>): void; + function getActiveSimAccountInfoList(): Promise>; + + /** + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 7 + */ + function setDefaultVoiceSlotId(slotId: number, callback: AsyncCallback): void; + function setDefaultVoiceSlotId(slotId: number): Promise; + + /** + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 8 + */ + function activateSim(slotId: number, callback: AsyncCallback): void; + function activateSim(slotId: number): Promise; + + /** + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 8 + */ + function deactivateSim(slotId: number, callback: AsyncCallback): void; + function deactivateSim(slotId: number): Promise; + + /** + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 8 + */ + function setShowName(slotId: number, name: string, callback: AsyncCallback): void; + function setShowName(slotId: number, name: string): Promise; + + /** + * @permission ohos.permission.GET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 8 + */ + function getShowName(slotId: number, callback: AsyncCallback): void; + function getShowName(slotId: number): Promise; + + /** + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 8 + */ + function setShowNumber(slotId: number, number: string, callback: AsyncCallback): void; + function setShowNumber(slotId: number, number: string): Promise; + + /** + * @permission ohos.permission.GET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 8 + */ + function getShowNumber(slotId: number, callback: AsyncCallback): void; + function getShowNumber(slotId: number): Promise; + + /** + * @permission ohos.permission.GET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 8 + */ + function getOperatorConfigs(slotId: number, callback: AsyncCallback>): void; + function getOperatorConfigs(slotId: number): Promise>; + + /** + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 7 + */ + function unlockPin(slotId: number, pin: string, callback: AsyncCallback): void; + function unlockPin(slotId: number, pin: string): Promise; + + /** + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 7 + */ + function unlockPuk(slotId: number, newPin: string, puk: string, callback: AsyncCallback): void; + function unlockPuk(slotId: number, newPin: string, puk: string): Promise; + + /** + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 7 + */ + function alterPin(slotId: number, newPin: string, oldPin: string, callback: AsyncCallback): void; + function alterPin(slotId: number, newPin: string, oldPin: string): Promise; + + /** + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 7 + */ + function setLockState(slotId: number, options: LockInfo, callback: AsyncCallback): void; + function setLockState(slotId: number, options: LockInfo): Promise; + + /** + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 8 + */ + function unlockPin2(slotId: number, pin2: string, callback: AsyncCallback): void; + function unlockPin2(slotId: number, pin2: string): Promise; + + /** + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 8 + */ + function unlockPuk2(slotId: number, newPin2: string, puk2: string, callback: AsyncCallback): void; + function unlockPuk2(slotId: number, newPin2: string, puk2: string): Promise; + + /** + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 8 + */ + function alterPin2(slotId: number, newPin2: string, oldPin2: string, callback: AsyncCallback): void; + function alterPin2(slotId: number, newPin2: string, oldPin2: string): Promise; + + /** + * @permission ohos.permission.READ_CONTACTS + * @systemapi Hide this for inner system use. + * @since 8 + */ + function queryIccDiallingNumbers(slotId: number, type: ContactType, callback: AsyncCallback>): void + function queryIccDiallingNumbers(slotId: number, type: ContactType): Promise>; + + /** + * @permission ohos.permission.WRITE_CONTACTS + * @systemapi Hide this for inner system use. + * @since 8 + */ + function addIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo, callback: AsyncCallback): void; + function addIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo): Promise; + + /** + * @permission ohos.permission.WRITE_CONTACTS + * @systemapi Hide this for inner system use. + * @since 8 + */ + function delIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo, callback: AsyncCallback): void; + function delIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo): Promise; + + /** + * @permission ohos.permission.WRITE_CONTACTS + * @systemapi Hide this for inner system use. + * @since 8 + */ + function updateIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo, callback: AsyncCallback): void; + function updateIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function getLockState(slotId: number, lockType: LockType, callback: AsyncCallback): void; + function getLockState(slotId: number, lockType: LockType): Promise; + + /** + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 8 + */ + function sendEnvelopeCmd(slotId: number, cmd: string, callback: AsyncCallback): void; + function sendEnvelopeCmd(slotId: number, cmd: string): Promise; + + /** + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 8 + */ + function sendTerminalResponseCmd(slotId: number, cmd: string, callback: AsyncCallback): void; + function sendTerminalResponseCmd(slotId: number, cmd: string): Promise; + + /** + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 8 + */ + function unlockSimLock(slotId: number, lockInfo: PersoLockInfo, callback: AsyncCallback): void; + function unlockSimLock(slotId: number, lockInfo: PersoLockInfo): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export interface OperatorConfig { + field: string; + value: string; + } + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + export interface IccAccountInfo { + /** + * sim Id for card. + */ + simId: number; + /** + * slot id. + */ + slotIndex: number; + /** + * mark card is eSim or not. + */ + isEsim: boolean; + /** + * active status for card. + */ + isActive: boolean; + /** + * iccId for card. + */ + iccId: string; + /** + * display name for card. + */ + showName: string; + /** + * display number for card. + */ + showNumber: string; + } + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + export interface LockStatusResponse { + /** + * Current operation result + */ + result: number; + /** + * Operations remaining + */ + remain?: number; + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export interface DiallingNumbersInfo { + alphaTag: string; + number: string; + recordNumber?: number; + pin2?: string; + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export interface LockInfo { + lockType: LockType; + password: string; + state: LockState; + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export interface PersoLockInfo { + lockType: PersoLockType; + password: string; + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum LockType { + PIN_LOCK = 1, + FDN_LOCK = 2, + } + + /** + * @since 7 + */ + export enum CardType { + /** Icc card type: Unknow type Card. */ + UNKNOWN_CARD = -1, + + /** Icc card type: Single sim card type. */ + SINGLE_MODE_SIM_CARD = 10, + + /** Icc card type: Single usim card type. */ + SINGLE_MODE_USIM_CARD = 20, + + /** Icc card type: Single ruim card type. */ + SINGLE_MODE_RUIM_CARD = 30, + + /** Icc card type: Double card C+G. */ + DUAL_MODE_CG_CARD = 40, + + /** Icc card type: China Telecom Internal Roaming Card (Dual Mode). */ + CT_NATIONAL_ROAMING_CARD = 41, + + /** Icc card type: China Unicom Dual Mode Card. */ + CU_DUAL_MODE_CARD = 42, + + /** Icc card type: China Telecom LTE Card (Dual Mode). */ + DUAL_MODE_TELECOM_LTE_CARD = 43, + + /** Icc card type: Double card U+G. */ + DUAL_MODE_UG_CARD = 50, + + /** + * Icc card type: Single isim card type. + * @since 8 + */ + SINGLE_MODE_ISIM_CARD = 60 + } + + export enum SimState { + /** + * Indicates unknown SIM card state, that is, the accurate status cannot be obtained. + */ + SIM_STATE_UNKNOWN, + + /** + * Indicates that the SIM card is in the not present state, that is, no SIM card is inserted + * into the card slot. + */ + SIM_STATE_NOT_PRESENT, + + /** + * Indicates that the SIM card is in the locked state, that is, the SIM card is locked by the + * personal identification number (PIN)/PIN unblocking key (PUK) or network. + */ + SIM_STATE_LOCKED, + + /** + * Indicates that the SIM card is in the not ready state, that is, the SIM card is in position + * but cannot work properly. + */ + SIM_STATE_NOT_READY, + + /** + * Indicates that the SIM card is in the ready state, that is, the SIM card is in position and + * is working properly. + */ + SIM_STATE_READY, + + /** + * Indicates that the SIM card is in the loaded state, that is, the SIM card is in position and + * is working properly. + */ + SIM_STATE_LOADED + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum LockState { + /**Indicates that the lock state card is in the off state. */ + LOCK_OFF = 0, + + /**Indicates that the lock state card is in the on state. */ + LOCK_ON = 1, + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum ContactType { + GENERAL_CONTACT = 1, + FIXED_DIALING = 2, + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum PersoLockType { + PN_PIN_LOCK, //Network Personalization (refer 3GPP TS 22.022 [33]) + PN_PUK_LOCK, + PU_PIN_LOCK, //network sUbset Personalization (refer 3GPP TS 22.022 [33]) + PU_PUK_LOCK, + PP_PIN_LOCK, //service Provider Personalization (refer 3GPP TS 22.022 [33]) + PP_PUK_LOCK, + PC_PIN_LOCK, //Corporate Personalization (refer 3GPP TS 22.022 [33]) + PC_PUK_LOCK, + SIM_PIN_LOCK, //SIM/USIM personalisation (refer 3GPP TS 22.022 [33]) + SIM_PUK_LOCK, + } +} + +export default sim; diff --git a/api/@ohos.telephony.sms.d.ts b/api/@ohos.telephony.sms.d.ts index 709f1b690..9a0d5cbd8 100644 --- a/api/@ohos.telephony.sms.d.ts +++ b/api/@ohos.telephony.sms.d.ts @@ -1,303 +1,644 @@ -/* -* Copyright (C) 2021 Huawei Device Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import {AsyncCallback} from "./basic"; - -/** - * Provides the capabilities and methods for obtaining Short Message Service (SMS) management objects. - * - * @since 6 - * @sysCap SystemCapability.Telephony.Telephony - */ -declare namespace sms { - /** - * Creates an SMS message instance based on the protocol data unit (PDU) and the specified SMS protocol. - * - *

          After receiving the original PDU data, the system creates an SMS message instance according to the specified - * SMS protocol. - * - * @param pdu Indicates the original data, which is obtained from the received SMS. - * @param specification Indicates the SMS protocol type. The value {@code 3gpp} indicates GSM/UMTS/LTE SMS, - * and the value {@code 3gpp2} indicates CDMA/LTE SMS. - * @param callback Returns an SMS message instance; returns {@code null} if {@code pdu} is empty or - * {@code specification} is not supported. - */ - function createMessage(pdu: Array, specification: string, callback: AsyncCallback): void; - function createMessage(pdu: Array, specification: string): Promise; - - /** - * Sends a text or data SMS message. - * - *

          This method checks whether the length of an SMS message exceeds the maximum length. If the - * maximum length is exceeded, the SMS message is split into multiple parts and sent separately. - *

          You need to obtain the following permission before calling this method: - * {@code ohos.permission.SEND_MESSAGES} - * - * @param options Indicates the parameters and callback for sending the SMS message. - * @permission ohos.permission.SEND_MESSAGES - */ - function sendMessage(options: SendMessageOptions): void; - - /** - * Sets the default SIM card for sending SMS messages. You can obtain the default SIM card by - * using {@code getDefaultSmsSlotId}. - * - * @param slotId Indicates the default SIM card for sending SMS messages. The value {@code 0} indicates card slot 1, - * and the value {@code 1} indicates card slot 2. - * @permission ohos.permission.SET_TELEPHONY_STATE - * @systemapi Hide this for inner system use. - * @since 7 - */ - function setDefaultSmsSlotId(slotId: number, callback: AsyncCallback): void; - function setDefaultSmsSlotId(slotId: number): Promise; - - /** - * Obtains the default SIM card for sending SMS messages. - * - * @param callback Returns {@code 0} if the default SIM card for sending SMS messages is in card slot 1; - * returns {@code 1} if the default SIM card for sending SMS messages is in card slot 2. - * @since 7 - */ - function getDefaultSmsSlotId(callback: AsyncCallback): void; - function getDefaultSmsSlotId(): Promise; - - /** - * Sets the address for the Short Message Service Center (SMSC) based on a specified slot ID. - * - *

          Permissions: {@link ohos.security.SystemPermission#SET_TELEPHONY_STATE} - * - * @param slotId Indicates the ID of the slot holding the SIM card for sending SMS messages. - * @param smscAddr Indicates the SMSC address. - * @permission ohos.permission.SET_TELEPHONY_STATE - * @since 7 - */ - function setSmscAddr(slotId: number, smscAddr: string, callback: AsyncCallback): void; - function setSmscAddr(slotId: number, smscAddr: string): Promise; - - /** - * Obtains the SMSC address based on a specified slot ID. - * - *

          Permissions: {@link ohos.security.SystemPermission#GET_TELEPHONY_STATE} - * - * @param slotId Indicates the ID of the slot holding the SIM card for sending SMS messages. - * @param callback Returns the SMSC address. - * @permission ohos.permission.GET_TELEPHONY_STATE - * @since 7 - */ - function getSmscAddr(slotId: number, callback: AsyncCallback): void; - function getSmscAddr(slotId: number): Promise; - - /** - * @permission ohos.permission.RECEIVE_SMS,ohos.permission.SEND_MESSAGES - * @systemapi Hide this for inner system use. - * @since 7 - */ - function addSimMessage(options: SimMessageOptions, callback: AsyncCallback): void; - function addSimMessage(options: SimMessageOptions): Promise; - - /** - * @permission ohos.permission.RECEIVE_SMS,ohos.permission.SEND_MESSAGES - * @systemapi Hide this for inner system use. - * @since 7 - */ - function delSimMessage(slotId: number, msgIndex: number, callback: AsyncCallback): void; - function delSimMessage(slotId: number, msgIndex: number): Promise; - - /** - * @permission ohos.permission.RECEIVE_SMS,ohos.permission.SEND_MESSAGES - * @systemapi Hide this for inner system use. - * @since 7 - */ - function updateSimMessage(options: UpdateSimMessageOptions, callback: AsyncCallback): void; - function updateSimMessage(options: UpdateSimMessageOptions): Promise; - - /** - * @permission ohos.permission.RECEIVE_SMS - * @systemapi Hide this for inner system use. - * @since 7 - */ - function getAllSimMessages(slotId: number, callback: AsyncCallback>): void; - function getAllSimMessages(slotId: number): Promise>; - - /** - * @permission ohos.permission.RECEIVE_SMS - * @systemapi Hide this for inner system use. - * @since 7 - */ - function setCBConfig(options: CBConfigOptions, callback: AsyncCallback): void; - function setCBConfig(options: CBConfigOptions): Promise; - - /** - * @systemapi Hide this for inner system use. - * @since 7 - */ - export interface CBConfigOptions { - slotId: number, - enable: boolean, - startMessageId: number, - endMessageId: number, - ranType: number - } - - /** - * @systemapi Hide this for inner system use. - * @since 7 - */ - export interface SimMessageOptions { - slotId: number, - smsc: string, - pdu: string, - status: SimMessageStatus - } - - /** - * @systemapi Hide this for inner system use. - * @since 7 - */ - export interface UpdateSimMessageOptions { - slotId: number, - msgIndex: number, - newStatus: SimMessageStatus, - pdu: string, - smsc: string - } - - export interface ShortMessage { - /** Indicates the SMS message body. */ - visibleMessageBody: string; - /** Indicates the address of the sender, which is to be displayed on the UI. */ - visibleRawAddress: string; - /** Indicates the SMS type. */ - messageClass: ShortMessageClass; - /** Indicates the protocol identifier. */ - protocolId: number; - /** Indicates the short message service center (SMSC) address. */ - scAddress: string; - /** Indicates the SMSC timestamp. */ - scTimestamp: number; - /** Indicates whether the received SMS is a "replace short message". */ - isReplaceMessage: boolean; - /** Indicates whether the received SMS contains "TP-Reply-Path". */ - hasReplyPath: boolean; - /** Indicates Protocol Data Units (PDUs) from an SMS message. */ - pdu: Array; - /** - * Indicates the SMS message status from the SMS-STATUS-REPORT message sent by the - * Short Message Service Center (SMSC). - */ - status: number; - /** Indicates whether the current message is SMS-STATUS-REPORT. */ - isSmsStatusReportMessage: boolean; - } - - /** - * @systemapi Hide this for inner system use. - * @since 7 - */ - export interface SimShortMessage { - shortMessage: ShortMessage; - - /** Indicates the storage status of SMS messages in the SIM */ - simMessageStatus: SimMessageStatus; - /** Indicates the index of SMS messages in the SIM */ - indexOnSim: number; - } - - /** - * @systemapi Hide this for inner system use. - * @since 7 - */ - export enum SimMessageStatus { - /** status free space ON SIM */ - SIM_MESSAGE_STATUS_FREE = 0, - /** REC READ received read message */ - SIM_MESSAGE_STATUS_READ = 1, - /** REC UNREAD received unread message */ - SIM_MESSAGE_STATUS_UNREAD = 3, - /** STO SENT stored sent message (only applicable to SMs) */ - SIM_MESSAGE_STATUS_SENT = 5, - /** STO UNSENT stored unsent message (only applicable to SMs) */ - SIM_MESSAGE_STATUS_UNSENT = 7, - } - - export enum ShortMessageClass { - /** Indicates an unknown type. */ - UNKNOWN, - /** Indicates an instant message, which is displayed immediately after being received. */ - INSTANT_MESSAGE, - /** Indicates an SMS message that can be stored on the device or SIM card based on the storage status. */ - OPTIONAL_MESSAGE, - /** Indicates an SMS message containing SIM card information, which is to be stored in a SIM card. */ - SIM_MESSAGE, - /** Indicates an SMS message to be forwarded to another device. */ - FORWARD_MESSAGE - } - - export interface SendMessageOptions { - /** Indicates the ID of the SIM card slot used for sending the SMS message. */ - slotId: number; - /** Indicates the address to which the SMS message is sent. */ - destinationHost: string; - /** Indicates the SMSC address. If the value is {@code null}, the default SMSC address of the SIM card*/ - serviceCenter?: string; - /** If the content is a string, this is a short message. If the content is a byte array, this is a data message. */ - content: string | Array; - /** If send data message, destinationPort is mandatory. Otherwise is optional. */ - destinationPort?: number; - /** Indicates the callback invoked after the SMS message is sent. */ - sendCallback?: AsyncCallback; - /** Indicates the callback invoked after the SMS message is delivered. */ - deliveryCallback?: AsyncCallback; - } - - export interface ISendShortMessageCallback { - /** Indicates the SMS message sending result. */ - result: SendSmsResult; - /** Indicates the URI to store the sent SMS message. */ - url: string; - /** Specifies whether this is the last part of a multi-part SMS message. */ - isLastPart: boolean; - } - - export interface IDeliveryShortMessageCallback { - /** Indicates the SMS delivery report. */ - pdu: Array; - } - - export enum SendSmsResult { - /** - * Indicates that the SMS message is successfully sent. - */ - SEND_SMS_SUCCESS = 0, - - /** - * Indicates that sending the SMS message fails due to an unknown reason. - */ - SEND_SMS_FAILURE_UNKNOWN = 1, - - /** - * Indicates that sending the SMS fails because the modem is powered off. - */ - SEND_SMS_FAILURE_RADIO_OFF = 2, - - /** - * Indicates that sending the SMS message fails because the network is unavailable - * or does not support sending or reception of SMS messages. - */ - SEND_SMS_FAILURE_SERVICE_UNAVAILABLE = 3 - } -} - -export default sms; +/* +* Copyright (C) 2021 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import {AsyncCallback} from "./basic"; + +/** + * Provides the capabilities and methods for obtaining Short Message Service (SMS) management objects. + * + * @since 6 + * @sysCap SystemCapability.Telephony.SmsMms + */ +declare namespace sms { + /** + * Splits a long SMS message into multiple fragments. + * + *

          If the length of an SMS message exceeds the maximum length allowed (140 bytes), + * the SMS message is split into multiple segments for processing. + *

          Applications must have the {@code ohos.permission.SEND_MESSAGES} permission to call this method. + * + * @param content Indicates the short message content, which cannot be {@code null}. + * @param callback Returns a list of split segments, which can be combined into a complete SMS message; + * returns an empty string if no permission is granted or the short message content is {@code null}. + * @permission ohos.permission.SEND_MESSAGES + * @systemapi Hide this for inner system use. + * @since 8 + */ + function splitMessage(content: string, callback: AsyncCallback>): void; + function splitMessage(content: string): Promise>; + + /** + * Creates an SMS message instance based on the protocol data unit (PDU) and the specified SMS protocol. + * + *

          After receiving the original PDU data, the system creates an SMS message instance according to the specified + * SMS protocol. + * + * @param pdu Indicates the original data, which is obtained from the received SMS. + * @param specification Indicates the SMS protocol type. The value {@code 3gpp} indicates GSM/UMTS/LTE SMS, + * and the value {@code 3gpp2} indicates CDMA/LTE SMS. + * @param callback Returns an SMS message instance; returns {@code null} if {@code pdu} is empty or + * {@code specification} is not supported. + */ + function createMessage(pdu: Array, specification: string, callback: AsyncCallback): void; + function createMessage(pdu: Array, specification: string): Promise; + + /** + * Sends a text or data SMS message. + * + *

          This method checks whether the length of an SMS message exceeds the maximum length. If the + * maximum length is exceeded, the SMS message is split into multiple parts and sent separately. + *

          You need to obtain the following permission before calling this method: + * {@code ohos.permission.SEND_MESSAGES} + * + * @param options Indicates the parameters and callback for sending the SMS message. + * @permission ohos.permission.SEND_MESSAGES + */ + function sendMessage(options: SendMessageOptions): void; + + /** + * Sets the default SIM card for sending SMS messages. You can obtain the default SIM card by + * using {@code getDefaultSmsSlotId}. + * + * @param slotId Indicates the default SIM card for sending SMS messages. The value {@code 0} indicates card slot 1, + * and the value {@code 1} indicates card slot 2. + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 7 + */ + function setDefaultSmsSlotId(slotId: number, callback: AsyncCallback): void; + function setDefaultSmsSlotId(slotId: number): Promise; + + /** + * Obtains the default SIM card for sending SMS messages. + * + * @param callback Returns {@code 0} if the default SIM card for sending SMS messages is in card slot 1; + * returns {@code 1} if the default SIM card for sending SMS messages is in card slot 2. + * @since 7 + */ + function getDefaultSmsSlotId(callback: AsyncCallback): void; + function getDefaultSmsSlotId(): Promise; + + /** + * Sets the address for the Short Message Service Center (SMSC) based on a specified slot ID. + * + *

          Permissions: {@link ohos.security.SystemPermission#SET_TELEPHONY_STATE} + * + * @param slotId Indicates the ID of the slot holding the SIM card for sending SMS messages. + * @param smscAddr Indicates the SMSC address. + * @permission ohos.permission.SET_TELEPHONY_STATE + * @since 7 + */ + function setSmscAddr(slotId: number, smscAddr: string, callback: AsyncCallback): void; + function setSmscAddr(slotId: number, smscAddr: string): Promise; + + /** + * Obtains the SMSC address based on a specified slot ID. + * + *

          Permissions: {@link ohos.security.SystemPermission#GET_TELEPHONY_STATE} + * + * @param slotId Indicates the ID of the slot holding the SIM card for sending SMS messages. + * @param callback Returns the SMSC address. + * @permission ohos.permission.GET_TELEPHONY_STATE + * @since 7 + */ + function getSmscAddr(slotId: number, callback: AsyncCallback): void; + function getSmscAddr(slotId: number): Promise; + + /** + * Returns whether a device is capable of sending and receiving SMS messages. + * + * @return Returns {@code true} if the device is capable of sending and receiving SMS messages; + * returns {@code false} otherwise. + * @since 7 + */ + function hasSmsCapability(): boolean; + + /** + * @permission ohos.permission.RECEIVE_SMS,ohos.permission.SEND_MESSAGES + * @systemapi Hide this for inner system use. + * @since 7 + */ + function addSimMessage(options: SimMessageOptions, callback: AsyncCallback): void; + function addSimMessage(options: SimMessageOptions): Promise; + + /** + * @permission ohos.permission.RECEIVE_SMS,ohos.permission.SEND_MESSAGES + * @systemapi Hide this for inner system use. + * @since 7 + */ + function delSimMessage(slotId: number, msgIndex: number, callback: AsyncCallback): void; + function delSimMessage(slotId: number, msgIndex: number): Promise; + + /** + * @permission ohos.permission.RECEIVE_SMS,ohos.permission.SEND_MESSAGES + * @systemapi Hide this for inner system use. + * @since 7 + */ + function updateSimMessage(options: UpdateSimMessageOptions, callback: AsyncCallback): void; + function updateSimMessage(options: UpdateSimMessageOptions): Promise; + + /** + * @permission ohos.permission.RECEIVE_SMS + * @systemapi Hide this for inner system use. + * @since 7 + */ + function getAllSimMessages(slotId: number, callback: AsyncCallback>): void; + function getAllSimMessages(slotId: number): Promise>; + + /** + * @permission ohos.permission.RECEIVE_SMS + * @systemapi Hide this for inner system use. + * @since 7 + */ + function setCBConfig(options: CBConfigOptions, callback: AsyncCallback): void; + function setCBConfig(options: CBConfigOptions): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function getSmsSegmentsInfo(slotId: number, message: string, force7bit: boolean, callback: AsyncCallback): void; + function getSmsSegmentsInfo(slotId: number, message: string, force7bit: boolean): Promise; + + /** + * SMS over IMS is supported if IMS is registered and SMS is supported on IMS. + * + * @param callback Returns true if SMS over IMS is supported, false otherwise. + * @systemapi Hide this for inner system use. + * @since 8 + */ + function isImsSmsSupported(callback: AsyncCallback): void; + function isImsSmsSupported(): Promise; + + /** + * Gets SMS format supported on IMS. SMS over IMS format is either 3GPP or 3GPP2. + * + * @param callback Returns format, 3gpp, 3gpp2 or unknown. + * @systemapi Hide this for inner system use. + * @since 8 + */ + function getImsShortMessageFormat(callback: AsyncCallback): void; + function getImsShortMessageFormat(): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function decodeMms(mmsFilePathName: string | Array, callback: AsyncCallback): void; + function decodeMms(mmsFilePathName: string | Array): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + function encodeMms(mms: MmsInformation, callback: AsyncCallback>): void; + function encodeMms(mms: MmsInformation): Promise>; + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export interface MmsInformation { + messageType: MessageType; + mmsType: MmsSendReq | MmsSendConf | MmsNotificationInd | MmsRespInd | MmsRetrieveConf | MmsAcknowledgeInd | MmsDeliveryInd | MmsReadOrigInd | MmsReadRecInd; + attachment?: Array; + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export interface MmsSendReq { + from: MmsAddress; + transactionId: string; + contentType: string; + version: MmsVersionType; + to?: Array; + date?: number; + cc?: Array; + bcc?: Array; + subject?: string; + messageClass?: number; + expiry?: number; + priority?: MmsPriorityType; + senderVisibility?: number; + deliveryReport?: number; + readReport?: number; + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export interface MmsSendConf { + responseState: number; + transactionId: string; + version: MmsVersionType; + messageId?: string; + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export interface MmsNotificationInd { + transactionId: string; + messageClass: number; + messageSize: number; + expiry: number; + contentLocation: string; + version: MmsVersionType; + from?: MmsAddress; + subject?: string; + deliveryReport?: number; + contentClass?: number; + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export interface MmsRespInd { + transactionId: string; + status: number; + version: MmsVersionType; + reportAllowed?: ReportType; + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export interface MmsRetrieveConf { + transactionId: string; + messageId: string; + date: number; + contentType: string; + to: Array; + version: MmsVersionType; + from?: MmsAddress; + cc?: Array; + subject?: string; + priority?: MmsPriorityType; + deliveryReport?: number; + readReport?: number; + retrieveStatus?: number; + retrieveText?: string; + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export interface MmsAcknowledgeInd { + transactionId: string; + version: MmsVersionType; + reportAllowed?: ReportType; + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export interface MmsDeliveryInd { + messageId: string; + date: number; + to: Array; + status: number; + version: MmsVersionType; + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export interface MmsReadOrigInd { + version: MmsVersionType; + messageId: string; + to: Array; + from: MmsAddress; + date: number; + readStatus: number; + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export interface MmsReadRecInd { + version: MmsVersionType; + messageId: string; + to: Array; + from: MmsAddress; + readStatus: number; + date?: number; + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export interface MmsAttachment { + contentId: string; + contentLocation: string; + contentDisposition: DispositionType; + contentTransferEncoding: string; + contentType: string; + isSmil: boolean; + path?: string; + inBuff?: Array; + fileName?: string; + charset?: MmsCharSets; + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export interface MmsAddress { + address: string; + charset: MmsCharSets; + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum MessageType { + TYPE_MMS_SEND_REQ = 128, + TYPE_MMS_SEND_CONF, + TYPE_MMS_NOTIFICATION_IND, + TYPE_MMS_RESP_IND, + TYPE_MMS_RETRIEVE_CONF, + TYPE_MMS_ACKNOWLEDGE_IND, + TYPE_MMS_DELIVERY_IND, + TYPE_MMS_READ_REC_IND, + TYPE_MMS_READ_ORIG_IND, + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum MmsPriorityType { + MMS_LOW = 128, + MMS_NORMAL, + MMS_HIGH, + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum MmsVersionType { + MMS_VERSION_1_0 = 0x10, + MMS_VERSION_1_1, + MMS_VERSION_1_2, + MMS_VERSION_1_3, + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum MmsCharSets { + BIG5 = 0X07EA, + ISO_10646_UCS_2 = 0X03E8, + ISO_8859_1 = 0X04, + ISO_8859_2, + ISO_8859_3, + ISO_8859_4, + ISO_8859_5, + ISO_8859_6, + ISO_8859_7, + ISO_8859_8, + ISO_8859_9, + SHIFT_JIS = 0X11, + US_ASCII = 0X03, + UTF_8 = 0X6A, + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum DispositionType { + FROM_DATA = 0, + ATTACHMENT, + INLINE, + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum ReportType { + MMS_YES = 128, + MMS_NO, + } + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + export interface CBConfigOptions { + slotId: number; + enable: boolean; + startMessageId: number; + endMessageId: number; + ranType: RanType; + } + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + export interface SimMessageOptions { + slotId: number; + smsc: string; + pdu: string; + status: SimMessageStatus; + } + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + export interface UpdateSimMessageOptions { + slotId: number; + msgIndex: number; + newStatus: SimMessageStatus; + pdu: string; + smsc: string; + } + + export interface ShortMessage { + /** Indicates the SMS message body. */ + visibleMessageBody: string; + /** Indicates the address of the sender, which is to be displayed on the UI. */ + visibleRawAddress: string; + /** Indicates the SMS type. */ + messageClass: ShortMessageClass; + /** Indicates the protocol identifier. */ + protocolId: number; + /** Indicates the short message service center (SMSC) address. */ + scAddress: string; + /** Indicates the SMSC timestamp. */ + scTimestamp: number; + /** Indicates whether the received SMS is a "replace short message". */ + isReplaceMessage: boolean; + /** Indicates whether the received SMS contains "TP-Reply-Path". */ + hasReplyPath: boolean; + /** Indicates Protocol Data Units (PDUs) from an SMS message. */ + pdu: Array; + /** + * Indicates the SMS message status from the SMS-STATUS-REPORT message sent by the + * Short Message Service Center (SMSC). + */ + status: number; + /** Indicates whether the current message is SMS-STATUS-REPORT. */ + isSmsStatusReportMessage: boolean; + } + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + export interface SimShortMessage { + shortMessage: ShortMessage; + + /** Indicates the storage status of SMS messages in the SIM */ + simMessageStatus: SimMessageStatus; + /** Indicates the index of SMS messages in the SIM */ + indexOnSim: number; + } + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + export enum SimMessageStatus { + /** status free space ON SIM */ + SIM_MESSAGE_STATUS_FREE = 0, + /** REC READ received read message */ + SIM_MESSAGE_STATUS_READ = 1, + /** REC UNREAD received unread message */ + SIM_MESSAGE_STATUS_UNREAD = 3, + /** STO SENT stored sent message (only applicable to SMs) */ + SIM_MESSAGE_STATUS_SENT = 5, + /** STO UNSENT stored unsent message (only applicable to SMs) */ + SIM_MESSAGE_STATUS_UNSENT = 7, + } + + export enum ShortMessageClass { + /** Indicates an unknown type. */ + UNKNOWN, + /** Indicates an instant message, which is displayed immediately after being received. */ + INSTANT_MESSAGE, + /** Indicates an SMS message that can be stored on the device or SIM card based on the storage status. */ + OPTIONAL_MESSAGE, + /** Indicates an SMS message containing SIM card information, which is to be stored in a SIM card. */ + SIM_MESSAGE, + /** Indicates an SMS message to be forwarded to another device. */ + FORWARD_MESSAGE + } + + export interface SendMessageOptions { + /** Indicates the ID of the SIM card slot used for sending the SMS message. */ + slotId: number; + /** Indicates the address to which the SMS message is sent. */ + destinationHost: string; + /** Indicates the SMSC address. If the value is {@code null}, the default SMSC address of the SIM card*/ + serviceCenter?: string; + /** If the content is a string, this is a short message. If the content is a byte array, this is a data message. */ + content: string | Array; + /** If send data message, destinationPort is mandatory. Otherwise is optional. */ + destinationPort?: number; + /** Indicates the callback invoked after the SMS message is sent. */ + sendCallback?: AsyncCallback; + /** Indicates the callback invoked after the SMS message is delivered. */ + deliveryCallback?: AsyncCallback; + } + + export interface ISendShortMessageCallback { + /** Indicates the SMS message sending result. */ + result: SendSmsResult; + /** Indicates the URI to store the sent SMS message. */ + url: string; + /** Specifies whether this is the last part of a multi-part SMS message. */ + isLastPart: boolean; + } + + export interface IDeliveryShortMessageCallback { + /** Indicates the SMS delivery report. */ + pdu: Array; + } + + export enum SendSmsResult { + /** + * Indicates that the SMS message is successfully sent. + */ + SEND_SMS_SUCCESS = 0, + + /** + * Indicates that sending the SMS message fails due to an unknown reason. + */ + SEND_SMS_FAILURE_UNKNOWN = 1, + + /** + * Indicates that sending the SMS fails because the modem is powered off. + */ + SEND_SMS_FAILURE_RADIO_OFF = 2, + + /** + * Indicates that sending the SMS message fails because the network is unavailable + * or does not support sending or reception of SMS messages. + */ + SEND_SMS_FAILURE_SERVICE_UNAVAILABLE = 3 + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum RanType { + TYPE_GSM = 1, // GSM + TYPE_CDMA = 2, // CDMA + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export interface SmsSegmentsInfo { + splitCount: number; + encodeCount: number; + encodeCountRemaining: number; + scheme: SmsEncodingScheme; + } + + /** + * @systemapi Hide this for inner system use. + * @since 8 + */ + export enum SmsEncodingScheme { + SMS_ENCODING_UNKNOWN = 0, + SMS_ENCODING_7BIT, + SMS_ENCODING_8BIT, + SMS_ENCODING_16BIT, + } +} + +export default sms; \ No newline at end of file From 0c87896475501a53e2b1fc5cfd9ca95593d934a7 Mon Sep 17 00:00:00 2001 From: clevercong Date: Fri, 18 Feb 2022 17:12:15 +0800 Subject: [PATCH 2/2] format code. Signed-off-by: clevercong --- api/@ohos.net.connection.d.ts | 7 ------- api/@ohos.telephony.call.d.ts | 3 +++ api/@ohos.telephony.sms.d.ts | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/api/@ohos.net.connection.d.ts b/api/@ohos.net.connection.d.ts index 0014fd3e2..2099f741b 100644 --- a/api/@ohos.net.connection.d.ts +++ b/api/@ohos.net.connection.d.ts @@ -212,7 +212,6 @@ declare namespace connection { */ NET_CAPABILITY_MMS = 0, - /** * Indicates that the network traffic is not metered. */ @@ -223,7 +222,6 @@ declare namespace connection { */ NET_CAPABILITY_INTERNET = 12, - /** * Indicates that the network does not use a VPN. */ @@ -233,7 +231,6 @@ declare namespace connection { * Indicates that the network is available. */ NET_CAPABILITY_VALIDATED = 16, - } export enum NetBearType { @@ -251,7 +248,6 @@ declare namespace connection { * Indicates that the network is an Ethernet network. */ BEARER_ETHERNET = 3, - } export interface ConnectionProperties { @@ -263,7 +259,6 @@ declare namespace connection { mtu: number; } - export interface RouteInfo { interface: string; destination: LinkAddress; @@ -285,8 +280,6 @@ declare namespace connection { family?: number; // IPv4 = 1; IPv6 = 2, default is IPv4 port?: number; // [0, 65535] } - - } export default connection; \ No newline at end of file diff --git a/api/@ohos.telephony.call.d.ts b/api/@ohos.telephony.call.d.ts index e2d30005e..6450e8c35 100644 --- a/api/@ohos.telephony.call.d.ts +++ b/api/@ohos.telephony.call.d.ts @@ -134,18 +134,21 @@ declare namespace call { /** * @systemapi Hide this for inner system use. + * @since 7 */ function holdCall(callId: number, callback: AsyncCallback): void; function holdCall(callId: number): Promise; /** * @systemapi Hide this for inner system use. + * @since 7 */ function unHoldCall(callId: number, callback: AsyncCallback): void; function unHoldCall(callId: number): Promise; /** * @systemapi Hide this for inner system use. + * @since 7 */ function switchCall(callId: number, callback: AsyncCallback): void; function switchCall(callId: number): Promise; diff --git a/api/@ohos.telephony.sms.d.ts b/api/@ohos.telephony.sms.d.ts index 9a0d5cbd8..940e63150 100644 --- a/api/@ohos.telephony.sms.d.ts +++ b/api/@ohos.telephony.sms.d.ts @@ -611,7 +611,7 @@ declare namespace sms { /** * @systemapi Hide this for inner system use. - * @since 8 + * @since 7 */ export enum RanType { TYPE_GSM = 1, // GSM