update telephony js api in version 7.

Signed-off-by: clevercong <lichunlin2@huawei.com>
This commit is contained in:
clevercong 2021-10-11 15:18:39 +08:00
parent f0dcc64b94
commit d35e38fc46
6 changed files with 1329 additions and 811 deletions

419
api/@ohos.telephony.call.d.ts vendored Executable file → Normal file
View File

@ -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.
*
* <p>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<boolean>): void;
function dial(phoneNumber: string, options: DialOptions, callback: AsyncCallback<boolean>): void;
function dial(phoneNumber: string, options?: DialOptions): Promise<boolean>;
/**
* Obtains the call state.
*
* <p>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<CallState>): void;
function getCallState(): Promise<CallState>;
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.
*
* <p>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<boolean>): void;
function dial(phoneNumber: string, options: DialOptions, callback: AsyncCallback<boolean>): void;
function dial(phoneNumber: string, options?: DialOptions): Promise<boolean>;
/**
* 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<boolean>): void;
function hasCall(): Promise<boolean>;
/**
* Obtains the call state.
*
* <p>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<CallState>): void;
function getCallState(): Promise<CallState>;
/**
* 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<boolean>): void;
function isEmergencyPhoneNumber(phoneNumber: string, options: EmergencyNumberOptions, callback: AsyncCallback<boolean>): void;
function isEmergencyPhoneNumber(phoneNumber: string, options?: EmergencyNumberOptions): Promise<boolean>;
/**
* 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<string>): void;
function formatPhoneNumber(phoneNumber: string, options: NumberFormatOptions, callback: AsyncCallback<string>): void;
function formatPhoneNumber(phoneNumber: string, options?: NumberFormatOptions): Promise<string>;
/**
* 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<string>): void;
function formatPhoneNumberToE164(phoneNumber: string, countryCode: string): Promise<string>;
/**
* @systemapi Hide this for inner system use.
* @since 7
*/
function answer(callId: number, callback: AsyncCallback<void>): void;
function answer(callId: number): Promise<void>;
/**
* @systemapi Hide this for inner system use.
* @since 7
*/
function hangup(callId: number, callback: AsyncCallback<void>): void;
function hangup(callId: number): Promise<void>;
/**
* @systemapi Hide this for inner system use.
* @since 7
*/
function reject(callId: number, callback: AsyncCallback<void>): void;
function reject(callId: number, options: RejectMessageOptions, callback: AsyncCallback<void>): void;
function reject(callId: number, options?: RejectMessageOptions): Promise<void>;
/**
* @systemapi Hide this for inner system use.
*/
function holdCall(callId: number, callback: AsyncCallback<void>): void;
function holdCall(callId: number): Promise<void>;
/**
* @systemapi Hide this for inner system use.
*/
function unHoldCall(callId: number, callback: AsyncCallback<void>): void;
function unHoldCall(callId: number): Promise<void>;
/**
* @systemapi Hide this for inner system use.
*/
function switchCall(callId: number, callback: AsyncCallback<void>): void;
function switchCall(callId: number): Promise<void>;
/**
* @systemapi Hide this for inner system use.
* @since 7
*/
function combineConference(callId: number, callback: AsyncCallback<void>): void;
function combineConference(callId: number): Promise<void>;
/**
* @systemapi Hide this for inner system use.
* @since 7
*/
function getMainCallId(callId: number, callback: AsyncCallback<number>): void;
function getMainCallId(callId: number): Promise<number>;
/**
* @systemapi Hide this for inner system use.
* @since 7
*/
function getSubCallIdList(callId: number, callback: AsyncCallback<Array<string>>): void;
function getSubCallIdList(callId: number): Promise<Array<string>>;
/**
* @systemapi Hide this for inner system use.
* @since 7
*/
function getCallIdListForConference(callId: number, callback: AsyncCallback<Array<string>>): void;
function getCallIdListForConference(callId: number): Promise<Array<string>>;
/**
* @systemapi Hide this for inner system use.
* @since 7
*/
function getCallWaitingStatus(slotId: number, callback: AsyncCallback<CallWaitingStatus>): void;
function getCallWaitingStatus(slotId: number): Promise<CallWaitingStatus>;
/**
* @systemapi Hide this for inner system use.
* @since 7
*/
function setCallWaiting(slotId: number, activate: boolean, callback: AsyncCallback<void>): void;
function setCallWaiting(slotId: number, activate: boolean): Promise<void>;
/**
* @systemapi Hide this for inner system use.
* @since 7
*/
function startDTMF(callId: number, character: string, callback: AsyncCallback<void>): void;
function startDTMF(callId: number, character: string): Promise<void>;
/**
* @systemapi Hide this for inner system use.
* @since 7
*/
function stopDTMF(callId: number, callback: AsyncCallback<void>): void;
function stopDTMF(callId: number): Promise<void>;
/**
* @permission ohos.permission.SET_TELEPHONY_STATE
* @systemapi Hide this for inner system use.
* @since 7
*/
function isInEmergencyCall(callback: AsyncCallback<boolean>): void;
function isInEmergencyCall(): Promise<boolean>;
/**
* @systemapi Hide this for inner system use.
* @since 7
*/
function on(type: 'callDetailsChange', callback: Callback<CallAttributeOptions>): void;
function off(type: 'callDetailsChange', callback?: Callback<CallAttributeOptions>): 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;

View File

@ -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:
* <ul>
* <li>{@code DataConnectState#DATA_STATE_UNKNOWN}
* <li>{@code DataConnectState#DATA_STATE_DISCONNECTED}
* <li>{@code DataConnectState#DATA_STATE_CONNECTING}
* <li>{@code DataConnectState#DATA_STATE_CONNECTED}
* <li>{@code DataConnectState#DATA_STATE_SUSPENDED}
* </ul>
*/
function getCellularDataState(callback: AsyncCallback<DataConnectState>): void;
function getCellularDataState(): Promise<DataConnectState>;
/**
* Checks whether cellular data services are enabled.
*
* <p>Requires Permission: {@code ohos.permission.GET_NETWORK_INFO}.
*
* @param callback Returns {@code true} if cellular data services are enabled; returns {@code false} otherwise.
*/
function isCellularDataEnabled(callback: AsyncCallback<boolean>): void;
function isCellularDataEnabled(): Promise<boolean>;
/**
* Enables cellular data services.
*
* @hide Used for system app.
*/
function enableCellularData(callback: AsyncCallback<void>): void;
function enableCellularData(): Promise<void>;
/**
* Diables cellular data services.
*
* @hide Used for system app.
*/
function disableCellularData(callback: AsyncCallback<void>): void;
function disableCellularData(): Promise<void>;
/**
* 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;

View File

@ -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<Array<SignalInformation>>): 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.

781
api/@ohos.telephony.radio.d.ts vendored Executable file → Normal file
View File

@ -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.
*
* <p>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:
* <ul>
* <li>{@code RadioTechnology#RADIO_TECHNOLOGY_UNKNOWN}
* <li>{@code RadioTechnology#RADIO_TECHNOLOGY_GSM}
* <li>{@code RadioTechnology#RADIO_TECHNOLOGY_1XRTT}
* <li>{@code RadioTechnology#RADIO_TECHNOLOGY_WCDMA}
* <li>{@code RadioTechnology#RADIO_TECHNOLOGY_HSPA}
* <li>{@code RadioTechnology#RADIO_TECHNOLOGY_HSPAP}
* <li>{@code RadioTechnology#RADIO_TECHNOLOGY_TD_SCDMA}
* <li>{@code RadioTechnology#RADIO_TECHNOLOGY_EVDO}
* <li>{@code RadioTechnology#RADIO_TECHNOLOGY_EHRPD}
* <li>{@code RadioTechnology#RADIO_TECHNOLOGY_LTE}
* <li>{@code RadioTechnology#RADIO_TECHNOLOGY_LTE_CA}
* <li>{@code RadioTechnology#RADIO_TECHNOLOGY_IWLAN}
* <li>{@code RadioTechnology#RADIO_TECHNOLOGY_NR}
* </ul>
*/
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.
*
* <p>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<NetworkState>): void;
function getNetworkState(slotId: number, callback: AsyncCallback<NetworkState>): void;
function getNetworkState(slotId?: number): Promise<NetworkState>;
/**
* 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<Array<SignalInformation>>): void;
function getSignalInformation(slotId: number): Promise<Array<SignalInformation>>;
/**
* 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.
*
* <p>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:
* <ul>
* <li>{@code RadioTechnology#RADIO_TECHNOLOGY_UNKNOWN}
* <li>{@code RadioTechnology#RADIO_TECHNOLOGY_GSM}
* <li>{@code RadioTechnology#RADIO_TECHNOLOGY_1XRTT}
* <li>{@code RadioTechnology#RADIO_TECHNOLOGY_WCDMA}
* <li>{@code RadioTechnology#RADIO_TECHNOLOGY_HSPA}
* <li>{@code RadioTechnology#RADIO_TECHNOLOGY_HSPAP}
* <li>{@code RadioTechnology#RADIO_TECHNOLOGY_TD_SCDMA}
* <li>{@code RadioTechnology#RADIO_TECHNOLOGY_EVDO}
* <li>{@code RadioTechnology#RADIO_TECHNOLOGY_EHRPD}
* <li>{@code RadioTechnology#RADIO_TECHNOLOGY_LTE}
* <li>{@code RadioTechnology#RADIO_TECHNOLOGY_LTE_CA}
* <li>{@code RadioTechnology#RADIO_TECHNOLOGY_IWLAN}
* <li>{@code RadioTechnology#RADIO_TECHNOLOGY_NR}
* </ul>
* @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.
*
* <p>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<NetworkState>): void;
function getNetworkState(slotId: number, callback: AsyncCallback<NetworkState>): void;
function getNetworkState(slotId?: number): Promise<NetworkState>;
/**
* 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:
* <ul>
* <li>{@link NetworkSelectionMode#NETWORK_SELECTION_UNKNOWN}
* <li>{@link NetworkSelectionMode#NETWORK_SELECTION_AUTOMATIC}
* <li>{@link NetworkSelectionMode#NETWORK_SELECTION_MANUAL}
* <ul>
*/
function getNetworkSelectionMode(slotId: number, callback: AsyncCallback<NetworkSelectionMode>): void;
function getNetworkSelectionMode(slotId: number): Promise<NetworkSelectionMode>;
/**
* @permission ohos.permission.SET_TELEPHONY_STATE
* @systemapi Hide this for inner system use.
*/
function setNetworkSelectionMode(options: NetworkSelectionModeOptions, callback: AsyncCallback<void>): void;
function setNetworkSelectionMode(options: NetworkSelectionModeOptions): Promise<void>;
/**
* @permission ohos.permission.GET_TELEPHONY_STATE
* @systemapi Hide this for inner system use.
*/
function getNetworkSearchInformation(slotId: number, callback: AsyncCallback<NetworkSearchResult>): void;
function getNetworkSearchInformation(slotId: number): Promise<NetworkSearchResult>;
/**
* 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<string>): void;
function getISOCountryCodeForNetwork(slotId: number): Promise<string>;
/**
* 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<Array<SignalInformation>>): void;
function getSignalInformation(slotId: number): Promise<Array<SignalInformation>>;
/**
* @permission ohos.permission.GET_NETWORK_INFO
* @since 7
*/
function isRadioOn(callback: AsyncCallback<boolean>): void;
function isRadioOn(): Promise<boolean>;
/**
* @permission ohos.permission.SET_TELEPHONY_STATE
* @systemapi Hide this for inner system use.
* @since 7
*/
function turnOnRadio(callback: AsyncCallback<void>): void;
function turnOnRadio(): Promise<void>;
/**
* @permission ohos.permission.SET_TELEPHONY_STATE
* @systemapi Hide this for inner system use.
* @since 7
*/
function turnOffRadio(callback: AsyncCallback<void>): void;
function turnOffRadio(): Promise<void>;
/**
* 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<NetworkInformation>;
}
/**
* @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;

351
api/@ohos.telephony.sim.d.ts vendored Executable file → Normal file
View File

@ -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<string>): void;
function getISOCountryCodeForSim(slotId: number): Promise<string>;
/**
* Obtains the home PLMN number of the SIM card in a specified slot.
*
* <p>The value is recorded in the SIM card and is irrelevant to the network
* with which the SIM card is currently registered.
*
* @param slotId Indicates the card slot index number,
* ranging from 0 to the maximum card slot index number supported by the device.
* @param callback Returns the PLMN number; returns an empty string if no SIM card is inserted.
*/
function getSimOperatorNumeric(slotId: number, callback: AsyncCallback<string>): void;
function getSimOperatorNumeric(slotId: number): Promise<string>;
/**
* Obtains the service provider name (SPN) of the SIM card in a specified slot.
*
* <p>The value is recorded in the EFSPN file of the SIM card and is irrelevant to the network
* with which the SIM card is currently registered.
*
* @param slotId Indicates the card slot index number,
* ranging from 0 to the maximum card slot index number supported by the device.
* @param callback Returns the SPN; returns an empty string if no SIM card is inserted or
* no EFSPN file in the SIM card.
*/
function getSimSpn(slotId: number, callback: AsyncCallback<string>): void;
function getSimSpn(slotId: number): Promise<string>;
/**
* Obtains the state of the SIM card in a specified slot.
*
* @param slotId Indicates the card slot index number,
* ranging from {@code 0} to the maximum card slot index number supported by the device.
* @param callback Returns one of the following SIM card states:
* <ul>
* <li>{@code SimState#SIM_STATE_UNKNOWN}
* <li>{@code SimState#SIM_STATE_NOT_PRESENT}
* <li>{@code SimState#SIM_STATE_LOCKED}
* <li>{@code SimState#SIM_STATE_NOT_READY}
* <li>{@code SimState#SIM_STATE_READY}
* <li>{@code SimState#SIM_STATE_LOADED}
* </ul>
*/
function getSimState(slotId: number, callback: AsyncCallback<SimState>): void;
function getSimState(slotId: number): Promise<SimState>;
export enum SimState {
/**
* Indicates unknown SIM card state, that is, the accurate status cannot be obtained.
*/
SIM_STATE_UNKNOWN,
/**
* Indicates that the SIM card is in the <b>not present</b> state, that is, no SIM card is inserted
* into the card slot.
*/
SIM_STATE_NOT_PRESENT,
/**
* Indicates that the SIM card is in the <b>locked</b> state, that is, the SIM card is locked by the
* personal identification number (PIN)/PIN unblocking key (PUK) or network.
*/
SIM_STATE_LOCKED,
/**
* Indicates that the SIM card is in the <b>not ready</b> state, that is, the SIM card is in position
* but cannot work properly.
*/
SIM_STATE_NOT_READY,
/**
* Indicates that the SIM card is in the <b>ready</b> state, that is, the SIM card is in position and
* is working properly.
*/
SIM_STATE_READY,
/**
* Indicates that the SIM card is in the <b>loaded</b> state, that is, the SIM card is in position and
* is working properly.
*/
SIM_STATE_LOADED
}
}
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {AsyncCallback} from "./basic";
/**
* Provides applications with APIs for obtaining SIM card status, card file information, and card specifications.
* SIM cards include SIM, USIM, and CSIM cards.
*
* @since 6
* @sysCap SystemCapability.Telephony.Telephony
*/
declare namespace sim {
/**
* Obtains the default card slot for the voice service.
*
* @param callback Returns {@code 0} if card 1 is used as the default card slot for the voice service;
* returns {@code 1} if card 2 is used as the default card slot for the voice service;
* returns {@code -1} if no card is available for the voice service.
* @since 7
*/
function getDefaultVoiceSlotId(callback: AsyncCallback<number>): void;
function getDefaultVoiceSlotId(): Promise<number>;
/**
* Obtains the ISO country code of the SIM card in a specified slot.
*
* @param slotId Indicates the card slot index number,
* ranging from 0 to the maximum card slot index number supported by the device.
* @param callback Returns the country code defined in ISO 3166-2; returns an empty string if no SIM card is inserted.
*/
function getISOCountryCodeForSim(slotId: number, callback: AsyncCallback<string>): void;
function getISOCountryCodeForSim(slotId: number): Promise<string>;
/**
* Obtains the home PLMN number of the SIM card in a specified slot.
*
* <p>The value is recorded in the SIM card and is irrelevant to the network
* with which the SIM card is currently registered.
*
* @param slotId Indicates the card slot index number,
* ranging from 0 to the maximum card slot index number supported by the device.
* @param callback Returns the PLMN number; returns an empty string if no SIM card is inserted.
*/
function getSimOperatorNumeric(slotId: number, callback: AsyncCallback<string>): void;
function getSimOperatorNumeric(slotId: number): Promise<string>;
/**
* Obtains the service provider name (SPN) of the SIM card in a specified slot.
*
* <p>The value is recorded in the EFSPN file of the SIM card and is irrelevant to the network
* with which the SIM card is currently registered.
*
* @param slotId Indicates the card slot index number,
* ranging from 0 to the maximum card slot index number supported by the device.
* @param callback Returns the SPN; returns an empty string if no SIM card is inserted or
* no EFSPN file in the SIM card.
*/
function getSimSpn(slotId: number, callback: AsyncCallback<string>): void;
function getSimSpn(slotId: number): Promise<string>;
/**
* Obtains the state of the SIM card in a specified slot.
*
* @param slotId Indicates the card slot index number,
* ranging from {@code 0} to the maximum card slot index number supported by the device.
* @param callback Returns one of the following SIM card states:
* <ul>
* <li>{@code SimState#SIM_STATE_UNKNOWN}
* <li>{@code SimState#SIM_STATE_NOT_PRESENT}
* <li>{@code SimState#SIM_STATE_LOCKED}
* <li>{@code SimState#SIM_STATE_NOT_READY}
* <li>{@code SimState#SIM_STATE_READY}
* <li>{@code SimState#SIM_STATE_LOADED}
* </ul>
*/
function getSimState(slotId: number, callback: AsyncCallback<SimState>): void;
function getSimState(slotId: number): Promise<SimState>;
/**
* Obtains the ICCID of the SIM card in a specified slot.
*
* <p>The ICCID is a unique identifier of a SIM card. It consists of 20 digits
* and is recorded in the EFICCID file of the SIM card.
*
* <p>Requires Permission: {@code ohos.permission.GET_TELEPHONY_STATE}.
*
* @param slotId Indicates the card slot index number,
* ranging from 0 to the maximum card slot index number supported by the device.
* @param callback Returns the ICCID; returns an empty string if no SIM card is inserted.
* @permission ohos.permission.GET_TELEPHONY_STATE
*/
function getSimIccId(slotId: number, callback: AsyncCallback<string>): void;
function getSimIccId(slotId: number): Promise<string>;
/**
* Obtains the Group Identifier Level 1 (GID1) of the SIM card in a specified slot.
* The GID1 is recorded in the EFGID1 file of the SIM card.
*
* <p>Requires Permission: {@code ohos.permission.GET_TELEPHONY_STATE}.
*
* @param slotId Indicates the card slot index number,
* ranging from 0 to the maximum card slot index number supported by the device.
* @param callback Returns the GID1; returns an empty string if no SIM card is inserted or
* no GID1 in the SIM card.
* @permission ohos.permission.GET_TELEPHONY_STATE
*/
function getSimGid1(slotId: number, callback: AsyncCallback<string>): void;
function getSimGid1(slotId: number): Promise<string>;
/**
* @permission ohos.permission.GET_TELEPHONY_STATE
* @systemapi Hide this for inner system use.
*/
function getIMSI(slotId: number, callback: AsyncCallback<string>): void;
function getIMSI(slotId: number): Promise<string>;
/**
* @permission ohos.permission.GET_TELEPHONY_STATE
* @systemapi Hide this for inner system use.
* @since 7
*/
function getSimAccountInfo(slotId: number, callback: AsyncCallback<IccAccountInfo>): void;
function getSimAccountInfo(slotId: number): Promise<IccAccountInfo>;
/**
* @permission ohos.permission.SET_TELEPHONY_STATE
* @systemapi Hide this for inner system use.
* @since 7
*/
function setDefaultVoiceSlotId(slotId: number, callback: AsyncCallback<void>): void;
function setDefaultVoiceSlotId(slotId: number): Promise<void>;
/**
* @permission ohos.permission.SET_TELEPHONY_STATE
* @systemapi Hide this for inner system use.
* @since 7
*/
function unlockPin(slotId: number, pin: string, callback: AsyncCallback<LockStatusResponse>): void;
function unlockPin(slotId: number, pin: string): Promise<LockStatusResponse>;
/**
* @permission ohos.permission.SET_TELEPHONY_STATE
* @systemapi Hide this for inner system use.
* @since 7
*/
function unlockPuk(slotId: number, newPin: string, puk: string, callback: AsyncCallback<LockStatusResponse>): void;
function unlockPuk(slotId: number, newPin: string, puk: string): Promise<LockStatusResponse>;
/**
* @permission ohos.permission.SET_TELEPHONY_STATE
* @systemapi Hide this for inner system use.
* @since 7
*/
function alterPin(slotId: number, newPin: string, oldPin: string, callback: AsyncCallback<LockStatusResponse>): void;
function alterPin(slotId: number, newPin: string, oldPin: string): Promise<LockStatusResponse>;
/**
* @permission ohos.permission.SET_TELEPHONY_STATE
* @systemapi Hide this for inner system use.
* @since 7
*/
function setLockState(slotId: number, pin: string, enable: number, callback: AsyncCallback<LockStatusResponse>): void;
function setLockState(slotId: number, pin: string, enable: number): Promise<LockStatusResponse>;
/**
* @systemapi Hide this for inner system use.
* @since 7
*/
export interface IccAccountInfo {
slotIndex: number, /* slot id */
showName: string, /* display name for card */
showNumber: string, /* display number for card */
}
/**
* @systemapi Hide this for inner system use.
* @since 7
*/
export interface LockStatusResponse {
result: number, /* Current operation result */
remain?: number, /* Operations remaining */
}
export enum SimState {
/**
* Indicates unknown SIM card state, that is, the accurate status cannot be obtained.
*/
SIM_STATE_UNKNOWN,
/**
* Indicates that the SIM card is in the <b>not present</b> state, that is, no SIM card is inserted
* into the card slot.
*/
SIM_STATE_NOT_PRESENT,
/**
* Indicates that the SIM card is in the <b>locked</b> state, that is, the SIM card is locked by the
* personal identification number (PIN)/PIN unblocking key (PUK) or network.
*/
SIM_STATE_LOCKED,
/**
* Indicates that the SIM card is in the <b>not ready</b> state, that is, the SIM card is in position
* but cannot work properly.
*/
SIM_STATE_NOT_READY,
/**
* Indicates that the SIM card is in the <b>ready</b> state, that is, the SIM card is in position and
* is working properly.
*/
SIM_STATE_READY,
/**
* Indicates that the SIM card is in the <b>loaded</b> state, that is, the SIM card is in position and
* is working properly.
*/
SIM_STATE_LOADED
}
}
export default sim;

458
api/@ohos.telephony.sms.d.ts vendored Executable file → Normal file
View File

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