From bf4e6e165456e93a440fe2a642d11b4ffa7c6de8 Mon Sep 17 00:00:00 2001 From: chentao Date: Wed, 3 Nov 2021 16:12:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9F=BA=E4=BA=8Ehdc=E5=BC=80=E6=BA=90.d.ts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/@ohos.telephony.data.d.ts | 86 +++++ api/@ohos.telephony.observer.d.ts | 74 ++-- api/@ohos.telephony.radio.d.ts | 53 ++- api/@ohos.telephony.sim.d.ts | 526 ++++++++++++++------------ api/@ohos.telephony.sms.d.ts | 593 +++++++++++++++--------------- 5 files changed, 744 insertions(+), 588 deletions(-) create mode 100644 api/@ohos.telephony.data.d.ts diff --git a/api/@ohos.telephony.data.d.ts b/api/@ohos.telephony.data.d.ts new file mode 100644 index 0000000000..4d5bddc397 --- /dev/null +++ b/api/@ohos.telephony.data.d.ts @@ -0,0 +1,86 @@ +/* +* 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 { + + function getCellularDataState(callback: AsyncCallback): void; + function getCellularDataState(): Promise; + + // need ohos.permission.GET_NETWORK_INFO + function isCellularDataEnabled(callback: AsyncCallback): void; + function isCellularDataEnabled(): Promise; + + // @SystemApi, used for system app. + function enableCellularData(callback: AsyncCallback): void; + function enableCellularData(): Promise; + + // @SystemApi, used for system app. + function disableCellularData(callback: AsyncCallback): void; + function disableCellularData(): Promise; + + // @SystemApi, used for system app. + function enableCellularDataRoaming(slotId: number, callback: AsyncCallback): void; + function enableCellularDataRoaming(slotId: number): Promise; + + // @SystemApi, used for system app. + function disableCellularDataRoaming(slotId: number, callback: AsyncCallback): void; + function disableCellularDataRoaming(slotId: number): Promise; + + // need ohos.permission.GET_NETWORK_INFO + function isCellularDataRoamingEnabled(slotId: number, callback: AsyncCallback): void; + function isCellularDataRoamingEnabled(slotId: number): Promise; + + /** + * Describes the cellular data link connection state. + * + * @devices phone, tablet + * @version 5 + */ + 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 d1c0fe0b18..1fc1916539 100755 --- a/api/@ohos.telephony.observer.d.ts +++ b/api/@ohos.telephony.observer.d.ts @@ -13,10 +13,11 @@ * limitations under the License. */ -import {AsyncCallback} from "./basic"; +import { Callback } from "./basic"; import radio from "./@ohos.telephony.radio"; +import data from "./@ohos.telephony.data"; import call from "./@ohos.telephony.call"; - +import { SimState } 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. @@ -24,9 +25,13 @@ import call from "./@ohos.telephony.call"; * @since 6 */ declare namespace observer { - type NetworkState = radio.NetworkState; - type SignalInformation = radio.SignalInformation; - type CallState = call.CallState; + 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; /** * Called when the network state corresponding to a monitored {@code slotId} updates. @@ -39,13 +44,13 @@ declare namespace observer { * The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2. * @param callback including an instance of the {@code NetworkState} class. */ - function on(type: 'networkStateChange', callback: AsyncCallback): void; - function on(type: 'networkStateChange', options: { slotId: number }, callback: AsyncCallback): void; + function on(type: 'networkStateChange', callback: Callback): void; + function on(type: 'networkStateChange', options: { slotId: number }, callback: Callback): void; - function once(type: 'networkStateChange', callback: AsyncCallback): void; - function once(type: 'networkStateChange', options: { slotId: number }, callback: AsyncCallback): void; + function once(type: 'networkStateChange', callback: Callback): void; + function once(type: 'networkStateChange', options: { slotId: number }, callback: Callback): void; - function off(type: 'networkStateChange', callback?: AsyncCallback): void; + function off(type: 'networkStateChange', callback?: Callback): void; /** * Called when the signal strength corresponding to a monitored {@code slotId} updates. @@ -55,15 +60,15 @@ declare namespace observer { * 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 SignalInformation}. */ - function on(type: 'signalInfoChange', callback: AsyncCallback>): void; + function on(type: 'signalInfoChange', callback: Callback>): void; function on(type: 'signalInfoChange', options: { slotId: number }, - callback: AsyncCallback>): void; + callback: Callback>): void; - function once(type: 'signalInfoChange', callback: AsyncCallback>): void; + function once(type: 'signalInfoChange', callback: Callback>): void; function once(type: 'signalInfoChange', options: { slotId: number }, - callback: AsyncCallback>): void; + callback: Callback>): void; - function off(type: 'signalInfoChange', callback?: AsyncCallback>): void; + function off(type: 'signalInfoChange', callback?: Callback>): void; /** * Receives a call state change. This callback is invoked when the call state of a specified card updates @@ -76,15 +81,42 @@ declare namespace observer { * The value of number is an empty string if the application does not have * the {@code ohos.permission#READ_CALL_LOG READ_CALL_LOG} permission. */ - function on(type: 'callStateChange', callback: AsyncCallback<{ state: CallState, number: String }>): void; + function on(type: 'callStateChange', callback: Callback<{ state: CallState, number: String }>): void; function on(type: 'callStateChange', options: { slotId: number }, - callback: AsyncCallback<{ state: CallState, number: String }>): void; + callback: Callback<{ state: CallState, number: String }>): void; - function once(type: 'callStateChange', callback: AsyncCallback<{ state: CallState, number: String }>): void; + function once(type: 'callStateChange', callback: Callback<{ state: CallState, number: String }>): void; function once(type: 'callStateChange', options: { slotId: number }, - callback: AsyncCallback<{ state: CallState, number: String }>): void; + callback: Callback<{ state: CallState, number: String }>): void; - function off(type: 'callStateChange', callback?: AsyncCallback<{ 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 + */ + function on(type: 'simStateChange', callback: Callback): void; + function on(type: 'simStateChange', options: { slotId: number }, + callback: Callback): void; + function once(type: 'simStateChange', callback: Callback): void; + function once(type: 'simStateChange', options: { slotId: number }, + callback: Callback): void; + function off(type: 'simStateChange', callback?: Callback): void; + export interface SimStateData { + state: SimState, + reason: LockReason + } + export enum LockReason { + SIM_NONE, + SIM_PIN, + SIM_PUK, + } +} export default observer; \ No newline at end of file diff --git a/api/@ohos.telephony.radio.d.ts b/api/@ohos.telephony.radio.d.ts index bbc4dcfc71..c01ff38350 100644 --- a/api/@ohos.telephony.radio.d.ts +++ b/api/@ohos.telephony.radio.d.ts @@ -13,20 +13,22 @@ * limitations under the License. */ -import {AsyncCallback} from "./basic"; +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 + * @since 7 * @sysCap SystemCapability.Telephony.Telephony + * @devices phone, tablet, wearable */ 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. + * 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}. * @@ -51,8 +53,8 @@ declare namespace radio { * @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}>; + callback: AsyncCallback<{ psRadioTech: RadioTechnology, csRadioTech: RadioTechnology }>): void; + function getRadioTech(slotId: number): Promise<{ psRadioTech: RadioTechnology, csRadioTech: RadioTechnology }>; /** * Obtains the network state of the registered network. @@ -103,25 +105,23 @@ declare namespace radio { * 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 - */ + * 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>; /** - * @permission ohos.permission.GET_NETWORK_INFO - * @since 7 + * @permission ohos.permission.GET_TELEPHONY_STATE + * @systemapi Hide this for inner system use. */ function isRadioOn(callback: AsyncCallback): void; function isRadioOn(): Promise; @@ -129,7 +129,6 @@ declare namespace radio { /** * @permission ohos.permission.SET_TELEPHONY_STATE * @systemapi Hide this for inner system use. - * @since 7 */ function turnOnRadio(callback: AsyncCallback): void; function turnOnRadio(): Promise; @@ -137,11 +136,17 @@ declare namespace radio { /** * @permission ohos.permission.SET_TELEPHONY_STATE * @systemapi Hide this for inner system use. - * @since 7 */ function turnOffRadio(callback: AsyncCallback): void; function turnOffRadio(): Promise; + /** + * @permission ohos.permission.GET_TELEPHONY_STATE + */ + function getIMEI(callback: AsyncCallback): void; + function getIMEI(slotId: number, callback: AsyncCallback): void; + function getIMEI(slotId?: number): Promise; + /** * Describes the radio access technology. */ @@ -393,17 +398,11 @@ declare namespace radio { 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; @@ -411,9 +410,6 @@ declare namespace radio { radioTech: string; } - /** - * @systemapi Hide this for inner system use. - */ export enum NetworkInformationState { /** Indicates that the network state is unknown. */ NETWORK_UNKNOWN, @@ -428,9 +424,6 @@ declare namespace radio { NETWORK_FORBIDDEN } - /** - * @systemapi Hide this for inner system use. - */ export interface NetworkSelectionModeOptions { slotId: number; selectMode: NetworkSelectionMode; diff --git a/api/@ohos.telephony.sim.d.ts b/api/@ohos.telephony.sim.d.ts index ed9652a51a..a7ab061aaa 100644 --- a/api/@ohos.telephony.sim.d.ts +++ b/api/@ohos.telephony.sim.d.ts @@ -1,235 +1,293 @@ -/* -* 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 - } -} - +/* +* 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 { + /** + * 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. + */ + function hasSimCard(slotId: number, callback: AsyncCallback): void; + function hasSimCard(slotId: number): Promise; + + /** + * Obtains the default card slot for the voice service. + * + * @param callback Returns {@code 0} if card 1 is used as the default card slot for the voice service; + * returns {@code 1} if card 2 is used as the default card slot for the voice service; + * returns {@code -1} if no card is available for the voice service. + * @since 7 + */ + function getDefaultVoiceSlotId(callback: AsyncCallback): void; + function getDefaultVoiceSlotId(): Promise; + + /** + * 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; + + /** + * Obtains the MSISDN of the SIM card in a specified slot. + * The MSISDN is recorded in the EFMSISDN file of the SIM card. + * + *

Requires Permission: {@code ohos.permission.GET_TELEPHONY_STATE}. + * + * @param slotId Indicates the card slot index number, + * ranging from 0 to the maximum card slot index number supported by the device. + * @param callback Returns the MSISDN; returns an empty string if no SIM card is inserted or + * no MSISDN is recorded in the EFMSISDN file. + * @permission ohos.permission.GET_TELEPHONY_STATE + */ + function getSimTelephoneNumber(slotId: number, callback: AsyncCallback): void; + function getSimTelephoneNumber(slotId: number): Promise; + + /** + * @systemapi Hide this for inner system use. + */ + function queryIccDiallingNumbers(slotId: number, type: number, callback: AsyncCallback>): void + function queryIccDiallingNumbers(slotId: number, type: number): Promise>; + + /** + * @systemapi Hide this for inner system use. + */ + function addIccDiallingNumbers(slotId: number, type: number, diallingNumbers: DiallingNumbersInfo, callback: AsyncCallback): void; + function addIccDiallingNumbers(slotId: number, type: number, diallingNumbers: DiallingNumbersInfo): Promise; + + /** + * @systemapi Hide this for inner system use. + */ + function delIccDiallingNumbers(slotId: number, type: number, index: number, callback :AsyncCallback): void; + function delIccDiallingNumbers(slotId: number, type: number, index: number): Promise; + + /** + * @systemapi Hide this for inner system use. + */ + function updateIccDiallingNumbers(slotId: number, type: number, diallingNumbers: DiallingNumbersInfo, index: number, callback: AsyncCallback): void; + function updateIccDiallingNumbers(slotId: number, type: number, diallingNumbers: DiallingNumbersInfo, index: 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 */ + } + + /** + * @systemapi Hide this for inner system use. + */ + export interface DiallingNumbersInfo { + recordNumber: number, + alphaTag: string, + number: string, + } + + 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 index 709f1b6900..cc0fa7cfeb 100644 --- a/api/@ohos.telephony.sms.d.ts +++ b/api/@ohos.telephony.sms.d.ts @@ -1,303 +1,290 @@ -/* -* Copyright (C) 2021 Huawei Device Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import {AsyncCallback} from "./basic"; - -/** - * Provides the capabilities and methods for obtaining Short Message Service (SMS) management objects. - * - * @since 6 - * @sysCap SystemCapability.Telephony.Telephony - */ -declare namespace sms { - /** - * Creates an SMS message instance based on the protocol data unit (PDU) and the specified SMS protocol. - * - *

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

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

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

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

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