From 274b6e8a28511aeb3eeb2edb18a39c357b20e3ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=BB=94?= Date: Wed, 3 Nov 2021 10:55:54 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20sim=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/@ohos.telephony.sim.d.ts | 58 ++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/api/@ohos.telephony.sim.d.ts b/api/@ohos.telephony.sim.d.ts index ed9652a51a..599296dee0 100644 --- a/api/@ohos.telephony.sim.d.ts +++ b/api/@ohos.telephony.sim.d.ts @@ -23,6 +23,16 @@ import {AsyncCallback} from "./basic"; * @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. * @@ -175,6 +185,45 @@ declare namespace sim { 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 @@ -194,6 +243,15 @@ declare namespace sim { 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. -- Gitee From ef3a861781171f314c2f7e0413a4e331608b1c11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=BB=94?= Date: Wed, 3 Nov 2021 11:00:55 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0sms/observer/radio=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/@ohos.telephony.observer.d.ts | 74 ++++++++++----- api/@ohos.telephony.radio.d.ts | 149 ++++++++++++++++++++++++------ api/@ohos.telephony.sms.d.ts | 17 +--- 3 files changed, 174 insertions(+), 66 deletions(-) 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..0171e51ada 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,107 @@ declare namespace radio { NSA_STATE_SA_ATTACHED = 6 } - /** - * @systemapi Hide this for inner system use. - */ + export interface CellInformation { + /** + * Obtains the network type of the serving cell. + * + *

An application can call this method to determine the network type that the child class uses. + * + * @return Returns the the network type of the serving cell. + * @version 5 + */ + networkType: NetworkType; + + /** + * Obtains the camp-on status of the serving cell. + * + * @return Returns {@code true} if the user equipment (UE) is camped on the cell; returns + * {@code false} otherwise. + * @version 5 + */ + isCamped: boolean; + + /** + * Obtains the timestamp when the cell information is obtained. + * + * @return Returns a timestamp since boot, in nanoseconds. + * @version 5 + */ + timeStamp: number; + + /** + * An abstract method of the parent class whose implementation depends on the child classes. + * Returned child class objects vary according to the network type. + * + * @return Returns child class objects specific to the network type. + * @version 5 + */ + signalInformation: SignalInformation; + + data: CdmaCellInformation | GsmCellInformation | LteCellInformation | NrCellInformation | TdscdmaCellInformation + | WcdmaCellInformation; + } + + export interface CdmaCellInformation { + baseId: number, + latitude: number, + longitude: number, + nid: number, + sid: number, + } + + export interface GsmCellInformation { + lac: number; + cellId: number; + arfcn: number; + bsic: number; + mcc: string; + mnc: string; + } + + export interface LteCellInformation { + cgi: number; + pci: number; + tac: number; + earfcn: number; + bandwidth: number; + mcc: string; + mnc: string; + isSupportEndc: boolean; + } + + export interface NrCellInformation { + nrArfcn: number; + pci: number; + tac: number; + nci: number; + mcc: string; + mnc: string; + } + + export interface TdscdmaCellInformation { + lac: number; + cellId: number; + cpid: number; + uarfcn: number; + mcc: string; + mnc: string; + } + + export interface WcdmaCellInformation { + lac: number; + cellId: number; + psc: number; + uarfcn: number; + mcc: number; + mnc: number; + } + export interface NetworkSearchResult { isNetworkSearchSuccess: boolean; networkSearchResult: Array; } - /** - * @systemapi Hide this for inner system use. - */ export interface NetworkInformation { operatorName: string; operatorNumeric: string; @@ -411,9 +506,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 +520,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.sms.d.ts b/api/@ohos.telephony.sms.d.ts index 709f1b6900..2ac12bb2e1 100644 --- a/api/@ohos.telephony.sms.d.ts +++ b/api/@ohos.telephony.sms.d.ts @@ -18,8 +18,9 @@ import {AsyncCallback} from "./basic"; /** * Provides the capabilities and methods for obtaining Short Message Service (SMS) management objects. * - * @since 6 + * @since 7 * @sysCap SystemCapability.Telephony.Telephony + * @devices phone, tablet, wearable */ declare namespace sms { /** @@ -58,7 +59,6 @@ declare namespace sms { * 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; @@ -68,7 +68,6 @@ declare namespace sms { * * @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; @@ -81,7 +80,6 @@ declare namespace sms { * @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; @@ -94,7 +92,6 @@ declare namespace sms { * @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; @@ -102,7 +99,6 @@ declare namespace sms { /** * @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; @@ -110,7 +106,6 @@ declare namespace sms { /** * @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; @@ -118,7 +113,6 @@ declare namespace sms { /** * @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; @@ -126,7 +120,6 @@ declare namespace sms { /** * @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>; @@ -134,14 +127,12 @@ declare namespace sms { /** * @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, @@ -153,7 +144,6 @@ declare namespace sms { /** * @systemapi Hide this for inner system use. - * @since 7 */ export interface SimMessageOptions { slotId: number, @@ -164,7 +154,6 @@ declare namespace sms { /** * @systemapi Hide this for inner system use. - * @since 7 */ export interface UpdateSimMessageOptions { slotId: number, @@ -204,7 +193,6 @@ declare namespace sms { /** * @systemapi Hide this for inner system use. - * @since 7 */ export interface SimShortMessage { shortMessage: ShortMessage; @@ -217,7 +205,6 @@ declare namespace sms { /** * @systemapi Hide this for inner system use. - * @since 7 */ export enum SimMessageStatus { /** status free space ON SIM */ -- Gitee