mirror of
https://gitee.com/openharmony/interface_sdk-js
synced 2025-03-02 14:21:40 +00:00
!702 Update telephony and net d.ts files.
Merge pull request !702 from clevercong/master
This commit is contained in:
commit
f0f66970a7
285
api/@ohos.net.connection.d.ts
vendored
Normal file
285
api/@ohos.net.connection.d.ts
vendored
Normal file
@ -0,0 +1,285 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* <p>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<NetHandle>): void;
|
||||
function getDefaultNet(): Promise<NetHandle>;
|
||||
|
||||
/**
|
||||
* Obtains the list of data networks that are activated.
|
||||
*
|
||||
* <p>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<Array<NetHandle>>): void;
|
||||
function getAllNets(): Promise<Array<NetHandle>>;
|
||||
|
||||
/**
|
||||
* Queries the connection properties of a network.
|
||||
*
|
||||
* <p>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<ConnectionProperties>): void;
|
||||
function getConnectionProperties(netHandle: NetHandle): Promise<ConnectionProperties>;
|
||||
|
||||
/**
|
||||
* Obtains {@link NetCapabilities} of a {@link NetHandle} object.
|
||||
*
|
||||
* <p>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<NetCapabilities>): void;
|
||||
function getNetCapabilities(netHandle: NetHandle): Promise<NetCapabilities>;
|
||||
|
||||
/**
|
||||
* 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<boolean>): void;
|
||||
function hasDefaultNet(): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Enables the airplane mode for a device.
|
||||
*
|
||||
* @systemapi Hide this for inner system use. Only used for system app.
|
||||
*/
|
||||
function enableAirplaneMode(callback: AsyncCallback<void>): void;
|
||||
function enableAirplaneMode(): Promise<void>;
|
||||
|
||||
/**
|
||||
* Disables the airplane mode for a device.
|
||||
*
|
||||
* @systemapi Hide this for inner system use. Only used for system app.
|
||||
*/
|
||||
function disableAirplaneMode(callback: AsyncCallback<void>): void;
|
||||
function disableAirplaneMode(): Promise<void>;
|
||||
|
||||
/**
|
||||
* 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>): void;
|
||||
function reportNetConnected(netHandle: NetHandle): Promise<void>;
|
||||
|
||||
/**
|
||||
* 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>): void;
|
||||
function reportNetDisconnected(netHandle: NetHandle): Promise<void>;
|
||||
|
||||
/**
|
||||
* 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<Array<NetAddress>>): void;
|
||||
function getAddressesByName(host: string): Promise<Array<NetAddress>>;
|
||||
|
||||
export interface NetConnection {
|
||||
on(type: 'netAvailable', callback: Callback<NetHandle>): 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<NetHandle>): void;
|
||||
|
||||
on(type: 'netUnavailable', callback: Callback<void>): void;
|
||||
|
||||
/**
|
||||
* Receives status change notifications of a specified network.
|
||||
*
|
||||
* @permission ohos.permission.GET_NETWORK_INFO
|
||||
*/
|
||||
register(callback: AsyncCallback<void>): void;
|
||||
|
||||
/**
|
||||
* Cancels listening for network status changes.
|
||||
*/
|
||||
unregister(callback: AsyncCallback<void>): 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>): void;
|
||||
bindSocket(socketParam: TCPSocket | UDPSocket): Promise<void>;
|
||||
|
||||
/**
|
||||
* 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<Array<NetAddress>>): void;
|
||||
getAddressesByName(host: string): Promise<Array<NetAddress>>;
|
||||
|
||||
/**
|
||||
* 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<NetAddress>): void;
|
||||
getAddressByName(host: string): Promise<NetAddress>;
|
||||
}
|
||||
|
||||
export interface NetCapabilities {
|
||||
linkUpBandwidthKbps?: number;
|
||||
linkDownBandwidthKbps?: number;
|
||||
networkCap?: Array<NetCap>;
|
||||
bearerTypes: Array<NetBearType>;
|
||||
}
|
||||
|
||||
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<LinkAddress>;
|
||||
dnses: Array<NetAddress>;
|
||||
routes: Array<RouteInfo>;
|
||||
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;
|
152
api/@ohos.net.http.d.ts
vendored
Normal file
152
api/@ohos.net.http.d.ts
vendored
Normal file
@ -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<HttpResponse>): void;
|
||||
request(url: string, options: HttpRequestOptions, callback: AsyncCallback<HttpResponse>): void;
|
||||
request(url: string, options?: HttpRequestOptions): Promise<HttpResponse>;
|
||||
|
||||
/**
|
||||
* Destroys an HTTP request.
|
||||
*/
|
||||
destroy(): void;
|
||||
|
||||
/**
|
||||
* Registers an observer for HTTP Response Header events.
|
||||
*/
|
||||
on(type: "headerReceive", callback: AsyncCallback<Object>): void;
|
||||
|
||||
/**
|
||||
* Unregisters the observer for HTTP Response Header events.
|
||||
*/
|
||||
off(type: "headerReceive", callback?: AsyncCallback<Object>): 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;
|
319
api/@ohos.net.socket.d.ts
vendored
Normal file
319
api/@ohos.net.socket.d.ts
vendored
Normal file
@ -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>): void;
|
||||
bind(address: NetAddress): Promise<void>;
|
||||
|
||||
/**
|
||||
* Sends data over a UDPSocket connection.
|
||||
*
|
||||
* @param options Optional parameters {@link UDPSendOptions}.
|
||||
* @permission ohos.permission.INTERNET
|
||||
*/
|
||||
send(options: UDPSendOptions, callback: AsyncCallback<void>): void;
|
||||
send(options: UDPSendOptions): Promise<void>;
|
||||
|
||||
/**
|
||||
* Closes a UDPSocket connection.
|
||||
* @permission ohos.permission.INTERNET
|
||||
*/
|
||||
close(callback: AsyncCallback<void>): void;
|
||||
close(): Promise<void>;
|
||||
|
||||
/**
|
||||
* Obtains the status of the UDPSocket connection.
|
||||
*
|
||||
* @param callback Callback used to return the result. {@link SocketStateBase}.
|
||||
* @permission ohos.permission.INTERNET
|
||||
*/
|
||||
getState(callback: AsyncCallback<SocketStateBase>): void;
|
||||
getState(): Promise<SocketStateBase>;
|
||||
|
||||
/**
|
||||
* Sets other attributes of the UDPSocket connection.
|
||||
*
|
||||
* @param options Optional parameters {@link UDPExtraOptions}.
|
||||
* @permission ohos.permission.INTERNET
|
||||
*/
|
||||
setExtraOptions(options: UDPExtraOptions, callback: AsyncCallback<void>): void;
|
||||
setExtraOptions(options: UDPExtraOptions): Promise<void>;
|
||||
|
||||
/**
|
||||
* 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>): void;
|
||||
|
||||
/**
|
||||
* Cancels listening for data packet message events or close events of the UDPSocket connection.
|
||||
*/
|
||||
off(type: 'listening' | 'close', callback?: Callback<void>): 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>): void;
|
||||
bind(address: NetAddress): Promise<void>;
|
||||
|
||||
/**
|
||||
* 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>): void;
|
||||
connect(options: TCPConnectOptions): Promise<void>;
|
||||
|
||||
/**
|
||||
* Sends data over a TCPSocket connection.
|
||||
*
|
||||
* @param options Optional parameters {@link TCPSendOptions}.
|
||||
* @permission ohos.permission.INTERNET
|
||||
*/
|
||||
send(options: TCPSendOptions, callback: AsyncCallback<void>): void;
|
||||
send(options: TCPSendOptions): Promise<void>;
|
||||
|
||||
/**
|
||||
* Closes a TCPSocket connection.
|
||||
* @permission ohos.permission.INTERNET
|
||||
*/
|
||||
close(callback: AsyncCallback<void>): void;
|
||||
close(): Promise<void>;
|
||||
|
||||
/**
|
||||
* 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<NetAddress>): void;
|
||||
getRemoteAddress(): Promise<NetAddress>;
|
||||
|
||||
/**
|
||||
* Obtains the status of the TCPSocket connection.
|
||||
*
|
||||
* @param callback Callback used to return the result. {@link SocketStateBase}
|
||||
* @permission ohos.permission.INTERNET
|
||||
*/
|
||||
getState(callback: AsyncCallback<SocketStateBase>): void;
|
||||
getState(): Promise<SocketStateBase>;
|
||||
|
||||
/**
|
||||
* Sets other attributes of the TCPSocket connection.
|
||||
*
|
||||
* @param options Optional parameters {@link TCPExtraOptions}.
|
||||
* @permission ohos.permission.INTERNET
|
||||
*/
|
||||
setExtraOptions(options: TCPExtraOptions, callback: AsyncCallback<void>): void;
|
||||
setExtraOptions(options: TCPExtraOptions): Promise<void>;
|
||||
|
||||
/**
|
||||
* 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>): void;
|
||||
|
||||
/**
|
||||
* Cancels listening for connection or close events of the TCPSocket connection.
|
||||
*/
|
||||
off(type: 'connect' | 'close', callback?: Callback<void>): 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;
|
157
api/@ohos.net.statistics.d.ts
vendored
Normal file
157
api/@ohos.net.statistics.d.ts
vendored
Normal file
@ -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<number>): void;
|
||||
function getIfaceRxBytes(nic: string): Promise<number>;
|
||||
|
||||
/**
|
||||
* 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<number>): void;
|
||||
function getIfaceTxBytes(nic: string): Promise<number>;
|
||||
|
||||
/**
|
||||
* 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<number>): void;
|
||||
function getCellularRxBytes(): Promise<number>;
|
||||
|
||||
/**
|
||||
* 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<number>): void;
|
||||
function getCellularTxBytes(): Promise<number>;
|
||||
|
||||
/**
|
||||
* 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<number>): void;
|
||||
function getAllTxBytes(): Promise<number>;
|
||||
|
||||
/**
|
||||
* 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<number>): void;
|
||||
function getAllRxBytes(): Promise<number>;
|
||||
|
||||
/**
|
||||
* 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<number>): void;
|
||||
function getUidRxBytes(uid: number): Promise<number>;
|
||||
|
||||
/**
|
||||
* 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<number>): void;
|
||||
function getUidTxBytes(uid: number): Promise<number>;
|
||||
|
||||
/**
|
||||
* 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<NetStatsInfo>): void;
|
||||
function getIfaceStats(ifaceInfo: IfaceInfo): Promise<NetStatsInfo>;
|
||||
|
||||
/**
|
||||
* 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<NetStatsInfo>): void;
|
||||
function getIfaceUidStats(uidStatsInfo: UidStatsInfo): Promise<NetStatsInfo>;
|
||||
|
||||
/**
|
||||
* @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;
|
1024
api/@ohos.telephony.call.d.ts
vendored
1024
api/@ohos.telephony.call.d.ts
vendored
File diff suppressed because it is too large
Load Diff
196
api/@ohos.telephony.data.d.ts
vendored
Normal file
196
api/@ohos.telephony.data.d.ts
vendored
Normal file
@ -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.
|
||||
*
|
||||
* <p>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<number>): void;
|
||||
function getDefaultCellularDataSlotId(): Promise<number>;
|
||||
|
||||
/**
|
||||
* 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>): void;
|
||||
function setDefaultCellularDataSlotId(slotId: number): Promise<void>;
|
||||
|
||||
/**
|
||||
* Indicates that there is no uplink or downlink data.
|
||||
*
|
||||
* <p>It is a return value of service state query of cellular data services.
|
||||
*/
|
||||
function getCellularDataFlowType(callback: AsyncCallback<DataFlowType>): void;
|
||||
function getCellularDataFlowType(): Promise<DataFlowType>;
|
||||
|
||||
/**
|
||||
* 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:
|
||||
* <ul>
|
||||
* <li>{@code DataConnectState#DATA_STATE_UNKNOWN}
|
||||
* <li>{@code DataConnectState#DATA_STATE_DISCONNECTED}
|
||||
* <li>{@code DataConnectState#DATA_STATE_CONNECTING}
|
||||
* <li>{@code DataConnectState#DATA_STATE_CONNECTED}
|
||||
* <li>{@code DataConnectState#DATA_STATE_SUSPENDED}
|
||||
* </ul>
|
||||
*/
|
||||
function getCellularDataState(callback: AsyncCallback<DataConnectState>): void;
|
||||
function getCellularDataState(): Promise<DataConnectState>;
|
||||
|
||||
/**
|
||||
* Checks whether cellular data services are enabled.
|
||||
*
|
||||
* <p>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<boolean>): void;
|
||||
function isCellularDataEnabled(): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Enables cellular data services.
|
||||
*
|
||||
* @permission ohos.permission.SET_TELEPHONY_STATE
|
||||
* @systemapi Hide this for inner system use.
|
||||
*/
|
||||
function enableCellularData(callback: AsyncCallback<void>): void;
|
||||
function enableCellularData(): Promise<void>;
|
||||
|
||||
/**
|
||||
* Diables cellular data services.
|
||||
*
|
||||
* @permission ohos.permission.SET_TELEPHONY_STATE
|
||||
* @systemapi Hide this for inner system use.
|
||||
*/
|
||||
function disableCellularData(callback: AsyncCallback<void>): void;
|
||||
function disableCellularData(): Promise<void>;
|
||||
|
||||
/**
|
||||
* Checks whether roaming is enabled for cellular data services.
|
||||
*
|
||||
* <p>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<boolean>): void;
|
||||
function isCellularDataRoamingEnabled(slotId: number): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* 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>): void;
|
||||
function enableCellularDataRoaming(slotId: number): Promise<void>;
|
||||
|
||||
/**
|
||||
* 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>): void;
|
||||
function disableCellularDataRoaming(slotId: number): Promise<void>;
|
||||
|
||||
/**
|
||||
* 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;
|
113
api/@ohos.telephony.observer.d.ts
vendored
113
api/@ohos.telephony.observer.d.ts
vendored
@ -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<Array<SignalInformation>>): void;
|
||||
|
||||
/**
|
||||
* Called back when the cell information corresponding to a monitored {@code slotId} updates.
|
||||
*
|
||||
* <p>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<Array<CellInformation>>): void;
|
||||
function on(type: 'cellInfoChange', options: { slotId: number },
|
||||
callback: Callback<Array<CellInformation>>): void;
|
||||
|
||||
/**
|
||||
* @systemapi Hide this for inner system use.
|
||||
* @since 8
|
||||
*/
|
||||
function off(type: 'cellInfoChange', callback?: Callback<Array<CellInformation>>): 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<DataFlowType>): void;
|
||||
function on(type: 'cellularDataFlowChange', options: { slotId: number },
|
||||
callback: Callback<DataFlowType>): void;
|
||||
|
||||
function off(type: 'cellularDataFlowChange', callback?: Callback<DataFlowType>): 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<SimStateData>): void;
|
||||
function on(type: 'simStateChange', options: { slotId: number }, callback: Callback<SimStateData>): void;
|
||||
|
||||
function off(type: 'simStateChange', callback?: Callback<SimStateData>): 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;
|
1226
api/@ohos.telephony.radio.d.ts
vendored
1226
api/@ohos.telephony.radio.d.ts
vendored
File diff suppressed because it is too large
Load Diff
883
api/@ohos.telephony.sim.d.ts
vendored
883
api/@ohos.telephony.sim.d.ts
vendored
@ -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<number>): void;
|
||||
function getDefaultVoiceSlotId(): Promise<number>;
|
||||
|
||||
/**
|
||||
* 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<string>): void;
|
||||
function getISOCountryCodeForSim(slotId: number): Promise<string>;
|
||||
|
||||
/**
|
||||
* Obtains the home PLMN number of the SIM card in a specified slot.
|
||||
*
|
||||
* <p>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<string>): void;
|
||||
function getSimOperatorNumeric(slotId: number): Promise<string>;
|
||||
|
||||
/**
|
||||
* Obtains the service provider name (SPN) of the SIM card in a specified slot.
|
||||
*
|
||||
* <p>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<string>): void;
|
||||
function getSimSpn(slotId: number): Promise<string>;
|
||||
|
||||
/**
|
||||
* 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:
|
||||
* <ul>
|
||||
* <li>{@code SimState#SIM_STATE_UNKNOWN}
|
||||
* <li>{@code SimState#SIM_STATE_NOT_PRESENT}
|
||||
* <li>{@code SimState#SIM_STATE_LOCKED}
|
||||
* <li>{@code SimState#SIM_STATE_NOT_READY}
|
||||
* <li>{@code SimState#SIM_STATE_READY}
|
||||
* <li>{@code SimState#SIM_STATE_LOADED}
|
||||
* </ul>
|
||||
*/
|
||||
function getSimState(slotId: number, callback: AsyncCallback<SimState>): void;
|
||||
function getSimState(slotId: number): Promise<SimState>;
|
||||
|
||||
/**
|
||||
* Obtains the ICCID of the SIM card in a specified slot.
|
||||
*
|
||||
* <p>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.
|
||||
*
|
||||
* <p>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<string>): void;
|
||||
function getSimIccId(slotId: number): Promise<string>;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* <p>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<string>): void;
|
||||
function getSimGid1(slotId: number): Promise<string>;
|
||||
|
||||
/**
|
||||
* @permission ohos.permission.GET_TELEPHONY_STATE
|
||||
* @systemapi Hide this for inner system use.
|
||||
*/
|
||||
function getIMSI(slotId: number, callback: AsyncCallback<string>): void;
|
||||
function getIMSI(slotId: number): Promise<string>;
|
||||
|
||||
/**
|
||||
* @permission ohos.permission.GET_TELEPHONY_STATE
|
||||
* @systemapi Hide this for inner system use.
|
||||
* @since 7
|
||||
*/
|
||||
function getSimAccountInfo(slotId: number, callback: AsyncCallback<IccAccountInfo>): void;
|
||||
function getSimAccountInfo(slotId: number): Promise<IccAccountInfo>;
|
||||
|
||||
/**
|
||||
* @permission ohos.permission.SET_TELEPHONY_STATE
|
||||
* @systemapi Hide this for inner system use.
|
||||
* @since 7
|
||||
*/
|
||||
function setDefaultVoiceSlotId(slotId: number, callback: AsyncCallback<void>): void;
|
||||
function setDefaultVoiceSlotId(slotId: number): Promise<void>;
|
||||
|
||||
/**
|
||||
* @permission ohos.permission.SET_TELEPHONY_STATE
|
||||
* @systemapi Hide this for inner system use.
|
||||
* @since 7
|
||||
*/
|
||||
function unlockPin(slotId: number, pin: string, callback: AsyncCallback<LockStatusResponse>): void;
|
||||
function unlockPin(slotId: number, pin: string): Promise<LockStatusResponse>;
|
||||
|
||||
/**
|
||||
* @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<LockStatusResponse>): void;
|
||||
function unlockPuk(slotId: number, newPin: string, puk: string): Promise<LockStatusResponse>;
|
||||
|
||||
/**
|
||||
* @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<LockStatusResponse>): void;
|
||||
function alterPin(slotId: number, newPin: string, oldPin: string): Promise<LockStatusResponse>;
|
||||
|
||||
/**
|
||||
* @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<LockStatusResponse>): void;
|
||||
function setLockState(slotId: number, pin: string, enable: number): Promise<LockStatusResponse>;
|
||||
|
||||
/**
|
||||
* @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 <b>not present</b> state, that is, no SIM card is inserted
|
||||
* into the card slot.
|
||||
*/
|
||||
SIM_STATE_NOT_PRESENT,
|
||||
|
||||
/**
|
||||
* Indicates that the SIM card is in the <b>locked</b> 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 <b>not ready</b> 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 <b>ready</b> state, that is, the SIM card is in position and
|
||||
* is working properly.
|
||||
*/
|
||||
SIM_STATE_READY,
|
||||
|
||||
/**
|
||||
* Indicates that the SIM card is in the <b>loaded</b> state, that is, the SIM card is in position and
|
||||
* is working properly.
|
||||
*/
|
||||
SIM_STATE_LOADED
|
||||
}
|
||||
}
|
||||
|
||||
export default sim;
|
||||
/*
|
||||
* 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<boolean>): void;
|
||||
function isSimActive(slotId: number): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* 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<number>): void;
|
||||
function getDefaultVoiceSlotId(): Promise<number>;
|
||||
|
||||
/**
|
||||
* 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<boolean>): void;
|
||||
function hasOperatorPrivileges(slotId: number): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* 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<string>): void;
|
||||
function getISOCountryCodeForSim(slotId: number): Promise<string>;
|
||||
|
||||
/**
|
||||
* Obtains the home PLMN number of the SIM card in a specified slot.
|
||||
*
|
||||
* <p>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<string>): void;
|
||||
function getSimOperatorNumeric(slotId: number): Promise<string>;
|
||||
|
||||
/**
|
||||
* Obtains the service provider name (SPN) of the SIM card in a specified slot.
|
||||
*
|
||||
* <p>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<string>): void;
|
||||
function getSimSpn(slotId: number): Promise<string>;
|
||||
|
||||
/**
|
||||
* 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:
|
||||
* <ul>
|
||||
* <li>{@code SimState#SIM_STATE_UNKNOWN}
|
||||
* <li>{@code SimState#SIM_STATE_NOT_PRESENT}
|
||||
* <li>{@code SimState#SIM_STATE_LOCKED}
|
||||
* <li>{@code SimState#SIM_STATE_NOT_READY}
|
||||
* <li>{@code SimState#SIM_STATE_READY}
|
||||
* <li>{@code SimState#SIM_STATE_LOADED}
|
||||
* </ul>
|
||||
*/
|
||||
function getSimState(slotId: number, callback: AsyncCallback<SimState>): void;
|
||||
function getSimState(slotId: number): Promise<SimState>;
|
||||
|
||||
/**
|
||||
* 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<CardType>): void;
|
||||
function getCardType(slotId: number): Promise<CardType>;
|
||||
|
||||
/**
|
||||
* Obtains the ICCID of the SIM card in a specified slot.
|
||||
*
|
||||
* <p>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.
|
||||
*
|
||||
* <p>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<string>): void;
|
||||
function getSimIccId(slotId: number): Promise<string>;
|
||||
|
||||
/**
|
||||
* Obtains the alpha identifier of the voice mailbox of the SIM card in a specified slot.
|
||||
*
|
||||
* <p>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<string>): void;
|
||||
function getVoiceMailIdentifier(slotId: number): Promise<string>;
|
||||
|
||||
/**
|
||||
* Obtains the voice mailbox number of the SIM card in a specified slot.
|
||||
*
|
||||
* <p>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<string>): void;
|
||||
function getVoiceMailNumber(slotId: number): Promise<string>;
|
||||
|
||||
/**
|
||||
* @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>): void;
|
||||
function setVoiceMailInfo(slotId: number, mailName: string, mailNumber: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* Obtains the MSISDN of the SIM card in a specified slot.
|
||||
* The MSISDN is recorded in the EFMSISDN file of the SIM card.
|
||||
*
|
||||
* <p>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<string>): void;
|
||||
function getSimTelephoneNumber(slotId: number): Promise<string>;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* <p>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<string>): void;
|
||||
function getSimGid1(slotId: number): Promise<string>;
|
||||
|
||||
/**
|
||||
* 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<string>): void;
|
||||
function getIMSI(slotId: number): Promise<string>;
|
||||
|
||||
/**
|
||||
* 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<boolean>): void;
|
||||
function hasSimCard(slotId: number): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* @permission ohos.permission.GET_TELEPHONY_STATE
|
||||
* @systemapi Hide this for inner system use.
|
||||
* @since 7
|
||||
*/
|
||||
function getSimAccountInfo(slotId: number, callback: AsyncCallback<IccAccountInfo>): void;
|
||||
function getSimAccountInfo(slotId: number): Promise<IccAccountInfo>;
|
||||
|
||||
/**
|
||||
* @permission ohos.permission.GET_TELEPHONY_STATE
|
||||
* @systemapi Hide this for inner system use.
|
||||
* @since 8
|
||||
*/
|
||||
function getActiveSimAccountInfoList(callback: AsyncCallback<Array<IccAccountInfo>>): void;
|
||||
function getActiveSimAccountInfoList(): Promise<Array<IccAccountInfo>>;
|
||||
|
||||
/**
|
||||
* @permission ohos.permission.SET_TELEPHONY_STATE
|
||||
* @systemapi Hide this for inner system use.
|
||||
* @since 7
|
||||
*/
|
||||
function setDefaultVoiceSlotId(slotId: number, callback: AsyncCallback<void>): void;
|
||||
function setDefaultVoiceSlotId(slotId: number): Promise<void>;
|
||||
|
||||
/**
|
||||
* @permission ohos.permission.SET_TELEPHONY_STATE
|
||||
* @systemapi Hide this for inner system use.
|
||||
* @since 8
|
||||
*/
|
||||
function activateSim(slotId: number, callback: AsyncCallback<void>): void;
|
||||
function activateSim(slotId: number): Promise<void>;
|
||||
|
||||
/**
|
||||
* @permission ohos.permission.SET_TELEPHONY_STATE
|
||||
* @systemapi Hide this for inner system use.
|
||||
* @since 8
|
||||
*/
|
||||
function deactivateSim(slotId: number, callback: AsyncCallback<void>): void;
|
||||
function deactivateSim(slotId: number): Promise<void>;
|
||||
|
||||
/**
|
||||
* @permission ohos.permission.SET_TELEPHONY_STATE
|
||||
* @systemapi Hide this for inner system use.
|
||||
* @since 8
|
||||
*/
|
||||
function setShowName(slotId: number, name: string, callback: AsyncCallback<void>): void;
|
||||
function setShowName(slotId: number, name: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* @permission ohos.permission.GET_TELEPHONY_STATE
|
||||
* @systemapi Hide this for inner system use.
|
||||
* @since 8
|
||||
*/
|
||||
function getShowName(slotId: number, callback: AsyncCallback<string>): void;
|
||||
function getShowName(slotId: number): Promise<string>;
|
||||
|
||||
/**
|
||||
* @permission ohos.permission.SET_TELEPHONY_STATE
|
||||
* @systemapi Hide this for inner system use.
|
||||
* @since 8
|
||||
*/
|
||||
function setShowNumber(slotId: number, number: string, callback: AsyncCallback<void>): void;
|
||||
function setShowNumber(slotId: number, number: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* @permission ohos.permission.GET_TELEPHONY_STATE
|
||||
* @systemapi Hide this for inner system use.
|
||||
* @since 8
|
||||
*/
|
||||
function getShowNumber(slotId: number, callback: AsyncCallback<string>): void;
|
||||
function getShowNumber(slotId: number): Promise<string>;
|
||||
|
||||
/**
|
||||
* @permission ohos.permission.GET_TELEPHONY_STATE
|
||||
* @systemapi Hide this for inner system use.
|
||||
* @since 8
|
||||
*/
|
||||
function getOperatorConfigs(slotId: number, callback: AsyncCallback<Array<OperatorConfig>>): void;
|
||||
function getOperatorConfigs(slotId: number): Promise<Array<OperatorConfig>>;
|
||||
|
||||
/**
|
||||
* @permission ohos.permission.SET_TELEPHONY_STATE
|
||||
* @systemapi Hide this for inner system use.
|
||||
* @since 7
|
||||
*/
|
||||
function unlockPin(slotId: number, pin: string, callback: AsyncCallback<LockStatusResponse>): void;
|
||||
function unlockPin(slotId: number, pin: string): Promise<LockStatusResponse>;
|
||||
|
||||
/**
|
||||
* @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<LockStatusResponse>): void;
|
||||
function unlockPuk(slotId: number, newPin: string, puk: string): Promise<LockStatusResponse>;
|
||||
|
||||
/**
|
||||
* @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<LockStatusResponse>): void;
|
||||
function alterPin(slotId: number, newPin: string, oldPin: string): Promise<LockStatusResponse>;
|
||||
|
||||
/**
|
||||
* @permission ohos.permission.SET_TELEPHONY_STATE
|
||||
* @systemapi Hide this for inner system use.
|
||||
* @since 7
|
||||
*/
|
||||
function setLockState(slotId: number, options: LockInfo, callback: AsyncCallback<LockStatusResponse>): void;
|
||||
function setLockState(slotId: number, options: LockInfo): Promise<LockStatusResponse>;
|
||||
|
||||
/**
|
||||
* @permission ohos.permission.SET_TELEPHONY_STATE
|
||||
* @systemapi Hide this for inner system use.
|
||||
* @since 8
|
||||
*/
|
||||
function unlockPin2(slotId: number, pin2: string, callback: AsyncCallback<LockStatusResponse>): void;
|
||||
function unlockPin2(slotId: number, pin2: string): Promise<LockStatusResponse>;
|
||||
|
||||
/**
|
||||
* @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<LockStatusResponse>): void;
|
||||
function unlockPuk2(slotId: number, newPin2: string, puk2: string): Promise<LockStatusResponse>;
|
||||
|
||||
/**
|
||||
* @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<LockStatusResponse>): void;
|
||||
function alterPin2(slotId: number, newPin2: string, oldPin2: string): Promise<LockStatusResponse>;
|
||||
|
||||
/**
|
||||
* @permission ohos.permission.READ_CONTACTS
|
||||
* @systemapi Hide this for inner system use.
|
||||
* @since 8
|
||||
*/
|
||||
function queryIccDiallingNumbers(slotId: number, type: ContactType, callback: AsyncCallback<Array<DiallingNumbersInfo>>): void
|
||||
function queryIccDiallingNumbers(slotId: number, type: ContactType): Promise<Array<DiallingNumbersInfo>>;
|
||||
|
||||
/**
|
||||
* @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>): void;
|
||||
function addIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo): Promise<void>;
|
||||
|
||||
/**
|
||||
* @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>): void;
|
||||
function delIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo): Promise<void>;
|
||||
|
||||
/**
|
||||
* @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>): void;
|
||||
function updateIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo): Promise<void>;
|
||||
|
||||
/**
|
||||
* @systemapi Hide this for inner system use.
|
||||
* @since 8
|
||||
*/
|
||||
function getLockState(slotId: number, lockType: LockType, callback: AsyncCallback<LockState>): void;
|
||||
function getLockState(slotId: number, lockType: LockType): Promise<LockState>;
|
||||
|
||||
/**
|
||||
* @permission ohos.permission.SET_TELEPHONY_STATE
|
||||
* @systemapi Hide this for inner system use.
|
||||
* @since 8
|
||||
*/
|
||||
function sendEnvelopeCmd(slotId: number, cmd: string, callback: AsyncCallback<void>): void;
|
||||
function sendEnvelopeCmd(slotId: number, cmd: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* @permission ohos.permission.SET_TELEPHONY_STATE
|
||||
* @systemapi Hide this for inner system use.
|
||||
* @since 8
|
||||
*/
|
||||
function sendTerminalResponseCmd(slotId: number, cmd: string, callback: AsyncCallback<void>): void;
|
||||
function sendTerminalResponseCmd(slotId: number, cmd: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* @permission ohos.permission.SET_TELEPHONY_STATE
|
||||
* @systemapi Hide this for inner system use.
|
||||
* @since 8
|
||||
*/
|
||||
function unlockSimLock(slotId: number, lockInfo: PersoLockInfo, callback: AsyncCallback<LockStatusResponse>): void;
|
||||
function unlockSimLock(slotId: number, lockInfo: PersoLockInfo): Promise<LockStatusResponse>;
|
||||
|
||||
/**
|
||||
* @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 <b>not present</b> state, that is, no SIM card is inserted
|
||||
* into the card slot.
|
||||
*/
|
||||
SIM_STATE_NOT_PRESENT,
|
||||
|
||||
/**
|
||||
* Indicates that the SIM card is in the <b>locked</b> 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 <b>not ready</b> 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 <b>ready</b> state, that is, the SIM card is in position and
|
||||
* is working properly.
|
||||
*/
|
||||
SIM_STATE_READY,
|
||||
|
||||
/**
|
||||
* Indicates that the SIM card is in the <b>loaded</b> 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 <b>off</b> state. */
|
||||
LOCK_OFF = 0,
|
||||
|
||||
/**Indicates that the lock state card is in the <b>on</b> 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;
|
||||
|
947
api/@ohos.telephony.sms.d.ts
vendored
947
api/@ohos.telephony.sms.d.ts
vendored
@ -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.
|
||||
*
|
||||
* <p>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<number>, specification: string, callback: AsyncCallback<ShortMessage>): void;
|
||||
function createMessage(pdu: Array<number>, specification: string): Promise<ShortMessage>;
|
||||
|
||||
/**
|
||||
* Sends a text or data SMS message.
|
||||
*
|
||||
* <p>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.
|
||||
* <p>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>): void;
|
||||
function setDefaultSmsSlotId(slotId: number): Promise<void>;
|
||||
|
||||
/**
|
||||
* 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<number>): void;
|
||||
function getDefaultSmsSlotId(): Promise<number>;
|
||||
|
||||
/**
|
||||
* Sets the address for the Short Message Service Center (SMSC) based on a specified slot ID.
|
||||
*
|
||||
* <p><b>Permissions: </b>{@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>): void;
|
||||
function setSmscAddr(slotId: number, smscAddr: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* Obtains the SMSC address based on a specified slot ID.
|
||||
*
|
||||
* <p><b>Permissions: </b>{@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<string>): void;
|
||||
function getSmscAddr(slotId: number): Promise<string>;
|
||||
|
||||
/**
|
||||
* @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>): void;
|
||||
function addSimMessage(options: SimMessageOptions): Promise<void>;
|
||||
|
||||
/**
|
||||
* @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>): void;
|
||||
function delSimMessage(slotId: number, msgIndex: number): Promise<void>;
|
||||
|
||||
/**
|
||||
* @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>): void;
|
||||
function updateSimMessage(options: UpdateSimMessageOptions): Promise<void>;
|
||||
|
||||
/**
|
||||
* @permission ohos.permission.RECEIVE_SMS
|
||||
* @systemapi Hide this for inner system use.
|
||||
* @since 7
|
||||
*/
|
||||
function getAllSimMessages(slotId: number, callback: AsyncCallback<Array<SimShortMessage>>): void;
|
||||
function getAllSimMessages(slotId: number): Promise<Array<SimShortMessage>>;
|
||||
|
||||
/**
|
||||
* @permission ohos.permission.RECEIVE_SMS
|
||||
* @systemapi Hide this for inner system use.
|
||||
* @since 7
|
||||
*/
|
||||
function setCBConfig(options: CBConfigOptions, callback: AsyncCallback<void>): void;
|
||||
function setCBConfig(options: CBConfigOptions): Promise<void>;
|
||||
|
||||
/**
|
||||
* @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<number>;
|
||||
/**
|
||||
* 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<number>;
|
||||
/** If send data message, destinationPort is mandatory. Otherwise is optional. */
|
||||
destinationPort?: number;
|
||||
/** Indicates the callback invoked after the SMS message is sent. */
|
||||
sendCallback?: AsyncCallback<ISendShortMessageCallback>;
|
||||
/** Indicates the callback invoked after the SMS message is delivered. */
|
||||
deliveryCallback?: AsyncCallback<IDeliveryShortMessageCallback>;
|
||||
}
|
||||
|
||||
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<number>;
|
||||
}
|
||||
|
||||
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.
|
||||
*
|
||||
* <p>If the length of an SMS message exceeds the maximum length allowed (140 bytes),
|
||||
* the SMS message is split into multiple segments for processing.
|
||||
* <p>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<Array<string>>): void;
|
||||
function splitMessage(content: string): Promise<Array<string>>;
|
||||
|
||||
/**
|
||||
* Creates an SMS message instance based on the protocol data unit (PDU) and the specified SMS protocol.
|
||||
*
|
||||
* <p>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<number>, specification: string, callback: AsyncCallback<ShortMessage>): void;
|
||||
function createMessage(pdu: Array<number>, specification: string): Promise<ShortMessage>;
|
||||
|
||||
/**
|
||||
* Sends a text or data SMS message.
|
||||
*
|
||||
* <p>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.
|
||||
* <p>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>): void;
|
||||
function setDefaultSmsSlotId(slotId: number): Promise<void>;
|
||||
|
||||
/**
|
||||
* 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<number>): void;
|
||||
function getDefaultSmsSlotId(): Promise<number>;
|
||||
|
||||
/**
|
||||
* Sets the address for the Short Message Service Center (SMSC) based on a specified slot ID.
|
||||
*
|
||||
* <p><b>Permissions: </b>{@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>): void;
|
||||
function setSmscAddr(slotId: number, smscAddr: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* Obtains the SMSC address based on a specified slot ID.
|
||||
*
|
||||
* <p><b>Permissions: </b>{@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<string>): void;
|
||||
function getSmscAddr(slotId: number): Promise<string>;
|
||||
|
||||
/**
|
||||
* 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>): void;
|
||||
function addSimMessage(options: SimMessageOptions): Promise<void>;
|
||||
|
||||
/**
|
||||
* @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>): void;
|
||||
function delSimMessage(slotId: number, msgIndex: number): Promise<void>;
|
||||
|
||||
/**
|
||||
* @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>): void;
|
||||
function updateSimMessage(options: UpdateSimMessageOptions): Promise<void>;
|
||||
|
||||
/**
|
||||
* @permission ohos.permission.RECEIVE_SMS
|
||||
* @systemapi Hide this for inner system use.
|
||||
* @since 7
|
||||
*/
|
||||
function getAllSimMessages(slotId: number, callback: AsyncCallback<Array<SimShortMessage>>): void;
|
||||
function getAllSimMessages(slotId: number): Promise<Array<SimShortMessage>>;
|
||||
|
||||
/**
|
||||
* @permission ohos.permission.RECEIVE_SMS
|
||||
* @systemapi Hide this for inner system use.
|
||||
* @since 7
|
||||
*/
|
||||
function setCBConfig(options: CBConfigOptions, callback: AsyncCallback<void>): void;
|
||||
function setCBConfig(options: CBConfigOptions): Promise<void>;
|
||||
|
||||
/**
|
||||
* @systemapi Hide this for inner system use.
|
||||
* @since 8
|
||||
*/
|
||||
function getSmsSegmentsInfo(slotId: number, message: string, force7bit: boolean, callback: AsyncCallback<SmsSegmentsInfo>): void;
|
||||
function getSmsSegmentsInfo(slotId: number, message: string, force7bit: boolean): Promise<SmsSegmentsInfo>;
|
||||
|
||||
/**
|
||||
* 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<boolean>): void;
|
||||
function isImsSmsSupported(): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* 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<string>): void;
|
||||
function getImsShortMessageFormat(): Promise<string>;
|
||||
|
||||
/**
|
||||
* @systemapi Hide this for inner system use.
|
||||
* @since 8
|
||||
*/
|
||||
function decodeMms(mmsFilePathName: string | Array<number>, callback: AsyncCallback<MmsInformation>): void;
|
||||
function decodeMms(mmsFilePathName: string | Array<number>): Promise<MmsInformation>;
|
||||
|
||||
/**
|
||||
* @systemapi Hide this for inner system use.
|
||||
* @since 8
|
||||
*/
|
||||
function encodeMms(mms: MmsInformation, callback: AsyncCallback<Array<number>>): void;
|
||||
function encodeMms(mms: MmsInformation): Promise<Array<number>>;
|
||||
|
||||
/**
|
||||
* @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<MmsAttachment>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @systemapi Hide this for inner system use.
|
||||
* @since 8
|
||||
*/
|
||||
export interface MmsSendReq {
|
||||
from: MmsAddress;
|
||||
transactionId: string;
|
||||
contentType: string;
|
||||
version: MmsVersionType;
|
||||
to?: Array<MmsAddress>;
|
||||
date?: number;
|
||||
cc?: Array<MmsAddress>;
|
||||
bcc?: Array<MmsAddress>;
|
||||
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<MmsAddress>;
|
||||
version: MmsVersionType;
|
||||
from?: MmsAddress;
|
||||
cc?: Array<MmsAddress>;
|
||||
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<MmsAddress>;
|
||||
status: number;
|
||||
version: MmsVersionType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @systemapi Hide this for inner system use.
|
||||
* @since 8
|
||||
*/
|
||||
export interface MmsReadOrigInd {
|
||||
version: MmsVersionType;
|
||||
messageId: string;
|
||||
to: Array<MmsAddress>;
|
||||
from: MmsAddress;
|
||||
date: number;
|
||||
readStatus: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* @systemapi Hide this for inner system use.
|
||||
* @since 8
|
||||
*/
|
||||
export interface MmsReadRecInd {
|
||||
version: MmsVersionType;
|
||||
messageId: string;
|
||||
to: Array<MmsAddress>;
|
||||
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<number>;
|
||||
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<number>;
|
||||
/**
|
||||
* 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<number>;
|
||||
/** If send data message, destinationPort is mandatory. Otherwise is optional. */
|
||||
destinationPort?: number;
|
||||
/** Indicates the callback invoked after the SMS message is sent. */
|
||||
sendCallback?: AsyncCallback<ISendShortMessageCallback>;
|
||||
/** Indicates the callback invoked after the SMS message is delivered. */
|
||||
deliveryCallback?: AsyncCallback<IDeliveryShortMessageCallback>;
|
||||
}
|
||||
|
||||
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<number>;
|
||||
}
|
||||
|
||||
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 7
|
||||
*/
|
||||
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;
|
Loading…
x
Reference in New Issue
Block a user