diff --git a/api/@ohos.net.connection.d.ts b/api/@ohos.net.connection.d.ts index f22c9e7ee02ace7ffbcfdd2a6e8516cbdd0173bf..e69470eeb680f5723d5d101ed146f3e9b8bd8e35 100644 --- a/api/@ohos.net.connection.d.ts +++ b/api/@ohos.net.connection.d.ts @@ -20,11 +20,6 @@ import type { AsyncCallback, Callback } from './@ohos.base'; -/*** if arkts 1.1 */ -import type http from './@ohos.net.http'; -import type socket from './@ohos.net.socket'; -/*** endif */ - /** * Provides interfaces to manage and use data networks. * @namespace connection @@ -100,7 +95,7 @@ declare namespace connection { /** * Create a network connection with optional netSpecifier and timeout. * @param { NetSpecifier } [netSpecifier] - Indicates the network specifier. See {@link NetSpecifier}. - * @param { number } [timeout] - The time in milliseconds to attempt looking for a suitable network before + * @param { int } [timeout] - The time in milliseconds to attempt looking for a suitable network before * {@link NetConnection#netUnavailable} is called. * @returns { NetConnection } the NetConnection of the NetSpecifier. * @syscap SystemCapability.Communication.NetManager.Core @@ -109,7 +104,7 @@ declare namespace connection { /** * Create a network connection with optional netSpecifier and timeout. * @param { NetSpecifier } [netSpecifier] - Indicates the network specifier. See {@link NetSpecifier}. - * @param { number } [timeout] - The time in milliseconds to attempt looking for a suitable network before + * @param { int } [timeout] - The time in milliseconds to attempt looking for a suitable network before * {@link NetConnection#netUnavailable} is called. * @returns { NetConnection } the NetConnection of the NetSpecifier. * @syscap SystemCapability.Communication.NetManager.Core @@ -119,15 +114,16 @@ declare namespace connection { /** * Create a network connection with optional netSpecifier and timeout. * @param { NetSpecifier } [netSpecifier] - Indicates the network specifier. See {@link NetSpecifier}. - * @param { number } [timeout] - The time in milliseconds to attempt looking for a suitable network before + * @param { int } [timeout] - The time in milliseconds to attempt looking for a suitable network before * {@link NetConnection#netUnavailable} is called. * @returns { NetConnection } the NetConnection of the NetSpecifier. * @syscap SystemCapability.Communication.NetManager.Core * @crossplatform * @atomicservice - * @since 11 + * @since arkts{ '1.1':'11','1.2':'20'} + * @arkts 1.1&1.2 */ - function createNetConnection(netSpecifier?: NetSpecifier, timeout?: number): NetConnection; + function createNetConnection(netSpecifier?: NetSpecifier, timeout?: int): NetConnection; /** * Obtains the data network that is activated by default. @@ -407,7 +403,7 @@ declare namespace connection { * @since 20 */ function setNetExtAttribute(netHandle: NetHandle, netExtAttribute: string): Promise; - + /** * Set the network extended attribute for a {@link NetHandle} object. * To invoke this method, you must have the {@code ohos.permission.SET_NET_EXT_ATTRIBUTE} permission. @@ -422,7 +418,7 @@ declare namespace connection { * @since 20 */ function setNetExtAttributeSync(netHandle: NetHandle, netExtAttribute: string): void; - + /** * Get the network extended attribute for a {@link NetHandle} object. * To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission. @@ -437,7 +433,7 @@ declare namespace connection { * @since 20 */ function getNetExtAttribute(netHandle: NetHandle): Promise; - + /** * Get the network extended attribute for a {@link NetHandle} object. * To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission. @@ -452,7 +448,7 @@ declare namespace connection { * @since 20 */ function getNetExtAttributeSync(netHandle: NetHandle): string; - + /** * Checks whether data traffic usage on the current network is metered. * @permission ohos.permission.GET_NETWORK_INFO @@ -563,7 +559,7 @@ declare namespace connection { * @throws { BusinessError } 202 - Non-system applications use system APIs. * @throws { BusinessError } 401 - Parameter error. * @throws { BusinessError } 2100002 - Failed to connect to the service. - * @throws { BusinessError } 2100003 - System internal error. + * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core * @systemapi Hide this for inner system use. Only used for system app. * @since 8 @@ -1060,6 +1056,30 @@ declare namespace connection { */ function factoryReset(): Promise; + /** + * Defines the running socket infos. + * @interface SocketInfos + * @syscap SystemCapability.Communication.NetManager.Core + * @since 20 + */ + export interface SocketInfos { + /** + * The socket protocol type. + * @type {string} + * @syscap SystemCapability.Communication.NetManager.Core + * @since 20 + */ + protocol: string; + + /** + * The connection state of the tcp socket. + * @type {?string} + * @syscap SystemCapability.Communication.NetManager.Core + * @since 20 + */ + state?: string; + } + /** * Represents the network connection handle. * @interface NetConnection @@ -1434,27 +1454,27 @@ declare namespace connection { export interface NetHandle { /** * Network ID, a value of 0 means that there is no default network, and the other values must be greater than or equal to 100. - * @type {number} + * @type {int} * @syscap SystemCapability.Communication.NetManager.Core * @since 8 */ /** * Network ID, a value of 0 means that there is no default network, and the other values must be greater than or equal to 100. - * @type {number} + * @type {int} * @syscap SystemCapability.Communication.NetManager.Core * @crossplatform * @since 10 */ /** * Network ID, a value of 0 means that there is no default network, and the other values must be greater than or equal to 100. - * @type {number} + * @type {int} * @syscap SystemCapability.Communication.NetManager.Core * @crossplatform * @atomicservice - * @since arkts {'1.1':'11','1.2':'20'} + * @since arkts{ '1.1':'11','1.2':'20'} * @arkts 1.1&1.2 */ - netId: number; + netId: int; /** *

Binds a TCPSocket or UDPSocket to the current network. All data flows from @@ -1599,19 +1619,21 @@ declare namespace connection { export interface NetCapabilities { /** * Uplink (device-to-network) bandwidth. - * @type {?number} + * @type {?int} * @syscap SystemCapability.Communication.NetManager.Core - * @since 8 + * @since arkts{ '1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ - linkUpBandwidthKbps?: number; + linkUpBandwidthKbps?: int; /** * Downstream (network-to-device) bandwidth. - * @type {?number} + * @type {?int} * @syscap SystemCapability.Communication.NetManager.Core - * @since 8 + * @since arkts{ '1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ - linkDownBandwidthKbps?: number; + linkDownBandwidthKbps?: int; /** * Network-specific capabilities. @@ -1700,16 +1722,17 @@ declare namespace connection { /** * Defines the network capability. - * @enum {number} + * @enum {int} * @syscap SystemCapability.Communication.NetManager.Core * @since 8 */ /** * Defines the network capability. - * @enum {number} + * @enum {int} * @syscap SystemCapability.Communication.NetManager.Core * @atomicservice - * @since 11 + * @since arkts{ '1.1':'11','1.2':'20'} + * @arkts 1.1&1.2 */ export enum NetCap { /** @@ -1795,24 +1818,25 @@ declare namespace connection { /** * Enumerates network types. - * @enum {number} + * @enum {int} * @syscap SystemCapability.Communication.NetManager.Core * @since 8 */ /** * Enumerates network types. - * @enum {number} + * @enum {int} * @syscap SystemCapability.Communication.NetManager.Core * @crossplatform * @since 10 */ /** * Enumerates network types. - * @enum {number} + * @enum {int} * @syscap SystemCapability.Communication.NetManager.Core * @crossplatform * @atomicservice - * @since 11 + * @since arkts{ '1.1':'11','1.2':'20'} + * @arkts 1.1&1.2 */ export enum NetBearType { /** @@ -1860,10 +1884,11 @@ declare namespace connection { * @syscap SystemCapability.Communication.NetManager.Core * @crossplatform * @atomicservice - * @since 12 + * @since arkts{ '1.1':'12','1.2':'20'} + * @arkts 1.1&1.2 */ BEARER_BLUETOOTH = 2, - + /** * Indicates that the network is an Ethernet network. * @syscap SystemCapability.Communication.NetManager.Core @@ -1882,7 +1907,7 @@ declare namespace connection { * @syscap SystemCapability.Communication.NetManager.Core * @since 12 */ - BEARER_VPN = 4, + BEARER_VPN = 4 } /** @@ -1932,11 +1957,12 @@ declare namespace connection { /** * Maximum transmission unit. - * @type {number} + * @type {int} * @syscap SystemCapability.Communication.NetManager.Core - * @since 8 + * @since arkts{ '1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ - mtu: number; + mtu: int; } /** @@ -2011,11 +2037,12 @@ declare namespace connection { address: NetAddress; /** * The length of the link address prefix. - * @type {number} + * @type {int} * @syscap SystemCapability.Communication.NetManager.Core - * @since 8 + * @since arkts{ '1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ - prefixLength: number; + prefixLength: int; } /** @@ -2049,33 +2076,35 @@ declare namespace connection { /** * Address family identifier. The value is 1 for IPv4 and 2 for IPv6. The default value is 1. - * @type {?number} + * @type {?int} * @syscap SystemCapability.Communication.NetManager.Core * @since 8 */ /** * Address family identifier. The value is 1 for IPv4 and 2 for IPv6. The default value is 1. - * @type {?number} + * @type {?int} * @syscap SystemCapability.Communication.NetManager.Core * @atomicservice - * @since 12 + * @since arkts{ '1.1':'12','1.2':'20'} + * @arkts 1.1&1.2 */ - family?: number; + family?: int; /** * Port number. The value ranges from 0 to 65535. - * @type {?number} + * @type {?int} * @syscap SystemCapability.Communication.NetManager.Core * @since 8 */ /** * Port number. The value ranges from 0 to 65535. - * @type {?number} + * @type {?int} * @syscap SystemCapability.Communication.NetManager.Core * @atomicservice - * @since 12 + * @since arkts{ '1.1':'12','1.2':'20'} + * @arkts 1.1&1.2 */ - port?: number; + port?: int; } /** @@ -2109,18 +2138,19 @@ declare namespace connection { /** * Host port. - * @type {number} + * @type {int} * @syscap SystemCapability.Communication.NetManager.Core * @since 10 */ /** * Host port. - * @type {number} + * @type {int} * @syscap SystemCapability.Communication.NetManager.Core * @atomicservice - * @since 11 + * @since arkts{ '1.1':'11','1.2':'20'} + * @arkts 1.1&1.2 */ - port: number; + port: int; /** * Http proxy username. @@ -2155,4 +2185,9 @@ declare namespace connection { } } -export default connection; +/*** if arkts 1.1 */ +import type http from './@ohos.net.http'; +import type socket from './@ohos.net.socket'; +/*** endif */ + +export default connection; \ No newline at end of file diff --git a/api/@ohos.net.networkSecurity.d.ts b/api/@ohos.net.networkSecurity.d.ts index c5eae54dfe7e37d6cddf421af207390745a0e442..7b15a8176771211cfb9a95c38eeabe97aee94759 100644 --- a/api/@ohos.net.networkSecurity.d.ts +++ b/api/@ohos.net.networkSecurity.d.ts @@ -1,206 +1,209 @@ -/* - * Copyright (c) 2023 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. - */ - -/** - * @file - * @kit NetworkKit - */ - -import type { AsyncCallback } from './@ohos.base'; - -/** - * Provides networkSecurity related APIs. - * @namespace networkSecurity - * @syscap SystemCapability.Communication.NetStack - * @since 11 - */ -declare namespace networkSecurity { - /** - * Defines the certificate type. - * @enum {number} - * @syscap SystemCapability.Communication.NetStack - * @since 11 - */ - export enum CertType { - /** - * PEM type certificate. - * @syscap SystemCapability.Communication.NetStack - * @since 11 - */ - CERT_TYPE_PEM = 0, - - /** - * DER type certificate. - * @syscap SystemCapability.Communication.NetStack - * @since 11 - */ - CERT_TYPE_DER = 1 - } - - /** - * Define the certificate content. - * @interface CertBlob - * @syscap SystemCapability.Communication.NetStack - * @since 11 - */ - export interface CertBlob { - /** - * Certificate type. - * @type { CertType } - * @syscap SystemCapability.Communication.NetStack - * @since 11 - */ - type: CertType; - - /** - * Certificate data. - * @type {string | ArrayBuffer} - * @syscap SystemCapability.Communication.NetStack - * @since 11 - */ - data: string | ArrayBuffer; - } - - /** - * Certificate verification to the server. - * @param { CertBlob } cert - Certificates to be verified. - * @param { CertBlob } [caCert] - Incoming custom CA cert. - * @returns { Promise } The promise returned by the function. - * Number equals 0 if verify of certification from server succeed, else verify failed. - * @throws { BusinessError } 401 - Parameter error. - * @throws { BusinessError } 2305001 - Unspecified error. - * @throws { BusinessError } 2305002 - Unable to get issuer certificate. - * @throws { BusinessError } 2305003 - Unable to get certificate revocation list (CRL). - * @throws { BusinessError } 2305004 - Unable to decrypt certificate signature. - * @throws { BusinessError } 2305005 - Unable to decrypt CRL signature. - * @throws { BusinessError } 2305006 - Unable to decode issuer public key. - * @throws { BusinessError } 2305007 - Certificate signature failure. - * @throws { BusinessError } 2305008 - CRL signature failure. - * @throws { BusinessError } 2305009 - Certificate is not yet valid. - * @throws { BusinessError } 2305010 - Certificate has expired. - * @throws { BusinessError } 2305011 - CRL is not yet valid. - * @throws { BusinessError } 2305012 - CRL has expired. - * @throws { BusinessError } 2305023 - Certificate has been revoked. - * @throws { BusinessError } 2305024 - Invalid certificate authority (CA). - * @throws { BusinessError } 2305027 - Certificate is untrusted. - * @syscap SystemCapability.Communication.NetStack - * @since 11 - */ - /** - * Certificate verification to the server. - * @param { CertBlob } cert - Certificates to be verified. - * @param { CertBlob } [caCert] - Incoming custom CA cert. - * @returns { Promise } The promise returned by the function. - * Number equals 0 if verify of certification from server succeed, else verify failed. - * @throws { BusinessError } 401 - Parameter error. - * @throws { BusinessError } 2305001 - Unspecified error. - * @throws { BusinessError } 2305002 - Unable to get issuer certificate. - * @throws { BusinessError } 2305003 - Unable to get certificate revocation list (CRL). - * @throws { BusinessError } 2305004 - Unable to decrypt certificate signature. - * @throws { BusinessError } 2305005 - Unable to decrypt CRL signature. - * @throws { BusinessError } 2305006 - Unable to decode issuer public key. - * @throws { BusinessError } 2305007 - Certificate signature failure. - * @throws { BusinessError } 2305008 - CRL signature failure. - * @throws { BusinessError } 2305009 - Certificate is not yet valid. - * @throws { BusinessError } 2305010 - Certificate has expired. - * @throws { BusinessError } 2305011 - CRL is not yet valid. - * @throws { BusinessError } 2305012 - CRL has expired. - * @throws { BusinessError } 2305018 - Self-signed certificate. - * @throws { BusinessError } 2305023 - Certificate has been revoked. - * @throws { BusinessError } 2305024 - Invalid certificate authority (CA). - * @throws { BusinessError } 2305027 - Certificate is untrusted. - * @throws { BusinessError } 2305069 - Invalid certificate verification context. - * @syscap SystemCapability.Communication.NetStack - * @since 12 - */ - export function certVerification(cert: CertBlob, caCert?: CertBlob): Promise; - - /** - * Certificate verification to the server. - * @param { CertBlob } cert - Certificates to be verified. - * @param { CertBlob } [caCert] - Incoming custom CA cert. - * @returns { number } Returns 0 if verify of certification from server succeed, else verify failed. - * @throws { BusinessError } 401 - Parameter error. - * @throws { BusinessError } 2305001 - Unspecified error. - * @throws { BusinessError } 2305002 - Unable to get issuer certificate. - * @throws { BusinessError } 2305003 - Unable to get certificate revocation list (CRL). - * @throws { BusinessError } 2305004 - Unable to decrypt certificate signature. - * @throws { BusinessError } 2305005 - Unable to decrypt CRL signature. - * @throws { BusinessError } 2305006 - Unable to decode issuer public key. - * @throws { BusinessError } 2305007 - Certificate signature failure. - * @throws { BusinessError } 2305008 - CRL signature failure. - * @throws { BusinessError } 2305009 - Certificate is not yet valid. - * @throws { BusinessError } 2305010 - Certificate has expired. - * @throws { BusinessError } 2305011 - CRL is not yet valid. - * @throws { BusinessError } 2305012 - CRL has expired. - * @throws { BusinessError } 2305023 - Certificate has been revoked. - * @throws { BusinessError } 2305024 - Invalid certificate authority (CA). - * @throws { BusinessError } 2305027 - Certificate is untrusted. - * @syscap SystemCapability.Communication.NetStack - * @since 11 - */ - /** - * Certificate verification to the server. - * @param { CertBlob } cert - Certificates to be verified. - * @param { CertBlob } [caCert] - Incoming custom CA cert. - * @returns { number } Returns 0 if verify of certification from server succeed, else verify failed. - * @throws { BusinessError } 401 - Parameter error. - * @throws { BusinessError } 2305001 - Unspecified error. - * @throws { BusinessError } 2305002 - Unable to get issuer certificate. - * @throws { BusinessError } 2305003 - Unable to get certificate revocation list (CRL). - * @throws { BusinessError } 2305004 - Unable to decrypt certificate signature. - * @throws { BusinessError } 2305005 - Unable to decrypt CRL signature. - * @throws { BusinessError } 2305006 - Unable to decode issuer public key. - * @throws { BusinessError } 2305007 - Certificate signature failure. - * @throws { BusinessError } 2305008 - CRL signature failure. - * @throws { BusinessError } 2305009 - Certificate is not yet valid. - * @throws { BusinessError } 2305010 - Certificate has expired. - * @throws { BusinessError } 2305011 - CRL is not yet valid. - * @throws { BusinessError } 2305012 - CRL has expired. - * @throws { BusinessError } 2305018 - Self-signed certificate. - * @throws { BusinessError } 2305023 - Certificate has been revoked. - * @throws { BusinessError } 2305024 - Invalid certificate authority (CA). - * @throws { BusinessError } 2305027 - Certificate is untrusted. - * @throws { BusinessError } 2305069 - Invalid certificate verification context. - * @syscap SystemCapability.Communication.NetStack - * @since 12 - */ - export function certVerificationSync(cert: CertBlob, caCert?: CertBlob): number; - - /** - * Checks whether the Cleartext traffic is permitted. - * To invoke this method, you must have the {@code ohos.permission.INTERNET} permission. - * @permission ohos.permission.INTERNET - * @returns { boolean } Returns true if the Cleartext traffic is permitted, else returns false. - * @throws { BusinessError } 201 - Permission denied. - * @syscap SystemCapability.Communication.NetStack - * @since 18 - */ - export function isCleartextPermitted(): boolean; - - /** - * Checks whether the Cleartext traffic for a specified hostname is permitted. - * To invoke this method, you must have the {@code ohos.permission.INTERNET} permission. - * @permission ohos.permission.INTERNET - * @param { string } hostName - Indicates the host name. - * @returns { boolean } Returns true if the Cleartext traffic is permitted, else returns false. - * @throws { BusinessError } 201 - Permission denied. - * @syscap SystemCapability.Communication.NetStack - * @since 18 - */ - export function isCleartextPermittedByHostName(hostName: string): boolean; -} - -export default networkSecurity; +/* + * Copyright (c) 2023 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. + */ + +/** + * @file + * @kit NetworkKit + */ + +import type { AsyncCallback } from './@ohos.base'; + +/** + * Provides networkSecurity related APIs. + * @namespace networkSecurity + * @syscap SystemCapability.Communication.NetStack + * @since 11 + */ +declare namespace networkSecurity { + /** + * Defines the certificate type. + * @enum {int} + * @syscap SystemCapability.Communication.NetStack + * @since arkts{ '1.1':'11','1.2':'20'} + * @arkts 1.1&1.2 + */ + export enum CertType { + /** + * PEM type certificate. + * @syscap SystemCapability.Communication.NetStack + * @since 11 + */ + CERT_TYPE_PEM = 0, + + /** + * DER type certificate. + * @syscap SystemCapability.Communication.NetStack + * @since 11 + */ + CERT_TYPE_DER = 1 + } + + /** + * Define the certificate content. + * @interface CertBlob + * @syscap SystemCapability.Communication.NetStack + * @since 11 + */ + export interface CertBlob { + /** + * Certificate type. + * @type { CertType } + * @syscap SystemCapability.Communication.NetStack + * @since 11 + */ + type: CertType; + + /** + * Certificate data. + * @type {string | ArrayBuffer} + * @syscap SystemCapability.Communication.NetStack + * @since 11 + */ + data: string | ArrayBuffer; + } + + /** + * Certificate verification to the server. + * @param { CertBlob } cert - Certificates to be verified. + * @param { CertBlob } [caCert] - Incoming custom CA cert. + * @returns { Promise } The promise returned by the function. + * Number equals 0 if verify of certification from server succeed, else verify failed. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 2305001 - Unspecified error. + * @throws { BusinessError } 2305002 - Unable to get issuer certificate. + * @throws { BusinessError } 2305003 - Unable to get certificate revocation list (CRL). + * @throws { BusinessError } 2305004 - Unable to decrypt certificate signature. + * @throws { BusinessError } 2305005 - Unable to decrypt CRL signature. + * @throws { BusinessError } 2305006 - Unable to decode issuer public key. + * @throws { BusinessError } 2305007 - Certificate signature failure. + * @throws { BusinessError } 2305008 - CRL signature failure. + * @throws { BusinessError } 2305009 - Certificate is not yet valid. + * @throws { BusinessError } 2305010 - Certificate has expired. + * @throws { BusinessError } 2305011 - CRL is not yet valid. + * @throws { BusinessError } 2305012 - CRL has expired. + * @throws { BusinessError } 2305023 - Certificate has been revoked. + * @throws { BusinessError } 2305024 - Invalid certificate authority (CA). + * @throws { BusinessError } 2305027 - Certificate is untrusted. + * @syscap SystemCapability.Communication.NetStack + * @since 11 + */ + /** + * Certificate verification to the server. + * @param { CertBlob } cert - Certificates to be verified. + * @param { CertBlob } [caCert] - Incoming custom CA cert. + * @returns { Promise } The promise returned by the function. + * Number equals 0 if verify of certification from server succeed, else verify failed. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 2305001 - Unspecified error. + * @throws { BusinessError } 2305002 - Unable to get issuer certificate. + * @throws { BusinessError } 2305003 - Unable to get certificate revocation list (CRL). + * @throws { BusinessError } 2305004 - Unable to decrypt certificate signature. + * @throws { BusinessError } 2305005 - Unable to decrypt CRL signature. + * @throws { BusinessError } 2305006 - Unable to decode issuer public key. + * @throws { BusinessError } 2305007 - Certificate signature failure. + * @throws { BusinessError } 2305008 - CRL signature failure. + * @throws { BusinessError } 2305009 - Certificate is not yet valid. + * @throws { BusinessError } 2305010 - Certificate has expired. + * @throws { BusinessError } 2305011 - CRL is not yet valid. + * @throws { BusinessError } 2305012 - CRL has expired. + * @throws { BusinessError } 2305018 - Self-signed certificate. + * @throws { BusinessError } 2305023 - Certificate has been revoked. + * @throws { BusinessError } 2305024 - Invalid certificate authority (CA). + * @throws { BusinessError } 2305027 - Certificate is untrusted. + * @throws { BusinessError } 2305069 - Invalid certificate verification context. + * @syscap SystemCapability.Communication.NetStack + * @since arkts{ '1.1':'12','1.2':'20'} + * @arkts 1.1&1.2 + */ + export function certVerification(cert: CertBlob, caCert?: CertBlob): Promise; + + /** + * Certificate verification to the server. + * @param { CertBlob } cert - Certificates to be verified. + * @param { CertBlob } [caCert] - Incoming custom CA cert. + * @returns { int } Returns 0 if verify of certification from server succeed, else verify failed. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 2305001 - Unspecified error. + * @throws { BusinessError } 2305002 - Unable to get issuer certificate. + * @throws { BusinessError } 2305003 - Unable to get certificate revocation list (CRL). + * @throws { BusinessError } 2305004 - Unable to decrypt certificate signature. + * @throws { BusinessError } 2305005 - Unable to decrypt CRL signature. + * @throws { BusinessError } 2305006 - Unable to decode issuer public key. + * @throws { BusinessError } 2305007 - Certificate signature failure. + * @throws { BusinessError } 2305008 - CRL signature failure. + * @throws { BusinessError } 2305009 - Certificate is not yet valid. + * @throws { BusinessError } 2305010 - Certificate has expired. + * @throws { BusinessError } 2305011 - CRL is not yet valid. + * @throws { BusinessError } 2305012 - CRL has expired. + * @throws { BusinessError } 2305023 - Certificate has been revoked. + * @throws { BusinessError } 2305024 - Invalid certificate authority (CA). + * @throws { BusinessError } 2305027 - Certificate is untrusted. + * @syscap SystemCapability.Communication.NetStack + * @since 11 + */ + /** + * Certificate verification to the server. + * @param { CertBlob } cert - Certificates to be verified. + * @param { CertBlob } [caCert] - Incoming custom CA cert. + * @returns { int } Returns 0 if verify of certification from server succeed, else verify failed. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 2305001 - Unspecified error. + * @throws { BusinessError } 2305002 - Unable to get issuer certificate. + * @throws { BusinessError } 2305003 - Unable to get certificate revocation list (CRL). + * @throws { BusinessError } 2305004 - Unable to decrypt certificate signature. + * @throws { BusinessError } 2305005 - Unable to decrypt CRL signature. + * @throws { BusinessError } 2305006 - Unable to decode issuer public key. + * @throws { BusinessError } 2305007 - Certificate signature failure. + * @throws { BusinessError } 2305008 - CRL signature failure. + * @throws { BusinessError } 2305009 - Certificate is not yet valid. + * @throws { BusinessError } 2305010 - Certificate has expired. + * @throws { BusinessError } 2305011 - CRL is not yet valid. + * @throws { BusinessError } 2305012 - CRL has expired. + * @throws { BusinessError } 2305018 - Self-signed certificate. + * @throws { BusinessError } 2305023 - Certificate has been revoked. + * @throws { BusinessError } 2305024 - Invalid certificate authority (CA). + * @throws { BusinessError } 2305027 - Certificate is untrusted. + * @throws { BusinessError } 2305069 - Invalid certificate verification context. + * @syscap SystemCapability.Communication.NetStack + * @since arkts{ '1.1':'12','1.2':'20'} + * @arkts 1.1&1.2 + */ + export function certVerificationSync(cert: CertBlob, caCert?: CertBlob): int; + + /** + * Checks whether the Cleartext traffic is permitted. + * To invoke this method, you must have the {@code ohos.permission.INTERNET} permission. + * @permission ohos.permission.INTERNET + * @returns { boolean } Returns true if the Cleartext traffic is permitted, else returns false. + * @throws { BusinessError } 201 - Permission denied. + * @syscap SystemCapability.Communication.NetStack + * @since 18 + */ + export function isCleartextPermitted(): boolean; + + /** + * Checks whether the Cleartext traffic for a specified hostname is permitted. + * To invoke this method, you must have the {@code ohos.permission.INTERNET} permission. + * @permission ohos.permission.INTERNET + * @param { string } hostName - Indicates the host name. + * @returns { boolean } Returns true if the Cleartext traffic is permitted, else returns false. + * @throws { BusinessError } 201 - Permission denied. + * @syscap SystemCapability.Communication.NetStack + * @since 18 + */ + export function isCleartextPermittedByHostName(hostName: string): boolean; +} + +export default networkSecurity; \ No newline at end of file diff --git a/api/@ohos.net.sharing.d.ts b/api/@ohos.net.sharing.d.ts index 74d63c28ce5aa652266de6869ce61cc250b35e19..82b06351e56dfd48d07b50cf33d0e459cacbc04f 100644 --- a/api/@ohos.net.sharing.d.ts +++ b/api/@ohos.net.sharing.d.ts @@ -49,7 +49,7 @@ declare namespace sharing { * @syscap SystemCapability.Communication.NetManager.NetSharing * @systemapi Hide this for inner system use. * @since 9 - */ + */ function isSharingSupported(callback: AsyncCallback): void; /** @@ -93,7 +93,7 @@ declare namespace sharing { * @throws { BusinessError } 2200003 - System internal error. * @throws { BusinessError } 2202011 - Cannot get network sharing configuration. * @syscap SystemCapability.Communication.NetManager.NetSharing - * @systemapi Hide this for inner system use. + * @systemapi Hide this for inner system use. * @since 9 */ function isSharing(): Promise; @@ -187,7 +187,7 @@ declare namespace sharing { /** * Obtains the number of downlink data bytes of the sharing network interfaces. * @permission ohos.permission.CONNECTIVITY_INTERNAL - * @param { AsyncCallback } callback - Returns the number of downlink data bytes of the sharing network interfaces. + * @param { AsyncCallback } callback - Returns the number of downlink data bytes of the sharing network interfaces. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 202 - Non-system applications use system APIs. * @throws { BusinessError } 401 - Parameter error. @@ -195,14 +195,15 @@ declare namespace sharing { * @throws { BusinessError } 2200003 - System internal error. * @syscap SystemCapability.Communication.NetManager.NetSharing * @systemapi Hide this for inner system use. - * @since 9 + * @since arkts{ '1.1':'9','1.2':'20'} + * @arkts 1.1&1.2 */ - function getStatsRxBytes(callback: AsyncCallback): void; + function getStatsRxBytes(callback: AsyncCallback): void; /** * Obtains the number of downlink data bytes of the sharing network interfaces. * @permission ohos.permission.CONNECTIVITY_INTERNAL - * @returns { Promise } The promise returned by the function. + * @returns { Promise } The promise returned by the function. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 202 - Non-system applications use system APIs. * @throws { BusinessError } 401 - Parameter error. @@ -210,14 +211,15 @@ declare namespace sharing { * @throws { BusinessError } 2200003 - System internal error. * @syscap SystemCapability.Communication.NetManager.NetSharing * @systemapi Hide this for inner system use. - * @since 9 + * @since arkts{ '1.1':'9','1.2':'20'} + * @arkts 1.1&1.2 */ - function getStatsRxBytes(): Promise; + function getStatsRxBytes(): Promise; /** * Obtains the number of uplink data bytes of the sharing network interfaces. * @permission ohos.permission.CONNECTIVITY_INTERNAL - * @param { AsyncCallback } callback - Returns the number of uplink data bytes of the sharing network interfaces. + * @param { AsyncCallback } callback - Returns the number of uplink data bytes of the sharing network interfaces. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 202 - Non-system applications use system APIs. * @throws { BusinessError } 401 - Parameter error. @@ -225,14 +227,15 @@ declare namespace sharing { * @throws { BusinessError } 2200003 - System internal error. * @syscap SystemCapability.Communication.NetManager.NetSharing * @systemapi Hide this for inner system use. - * @since 9 + * @since arkts{ '1.1':'9','1.2':'20'} + * @arkts 1.1&1.2 */ - function getStatsTxBytes(callback: AsyncCallback): void; + function getStatsTxBytes(callback: AsyncCallback): void; /** * Obtains the number of uplink data bytes of the sharing network interfaces. * @permission ohos.permission.CONNECTIVITY_INTERNAL - * @returns { Promise } The promise returned by the function. + * @returns { Promise } The promise returned by the function. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 202 - Non-system applications use system APIs. * @throws { BusinessError } 401 - Parameter error. @@ -240,14 +243,15 @@ declare namespace sharing { * @throws { BusinessError } 2200003 - System internal error. * @syscap SystemCapability.Communication.NetManager.NetSharing * @systemapi Hide this for inner system use. - * @since 9 + * @since arkts{ '1.1':'9','1.2':'20'} + * @arkts 1.1&1.2 */ - function getStatsTxBytes(): Promise; + function getStatsTxBytes(): Promise; /** * Obtains the number of total data bytes of the sharing network interfaces. * @permission ohos.permission.CONNECTIVITY_INTERNAL - * @param { AsyncCallback } callback - Returns the number of total data bytes of the sharing network interfaces. + * @param { AsyncCallback } callback - Returns the number of total data bytes of the sharing network interfaces. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 202 - Non-system applications use system APIs. * @throws { BusinessError } 401 - Parameter error. @@ -255,14 +259,15 @@ declare namespace sharing { * @throws { BusinessError } 2200003 - System internal error. * @syscap SystemCapability.Communication.NetManager.NetSharing * @systemapi Hide this for inner system use. - * @since 9 + * @since arkts{ '1.1':'9','1.2':'20'} + * @arkts 1.1&1.2 */ - function getStatsTotalBytes(callback: AsyncCallback): void; + function getStatsTotalBytes(callback: AsyncCallback): void; /** * Obtains the number of total data bytes of the sharing network interfaces. * @permission ohos.permission.CONNECTIVITY_INTERNAL - * @returns { Promise } The promise returned by the function. + * @returns { Promise } The promise returned by the function. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 202 - Non-system applications use system APIs. * @throws { BusinessError } 401 - Parameter error. @@ -270,9 +275,10 @@ declare namespace sharing { * @throws { BusinessError } 2200003 - System internal error. * @syscap SystemCapability.Communication.NetManager.NetSharing * @systemapi Hide this for inner system use. - * @since 9 + * @since arkts{ '1.1':'9','1.2':'20'} + * @arkts 1.1&1.2 */ - function getStatsTotalBytes(): Promise; + function getStatsTotalBytes(): Promise; /** * Obtains the names of interfaces in each sharing state. @@ -363,7 +369,7 @@ declare namespace sharing { * Get a list regular expression that defines any interface that can support network sharing. * @permission ohos.permission.CONNECTIVITY_INTERNAL * @param { SharingIfaceType } type - Is the enumeration of shareable interface types. - * @returns { Promise> } The promise returned by the function. + * @returns { Promise> } The promise returned by the function. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 202 - Non-system applications use system APIs. * @throws { BusinessError } 401 - Parameter error. @@ -486,10 +492,11 @@ declare namespace sharing { /** * Enumerates the network sharing states of an NIC. - * @enum {number} + * @enum {int} * @syscap SystemCapability.Communication.NetManager.NetSharing * @systemapi Hide this for inner system use. - * @since 9 + * @since arkts{ '1.1':'9','1.2':'20'} + * @arkts 1.1&1.2 */ export enum SharingIfaceState { /** @@ -553,10 +560,11 @@ declare namespace sharing { /** * Enumerates the network sharing types of an NIC. - * @enum {number} + * @enum {int} * @syscap SystemCapability.Communication.NetManager.NetSharing * @systemapi Hide this for inner system use. - * @since 9 + * @since arkts{ '1.1':'9','1.2':'20'} + * @arkts 1.1&1.2 */ export enum SharingIfaceType { /** @@ -585,4 +593,4 @@ declare namespace sharing { } } -export default sharing; +export default sharing; \ No newline at end of file diff --git a/api/@ohos.net.statistics.d.ts b/api/@ohos.net.statistics.d.ts index 1d0e9ec3862e4384641bf750e2e7598c9aca0cfd..2ef7d66745d1e07a42300f98fbac5e9bf1b5bed7 100644 --- a/api/@ohos.net.statistics.d.ts +++ b/api/@ohos.net.statistics.d.ts @@ -45,7 +45,7 @@ declare namespace statistics { /** * Queries the data traffic (including all TCP and UDP data packets) received through a specified NIC. * @param { string } nic - Network interface card. - * @param { AsyncCallback } callback - Returns the data traffic received through the specified NIC. + * @param { AsyncCallback } callback - Returns the data traffic received through the specified NIC. * @throws { BusinessError } 401 - Parameter error. * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. @@ -53,14 +53,15 @@ declare namespace statistics { * @throws { BusinessError } 2103011 - Failed to create a system map. * @throws { BusinessError } 2103012 - Failed to obtain the NIC name. * @syscap SystemCapability.Communication.NetManager.Core - * @since 10 + * @since arkts{ '1.1':'10','1.2':'20'} + * @arkts 1.1&1.2 */ - function getIfaceRxBytes(nic: string, callback: AsyncCallback): void; + function getIfaceRxBytes(nic: string, callback: AsyncCallback): void; /** * Queries the data traffic (including all TCP and UDP data packets) received through a specified NIC. * @param { string } nic - Network interface card. - * @returns { Promise } The promise returned by the function. + * @returns { Promise } The promise returned by the function. * @throws { BusinessError } 401 - Parameter error. * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. @@ -68,14 +69,15 @@ declare namespace statistics { * @throws { BusinessError } 2103011 - Failed to create a system map. * @throws { BusinessError } 2103012 - Failed to obtain the NIC name. * @syscap SystemCapability.Communication.NetManager.Core - * @since 10 + * @since arkts{ '1.1':'10','1.2':'20'} + * @arkts 1.1&1.2 */ - function getIfaceRxBytes(nic: string): Promise; + function getIfaceRxBytes(nic: string): Promise; /** * Queries the data traffic (including all TCP and UDP data packets) sent through a specified NIC. * @param { string } nic - Network interface card. - * @param { AsyncCallback } callback - Returns the data traffic sent through the specified NIC. + * @param { AsyncCallback } callback - Returns the data traffic sent through the specified NIC. * @throws { BusinessError } 401 - Parameter error. * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. @@ -83,14 +85,15 @@ declare namespace statistics { * @throws { BusinessError } 2103011 - Failed to create a system map. * @throws { BusinessError } 2103012 - Failed to obtain the NIC name. * @syscap SystemCapability.Communication.NetManager.Core - * @since 10 + * @since arkts{ '1.1':'10','1.2':'20'} + * @arkts 1.1&1.2 */ - function getIfaceTxBytes(nic: string, callback: AsyncCallback): void; + function getIfaceTxBytes(nic: string, callback: AsyncCallback): void; /** * Queries the data traffic (including all TCP and UDP data packets) sent through a specified NIC. * @param { string } nic - Network interface card. - * @returns { Promise } The promise returned by the function. + * @returns { Promise } The promise returned by the function. * @throws { BusinessError } 401 - Parameter error. * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. @@ -98,65 +101,70 @@ declare namespace statistics { * @throws { BusinessError } 2103011 - Failed to create a system map. * @throws { BusinessError } 2103012 - Failed to obtain the NIC name. * @syscap SystemCapability.Communication.NetManager.Core - * @since 10 + * @since arkts{ '1.1':'10','1.2':'20'} + * @arkts 1.1&1.2 */ - function getIfaceTxBytes(nic: string): Promise; + function getIfaceTxBytes(nic: string): Promise; /** * Queries the data traffic (including all TCP and UDP data packets) received through the cellular network. - * @param { AsyncCallback } callback - Returns the data traffic received through the cellular network. + * @param { AsyncCallback } callback - Returns the data traffic received through the cellular network. * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @throws { BusinessError } 2103005 - Failed to read the system map. * @throws { BusinessError } 2103011 - Failed to create a system map. * @throws { BusinessError } 2103012 - Failed to obtain the NIC name. * @syscap SystemCapability.Communication.NetManager.Core - * @since 10 + * @since arkts{ '1.1':'10','1.2':'20'} + * @arkts 1.1&1.2 */ - function getCellularRxBytes(callback: AsyncCallback): void; + function getCellularRxBytes(callback: AsyncCallback): void; /** * Queries the data traffic (including all TCP and UDP data packets) received through the cellular network. - * @returns { Promise } The promise returned by the function. + * @returns { Promise } The promise returned by the function. * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @throws { BusinessError } 2103005 - Failed to read the system map. * @throws { BusinessError } 2103011 - Failed to create a system map. * @throws { BusinessError } 2103012 - Failed to obtain the NIC name. * @syscap SystemCapability.Communication.NetManager.Core - * @since 10 + * @since arkts{ '1.1':'10','1.2':'20'} + * @arkts 1.1&1.2 */ - function getCellularRxBytes(): Promise; + function getCellularRxBytes(): Promise; /** * Queries the data traffic (including all TCP and UDP data packets) sent through the cellular network. - * @param { AsyncCallback } callback - Returns the data traffic sent through the cellular network. + * @param { AsyncCallback } callback - Returns the data traffic sent through the cellular network. * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @throws { BusinessError } 2103005 - Failed to read the system map. * @throws { BusinessError } 2103011 - Failed to create a system map. * @throws { BusinessError } 2103012 - Failed to obtain the NIC name. * @syscap SystemCapability.Communication.NetManager.Core - * @since 10 + * @since arkts{ '1.1':'10','1.2':'20'} + * @arkts 1.1&1.2 */ - function getCellularTxBytes(callback: AsyncCallback): void; + function getCellularTxBytes(callback: AsyncCallback): void; /** * Queries the data traffic (including all TCP and UDP data packets) sent through the cellular network. - * @returns { Promise } The promise returned by the function. + * @returns { Promise } The promise returned by the function. * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @throws { BusinessError } 2103005 - Failed to read the system map. * @throws { BusinessError } 2103011 - Failed to create a system map. * @throws { BusinessError } 2103012 - Failed to obtain the NIC name. * @syscap SystemCapability.Communication.NetManager.Core - * @since 10 + * @since arkts{ '1.1':'10','1.2':'20'} + * @arkts 1.1&1.2 */ - function getCellularTxBytes(): Promise; + function getCellularTxBytes(): Promise; /** * Queries the data traffic (including all TCP and UDP data packets) received through all NICs. - * @param { AsyncCallback } callback - Returns the data traffic received through all NICs. + * @param { AsyncCallback } callback - Returns the data traffic received through all NICs. * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @throws { BusinessError } 2103005 - Failed to read the system map. @@ -166,20 +174,21 @@ declare namespace statistics { */ /** * Queries the data traffic (including all TCP and UDP data packets) received through all NICs. - * @param { AsyncCallback } callback - Returns the data traffic received through all NICs. + * @param { AsyncCallback } callback - Returns the data traffic received through all NICs. * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @throws { BusinessError } 2103005 - Failed to read the system map. * @throws { BusinessError } 2103011 - Failed to create a system map. * @syscap SystemCapability.Communication.NetManager.Core * @atomicservice - * @since 15 + * @since arkts{ '1.1':'15','1.2':'20'} + * @arkts 1.1&1.2 */ - function getAllRxBytes(callback: AsyncCallback): void; + function getAllRxBytes(callback: AsyncCallback): void; /** * Queries the data traffic (including all TCP and UDP data packets) received through all NICs. - * @returns { Promise } The promise returned by the function. + * @returns { Promise } The promise returned by the function. * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @throws { BusinessError } 2103005 - Failed to read the system map. @@ -189,20 +198,21 @@ declare namespace statistics { */ /** * Queries the data traffic (including all TCP and UDP data packets) received through all NICs. - * @returns { Promise } The promise returned by the function. + * @returns { Promise } The promise returned by the function. * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @throws { BusinessError } 2103005 - Failed to read the system map. * @throws { BusinessError } 2103011 - Failed to create a system map. * @syscap SystemCapability.Communication.NetManager.Core * @atomicservice - * @since 15 + * @since arkts{ '1.1':'15','1.2':'20'} + * @arkts 1.1&1.2 */ - function getAllRxBytes(): Promise; + function getAllRxBytes(): Promise; /** * Queries the data traffic (including all TCP and UDP data packets) sent through all NICs. - * @param { AsyncCallback } callback - Returns the data traffic sent through all NICs. + * @param { AsyncCallback } callback - Returns the data traffic sent through all NICs. * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @throws { BusinessError } 2103005 - Failed to read the system map. @@ -212,20 +222,21 @@ declare namespace statistics { */ /** * Queries the data traffic (including all TCP and UDP data packets) sent through all NICs. - * @param { AsyncCallback } callback - Returns the data traffic sent through all NICs. + * @param { AsyncCallback } callback - Returns the data traffic sent through all NICs. * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @throws { BusinessError } 2103005 - Failed to read the system map. * @throws { BusinessError } 2103011 - Failed to create a system map. * @syscap SystemCapability.Communication.NetManager.Core * @atomicservice - * @since 15 + * @since arkts{ '1.1':'15','1.2':'20'} + * @arkts 1.1&1.2 */ - function getAllTxBytes(callback: AsyncCallback): void; + function getAllTxBytes(callback: AsyncCallback): void; /** * Queries the data traffic (including all TCP and UDP data packets) sent through all NICs. - * @returns { Promise } The promise returned by the function. + * @returns { Promise } The promise returned by the function. * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @throws { BusinessError } 2103005 - Failed to read the system map. @@ -235,78 +246,83 @@ declare namespace statistics { */ /** * Queries the data traffic (including all TCP and UDP data packets) sent through all NICs. - * @returns { Promise } The promise returned by the function. + * @returns { Promise } The promise returned by the function. * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @throws { BusinessError } 2103005 - Failed to read the system map. * @throws { BusinessError } 2103011 - Failed to create a system map. * @syscap SystemCapability.Communication.NetManager.Core * @atomicservice - * @since 15 + * @since arkts{ '1.1':'15','1.2':'20'} + * @arkts 1.1&1.2 */ - function getAllTxBytes(): Promise; + function getAllTxBytes(): Promise; /** * Queries the data traffic (including all TCP and UDP data packets) received by a specified application. - * @param { number } uid - Indicates the process ID of the application. - * @param { AsyncCallback } callback - Returns the data traffic received by the specified application. + * @param { int } uid - Indicates the process ID of the application. + * @param { AsyncCallback } callback - Returns the data traffic received by the specified application. * @throws { BusinessError } 401 - Parameter error. * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @throws { BusinessError } 2103005 - Failed to read the system map. * @throws { BusinessError } 2103011 - Failed to create a system map. * @syscap SystemCapability.Communication.NetManager.Core - * @since 10 + * @since arkts{ '1.1':'10','1.2':'20'} + * @arkts 1.1&1.2 */ - function getUidRxBytes(uid: number, callback: AsyncCallback): void; + function getUidRxBytes(uid: int, callback: AsyncCallback): void; /** * Queries the data traffic (including all TCP and UDP data packets) received by a specified application. - * @param { number } uid - Indicates the process ID of the application. - * @returns { Promise } The promise returned by the function. + * @param { int } uid - Indicates the process ID of the application. + * @returns { Promise } The promise returned by the function. * @throws { BusinessError } 401 - Parameter error. * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @throws { BusinessError } 2103005 - Failed to read the system map. * @throws { BusinessError } 2103011 - Failed to create a system map. * @syscap SystemCapability.Communication.NetManager.Core - * @since 10 + * @since arkts{ '1.1':'10','1.2':'20'} + * @arkts 1.1&1.2 */ - function getUidRxBytes(uid: number): Promise; + function getUidRxBytes(uid: int): Promise; /** * Queries the data traffic (including all TCP and UDP data packets) sent by a specified application. - * @param { number } uid - Indicates the process ID of the application. - * @param { AsyncCallback } callback - Returns the data traffic sent by the specified application. + * @param { int } uid - Indicates the process ID of the application. + * @param { AsyncCallback } callback - Returns the data traffic sent by the specified application. * @throws { BusinessError } 401 - Parameter error. * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @throws { BusinessError } 2103005 - Failed to read the system map. * @throws { BusinessError } 2103011 - Failed to create a system map. * @syscap SystemCapability.Communication.NetManager.Core - * @since 10 + * @since arkts{ '1.1':'10','1.2':'20'} + * @arkts 1.1&1.2 */ - function getUidTxBytes(uid: number, callback: AsyncCallback): void; - + function getUidTxBytes(uid: int, callback: AsyncCallback): void; + /** * Queries the data traffic (including all TCP and UDP data packets) sent by a specified application. - * @param { number } uid - Indicates the process ID of the application. - * @returns { Promise } The promise returned by the function. + * @param { int } uid - Indicates the process ID of the application. + * @returns { Promise } The promise returned by the function. * @throws { BusinessError } 401 - Parameter error. * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @throws { BusinessError } 2103005 - Failed to read the system map. * @throws { BusinessError } 2103011 - Failed to create a system map. * @syscap SystemCapability.Communication.NetManager.Core - * @since 10 + * @since arkts{ '1.1':'10','1.2':'20'} + * @arkts 1.1&1.2 */ - function getUidTxBytes(uid: number): Promise; + function getUidTxBytes(uid: int): Promise; /** * Register notifications of network traffic updates. * @permission ohos.permission.GET_NETWORK_STATS * @param { 'netStatsChange' } type - Indicates Event name. - * @param { Callback<{ iface: string, uid?: number }> } callback - The callback of on. + * @param { Callback<{ iface: string, uid?: int }> } callback - The callback of on. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 202 - Non-system applications use system APIs. * @throws { BusinessError } 401 - Parameter error. @@ -328,7 +344,8 @@ declare namespace statistics { * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core * @systemapi Hide this for inner system use. - * @since 11 + * @since arkts{ '1.1':'11','1.2':'20'} + * @arkts 1.1&1.2 */ function on(type: 'netStatsChange', callback: Callback): void; @@ -336,7 +353,7 @@ declare namespace statistics { * Unregister notifications of network traffic updates. * @permission ohos.permission.GET_NETWORK_STATS * @param { 'netStatsChange' } type - Indicates Event name. - * @param { Callback<{ iface: string, uid?: number }> } callback - The callback of off. + * @param { Callback<{ iface: string, uid?: int }> } callback - The callback of off. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 202 - Non-system applications use system APIs. * @throws { BusinessError } 401 - Parameter error. @@ -358,7 +375,8 @@ declare namespace statistics { * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core * @systemapi Hide this for inner system use. - * @since 11 + * @since arkts{ '1.1':'11','1.2':'20'} + * @arkts 1.1&1.2 */ function off(type: 'netStatsChange', callback?: Callback): void; @@ -379,7 +397,7 @@ declare namespace statistics { * @since 10 */ function getTrafficStatsByIface(ifaceInfo: IfaceInfo, callback: AsyncCallback): void; - + /** * Get the traffic usage details of the network interface in the specified time period. * @permission ohos.permission.GET_NETWORK_STATS @@ -415,7 +433,7 @@ declare namespace statistics { * @since 10 */ function getTrafficStatsByUid(uidInfo: UidInfo, callback: AsyncCallback): void; - + /** * Get the traffic usage details of the specified time period of the application. * @permission ohos.permission.GET_NETWORK_STATS @@ -436,55 +454,59 @@ declare namespace statistics { /** * Queries the data traffic (including all TCP and UDP data packets) received through a specified sockfd. - * @param { number } sockfd - Indicates the file descriptor of the given socket. - * @param { AsyncCallback } callback - Returns the data traffic bytes received by the specified sockfd. + * @param { int } sockfd - Indicates the file descriptor of the given socket. + * @param { AsyncCallback } callback - Returns the data traffic bytes received by the specified sockfd. * @throws { BusinessError } 401 - Parameter error. * @throws { BusinessError } 2100001 - Invalid parameter value. * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core - * @since 11 + * @since arkts{ '1.1':'11','1.2':'20'} + * @arkts 1.1&1.2 */ - function getSockfdRxBytes(sockfd: number, callback: AsyncCallback): void; + function getSockfdRxBytes(sockfd: int, callback: AsyncCallback): void; /** * Queries the data traffic (including all TCP and UDP data packets) received through a specified sockfd. - * @param { number } sockfd - Indicates the file descriptor of the given socket. - * @returns { Promise } Returns the data traffic bytes received by the specified sockfd. + * @param { int } sockfd - Indicates the file descriptor of the given socket. + * @returns { Promise } Returns the data traffic bytes received by the specified sockfd. * @throws { BusinessError } 401 - Parameter error. * @throws { BusinessError } 2100001 - Invalid parameter value. * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core - * @since 11 + * @since arkts{ '1.1':'11','1.2':'20'} + * @arkts 1.1&1.2 */ - function getSockfdRxBytes(sockfd: number): Promise; + function getSockfdRxBytes(sockfd: int): Promise; /** * Queries the data traffic (including all TCP and UDP data packets) sent through a specified sockfd. - * @param { number } sockfd - Indicates the file descriptor of the given socket. - * @param { AsyncCallback } callback - Returns the data traffic bytes sent by the specified sockfd. + * @param { int } sockfd - Indicates the file descriptor of the given socket. + * @param { AsyncCallback } callback - Returns the data traffic bytes sent by the specified sockfd. * @throws { BusinessError } 401 - Parameter error. * @throws { BusinessError } 2100001 - Invalid parameter value * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core - * @since 11 + * @since arkts{ '1.1':'11','1.2':'20'} + * @arkts 1.1&1.2 */ - function getSockfdTxBytes(sockfd: number, callback: AsyncCallback): void; + function getSockfdTxBytes(sockfd: int, callback: AsyncCallback): void; /** * Queries the data traffic (including all TCP and UDP data packets) sent through a specified sockfd. - * @param { number } sockfd - Indicates the file descriptor of the given socket. - * @returns { Promise } Returns the data traffic bytes sent by the specified sockfd. + * @param { int } sockfd - Indicates the file descriptor of the given socket. + * @returns { Promise } Returns the data traffic bytes sent by the specified sockfd. * @throws { BusinessError } 401 - Parameter error. * @throws { BusinessError } 2100001 - Invalid parameter value * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core - * @since 11 + * @since arkts{ '1.1':'11','1.2':'20'} + * @arkts 1.1&1.2 */ - function getSockfdTxBytes(sockfd: number): Promise; + function getSockfdTxBytes(sockfd: int): Promise; /** * Parameters for obtaining detailed information on network interface traffic usage. @@ -505,21 +527,23 @@ declare namespace statistics { /** * Start time for querying traffic. - * @type {number} + * @type {int} * @syscap SystemCapability.Communication.NetManager.Core * @systemapi Hide this for inner system use. - * @since 10 + * @since arkts{ '1.1':'10','1.2':'20'} + * @arkts 1.1&1.2 */ - startTime: number; + startTime: int; /** * End time for querying traffic. - * @type {number} + * @type {int} * @syscap SystemCapability.Communication.NetManager.Core * @systemapi Hide this for inner system use. - * @since 10 + * @since arkts{ '1.1':'10','1.2':'20'} + * @arkts 1.1&1.2 */ - endTime: number; + endTime: int; } /** @@ -541,12 +565,13 @@ declare namespace statistics { /** * Uid of app for querying traffic. - * @type {number} + * @type {int} * @syscap SystemCapability.Communication.NetManager.Core * @systemapi Hide this for inner system use. - * @since 10 + * @since arkts{ '1.1':'10','1.2':'20'} + * @arkts 1.1&1.2 */ - uid: number; + uid: int; } /** @@ -559,39 +584,43 @@ declare namespace statistics { export interface NetStatsInfo { /** * Bytes of received. - * @type {number} + * @type {long} * @syscap SystemCapability.Communication.NetManager.Core * @systemapi Hide this for inner system use. - * @since 10 + * @since arkts{ '1.1':'10','1.2':'20'} + * @arkts 1.1&1.2 */ - rxBytes: number; + rxBytes: long; /** * Bytes of send. - * @type {number} + * @type {long} * @syscap SystemCapability.Communication.NetManager.Core * @systemapi Hide this for inner system use. - * @since 10 + * @since arkts{ '1.1':'10','1.2':'20'} + * @arkts 1.1&1.2 */ - txBytes: number; + txBytes: long; /** * Packets of received. - * @type {number} + * @type {long} * @syscap SystemCapability.Communication.NetManager.Core * @systemapi Hide this for inner system use. - * @since 10 + * @since arkts{ '1.1':'10','1.2':'20'} + * @arkts 1.1&1.2 */ - rxPackets: number; + rxPackets: long; /** * Packets of send. - * @type {number} + * @type {long} * @syscap SystemCapability.Communication.NetManager.Core * @systemapi Hide this for inner system use. - * @since 10 + * @since arkts{ '1.1':'10','1.2':'20'} + * @arkts 1.1&1.2 */ - txPackets: number; + txPackets: long; } /** @@ -612,37 +641,39 @@ declare namespace statistics { iface: string; /** * Network interface for querying traffic. - * @type { ?number } + * @type { ?int } * @syscap SystemCapability.Communication.NetManager.Core * @systemapi Hide this for inner system use. - * @since 11 + * @since arkts{ '1.1':'11','1.2':'20'} + * @arkts 1.1&1.2 */ - uid?: number; + uid?: int; } /** * An {@link NetStatsInfo} array with start time and end time. * @syscap SystemCapability.Communication.NetManager.Core * @systemapi Hide this for inner system use. - * @since 12 + * @since arkts{ '1.1':'12','1.2':'20'} + * @arkts 1.1&1.2 */ export type NetStatsInfoSequence = { /** * Start time for querying traffic. - * @type { number } + * @type { int } * @syscap SystemCapability.Communication.NetManager.Core * @systemapi Hide this for inner system use. * @since 12 */ - startTime: number; + startTime: int; /** * End time for querying traffic. - * @type { number } + * @type { int } * @syscap SystemCapability.Communication.NetManager.Core * @systemapi Hide this for inner system use. * @since 12 */ - endTime: number; + endTime: int; /** * Detailed information of statistics. * @type { NetStatsInfo } @@ -655,12 +686,13 @@ declare namespace statistics { /** * {@link NetStatsInfo} for every UID. Key is UID. + * @typedef {object} * @syscap SystemCapability.Communication.NetManager.Core * @systemapi Hide this for inner system use. * @since 12 */ export type UidNetStatsInfo = { - [uid: number]: NetStatsInfo; + [uid: int]: NetStatsInfo; }; /** @@ -681,28 +713,31 @@ declare namespace statistics { type: NetBearType; /** * Start time for querying traffic. - * @type { number } + * @type { int } * @syscap SystemCapability.Communication.NetManager.Core * @systemapi Hide this for inner system use. - * @since 12 + * @since arkts{ '1.1':'12','1.2':'20'} + * @arkts 1.1&1.2 */ - startTime: number; + startTime: int; /** * End time for querying traffic. - * @type { number } + * @type { int } * @syscap SystemCapability.Communication.NetManager.Core * @systemapi Hide this for inner system use. - * @since 12 + * @since arkts{ '1.1':'12','1.2':'20'} + * @arkts 1.1&1.2 */ - endTime: number; + endTime: int; /** * SIM card id for querying traffic. - * @type { ?number } + * @type { ?int } * @syscap SystemCapability.Communication.NetManager.Core * @systemapi Hide this for inner system use. - * @since 12 + * @since arkts{ '1.1':'12','1.2':'20'} + * @arkts 1.1&1.2 */ - simId?: number; + simId?: int; } /** @@ -725,7 +760,7 @@ declare namespace statistics { /** * Get the traffic usage sequence of the specified network of the application in the specified time period. * @permission ohos.permission.GET_NETWORK_STATS - * @param { number } uid - UID with this parameter, get stats info of this UID. + * @param { int } uid - UID with this parameter, get stats info of this UID. * @param { NetworkInfo } networkInfo - Information about the network to be queried. * @returns { Promise } The statistics history of the sim card. * @throws { BusinessError } 201 - Permission denied. @@ -737,9 +772,10 @@ declare namespace statistics { * @throws { BusinessError } 2103017 - Failed to read the database. * @syscap SystemCapability.Communication.NetManager.Core * @systemapi Hide this for inner system use. - * @since 12 + * @since arkts{ '1.1':'12','1.2':'20'} + * @arkts 1.1&1.2 */ - function getTrafficStatsByUidNetwork(uid: number, networkInfo: NetworkInfo): Promise; + function getTrafficStatsByUidNetwork(uid: int, networkInfo: NetworkInfo): Promise; } export default statistics; \ No newline at end of file