From 7c2521b6c1d806f32e898f12abc074b699de01bf Mon Sep 17 00:00:00 2001 From: Yangys Date: Mon, 31 Oct 2022 21:25:51 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BD=91=E7=BB=9C=E6=8E=A5=E5=8F=A3=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Yangys --- api/@ohos.net.connection.d.ts | 16 ++++++++++ api/@ohos.net.socket.d.ts | 58 +++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/api/@ohos.net.connection.d.ts b/api/@ohos.net.connection.d.ts index 84576eeee7..253a7574fd 100644 --- a/api/@ohos.net.connection.d.ts +++ b/api/@ohos.net.connection.d.ts @@ -88,10 +88,26 @@ declare namespace connection { function getNetCapabilities(netHandle: NetHandle, callback: AsyncCallback): void; function getNetCapabilities(netHandle: NetHandle): Promise; + /** + * Checks whether data traffic usage on the current network is metered. + * + * @param callback Returns {@code true} if data traffic usage on the current network is metered; + * returns {@code false} otherwise. + * @permission ohos.permission.GET_NETWORK_INFO + * @throws {BusinessError} 401 - Parameter error. + * @throws {BusinessError} 2100000 - NETMANAGER_SUCCESS. + * @throws {BusinessError} 2100201 - NETMANAGER_ERR_PERMISSION_DENIED. + */ + function isDefaultNetMetered(callback: AsyncCallback): void; + function isDefaultNetMetered(): Promise; + /** * Checks whether the default data network is activated. * * @param callback Returns {@code true} if the default data network is activated; returns {@code false} otherwise. + * @throws {BusinessError} 401 - Parameter error. + * @throws {BusinessError} 2100000 - NETMANAGER_SUCCESS. + * @throws {BusinessError} 2100201 - NETMANAGER_ERR_PERMISSION_DENIED. */ function hasDefaultNet(callback: AsyncCallback): void; function hasDefaultNet(): Promise; diff --git a/api/@ohos.net.socket.d.ts b/api/@ohos.net.socket.d.ts index 3fcdd5c8f9..6a0a53f0fd 100644 --- a/api/@ohos.net.socket.d.ts +++ b/api/@ohos.net.socket.d.ts @@ -251,6 +251,10 @@ declare namespace socket { * * @param address Destination address. {@link NetAddress} * @permission ohos.permission.INTERNET + * @throws {BusinessError} 401 - Parameter error. + * @throws {BusinessError} 2303109 - TLS_ERR_SYS_EBADF. + * @throws {BusinessError} 2303113 - TLS_ERR_SYS_EACCES. + * @throws {BusinessError} 2303198 - TLS_ERR_SYS_EADDRINUSE. */ bind(address: NetAddress, callback: AsyncCallback): void; bind(address: NetAddress): Promise; @@ -276,6 +280,9 @@ declare namespace socket { /** * Closes a TCPSocket connection. * @permission ohos.permission.INTERNET + * @throws {BusinessError} 401 - Parameter error. + * @throws {BusinessError} 2303505 - TLS_ERR_SYSCALL. + * @throws {BusinessError} 2303506 - TLS_ERR_ZERO_RETURN. */ close(callback: AsyncCallback): void; close(): Promise; @@ -285,6 +292,10 @@ declare namespace socket { * * @param callback Callback used to return the result. {@link NetAddress} * @permission ohos.permission.INTERNET + * @throws {BusinessError} 401 - Parameter error. + * @throws {BusinessError} 2303114 - TLS_ERR_SYS_EFAULT. + * @throws {BusinessError} 2303122 - TLS_ERR_SYS_EINVAL. + * @throws {BusinessError} 2303188 - TLS_ERR_SYS_ENOTSOCK. */ getRemoteAddress(callback: AsyncCallback): void; getRemoteAddress(): Promise; @@ -294,6 +305,10 @@ declare namespace socket { * * @param callback Callback used to return the result. {@link SocketStateBase} * @permission ohos.permission.INTERNET + * @throws {BusinessError} 401 - Parameter error. + * @throws {BusinessError} 2303114 - TLS_ERR_SYS_EFAULT. + * @throws {BusinessError} 2303122 - TLS_ERR_SYS_EINVAL. + * @throws {BusinessError} 2303188 - TLS_ERR_SYS_ENOTSOCK. */ getState(callback: AsyncCallback): void; getState(): Promise; @@ -303,37 +318,50 @@ declare namespace socket { * * @param options Optional parameters {@link TCPExtraOptions}. * @permission ohos.permission.INTERNET + * @throws {BusinessError} 401 - Parameter error. */ setExtraOptions(options: TCPExtraOptions, callback: AsyncCallback): void; setExtraOptions(options: TCPExtraOptions): Promise; /** * Listens for message receiving events of the TCPSocket connection. + * + * @throws {BusinessError} 401 - Parameter error. */ on(type: 'message', callback: Callback<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}>): void; /** * Cancels listening for message receiving events of the TCPSocket connection. + * + * @throws {BusinessError} 401 - Parameter error. */ off(type: 'message', callback?: Callback<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}>): void; /** * Listens for connection or close events of the TCPSocket connection. + * + * @throws {BusinessError} 401 - Parameter error. */ on(type: 'connect' | 'close', callback: Callback): void; /** * Cancels listening for connection or close events of the TCPSocket connection. + * + * @throws {BusinessError} 401 - Parameter error. */ off(type: 'connect' | 'close', callback?: Callback): void; /** * Listens for error events of the TCPSocket connection. + * + * @throws {BusinessError} 401 - Parameter error. */ on(type: 'error', callback: ErrorCallback): void; /** * Cancels listening for error events of the TCPSocket connection. + * + * @throws {BusinessError} 401 - Parameter error. */ off(type: 'error', callback?: ErrorCallback): void; } @@ -345,6 +373,8 @@ declare namespace socket { /** * Returns an object representing a local certificate. + * + * @throws {BusinessError} 401 - Parameter error. */ getCertificate(callback: AsyncCallback): void; getCertificate(): Promise; @@ -354,6 +384,8 @@ declare namespace socket { * an empty object will be returned. If the socket is destroyed, null is returned. * If needChain is true, it contains the complete certificate chain. Otherwise, * it only contains the peer's certificate. + * + * @throws {BusinessError} 401 - Parameter error. */ getRemoteCertificate(callback: AsyncCallback): void; getRemoteCertificate(): Promise; @@ -362,6 +394,8 @@ declare namespace socket { * Returns a string containing the negotiated SSL/TLS protocol version of the current connection. * For connected sockets that have not completed the handshake process, the value 'unknown' will be returned. * Server sockets or disconnected client sockets will return a value of null. + * + * @throws {BusinessError} 401 - Parameter error. */ getProtocol(callback: AsyncCallback): void; getProtocol(): Promise; @@ -369,6 +403,11 @@ declare namespace socket { /** * Returns an object containing the negotiated cipher suite information. * For example:{"name": "AES128-SHA256", "standardName": "TLS_RSA_WITH_AES_128_CBC_SHA256", "version": "TLSv1.2"} + * + * @throws {BusinessError} 401 - Parameter error. + * @throws {BusinessError} 2303502 - TLS_ERR_WANT_READ. + * @throws {BusinessError} 2303505 - TLS_ERR_SYSCALL. + * @throws {BusinessError} 2303506 - TLS_ERR_ZERO_RETURN. */ getCipherSuite(callback: AsyncCallback>): void; getCipherSuite(): Promise>; @@ -376,12 +415,27 @@ declare namespace socket { /** * The list of signature algorithms shared between the server and the client, in descending order of priority. * @see https://www.openssl.org/docs/man1.1.1/man3/SSL_get_shared_sigalgs.html + * + * @throws {BusinessError} 401 - Parameter error. */ getSignatureAlgorithms(callback: AsyncCallback>): void; getSignatureAlgorithms(): Promise>; /** * @permission ohos.permission.INTERNET + * @throws {BusinessError} 401 - Parameter error. + * @throws {BusinessError} 2303104 - TLS_ERR_SYS_EINTR. + * @throws {BusinessError} 2303109 - TLS_ERR_SYS_EBADF. + * @throws {BusinessError} 2303111 - TLS_ERR_SYS_EAGAIN. + * @throws {BusinessError} 2303113 - TLS_ERR_SYS_EACCES. + * @throws {BusinessError} 2303188 - TLS_ERR_SYS_ENOTSOCK. + * @throws {BusinessError} 2303191 - TLS_ERR_SYS_EPROTOTYPE. + * @throws {BusinessError} 2303198 - TLS_ERR_SYS_EADDRINUSE. + * @throws {BusinessError} 2303199 - TLS_ERR_SYS_EADDRNOTAVAIL. + * @throws {BusinessError} 2303210 - TLS_ERR_SYS_ETIMEDOUT. + * @throws {BusinessError} 2303502 - TLS_ERR_WANT_READ. + * @throws {BusinessError} 2303505 - TLS_ERR_SYSCALL. + * @throws {BusinessError} 2303506 - TLS_ERR_ZERO_RETURN. */ connect(options: TLSConnectOptions, callback: AsyncCallback): void; connect(options: TLSConnectOptions): Promise; @@ -391,6 +445,10 @@ declare namespace socket { * * @param data Optional parameters {@link string}. * @permission ohos.permission.INTERNET + * @throws {BusinessError} 401 - Parameter error. + * @throws {BusinessError} 2303503 - TLS_ERR_WANT_WRITE. + * @throws {BusinessError} 2303505 - TLS_ERR_SYSCALL. + * @throws {BusinessError} 2303506 - TLS_ERR_ZERO_RETURN. */ send(data: string, callback: AsyncCallback): void; send(data: string): Promise; -- Gitee