From d35e38fc46fc6f7e11df5657e7b4f235c82832bb Mon Sep 17 00:00:00 2001 From: clevercong Date: Mon, 11 Oct 2021 15:18:39 +0800 Subject: [PATCH] update telephony js api in version 7. Signed-off-by: clevercong --- api/@ohos.telephony.call.d.ts | 419 ++++++++++++---- api/@ohos.telephony.data.d.ts | 98 ---- api/@ohos.telephony.observer.d.ts | 33 +- api/@ohos.telephony.radio.d.ts | 781 +++++++++++++++++------------- api/@ohos.telephony.sim.d.ts | 351 +++++++++----- api/@ohos.telephony.sms.d.ts | 458 ++++++++++++------ 6 files changed, 1329 insertions(+), 811 deletions(-) mode change 100755 => 100644 api/@ohos.telephony.call.d.ts delete mode 100755 api/@ohos.telephony.data.d.ts mode change 100755 => 100644 api/@ohos.telephony.radio.d.ts mode change 100755 => 100644 api/@ohos.telephony.sim.d.ts mode change 100755 => 100644 api/@ohos.telephony.sms.d.ts diff --git a/api/@ohos.telephony.call.d.ts b/api/@ohos.telephony.call.d.ts old mode 100755 new mode 100644 index a6d8fe57e0..25680a731f --- a/api/@ohos.telephony.call.d.ts +++ b/api/@ohos.telephony.call.d.ts @@ -1,83 +1,338 @@ -/* -* 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 call management. - * - * @since 6 - */ -declare namespace call { - /** - * Makes a call. - * - *

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

If an incoming call is ringing or waiting, the system returns {@code CallState#CALL_STATE_RINGING}. - * If at least one call is in the active, hold, or dialing state, the system returns - * {@code CallState#CALL_STATE_OFFHOOK}. - * In other cases, the system returns {@code CallState#CALL_STATE_IDLE}. - * - * @param callback Returns the call state. - */ - function getCallState(callback: AsyncCallback): void; - function getCallState(): Promise; - - export enum CallState { - /** - * Indicates an invalid state, which is used when the call state fails to be obtained. - */ - CALL_STATE_UNKNOWN = -1, - - /** - * Indicates that there is no ongoing call. - */ - CALL_STATE_IDLE = 0, - - /** - * Indicates that an incoming call is ringing or waiting. - */ - CALL_STATE_RINGING = 1, - - /** - * Indicates that a least one call is in the dialing, active, or hold state, and there is no new incoming call - * ringing or waiting. - */ - CALL_STATE_OFFHOOK = 2 - } - - export interface DialOptions { - /** - * boolean means whether the call to be made is a video call. The value {@code false} indicates a voice call. - */ - extras?: boolean; - } -} - +/* +* Copyright (C) 2021 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import {AsyncCallback, Callback} from "./basic"; + +/** + * Provides methods related to call management. + * + * @since 6 + * @sysCap SystemCapability.Telephony.DCall + */ +declare namespace call { + /** + * Makes a call. + * + *

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

If an incoming call is ringing or waiting, the system returns {@code CallState#CALL_STATE_RINGING}. + * If at least one call is in the active, hold, or dialing state, the system returns + * {@code CallState#CALL_STATE_OFFHOOK}. + * In other cases, the system returns {@code CallState#CALL_STATE_IDLE}. + * + * @param callback Returns the call state. + */ + function getCallState(callback: AsyncCallback): void; + function getCallState(): Promise; + + /** + * Checks whether a phone number is on the emergency number list. + * + * @param phoneNumber Indicates the phone number to check. + * @param callback Returns {@code true} if the phone number is on the emergency number list; + * returns {@code false} otherwise. + * @since 7 + */ + function isEmergencyPhoneNumber(phoneNumber: string, callback: AsyncCallback): void; + function isEmergencyPhoneNumber(phoneNumber: string, options: EmergencyNumberOptions, callback: AsyncCallback): void; + function isEmergencyPhoneNumber(phoneNumber: string, options?: EmergencyNumberOptions): Promise; + + /** + * Formats a phone number according to the Chinese Telephone Code Plan. Before the formatting, + * a phone number is in the format of country code (if any) + 3-digit service provider code + * + 4-digit area code + 4-digit subscriber number. After the formatting, + * each part is separated by a space. + * + * @param phoneNumber Indicates the phone number to format. + * @param callback Returns the phone number after being formatted; returns an empty string + * if the input phone number is invalid. + * @since 7 + */ + function formatPhoneNumber(phoneNumber: string, callback: AsyncCallback): void; + function formatPhoneNumber(phoneNumber: string, options: NumberFormatOptions, callback: AsyncCallback): void; + function formatPhoneNumber(phoneNumber: string, options?: NumberFormatOptions): Promise; + + /** + * Formats a phone number into an E.164 representation. + * + * @param phoneNumber Indicates the phone number to format. + * @param countryCode Indicates a two-digit country code defined in ISO 3166-1. + * @param callback Returns an E.164 number; returns an empty string if the input phone number is invalid. + * @since 7 + */ + function formatPhoneNumberToE164(phoneNumber: string, countryCode: string, callback: AsyncCallback): void; + function formatPhoneNumberToE164(phoneNumber: string, countryCode: string): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function answer(callId: number, callback: AsyncCallback): void; + function answer(callId: number): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function hangup(callId: number, callback: AsyncCallback): void; + function hangup(callId: number): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function reject(callId: number, callback: AsyncCallback): void; + function reject(callId: number, options: RejectMessageOptions, callback: AsyncCallback): void; + function reject(callId: number, options?: RejectMessageOptions): Promise; + + /** + * @systemapi Hide this for inner system use. + */ + function holdCall(callId: number, callback: AsyncCallback): void; + function holdCall(callId: number): Promise; + + /** + * @systemapi Hide this for inner system use. + */ + function unHoldCall(callId: number, callback: AsyncCallback): void; + function unHoldCall(callId: number): Promise; + + /** + * @systemapi Hide this for inner system use. + */ + function switchCall(callId: number, callback: AsyncCallback): void; + function switchCall(callId: number): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function combineConference(callId: number, callback: AsyncCallback): void; + function combineConference(callId: number): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function getMainCallId(callId: number, callback: AsyncCallback): void; + function getMainCallId(callId: number): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function getSubCallIdList(callId: number, callback: AsyncCallback>): void; + function getSubCallIdList(callId: number): Promise>; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function getCallIdListForConference(callId: number, callback: AsyncCallback>): void; + function getCallIdListForConference(callId: number): Promise>; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function getCallWaitingStatus(slotId: number, callback: AsyncCallback): void; + function getCallWaitingStatus(slotId: number): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function setCallWaiting(slotId: number, activate: boolean, callback: AsyncCallback): void; + function setCallWaiting(slotId: number, activate: boolean): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function startDTMF(callId: number, character: string, callback: AsyncCallback): void; + function startDTMF(callId: number, character: string): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function stopDTMF(callId: number, callback: AsyncCallback): void; + function stopDTMF(callId: number): Promise; + + /** + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 7 + */ + function isInEmergencyCall(callback: AsyncCallback): void; + function isInEmergencyCall(): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + function on(type: 'callDetailsChange', callback: Callback): void; + function off(type: 'callDetailsChange', callback?: Callback): void; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + export interface CallAttributeOptions { + accountNumber: string, + speakerphoneOn: boolean, + accountId: number, + videoState: VideoStateType, + startTime: number, + isEcc: boolean, + callType: CallType, + callId: number, + callState: DetailedCallState, + conferenceState: ConferenceState, + } + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + export enum ConferenceState { + TEL_CONFERENCE_IDLE = 0, + TEL_CONFERENCE_ACTIVE, + TEL_CONFERENCE_DISCONNECTING, + TEL_CONFERENCE_DISCONNECTED, + } + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + export enum CallType { + TYPE_CS = 0, // CS + TYPE_IMS = 1, // IMS + TYPE_OTT = 2, // OTT + TYPE_ERR_CALL = 3, // OTHER + } + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + export enum VideoStateType { + TYPE_VOICE = 0, // Voice + TYPE_VIDEO, // Video + } + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + export enum DetailedCallState { + CALL_STATUS_ACTIVE = 0, + CALL_STATUS_HOLDING, + CALL_STATUS_DIALING, + CALL_STATUS_ALERTING, + CALL_STATUS_INCOMING, + CALL_STATUS_WAITING, + CALL_STATUS_DISCONNECTED, + CALL_STATUS_DISCONNECTING, + CALL_STATUS_IDLE, + } + + export enum CallState { + /** + * Indicates an invalid state, which is used when the call state fails to be obtained. + */ + CALL_STATE_UNKNOWN = -1, + + /** + * Indicates that there is no ongoing call. + */ + CALL_STATE_IDLE = 0, + + /** + * Indicates that an incoming call is ringing or waiting. + */ + CALL_STATE_RINGING = 1, + + /** + * Indicates that a least one call is in the dialing, active, or hold state, and there is no new incoming call + * ringing or waiting. + */ + CALL_STATE_OFFHOOK = 2 + } + + export interface DialOptions { + /** + * boolean means whether the call to be made is a video call. The value {@code false} indicates a voice call. + */ + extras?: boolean; + } + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + export interface RejectMessageOptions { + messageContent: string, + } + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + export enum CallWaitingStatus { + CALL_WAITING_DISABLE = 0, + CALL_WAITING_ENABLE = 1 + } + + /** + * @since 7 + */ + export interface EmergencyNumberOptions { + slotId?: number; + } + + /** + * @since 7 + */ + export interface NumberFormatOptions { + countryCode?: string; + } +} + export default call; \ No newline at end of file diff --git a/api/@ohos.telephony.data.d.ts b/api/@ohos.telephony.data.d.ts deleted file mode 100755 index ffa1a3f853..0000000000 --- a/api/@ohos.telephony.data.d.ts +++ /dev/null @@ -1,98 +0,0 @@ -/* -* 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 6 - */ -declare namespace data { - /** - * 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: - *

- */ - function getCellularDataState(callback: AsyncCallback): void; - function getCellularDataState(): Promise; - - /** - * Checks whether cellular data services are enabled. - * - *

Requires Permission: {@code ohos.permission.GET_NETWORK_INFO}. - * - * @param callback Returns {@code true} if cellular data services are enabled; returns {@code false} otherwise. - */ - function isCellularDataEnabled(callback: AsyncCallback): void; - function isCellularDataEnabled(): Promise; - - /** - * Enables cellular data services. - * - * @hide Used for system app. - */ - function enableCellularData(callback: AsyncCallback): void; - function enableCellularData(): Promise; - - /** - * Diables cellular data services. - * - * @hide Used for system app. - */ - function disableCellularData(callback: AsyncCallback): void; - function disableCellularData(): Promise; - - /** - * Describes the cellular data link connection state. - */ - export enum DataConnectState { - /** - * Indicates that a cellular data link is unknown. - */ - DATA_STATE_UNKNOWN = -1, - - /** - * Indicates that a cellular data link is disconnected. - */ - DATA_STATE_DISCONNECTED = 0, - - /** - * Indicates that a cellular data link is being connected. - */ - DATA_STATE_CONNECTING = 1, - - /** - * Indicates that a cellular data link is connected. - */ - DATA_STATE_CONNECTED = 2, - - /** - * Indicates that a cellular data link is suspended. - */ - DATA_STATE_SUSPENDED = 3 - } -} - -export default data; \ No newline at end of file diff --git a/api/@ohos.telephony.observer.d.ts b/api/@ohos.telephony.observer.d.ts index 2e07a4b7b3..d1c0fe0b18 100755 --- a/api/@ohos.telephony.observer.d.ts +++ b/api/@ohos.telephony.observer.d.ts @@ -15,7 +15,6 @@ import {AsyncCallback} from "./basic"; import radio from "./@ohos.telephony.radio"; -import data from "./@ohos.telephony.data"; import call from "./@ohos.telephony.call"; /** @@ -25,13 +24,9 @@ import call from "./@ohos.telephony.call"; * @since 6 */ declare namespace observer { - export import NetworkState = radio.NetworkState; - export import SignalInformation = radio.SignalInformation; - export import CellInformation = radio.CellInformation; - export import DataConnectState = data.DataConnectState; - export import RatType = radio.RatType; - export import DataFlowType = data.DataFlowType; - export import CallState = call.CallState; + type NetworkState = radio.NetworkState; + type SignalInformation = radio.SignalInformation; + type CallState = call.CallState; /** * Called when the network state corresponding to a monitored {@code slotId} updates. @@ -70,28 +65,6 @@ declare namespace observer { function off(type: 'signalInfoChange', callback?: AsyncCallback>): 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. - */ - function on(type: 'cellularDataConnectionStateChange', - callback: AsyncCallback<{ state: DataConnectState, network: RatType }>): void; - function on(type: 'cellularDataConnectionStateChange', options: { slotId: number }, - callback: AsyncCallback<{ state: DataConnectState, network: RatType }>): void; - - function once(type: 'cellularDataConnectionStateChange', - callback: AsyncCallback<{ state: DataConnectState, network: RatType }>): void; - function once(type: 'cellularDataConnectionStateChange', options: { slotId: number }, - callback: AsyncCallback<{ state: DataConnectState, network: RatType }>): void; - - function off(type: 'cellularDataConnectionStateChange', - callback?: AsyncCallback<{ state: DataConnectState, network: RatType }>): 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. diff --git a/api/@ohos.telephony.radio.d.ts b/api/@ohos.telephony.radio.d.ts old mode 100755 new mode 100644 index 139ae0be8b..bbc4dcfc71 --- a/api/@ohos.telephony.radio.d.ts +++ b/api/@ohos.telephony.radio.d.ts @@ -1,330 +1,453 @@ -/* -* Copyright (C) 2021 Huawei Device Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import {AsyncCallback} from "./basic"; - -/** - * Provides interfaces for applications to obtain the radio access technology (RAT), network state, - * and signal information of the wireless cellular network (WCN). - * - * @since 6 - */ -declare namespace radio { - /** - * Obtains radio access technology (RAT) of the registered network. The system preferentially - * returns RAT of the packet service (PS) domain. If the device has not registered with the - * PS domain, the system returns RAT of the circuit service (CS) domain. - * - *

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

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

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

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

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

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

    + *
  • {@link NetworkSelectionMode#NETWORK_SELECTION_UNKNOWN} + *
  • {@link NetworkSelectionMode#NETWORK_SELECTION_AUTOMATIC} + *
  • {@link NetworkSelectionMode#NETWORK_SELECTION_MANUAL} + *
      + */ + function getNetworkSelectionMode(slotId: number, callback: AsyncCallback): void; + function getNetworkSelectionMode(slotId: number): Promise; + + /** + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + */ + function setNetworkSelectionMode(options: NetworkSelectionModeOptions, callback: AsyncCallback): void; + function setNetworkSelectionMode(options: NetworkSelectionModeOptions): Promise; + + /** + * @permission ohos.permission.GET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + */ + function getNetworkSearchInformation(slotId: number, callback: AsyncCallback): void; + function getNetworkSearchInformation(slotId: number): Promise; + + /** + * Obtains the ISO-defined country code of the country where the registered network is deployed. + * + * @param slotId Indicates the card slot index number, + * ranging from 0 to the maximum card slot index number supported by the device. + * @param callback Returns the country code defined in ISO 3166-2; + * returns an empty string if the device is not registered with any network. + * @since 7 + */ + function getISOCountryCodeForNetwork(slotId: number, callback: AsyncCallback): void; + function getISOCountryCodeForNetwork(slotId: number): Promise; + + /** + * Obtains the list of signal strength information of the registered network corresponding to a specified SIM card. + * + * @param slotId Indicates the card slot index number, ranging from 0 to the maximum card slot index number + * supported by the device. + * @param callback Returns the instance list of the child classes derived from {@link SignalInformation}. + * @since 7 + */ + function getSignalInformation(slotId: number, callback: AsyncCallback>): void; + function getSignalInformation(slotId: number): Promise>; + + /** + * @permission ohos.permission.GET_NETWORK_INFO + * @since 7 + */ + function isRadioOn(callback: AsyncCallback): void; + function isRadioOn(): Promise; + + /** + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 7 + */ + function turnOnRadio(callback: AsyncCallback): void; + function turnOnRadio(): Promise; + + /** + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 7 + */ + function turnOffRadio(callback: AsyncCallback): void; + function turnOffRadio(): Promise; + + /** + * Describes the radio access technology. + */ + export enum RadioTechnology { + /** + * Indicates unknown radio access technology (RAT). + */ + RADIO_TECHNOLOGY_UNKNOWN = 0, + + /** + * Indicates that RAT is global system for mobile communications (GSM), including GSM, general packet + * radio system (GPRS), and enhanced data rates for GSM evolution (EDGE). + */ + RADIO_TECHNOLOGY_GSM = 1, + + /** + * Indicates that RAT is code division multiple access (CDMA), including Interim Standard 95 (IS95) and + * Single-Carrier Radio Transmission Technology (1xRTT). + */ + RADIO_TECHNOLOGY_1XRTT = 2, + + /** + * Indicates that RAT is wideband code division multiple address (WCDMA). + */ + RADIO_TECHNOLOGY_WCDMA = 3, + + /** + * Indicates that RAT is high-speed packet access (HSPA), including HSPA, high-speed downlink packet + * access (HSDPA), and high-speed uplink packet access (HSUPA). + */ + RADIO_TECHNOLOGY_HSPA = 4, + + /** + * Indicates that RAT is evolved high-speed packet access (HSPA+), including HSPA+ and dual-carrier + * HSPA+ (DC-HSPA+). + */ + RADIO_TECHNOLOGY_HSPAP = 5, + + /** + * Indicates that RAT is time division-synchronous code division multiple access (TD-SCDMA). + */ + RADIO_TECHNOLOGY_TD_SCDMA = 6, + + /** + * Indicates that RAT is evolution data only (EVDO), including EVDO Rev.0, EVDO Rev.A, and EVDO Rev.B. + */ + RADIO_TECHNOLOGY_EVDO = 7, + + /** + * Indicates that RAT is evolved high rate packet data (EHRPD). + */ + RADIO_TECHNOLOGY_EHRPD = 8, + + /** + * Indicates that RAT is long term evolution (LTE). + */ + RADIO_TECHNOLOGY_LTE = 9, + + /** + * Indicates that RAT is LTE carrier aggregation (LTE-CA). + */ + RADIO_TECHNOLOGY_LTE_CA = 10, + + /** + * Indicates that RAT is interworking WLAN (I-WLAN). + */ + RADIO_TECHNOLOGY_IWLAN = 11, + + /** + * Indicates that RAT is 5G new radio (NR). + */ + RADIO_TECHNOLOGY_NR = 12 + } + + export interface SignalInformation { + /** + * Obtains the network type corresponding to the signal. + */ + signalType: NetworkType; + + /** + * Obtains the signal level of the current network. + */ + signalLevel: number; + } + + /** + * Describes the network type. + */ + export enum NetworkType { + /** + * Indicates unknown network type. + */ + NETWORK_TYPE_UNKNOWN, + + /** + * Indicates that the network type is GSM. + */ + NETWORK_TYPE_GSM, + + /** + * Indicates that the network type is CDMA. + */ + NETWORK_TYPE_CDMA, + + /** + * Indicates that the network type is WCDMA. + */ + NETWORK_TYPE_WCDMA, + + /** + * Indicates that the network type is TD-SCDMA. + */ + NETWORK_TYPE_TDSCDMA, + + /** + * Indicates that the network type is LTE. + */ + NETWORK_TYPE_LTE, + + /** + * Indicates that the network type is 5G NR. + */ + NETWORK_TYPE_NR + } + + /** + * Describes the network registration state. + */ + export interface NetworkState { + /** + * Obtains the operator name in the long alphanumeric format of the registered network. + * + * @return Returns the operator name in the long alphanumeric format as a string; + * returns an empty string if no operator name is obtained. + */ + longOperatorName: string; + + /** + * Obtains the operator name in the short alphanumeric format of the registered network. + * + * @return Returns the operator name in the short alphanumeric format as a string; + * returns an empty string if no operator name is obtained. + */ + shortOperatorName: string; + + /** + * Obtains the PLMN code of the registered network. + * + * @return Returns the PLMN code as a string; returns an empty string if no operator name is obtained. + */ + plmnNumeric: string; + + /** + * Checks whether the device is roaming. + * + * @return Returns {@code true} if the device is roaming; returns {@code false} otherwise. + */ + isRoaming: boolean; + + /** + * Obtains the network registration status of the device. + * + * @return Returns the network registration status {@code RegState}. + */ + regState: RegState; + + /** + * Obtains the NSA network registration status of the device. + * + * @return Returns the NSA network registration status {@code NsaState}. + */ + nsaState: NsaState; + + /** + * Obtains the status of CA. + * + * @return Returns {@code true} if CA is actived; returns {@code false} otherwise. + */ + isCaActive: boolean; + + /** + * Checks whether this device is allowed to make emergency calls only. + * + * @return Returns {@code true} if this device is allowed to make emergency calls only; + * returns {@code false} otherwise. + */ + isEmergency: boolean; + } + + /** + * Describes the network registration state. + */ + export enum RegState { + /** + * Indicates a state in which a device cannot use any service. + */ + REG_STATE_NO_SERVICE = 0, + + /** + * Indicates a state in which a device can use services properly. + */ + REG_STATE_IN_SERVICE = 1, + + /** + * Indicates a state in which a device can use only the emergency call service. + */ + REG_STATE_EMERGENCY_CALL_ONLY = 2, + + /** + * Indicates that the cellular radio is powered off. + */ + REG_STATE_POWER_OFF = 3 + } + + /** + * Describes the nsa state. + */ + export enum NsaState { + /** + * Indicates that a device is idle under or is connected to an LTE cell that does not support NSA. + */ + NSA_STATE_NOT_SUPPORT = 1, + + /** + * Indicates that a device is idle under an LTE cell supporting NSA but not NR coverage detection. + */ + NSA_STATE_NO_DETECT = 2, + + /** + * Indicates that a device is connected to an LTE network under an LTE cell + * that supports NSA and NR coverage detection. + */ + NSA_STATE_CONNECTED_DETECT = 3, + + /** + * Indicates that a device is idle under an LTE cell supporting NSA and NR coverage detection. + */ + NSA_STATE_IDLE_DETECT = 4, + + /** + * Indicates that a device is connected to an LTE + NR network under an LTE cell that supports NSA. + */ + NSA_STATE_DUAL_CONNECTED = 5, + + /** + * Indicates that a device is idle under or is connected to an NG-RAN cell while being attached to 5GC. + */ + NSA_STATE_SA_ATTACHED = 6 + } + + /** + * @systemapi Hide this for inner system use. + */ + export interface NetworkSearchResult { + isNetworkSearchSuccess: boolean; + networkSearchResult: Array; + } + + /** + * @systemapi Hide this for inner system use. + */ + export interface NetworkInformation { + operatorName: string; + operatorNumeric: string; + state: NetworkInformationState; + radioTech: string; + } + + /** + * @systemapi Hide this for inner system use. + */ + export enum NetworkInformationState { + /** Indicates that the network state is unknown. */ + NETWORK_UNKNOWN, + + /** Indicates that the network is available for registration. */ + NETWORK_AVAILABLE, + + /** Indicates that you have already registered with the network. */ + NETWORK_CURRENT, + + /** Indicates that the network is unavailable for registration. */ + NETWORK_FORBIDDEN + } + + /** + * @systemapi Hide this for inner system use. + */ + export interface NetworkSelectionModeOptions { + slotId: number; + selectMode: NetworkSelectionMode; + networkInformation: NetworkInformation; + resumeSelection: boolean; + } + + export enum NetworkSelectionMode { + /** Unknown network selection modes. */ + NETWORK_SELECTION_UNKNOWN, + + /** Automatic network selection modes. */ + NETWORK_SELECTION_AUTOMATIC, + + /** Manual network selection modes. */ + NETWORK_SELECTION_MANUAL + } +} + export default radio; \ No newline at end of file diff --git a/api/@ohos.telephony.sim.d.ts b/api/@ohos.telephony.sim.d.ts old mode 100755 new mode 100644 index e586e47276..ed9652a51a --- a/api/@ohos.telephony.sim.d.ts +++ b/api/@ohos.telephony.sim.d.ts @@ -1,118 +1,235 @@ -/* -* 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 - */ -declare namespace sim { - /** - * Obtains the ISO country code of the SIM card in a specified slot. - * - * @param slotId Indicates the card slot index number, - * ranging from 0 to the maximum card slot index number supported by the device. - * @param callback Returns the country code defined in ISO 3166-2; returns an empty string if no SIM card is inserted. - */ - function getISOCountryCodeForSim(slotId: number, callback: AsyncCallback): void; - function getISOCountryCodeForSim(slotId: number): Promise; - - /** - * Obtains the home PLMN number of the SIM card in a specified slot. - * - *

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

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

        - *
      • {@code SimState#SIM_STATE_UNKNOWN} - *
      • {@code SimState#SIM_STATE_NOT_PRESENT} - *
      • {@code SimState#SIM_STATE_LOCKED} - *
      • {@code SimState#SIM_STATE_NOT_READY} - *
      • {@code SimState#SIM_STATE_READY} - *
      • {@code SimState#SIM_STATE_LOADED} - *
      - */ - function getSimState(slotId: number, callback: AsyncCallback): void; - function getSimState(slotId: number): Promise; - - export enum SimState { - /** - * Indicates unknown SIM card state, that is, the accurate status cannot be obtained. - */ - SIM_STATE_UNKNOWN, - - /** - * Indicates that the SIM card is in the not present state, that is, no SIM card is inserted - * into the card slot. - */ - SIM_STATE_NOT_PRESENT, - - /** - * Indicates that the SIM card is in the locked state, that is, the SIM card is locked by the - * personal identification number (PIN)/PIN unblocking key (PUK) or network. - */ - SIM_STATE_LOCKED, - - /** - * Indicates that the SIM card is in the not ready state, that is, the SIM card is in position - * but cannot work properly. - */ - SIM_STATE_NOT_READY, - - /** - * Indicates that the SIM card is in the ready state, that is, the SIM card is in position and - * is working properly. - */ - SIM_STATE_READY, - - /** - * Indicates that the SIM card is in the loaded state, that is, the SIM card is in position and - * is working properly. - */ - SIM_STATE_LOADED - } -} - +/* +* Copyright (C) 2021 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import {AsyncCallback} from "./basic"; + +/** + * Provides applications with APIs for obtaining SIM card status, card file information, and card specifications. + * SIM cards include SIM, USIM, and CSIM cards. + * + * @since 6 + * @sysCap SystemCapability.Telephony.Telephony + */ +declare namespace sim { + /** + * Obtains the default card slot for the voice service. + * + * @param callback Returns {@code 0} if card 1 is used as the default card slot for the voice service; + * returns {@code 1} if card 2 is used as the default card slot for the voice service; + * returns {@code -1} if no card is available for the voice service. + * @since 7 + */ + function getDefaultVoiceSlotId(callback: AsyncCallback): void; + function getDefaultVoiceSlotId(): Promise; + + /** + * Obtains the ISO country code of the SIM card in a specified slot. + * + * @param slotId Indicates the card slot index number, + * ranging from 0 to the maximum card slot index number supported by the device. + * @param callback Returns the country code defined in ISO 3166-2; returns an empty string if no SIM card is inserted. + */ + function getISOCountryCodeForSim(slotId: number, callback: AsyncCallback): void; + function getISOCountryCodeForSim(slotId: number): Promise; + + /** + * Obtains the home PLMN number of the SIM card in a specified slot. + * + *

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

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

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

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

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

      Requires Permission: {@code ohos.permission.GET_TELEPHONY_STATE}. + * + * @param slotId Indicates the card slot index number, + * ranging from 0 to the maximum card slot index number supported by the device. + * @param callback Returns the GID1; returns an empty string if no SIM card is inserted or + * no GID1 in the SIM card. + * @permission ohos.permission.GET_TELEPHONY_STATE + */ + function getSimGid1(slotId: number, callback: AsyncCallback): void; + function getSimGid1(slotId: number): Promise; + + /** + * @permission ohos.permission.GET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + */ + function getIMSI(slotId: number, callback: AsyncCallback): void; + function getIMSI(slotId: number): Promise; + + /** + * @permission ohos.permission.GET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 7 + */ + function getSimAccountInfo(slotId: number, callback: AsyncCallback): void; + function getSimAccountInfo(slotId: number): Promise; + + /** + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 7 + */ + function setDefaultVoiceSlotId(slotId: number, callback: AsyncCallback): void; + function setDefaultVoiceSlotId(slotId: number): Promise; + + /** + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 7 + */ + function unlockPin(slotId: number, pin: string, callback: AsyncCallback): void; + function unlockPin(slotId: number, pin: string): Promise; + + /** + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 7 + */ + function unlockPuk(slotId: number, newPin: string, puk: string, callback: AsyncCallback): void; + function unlockPuk(slotId: number, newPin: string, puk: string): Promise; + + /** + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 7 + */ + function alterPin(slotId: number, newPin: string, oldPin: string, callback: AsyncCallback): void; + function alterPin(slotId: number, newPin: string, oldPin: string): Promise; + + /** + * @permission ohos.permission.SET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. + * @since 7 + */ + function setLockState(slotId: number, pin: string, enable: number, callback: AsyncCallback): void; + function setLockState(slotId: number, pin: string, enable: number): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + export interface IccAccountInfo { + slotIndex: number, /* slot id */ + showName: string, /* display name for card */ + showNumber: string, /* display number for card */ + } + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + export interface LockStatusResponse { + result: number, /* Current operation result */ + remain?: number, /* Operations remaining */ + } + + export enum SimState { + /** + * Indicates unknown SIM card state, that is, the accurate status cannot be obtained. + */ + SIM_STATE_UNKNOWN, + + /** + * Indicates that the SIM card is in the not present state, that is, no SIM card is inserted + * into the card slot. + */ + SIM_STATE_NOT_PRESENT, + + /** + * Indicates that the SIM card is in the locked state, that is, the SIM card is locked by the + * personal identification number (PIN)/PIN unblocking key (PUK) or network. + */ + SIM_STATE_LOCKED, + + /** + * Indicates that the SIM card is in the not ready state, that is, the SIM card is in position + * but cannot work properly. + */ + SIM_STATE_NOT_READY, + + /** + * Indicates that the SIM card is in the ready state, that is, the SIM card is in position and + * is working properly. + */ + SIM_STATE_READY, + + /** + * Indicates that the SIM card is in the loaded state, that is, the SIM card is in position and + * is working properly. + */ + SIM_STATE_LOADED + } +} + export default sim; \ No newline at end of file diff --git a/api/@ohos.telephony.sms.d.ts b/api/@ohos.telephony.sms.d.ts old mode 100755 new mode 100644 index a1b162bf6d..709f1b6900 --- a/api/@ohos.telephony.sms.d.ts +++ b/api/@ohos.telephony.sms.d.ts @@ -1,155 +1,303 @@ -/* -* 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 - */ -declare namespace sms { - /** - * Creates an SMS message instance based on the protocol data unit (PDU) and the specified SMS protocol. - * - *

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

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

      You need to obtain the following permission before calling this method: - * {@code ohos.permission.SEND_MESSAGES} - * - * @param options Indicates the parameters and callback for sending the SMS message. - */ - function sendMessage(options: SendMessageOptions): void; - - export interface ShortMessage { - /** Indicates the SMS message body. */ - visibleMessageBody: string; - /** Indicates the address of the sender, which is to be displayed on the UI. */ - visibleRawAddress: string; - /** Indicates the SMS type. */ - messageClass: ShortMessageClass; - /** Indicates the protocol identifier. */ - protocolId: number; - /** Indicates the short message service center (SMSC) address. */ - scAddress: string; - /** Indicates the SMSC timestamp. */ - scTimestamp: number; - /** Indicates whether the received SMS is a "replace short message". */ - isReplaceMessage: boolean; - /** Indicates whether the received SMS contains "TP-Reply-Path". */ - hasReplyPath: boolean; - /** Indicates Protocol Data Units (PDUs) from an SMS message. */ - pdu: Array; - /** - * Indicates the SMS message status from the SMS-STATUS-REPORT message sent by the - * Short Message Service Center (SMSC). - */ - status: number; - /** Indicates whether the current message is SMS-STATUS-REPORT. */ - isSmsStatusReportMessage: boolean; - /** Indicates the email message address. */ - emailAddress: string; - /** Indicates the email message body. */ - emailMessageBody: string; - /** Indicates the user data excluding the data header. */ - userRawData: Array; - /** Indicates whether the received SMS is an email message. */ - isEmailMessage: boolean; - } - - export enum ShortMessageClass { - /** Indicates an unknown type. */ - UNKNOWN, - /** Indicates an instant message, which is displayed immediately after being received. */ - INSTANT_MESSAGE, - /** Indicates an SMS message that can be stored on the device or SIM card based on the storage status. */ - OPTIONAL_MESSAGE, - /** Indicates an SMS message containing SIM card information, which is to be stored in a SIM card. */ - SIM_MESSAGE, - /** Indicates an SMS message to be forwarded to another device. */ - FORWARD_MESSAGE - } - - export interface SendMessageOptions { - /** Indicates the ID of the SIM card slot used for sending the SMS message. */ - slotId: number; - /** Indicates the address to which the SMS message is sent. */ - destinationHost: string; - /** Indicates the SMSC address. If the value is {@code null}, the default SMSC address of the SIM card*/ - serviceCenter?: string; - /** If the content is a string, this is a short message. If the content is a byte array, this is a data message. */ - content: string | Array; - /** If send data message, destinationPort is mandatory. Otherwise is optional. */ - destinationPort?: number; - /** Indicates the callback invoked after the SMS message is sent. */ - sendCallback?: AsyncCallback; - /** Indicates the callback invoked after the SMS message is delivered. */ - deliveryCallback?: AsyncCallback; - } - - export interface ISendShortMessageCallback { - /** Indicates the SMS message sending result. */ - result: SendSmsResult; - /** Indicates the URI to store the sent SMS message. */ - url: string; - /** Specifies whether this is the last part of a multi-part SMS message. */ - isLastPart: boolean; - } - - export interface IDeliveryShortMessageCallback { - /** Indicates the SMS delivery report. */ - pdu: Array; - } - - export enum SendSmsResult { - /** - * Indicates that the SMS message is successfully sent. - */ - SEND_SMS_SUCCESS = 0, - - /** - * Indicates that sending the SMS message fails due to an unknown reason. - */ - SEND_SMS_FAILURE_UNKNOWN = 1, - - /** - * Indicates that sending the SMS fails because the modem is powered off. - */ - SEND_SMS_FAILURE_RADIO_OFF = 2, - - /** - * Indicates that sending the SMS message fails because the network is unavailable - * or does not support sending or reception of SMS messages. - */ - SEND_SMS_FAILURE_SERVICE_UNAVAILABLE = 3 - } -} - -export default sms; \ No newline at end of file +/* +* Copyright (C) 2021 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import {AsyncCallback} from "./basic"; + +/** + * Provides the capabilities and methods for obtaining Short Message Service (SMS) management objects. + * + * @since 6 + * @sysCap SystemCapability.Telephony.Telephony + */ +declare namespace sms { + /** + * Creates an SMS message instance based on the protocol data unit (PDU) and the specified SMS protocol. + * + *

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

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

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

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

      Permissions: {@link ohos.security.SystemPermission#GET_TELEPHONY_STATE} + * + * @param slotId Indicates the ID of the slot holding the SIM card for sending SMS messages. + * @param callback Returns the SMSC address. + * @permission ohos.permission.GET_TELEPHONY_STATE + * @since 7 + */ + function getSmscAddr(slotId: number, callback: AsyncCallback): void; + function getSmscAddr(slotId: number): Promise; + + /** + * @permission ohos.permission.RECEIVE_SMS,ohos.permission.SEND_MESSAGES + * @systemapi Hide this for inner system use. + * @since 7 + */ + function addSimMessage(options: SimMessageOptions, callback: AsyncCallback): void; + function addSimMessage(options: SimMessageOptions): Promise; + + /** + * @permission ohos.permission.RECEIVE_SMS,ohos.permission.SEND_MESSAGES + * @systemapi Hide this for inner system use. + * @since 7 + */ + function delSimMessage(slotId: number, msgIndex: number, callback: AsyncCallback): void; + function delSimMessage(slotId: number, msgIndex: number): Promise; + + /** + * @permission ohos.permission.RECEIVE_SMS,ohos.permission.SEND_MESSAGES + * @systemapi Hide this for inner system use. + * @since 7 + */ + function updateSimMessage(options: UpdateSimMessageOptions, callback: AsyncCallback): void; + function updateSimMessage(options: UpdateSimMessageOptions): Promise; + + /** + * @permission ohos.permission.RECEIVE_SMS + * @systemapi Hide this for inner system use. + * @since 7 + */ + function getAllSimMessages(slotId: number, callback: AsyncCallback>): void; + function getAllSimMessages(slotId: number): Promise>; + + /** + * @permission ohos.permission.RECEIVE_SMS + * @systemapi Hide this for inner system use. + * @since 7 + */ + function setCBConfig(options: CBConfigOptions, callback: AsyncCallback): void; + function setCBConfig(options: CBConfigOptions): Promise; + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + export interface CBConfigOptions { + slotId: number, + enable: boolean, + startMessageId: number, + endMessageId: number, + ranType: number + } + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + export interface SimMessageOptions { + slotId: number, + smsc: string, + pdu: string, + status: SimMessageStatus + } + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + export interface UpdateSimMessageOptions { + slotId: number, + msgIndex: number, + newStatus: SimMessageStatus, + pdu: string, + smsc: string + } + + export interface ShortMessage { + /** Indicates the SMS message body. */ + visibleMessageBody: string; + /** Indicates the address of the sender, which is to be displayed on the UI. */ + visibleRawAddress: string; + /** Indicates the SMS type. */ + messageClass: ShortMessageClass; + /** Indicates the protocol identifier. */ + protocolId: number; + /** Indicates the short message service center (SMSC) address. */ + scAddress: string; + /** Indicates the SMSC timestamp. */ + scTimestamp: number; + /** Indicates whether the received SMS is a "replace short message". */ + isReplaceMessage: boolean; + /** Indicates whether the received SMS contains "TP-Reply-Path". */ + hasReplyPath: boolean; + /** Indicates Protocol Data Units (PDUs) from an SMS message. */ + pdu: Array; + /** + * Indicates the SMS message status from the SMS-STATUS-REPORT message sent by the + * Short Message Service Center (SMSC). + */ + status: number; + /** Indicates whether the current message is SMS-STATUS-REPORT. */ + isSmsStatusReportMessage: boolean; + } + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + export interface SimShortMessage { + shortMessage: ShortMessage; + + /** Indicates the storage status of SMS messages in the SIM */ + simMessageStatus: SimMessageStatus; + /** Indicates the index of SMS messages in the SIM */ + indexOnSim: number; + } + + /** + * @systemapi Hide this for inner system use. + * @since 7 + */ + export enum SimMessageStatus { + /** status free space ON SIM */ + SIM_MESSAGE_STATUS_FREE = 0, + /** REC READ received read message */ + SIM_MESSAGE_STATUS_READ = 1, + /** REC UNREAD received unread message */ + SIM_MESSAGE_STATUS_UNREAD = 3, + /** STO SENT stored sent message (only applicable to SMs) */ + SIM_MESSAGE_STATUS_SENT = 5, + /** STO UNSENT stored unsent message (only applicable to SMs) */ + SIM_MESSAGE_STATUS_UNSENT = 7, + } + + export enum ShortMessageClass { + /** Indicates an unknown type. */ + UNKNOWN, + /** Indicates an instant message, which is displayed immediately after being received. */ + INSTANT_MESSAGE, + /** Indicates an SMS message that can be stored on the device or SIM card based on the storage status. */ + OPTIONAL_MESSAGE, + /** Indicates an SMS message containing SIM card information, which is to be stored in a SIM card. */ + SIM_MESSAGE, + /** Indicates an SMS message to be forwarded to another device. */ + FORWARD_MESSAGE + } + + export interface SendMessageOptions { + /** Indicates the ID of the SIM card slot used for sending the SMS message. */ + slotId: number; + /** Indicates the address to which the SMS message is sent. */ + destinationHost: string; + /** Indicates the SMSC address. If the value is {@code null}, the default SMSC address of the SIM card*/ + serviceCenter?: string; + /** If the content is a string, this is a short message. If the content is a byte array, this is a data message. */ + content: string | Array; + /** If send data message, destinationPort is mandatory. Otherwise is optional. */ + destinationPort?: number; + /** Indicates the callback invoked after the SMS message is sent. */ + sendCallback?: AsyncCallback; + /** Indicates the callback invoked after the SMS message is delivered. */ + deliveryCallback?: AsyncCallback; + } + + export interface ISendShortMessageCallback { + /** Indicates the SMS message sending result. */ + result: SendSmsResult; + /** Indicates the URI to store the sent SMS message. */ + url: string; + /** Specifies whether this is the last part of a multi-part SMS message. */ + isLastPart: boolean; + } + + export interface IDeliveryShortMessageCallback { + /** Indicates the SMS delivery report. */ + pdu: Array; + } + + export enum SendSmsResult { + /** + * Indicates that the SMS message is successfully sent. + */ + SEND_SMS_SUCCESS = 0, + + /** + * Indicates that sending the SMS message fails due to an unknown reason. + */ + SEND_SMS_FAILURE_UNKNOWN = 1, + + /** + * Indicates that sending the SMS fails because the modem is powered off. + */ + SEND_SMS_FAILURE_RADIO_OFF = 2, + + /** + * Indicates that sending the SMS message fails because the network is unavailable + * or does not support sending or reception of SMS messages. + */ + SEND_SMS_FAILURE_SERVICE_UNAVAILABLE = 3 + } +} + +export default sms; -- Gitee