diff --git a/api/@ohos.net.connection.d.ts b/api/@ohos.net.connection.d.ts index 704b6a1147f8bf60679beac01e233b1df6494600..6dac4056c39d6cc7027966c7e3f743bf6d0c49ae 100644 --- a/api/@ohos.net.connection.d.ts +++ b/api/@ohos.net.connection.d.ts @@ -155,8 +155,7 @@ declare namespace connection { * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core * @atomicservice - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ function getDefaultNet(callback: AsyncCallback): void; @@ -182,11 +181,44 @@ declare namespace connection { * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core * @atomicservice - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ function getDefaultNet(): Promise; + /** + * Obtains the data network that is activated by default. + * To call this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission. + * @permission ohos.permission.GET_NETWORK_INFO + * @param { AsyncCallback } callback - the callback of getDefaultNet. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 2100002 - Failed to connect to the service. + * @throws { BusinessError } 2100003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.Core + * @since 20 + * @arkts 1.2 + */ + function getDefaultNetWithCallback(callback: AsyncCallback): void; + + /** + * Obtains the data network that is activated by default. + * To call this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission. + * @permission ohos.permission.GET_NETWORK_INFO + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2100002 - Failed to connect to the service. + * @throws { BusinessError } 2100003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.Core + * @since 20 + * @arkts 1.2 + */ + function getDefaultNetReturnsPromise(): Promise; + + /** + * @arkts 1.2 + */ + overload getDefaultNet { getDefaultNetWithCallback, getDefaultNetReturnsPromise }; + /** * Obtains the data network that is activated by default. * To call this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission. @@ -224,8 +256,7 @@ declare namespace connection { * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core - * @since arkts {'1.1':'8','1.2':'20'} - * @arkts 1.1&1.2 + * @since 8 */ function getAllNets(callback: AsyncCallback>): void; @@ -238,11 +269,44 @@ declare namespace connection { * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core - * @since arkts {'1.1':'8','1.2':'20'} - * @arkts 1.1&1.2 + * @since 8 */ function getAllNets(): Promise>; + /** + * Obtains the list of data networks that are activated. + * To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission. + * @permission ohos.permission.GET_NETWORK_INFO + * @param { AsyncCallback> } callback - the callback of getAllNets. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 2100002 - Failed to connect to the service. + * @throws { BusinessError } 2100003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.Core + * @since 20 + * @arkts 1.2 + */ + function getAllNetsWithCallback(callback: AsyncCallback>): void; + + /** + * Obtains the list of data networks that are activated. + * To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission. + * @permission ohos.permission.GET_NETWORK_INFO + * @returns { Promise> } The promise returned by the function. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2100002 - Failed to connect to the service. + * @throws { BusinessError } 2100003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.Core + * @since 20 + * @arkts 1.2 + */ + function getAllNetsReturnsPromise(): Promise>; + + /** + * @arkts 1.2 + */ + overload getAllNets { getAllNetsWithCallback, getAllNetsReturnsPromise }; + /** * Obtains the list of data networks that are activated. * To call this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission. @@ -269,8 +333,7 @@ declare namespace connection { * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core - * @since arkts {'1.1':'8','1.2':'20'} - * @arkts 1.1&1.2 + * @since 8 */ function getConnectionProperties(netHandle: NetHandle, callback: AsyncCallback): void; @@ -286,11 +349,51 @@ declare namespace connection { * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core - * @since arkts {'1.1':'8','1.2':'20'} - * @arkts 1.1&1.2 + * @since 8 */ function getConnectionProperties(netHandle: NetHandle): Promise; + /** + * Queries the connection properties of a network. + * This method requires the {@code ohos.permission.GET_NETWORK_INFO} permission. + * @permission ohos.permission.GET_NETWORK_INFO + * @param { NetHandle } netHandle - Indicates the network to be queried. + * @param { AsyncCallback } callback - the callback of + * getConnectionProperties.{@link ConnectionProperties}. + * @throws { BusinessError } 201 - Permission denied. + * @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 20 + * @arkts 1.2 + */ + function getConnectionPropertiesWithCallback(netHandle: NetHandle, + callback: AsyncCallback): void; + + /** + * Queries the connection properties of a network. + * This method requires the {@code ohos.permission.GET_NETWORK_INFO} permission. + * @permission ohos.permission.GET_NETWORK_INFO + * @param { NetHandle } netHandle - Indicates the network to be queried. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 201 - Permission denied. + * @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 20 + * @arkts 1.2 + */ + function getConnectionPropertiesReturnsPromise(netHandle: NetHandle): Promise; + + /** + * @arkts 1.2 + */ + overload getConnectionProperties { getConnectionPropertiesWithCallback, getConnectionPropertiesReturnsPromise }; + /** * Queries the connection properties of a network. * This method requires the {@code ohos.permission.GET_NETWORK_INFO} permission. @@ -335,8 +438,7 @@ declare namespace connection { * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core * @atomicservice - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ function getNetCapabilities(netHandle: NetHandle, callback: AsyncCallback): void; @@ -367,11 +469,49 @@ declare namespace connection { * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core * @atomicservice - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ function getNetCapabilities(netHandle: NetHandle): Promise; + /** + * Obtains {@link NetCapabilities} of a {@link NetHandle} object. + * To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission. + * @permission ohos.permission.GET_NETWORK_INFO + * @param { NetHandle } netHandle - Indicates the handle. See {@link NetHandle}. + * @param { AsyncCallback } callback - the callback of getNetCapabilities.{@link NetCapabilities}. + * @throws { BusinessError } 201 - Permission denied. + * @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 20 + * @arkts 1.2 + */ + function getNetCapabilitiesWithCallback(netHandle: NetHandle, callback: AsyncCallback): void; + + /** + * Obtains {@link NetCapabilities} of a {@link NetHandle} object. + * To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission. + * @permission ohos.permission.GET_NETWORK_INFO + * @param { NetHandle } netHandle - Indicates the handle. See {@link NetHandle}. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 201 - Permission denied. + * @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 20 + * @arkts 1.2 + */ + function getNetCapabilitiesReturnsPromise(netHandle: NetHandle): Promise; + + /** + * @arkts 1.2 + */ + overload getNetCapabilities { getNetCapabilitiesWithCallback, getNetCapabilitiesReturnsPromise }; + /** * Obtains {@link NetCapabilities} of a {@link NetHandle} object. * To invoke this method, you must have the {@code ohos.permission.GET_NETWORK_INFO} permission. @@ -475,8 +615,7 @@ declare namespace connection { * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ function isDefaultNetMetered(callback: AsyncCallback): void; @@ -488,11 +627,43 @@ declare namespace connection { * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ function isDefaultNetMetered(): Promise; + /** + * Checks whether data traffic usage on the current network is metered. + * @permission ohos.permission.GET_NETWORK_INFO + * @param { AsyncCallback } callback - Returns {@code true} if data traffic usage on the current network is metered; + * returns {@code false} otherwise. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 2100002 - Failed to connect to the service. + * @throws { BusinessError } 2100003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.Core + * @since 20 + * @arkts 1.2 + */ + function isDefaultNetMeteredWithCallback(callback: AsyncCallback): void; + + /** + * Checks whether data traffic usage on the current network is metered. + * @permission ohos.permission.GET_NETWORK_INFO + * @returns { Promise } the promise returned by the function. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2100002 - Failed to connect to the service. + * @throws { BusinessError } 2100003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.Core + * @since 20 + * @arkts 1.2 + */ + function isDefaultNetMeteredReturnsPromise(): Promise; + + /** + * @arkts 1.2 + */ + overload isDefaultNetMetered { isDefaultNetMeteredWithCallback, isDefaultNetMeteredReturnsPromise }; + /** * Checks whether data traffic usage on the current network is metered. * @permission ohos.permission.GET_NETWORK_INFO @@ -529,8 +700,7 @@ declare namespace connection { * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core * @crossplatform - * @since arkts {'1.1':'10','1.2':'20'} - * @arkts 1.1&1.2 + * @since 10 */ function hasDefaultNet(callback: AsyncCallback): void; @@ -554,11 +724,43 @@ declare namespace connection { * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core * @crossplatform - * @since arkts {'1.1':'10','1.2':'20'} - * @arkts 1.1&1.2 + * @since 10 */ function hasDefaultNet(): Promise; + /** + * Checks whether the default data network is activated. + * @permission ohos.permission.GET_NETWORK_INFO + * @param { AsyncCallback } callback - Returns {@code true} if the default data network is activated; + * returns {@code false} otherwise. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2100002 - Failed to connect to the service. + * @throws { BusinessError } 2100003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.Core + * @since 20 + * @arkts 1.2 + */ + function hasDefaultNetWithCallback(callback: AsyncCallback): void; + + /** + * Checks whether the default data network is activated. + * @permission ohos.permission.GET_NETWORK_INFO + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 2100002 - Failed to connect to the service. + * @throws { BusinessError } 2100003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.Core + * @since 20 + * @arkts 1.2 + */ + function hasDefaultNetReturnsPromise(): Promise; + + /** + * @arkts 1.2 + */ + overload hasDefaultNet { hasDefaultNetWithCallback, hasDefaultNetReturnsPromise }; + /** * Checks whether the default data network is activated. * @permission ohos.permission.GET_NETWORK_INFO @@ -584,8 +786,7 @@ declare namespace connection { * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core * @systemapi Hide this for inner system use. Only used for system app. - * @since arkts {'1.1':'8','1.2':'20'} - * @arkts 1.1&1.2 + * @since 8 */ function enableAirplaneMode(callback: AsyncCallback): void; @@ -600,30 +801,29 @@ declare namespace connection { * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core * @systemapi Hide this for inner system use. Only used for system app. - * @since arkts {'1.1':'8','1.2':'20'} - * @arkts 1.1&1.2 + * @since 8 */ function enableAirplaneMode(): Promise; /** - * Disables the airplane mode for a device. + * Enables the airplane mode for a device. * To invoke this method, you must have the {@code ohos.permission.CONNECTIVITY_INTERNAL} permission. * @permission ohos.permission.CONNECTIVITY_INTERNAL - * @param { AsyncCallback } callback - the callback of disableAirplaneMode. + * @param { AsyncCallback } callback - the callback of enableAirplaneMode. * @throws { BusinessError } 201 - Permission denied. * @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 arkts {'1.1':'8','1.2':'20'} - * @arkts 1.1&1.2 + * @since 20 + * @arkts 1.2 */ - function disableAirplaneMode(callback: AsyncCallback): void; + function enableAirplaneModeWithCallback(callback: AsyncCallback): void; /** - * Disables the airplane mode for a device. + * Enables the airplane mode for a device. * To invoke this method, you must have the {@code ohos.permission.CONNECTIVITY_INTERNAL} permission. * @permission ohos.permission.CONNECTIVITY_INTERNAL * @returns { Promise } The promise returned by the function. @@ -633,43 +833,152 @@ declare namespace connection { * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core * @systemapi Hide this for inner system use. Only used for system app. - * @since arkts {'1.1':'8','1.2':'20'} - * @arkts 1.1&1.2 + * @since 20 + * @arkts 1.2 */ - function disableAirplaneMode(): Promise; + function enableAirplaneModeReturnsPromise(): Promise; /** - * Reports the network state is connected. - * @permission ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET - * @param { NetHandle } netHandle - Indicates the network whose state is to be reported. - * @param { AsyncCallback } callback - the callback of reportNetConnected. + * @arkts 1.2 + */ + overload enableAirplaneMode { enableAirplaneModeWithCallback, enableAirplaneModeReturnsPromise }; + + /** + * Disables the airplane mode for a device. + * To invoke this method, you must have the {@code ohos.permission.CONNECTIVITY_INTERNAL} permission. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @param { AsyncCallback } callback - the callback of disableAirplaneMode. * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications use system APIs. * @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 arkts {'1.1':'8','1.2':'20'} - * @arkts 1.1&1.2 + * @systemapi Hide this for inner system use. Only used for system app. + * @since 8 */ - function reportNetConnected(netHandle: NetHandle, callback: AsyncCallback): void; + function disableAirplaneMode(callback: AsyncCallback): void; /** - * Reports the network state is connected. - * @permission ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET - * @param { NetHandle } netHandle - Indicates the network whose state is to be reported. + * Disables the airplane mode for a device. + * To invoke this method, you must have the {@code ohos.permission.CONNECTIVITY_INTERNAL} permission. + * @permission ohos.permission.CONNECTIVITY_INTERNAL * @returns { Promise } The promise returned by the function. * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @throws { BusinessError } 2100002 - Failed to connect to the service. + * @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 + */ + function disableAirplaneMode(): Promise; + + /** + * Disables the airplane mode for a device. + * To invoke this method, you must have the {@code ohos.permission.CONNECTIVITY_INTERNAL} permission. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @param { AsyncCallback } callback - the callback of disableAirplaneMode. + * @throws { BusinessError } 201 - Permission denied. + * @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. + * @syscap SystemCapability.Communication.NetManager.Core + * @systemapi Hide this for inner system use. Only used for system app. + * @since 20 + * @arkts 1.2 + */ + function disableAirplaneModeWithCallback(callback: AsyncCallback): void; + + /** + * Disables the airplane mode for a device. + * To invoke this method, you must have the {@code ohos.permission.CONNECTIVITY_INTERNAL} permission. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @throws { BusinessError } 2100002 - Failed to connect to the service. + * @throws { BusinessError } 2100003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.Core + * @systemapi Hide this for inner system use. Only used for system app. + * @since 20 + * @arkts 1.2 + */ + function disableAirplaneModeReturnsPromise(): Promise; + + /** + * @arkts 1.2 + */ + overload disableAirplaneMode { disableAirplaneModeWithCallback, disableAirplaneModeReturnsPromise }; + + /** + * Reports the network state is connected. + * @permission ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET + * @param { NetHandle } netHandle - Indicates the network whose state is to be reported. + * @param { AsyncCallback } callback - the callback of reportNetConnected. + * @throws { BusinessError } 201 - Permission denied. * @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 arkts {'1.1':'8','1.2':'20'} - * @arkts 1.1&1.2 + * @since 8 + */ + function reportNetConnected(netHandle: NetHandle, callback: AsyncCallback): void; + + /** + * Reports the network state is connected. + * @permission ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET + * @param { NetHandle } netHandle - Indicates the network whose state is to be reported. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 201 - Permission denied. + * @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 8 */ function reportNetConnected(netHandle: NetHandle): Promise; + /** + * Reports the network state is connected. + * @permission ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET + * @param { NetHandle } netHandle - Indicates the network whose state is to be reported. + * @param { AsyncCallback } callback - the callback of reportNetConnected. + * @throws { BusinessError } 201 - Permission denied. + * @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 20 + * @arkts 1.2 + */ + function reportNetConnectedWithCallback(netHandle: NetHandle, callback: AsyncCallback): void; + + /** + * Reports the network state is connected. + * @permission ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET + * @param { NetHandle } netHandle - Indicates the network whose state is to be reported. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 201 - Permission denied. + * @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 20 + * @arkts 1.2 + */ + function reportNetConnectedReturnsPromise(netHandle: NetHandle): Promise; + + /** + * @arkts 1.2 + */ + overload reportNetConnected { reportNetConnectedWithCallback, reportNetConnectedReturnsPromise }; + /** * Reports the network state is disconnected. * @permission ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET @@ -681,8 +990,7 @@ declare namespace connection { * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core - * @since arkts {'1.1':'8','1.2':'20'} - * @arkts 1.1&1.2 + * @since 8 */ function reportNetDisconnected(netHandle: NetHandle, callback: AsyncCallback): void; @@ -697,11 +1005,47 @@ declare namespace connection { * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core - * @since arkts {'1.1':'8','1.2':'20'} - * @arkts 1.1&1.2 + * @since 8 */ function reportNetDisconnected(netHandle: NetHandle): Promise; + /** + * Reports the network state is disconnected. + * @permission ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET + * @param { NetHandle } netHandle - Indicates the network whose state is to be reported. + * @param { AsyncCallback } callback - the callback of reportNetDisconnected. + * @throws { BusinessError } 201 - Permission denied. + * @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 20 + * @arkts 1.2 + */ + function reportNetDisconnectedWithCallback(netHandle: NetHandle, callback: AsyncCallback): void; + + /** + * Reports the network state is disconnected. + * @permission ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET + * @param { NetHandle } netHandle - Indicates the network whose state is to be reported. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 201 - Permission denied. + * @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 20 + * @arkts 1.2 + */ + function reportNetDisconnectedReturnsPromise(netHandle: NetHandle): Promise; + + /** + * @arkts 1.2 + */ + overload reportNetDisconnected { reportNetDisconnectedWithCallback, reportNetDisconnectedReturnsPromise }; + /** * Resolves the host name to obtain all IP addresses based on the default data network. * @permission ohos.permission.INTERNET @@ -713,8 +1057,7 @@ declare namespace connection { * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core - * @since arkts {'1.1':'8','1.2':'20'} - * @arkts 1.1&1.2 + * @since 8 */ function getAddressesByName(host: string, callback: AsyncCallback>): void; @@ -729,11 +1072,47 @@ declare namespace connection { * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core - * @since arkts {'1.1':'8','1.2':'20'} - * @arkts 1.1&1.2 + * @since 8 */ function getAddressesByName(host: string): Promise>; + /** + * Resolves the host name to obtain all IP addresses based on the default data network. + * @permission ohos.permission.INTERNET + * @param { string } host - Indicates the host name or the domain. + * @param { AsyncCallback> } callback - Returns the NetAddress list. + * @throws { BusinessError } 201 - Permission denied. + * @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 20 + * @arkts 1.2 + */ + function getAddressesByNameWithCallback(host: string, callback: AsyncCallback>): void; + + /** + * Resolves the host name to obtain all IP addresses based on the default data network. + * @permission ohos.permission.INTERNET + * @param { string } host - Indicates the host name or the domain. + * @returns { Promise> } The promise returned by the function. + * @throws { BusinessError } 201 - Permission denied. + * @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 20 + * @arkts 1.2 + */ + function getAddressesByNameReturnsPromise(host: string): Promise>; + + /** + * @arkts 1.2 + */ + overload getAddressesByName { getAddressesByNameWithCallback, getAddressesByNameReturnsPromise }; + /** * Obtains the {@link NetHandle} bound to a process using {@link setAppNet}. * @param { AsyncCallback } callback - Returns the {@link NetHandle} bound to the process; @@ -742,8 +1121,7 @@ declare namespace connection { * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ function getAppNet(callback: AsyncCallback): void; @@ -753,11 +1131,39 @@ declare namespace connection { * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ function getAppNet(): Promise; + /** + * Obtains the {@link NetHandle} bound to a process using {@link setAppNet}. + * @param { AsyncCallback } callback - Returns the {@link NetHandle} bound to the process; + * returns {@code null} if no {@link NetHandle} is bound to the process.For details, see {@link NetHandle}. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 2100002 - Failed to connect to the service. + * @throws { BusinessError } 2100003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.Core + * @since 20 + * @arkts 1.2 + */ + function getAppNetWithCallback(callback: AsyncCallback): void; + + /** + * Obtains the {@link NetHandle} bound to a process using {@link setAppNet}. + * @returns { Promise } the promise returned by the function. + * @throws { BusinessError } 2100002 - Failed to connect to the service. + * @throws { BusinessError } 2100003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.Core + * @since 20 + * @arkts 1.2 + */ + function getAppNetReturnsPromise(): Promise; + + /** + * @arkts 1.2 + */ + overload getAppNet { getAppNetWithCallback, getAppNetReturnsPromise }; + /** * Obtains the {@link NetHandle} bound to a process using {@link setAppNet}. * @returns { NetHandle } Returns the {@link NetHandle} bound to a process using {@link setAppNet}. @@ -782,8 +1188,7 @@ declare namespace connection { * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ function setAppNet(netHandle: NetHandle, callback: AsyncCallback): void; @@ -800,11 +1205,51 @@ declare namespace connection { * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ function setAppNet(netHandle: NetHandle): Promise; + /** + * Binds a process to {@code NetHandle}. + *

All the sockets created from the process will be bound to the {@code NetHandle}, + * and the resolution of all host names will be managed by the {@code NetHandle}.

+ * @permission ohos.permission.INTERNET + * @param { NetHandle } netHandle - Indicates the handle. For details, see {@link NetHandle}. + * @param { AsyncCallback } callback - the callback of setAppNet. + * @throws { BusinessError } 201 - Permission denied. + * @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 20 + * @arkts 1.2 + */ + function setAppNetWithCallback(netHandle: NetHandle, callback: AsyncCallback): void; + + /** + * Binds a process to {@code NetHandle}. + *

All the sockets created from the process will be bound to the {@code NetHandle}, + * and the resolution of all host names will be managed by the {@code NetHandle}.

+ * @permission ohos.permission.INTERNET + * @param { NetHandle } netHandle - Indicates the handle. For details, see {@link NetHandle}. + * @returns { Promise } the promise returned by the function. + * @throws { BusinessError } 201 - Permission denied. + * @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 20 + * @arkts 1.2 + */ + function setAppNetReturnsPromise(netHandle: NetHandle): Promise; + + /** + * @arkts 1.2 + */ + overload setAppNet { setAppNetWithCallback, setAppNetReturnsPromise }; + /** * Obtains the default {@link HttpProxy} proxy settings. * @@ -817,8 +1262,7 @@ declare namespace connection { * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core - * @since arkts {'1.1':'10','1.2':'20'} - * @arkts 1.1&1.2 + * @since 10 */ function getDefaultHttpProxy(callback: AsyncCallback): void; @@ -834,11 +1278,51 @@ declare namespace connection { * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core - * @since arkts {'1.1':'10','1.2':'20'} - * @arkts 1.1&1.2 + * @since 10 */ function getDefaultHttpProxy(): Promise; + /** + * Obtains the default {@link HttpProxy} proxy settings. + * + * If an application level proxy is set, the application level proxy parameters are returned. + * If a global proxy is set, the global proxy parameters are returned. + * If the process is bound to a {@link NetHandle} using {@link setAppNet}, + * the {@link NetHandle} proxy settings are returned. + * In other cases, the proxy settings of default network are returned. + * + * @param { AsyncCallback } callback - Returns the default {@link HttpProxy} settings. + * @throws { BusinessError } 2100002 - Failed to connect to the service. + * @throws { BusinessError } 2100003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.Core + * @since 20 + * @arkts 1.2 + */ + function getDefaultHttpProxyWithCallback(callback: AsyncCallback): void; + + /** + * Obtains the default {@link HttpProxy} proxy settings. + * + * If an application level proxy is set, the application level proxy parameters are returned. + * If a global proxy is set, the global proxy parameters are returned. + * If the process is bound to a {@link NetHandle} using {@link setAppNet}, + * the {@link NetHandle} proxy settings are returned. + * In other cases, the proxy settings of default network are returned. + * + * @returns { Promise } the promise returned by the function. + * @throws { BusinessError } 2100002 - Failed to connect to the service. + * @throws { BusinessError } 2100003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.Core + * @since 20 + * @arkts 1.2 + */ + function getDefaultHttpProxyReturnsPromise(): Promise; + + /** + * @arkts 1.2 + */ + overload getDefaultHttpProxy { getDefaultHttpProxyWithCallback, getDefaultHttpProxyReturnsPromise }; + /** * Obtains the network independent global {@link HttpProxy} proxy settings. * @param { AsyncCallback } callback - Returns the proxy settings. For details, see {@link HttpProxy}. @@ -848,10 +1332,35 @@ declare namespace connection { * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core * @systemapi Hide this for inner system use. - * @since arkts {'1.1':'10','1.2':'20'} - * @arkts 1.1&1.2 + * @since 10 + */ + function getGlobalHttpProxy(callback: AsyncCallback): void; + + /** + * Obtains the network independent global {@link HttpProxy} proxy settings. + * @returns { Promise } the promise returned by the function. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @throws { BusinessError } 2100002 - Failed to connect to the service. + * @throws { BusinessError } 2100003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.Core + * @systemapi Hide this for inner system use. + * @since 10 + */ + function getGlobalHttpProxy(): Promise; + + /** + * Obtains the network independent global {@link HttpProxy} proxy settings. + * @param { AsyncCallback } callback - Returns the proxy settings. For details, see {@link HttpProxy}. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @throws { BusinessError } 2100002 - Failed to connect to the service. + * @throws { BusinessError } 2100003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.Core + * @systemapi Hide this for inner system use. + * @since 20 + * @arkts 1.2 */ - function getGlobalHttpProxy(callback: AsyncCallback): void; + function getGlobalHttpProxyWithCallback(callback: AsyncCallback): void; /** * Obtains the network independent global {@link HttpProxy} proxy settings. @@ -861,10 +1370,15 @@ declare namespace connection { * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core * @systemapi Hide this for inner system use. - * @since arkts {'1.1':'10','1.2':'20'} - * @arkts 1.1&1.2 + * @since 20 + * @arkts 1.2 */ - function getGlobalHttpProxy(): Promise; + function getGlobalHttpProxyReturnsPromise(): Promise; + + /** + * @arkts 1.2 + */ + overload getGlobalHttpProxy { getGlobalHttpProxyWithCallback, getGlobalHttpProxyReturnsPromise }; /** * Set application level http proxy {@link HttpProxy}. @@ -890,8 +1404,7 @@ declare namespace connection { * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core * @systemapi Hide this for inner system use. - * @since arkts {'1.1':'10','1.2':'20'} - * @arkts 1.1&1.2 + * @since 10 */ function setGlobalHttpProxy(httpProxy: HttpProxy, callback: AsyncCallback): void; @@ -908,11 +1421,51 @@ declare namespace connection { * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core * @systemapi Hide this for inner system use. - * @since arkts {'1.1':'10','1.2':'20'} - * @arkts 1.1&1.2 + * @since 10 */ function setGlobalHttpProxy(httpProxy: HttpProxy): Promise; + /** + * Set a network independent global {@link HttpProxy} proxy settings. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @param { HttpProxy } httpProxy - Indicates the global proxy settings. For details, see {@link HttpProxy}. + * @param { AsyncCallback } callback - the callback of setGlobalHttpProxy. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @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 + * @systemapi Hide this for inner system use. + * @since 20 + * @arkts 1.2 + */ + function setGlobalHttpProxyWithCallback(httpProxy: HttpProxy, callback: AsyncCallback): void; + + /** + * Set a network independent global {@link HttpProxy} proxy settings. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @param { HttpProxy } httpProxy - Indicates the global proxy settings. For details, see {@link HttpProxy}. + * @returns { Promise } the promise returned by the function. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @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 + * @systemapi Hide this for inner system use. + * @since 20 + * @arkts 1.2 + */ + function setGlobalHttpProxyReturnsPromise(httpProxy: HttpProxy): Promise; + + /** + * @arkts 1.2 + */ + overload setGlobalHttpProxy { setGlobalHttpProxyWithCallback, setGlobalHttpProxyReturnsPromise }; + /** * Set the URL {@link pacUrl} of the current PAC script. * To invoke this method, you must have the {@code ohos.permission.SET_PAC_URL} permission. @@ -966,8 +1519,7 @@ declare namespace connection { * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core * @atomicservice - * @since arkts {'1.1':'15','1.2':'20'} - * @arkts 1.1&1.2 + * @since 15 */ function addCustomDnsRule(host: string, ip: Array, callback: AsyncCallback): void; @@ -998,11 +1550,51 @@ declare namespace connection { * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core * @atomicservice - * @since arkts {'1.1':'15','1.2':'20'} - * @arkts 1.1&1.2 + * @since 15 */ function addCustomDnsRule(host: string, ip: Array): Promise; + /** + * Add a custom {@link host} and corresponding {@link ip} mapping for current application. + * @permission ohos.permission.INTERNET + * @param { string } host - Indicates the host name or the domain. + * @param { Array } ip - List of IP addresses mapped to the host name. + * @param { AsyncCallback } callback - Returns the callback of addCustomDnsRule. + * @throws { BusinessError } 201 - Permission denied. + * @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 + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + function addCustomDnsRuleWithCallback(host: string, ip: Array, callback: AsyncCallback): void; + + /** + * Add a custom {@link host} and corresponding {@link ip} mapping for current application. + * @permission ohos.permission.INTERNET + * @param { string } host - Indicates the host name or the domain. + * @param { Array } ip - List of IP addresses mapped to the host name. + * @returns { Promise } the promise returned by the function. + * @throws { BusinessError } 201 - Permission denied. + * @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 + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + function addCustomDnsRuleReturnsPromise(host: string, ip: Array): Promise; + + /** + * @arkts 1.2 + */ + overload addCustomDnsRule { addCustomDnsRuleWithCallback, addCustomDnsRuleReturnsPromise }; + /** * Remove the custom DNS rule of the {@link host} for current application. * @permission ohos.permission.INTERNET @@ -1028,8 +1620,7 @@ declare namespace connection { * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core * @atomicservice - * @since arkts {'1.1':'15','1.2':'20'} - * @arkts 1.1&1.2 + * @since 15 */ function removeCustomDnsRule(host: string, callback: AsyncCallback): void; @@ -1058,11 +1649,47 @@ declare namespace connection { * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core * @atomicservice - * @since arkts {'1.1':'15','1.2':'20'} - * @arkts 1.1&1.2 + * @since 15 */ function removeCustomDnsRule(host: string): Promise; + /** + * Remove the custom DNS rule of the {@link host} for current application. + * @permission ohos.permission.INTERNET + * @param { string } host - Indicates the host name or the domain. + * @param { AsyncCallback } callback - Returns the callback of removeCustomDnsRule. + * @throws { BusinessError } 201 - Permission denied. + * @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 20 + * @arkts 1.2 + */ + function removeCustomDnsRuleWithCallback(host: string, callback: AsyncCallback): void; + + /** + * Remove the custom DNS rule of the {@link host} for current application. + * @permission ohos.permission.INTERNET + * @param { string } host - Indicates the host name or the domain. + * @returns { Promise } the promise returned by the function. + * @throws { BusinessError } 201 - Permission denied. + * @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 20 + * @arkts 1.2 + */ + function removeCustomDnsRuleReturnsPromise(host: string): Promise; + + /** + * @arkts 1.2 + */ + overload removeCustomDnsRule { removeCustomDnsRuleWithCallback, removeCustomDnsRuleReturnsPromise }; + /** * Clear all custom DNS rules for current application. * @permission ohos.permission.INTERNET @@ -1073,8 +1700,7 @@ declare namespace connection { * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ function clearCustomDnsRules(callback: AsyncCallback): void; @@ -1087,11 +1713,44 @@ declare namespace connection { * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ function clearCustomDnsRules(): Promise; + /** + * Clear all custom DNS rules for current application. + * @permission ohos.permission.INTERNET + * @param { AsyncCallback } callback - Returns the callback of clearCustomDnsRules. + * @throws { BusinessError } 201 - Permission denied. + * @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 20 + * @arkts 1.2 + */ + function clearCustomDnsRulesWithCallback(callback: AsyncCallback): void; + + /** + * Clear all custom DNS rules for current application. + * @permission ohos.permission.INTERNET + * @returns { Promise } the promise returned by the function. + * @throws { BusinessError } 201 - Permission denied. + * @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 20 + * @arkts 1.2 + */ + function clearCustomDnsRulesReturnsPromise(): Promise; + + /** + * @arkts 1.2 + */ + overload clearCustomDnsRules { clearCustomDnsRulesWithCallback, clearCustomDnsRulesReturnsPromise }; + /** * factory reset network settings * @@ -1154,11 +1813,20 @@ declare namespace connection { * @syscap SystemCapability.Communication.NetManager.Core * @crossplatform * @atomicservice - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ on(type: 'netAvailable', callback: Callback): void; + /** + * Registers a listener for netAvailable events. + * @param { 'netAvailable' } type - Indicates Event name. + * @param { Callback } callback - the callback used to return the result. + * @syscap SystemCapability.Communication.NetManager.Core + * @since 20 + * @arkts 1.2 + */ + onNetAvailableWithCallback(type: 'netAvailable', callback: Callback): void; + /** * Registers a listener for netBlockStatusChange events. * @param { 'netBlockStatusChange' } type - Indicates Event name. @@ -1171,11 +1839,20 @@ declare namespace connection { * @param { 'netBlockStatusChange' } type - Indicates Event name. * @param { Callback } callback - the callback used to return the result. * @syscap SystemCapability.Communication.NetManager.Core - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ on(type: 'netBlockStatusChange', callback: Callback): void; + /** + * Registers a listener for netBlockStatusChange events. + * @param { 'netBlockStatusChange' } type - Indicates Event name. + * @param { Callback } callback - the callback used to return the result. + * @syscap SystemCapability.Communication.NetManager.Core + * @since 20 + * @arkts 1.2 + */ + onNetBlockStatusChangeWithCallback(type: 'netBlockStatusChange', callback: Callback): void; + /** * Registers a listener for **netCapabilitiesChange** events. * @param { 'netCapabilitiesChange' } type - Indicates Event name. @@ -1198,11 +1875,20 @@ declare namespace connection { * @syscap SystemCapability.Communication.NetManager.Core * @crossplatform * @atomicservice - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ on(type: 'netCapabilitiesChange', callback: Callback): void; + /** + * Registers a listener for **netCapabilitiesChange** events. + * @param { 'netCapabilitiesChange' } type - Indicates Event name. + * @param { Callback } callback - the callback used to return the result. + * @syscap SystemCapability.Communication.NetManager.Core + * @since 20 + * @arkts 1.2 + */ + onNetCapabilitiesChangeWithCallback(type: 'netCapabilitiesChange', callback: Callback): void; + /** * Registers a listener for netConnectionPropertiesChange events. * @param { 'netConnectionPropertiesChange' } type - Indicates Event name. @@ -1215,11 +1901,20 @@ declare namespace connection { * @param { 'netConnectionPropertiesChange' } type - Indicates Event name. * @param { Callback } callback - the callback used to return the result. * @syscap SystemCapability.Communication.NetManager.Core - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ on(type: 'netConnectionPropertiesChange', callback: Callback): void; + /** + * Registers a listener for netConnectionPropertiesChange events. + * @param { 'netConnectionPropertiesChange' } type - Indicates Event name. + * @param { Callback } callback - the callback used to return the result. + * @syscap SystemCapability.Communication.NetManager.Core + * @since 20 + * @arkts 1.2 + */ + onNetConnectionPropertiesChangeWithCallback(type: 'netConnectionPropertiesChange', callback: Callback): void; + /** * Registers a listener for **netLost** events. * @param { 'netLost' } type - Indicates Event name. @@ -1242,11 +1937,20 @@ declare namespace connection { * @syscap SystemCapability.Communication.NetManager.Core * @crossplatform * @atomicservice - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ on(type: 'netLost', callback: Callback): void; + /** + * Registers a listener for **netLost** events. + * @param { 'netLost' } type - Indicates Event name. + * @param { Callback } callback - the callback used to return the result. + * @syscap SystemCapability.Communication.NetManager.Core + * @since 20 + * @arkts 1.2 + */ + onNetLostWtihCallback(type: 'netLost', callback: Callback): void; + /** * Registers a listener for netUnavailable events. * @param { 'netUnavailable' } type - Indicates Event name. @@ -1269,11 +1973,31 @@ declare namespace connection { * @syscap SystemCapability.Communication.NetManager.Core * @crossplatform * @atomicservice - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ on(type: 'netUnavailable', callback: Callback): void; + /** + * Registers a listener for netUnavailable events. + * @param { 'netUnavailable' } type - Indicates Event name. + * @param { Callback } callback - the callback used to return the result. + * @syscap SystemCapability.Communication.NetManager.Core + * @since 20 + * @arkts 1.2 + */ + onNetUnavailableWithCallback(type: 'netUnavailable', callback: Callback): void; + + /** + * @arkts 1.2 + */ + overload on { + onNetAvailableWithCallback, + onNetBlockStatusChangeWithCallback, + onNetCapabilitiesChangeWithCallback, + onNetConnectionPropertiesChangeWithCallback, + onNetLostWtihCallback, + onNetUnavailableWithCallback }; + /** * Receives status change notifications of a specified network. * @permission ohos.permission.GET_NETWORK_INFO @@ -1621,8 +2345,7 @@ declare namespace connection { * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core - * @since arkts {'1.1':'8','1.2':'20'} - * @arkts 1.1&1.2 + * @since 8 */ getAddressByName(host: string, callback: AsyncCallback): void; @@ -1637,10 +2360,46 @@ declare namespace connection { * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core - * @since arkts {'1.1':'8','1.2':'20'} - * @arkts 1.1&1.2 + * @since 8 */ getAddressByName(host: string): Promise; + + /** + * Resolves a host name to obtain the first IP address based on the specified NetHandle. + * @permission ohos.permission.INTERNET + * @param { string } host - Indicates the host name or the domain. + * @param { AsyncCallback } callback - the callback of getAddressByName. + * @throws { BusinessError } 201 - Permission denied. + * @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 20 + * @arkts 1.2 + */ + getAddressByNameWithCallback(host: string, callback: AsyncCallback): void; + + /** + * Resolves a host name to obtain the first IP address based on the specified NetHandle. + * @permission ohos.permission.INTERNET + * @param { string } host - Indicates the host name or the domain. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 201 - Permission denied. + * @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 20 + * @arkts 1.2 + */ + getAddressByNameReturnsPromise(host: string): Promise; + + /** + * @arkts 1.2 + */ + overload getAddressByName { getAddressByNameWithCallback, getAddressByNameReturnsPromise }; } /** diff --git a/api/@ohos.net.http.d.ts b/api/@ohos.net.http.d.ts index fbb2c980064be5e97be2fb655c40e10bf2df20fc..0a74e4747c9016f4a47d2f290d0cce00d8bbc659 100644 --- a/api/@ohos.net.http.d.ts +++ b/api/@ohos.net.http.d.ts @@ -1948,8 +1948,7 @@ declare namespace http { * @syscap SystemCapability.Communication.NetStack * @crossplatform * @atomicservice - * @since arkts {'1.1':'18','1.2':'20'} - * @arkts 1.1&1.2 + * @since 18 */ requestInStream(url: string, callback: AsyncCallback): void; @@ -2118,8 +2117,7 @@ declare namespace http { * @syscap SystemCapability.Communication.NetStack * @crossplatform * @atomicservice - * @since arkts {'1.1':'18','1.2':'20'} - * @arkts 1.1&1.2 + * @since 18 */ requestInStream(url: string, option: HttpRequestOptions, callback: AsyncCallback): void; @@ -2288,11 +2286,153 @@ declare namespace http { * @syscap SystemCapability.Communication.NetStack * @crossplatform * @atomicservice - * @since arkts {'1.1':'18','1.2':'20'} - * @arkts 1.1&1.2 + * @since 18 */ requestInStream(url: string, options?: HttpRequestOptions): Promise; + /** + * Initiates an HTTP request to a given URL, applicable to scenarios where http response supports streaming. + * @permission ohos.permission.INTERNET + * @param { string } url - URL for initiating an HTTP request. + * @param { AsyncCallback } callback - Returns the callback of requestInStream {@link ResponseCode}, + * should use on_headersReceive and on_dataReceive to get http response. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 2300001 - Unsupported protocol. + * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. + * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. + * @throws { BusinessError } 2300006 - Failed to resolve the host name. + * @throws { BusinessError } 2300007 - Failed to connect to the server. + * @throws { BusinessError } 2300008 - Invalid server response. + * @throws { BusinessError } 2300009 - Access to the remote resource denied. + * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. + * @throws { BusinessError } 2300018 - Transferred a partial file. + * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. + * @throws { BusinessError } 2300025 - Upload failed. + * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. + * @throws { BusinessError } 2300027 - Out of memory. + * @throws { BusinessError } 2300028 - Operation timeout. + * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. + * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). + * @throws { BusinessError } 2300055 - Failed to send data to the peer. + * @throws { BusinessError } 2300056 - Failed to receive data from the peer. + * @throws { BusinessError } 2300058 - Local SSL certificate error. + * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. + * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. + * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. + * @throws { BusinessError } 2300063 - Maximum file size exceeded. + * @throws { BusinessError } 2300070 - Remote disk full. + * @throws { BusinessError } 2300073 - Remote file already exists. + * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is inaccessible. + * @throws { BusinessError } 2300078 - Remote file not found. + * @throws { BusinessError } 2300094 - Authentication error. + * @throws { BusinessError } 2300997 - Cleartext traffic not permitted. + * @throws { BusinessError } 2300998 - It is not allowed to access this domain. + * @throws { BusinessError } 2300999 - Internal error. + * @syscap SystemCapability.Communication.NetStack + * @since 20 + * @arkts 1.2 + */ + requestInStreamWithCallback(url: string, callback: AsyncCallback): void; + + /** + * Initiates an HTTP request to a given URL, applicable to scenarios where http response supports streaming. + * @permission ohos.permission.INTERNET + * @param { string } url - URL for initiating an HTTP request. + * @param { HttpRequestOptions } option - Optional parameters {@link HttpRequestOptions}. + * @param { AsyncCallback } callback - the callback of requestInStream. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 2300001 - Unsupported protocol. + * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. + * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. + * @throws { BusinessError } 2300006 - Failed to resolve the host name. + * @throws { BusinessError } 2300007 - Failed to connect to the server. + * @throws { BusinessError } 2300008 - Invalid server response. + * @throws { BusinessError } 2300009 - Access to the remote resource denied. + * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. + * @throws { BusinessError } 2300018 - Transferred a partial file. + * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. + * @throws { BusinessError } 2300025 - Upload failed. + * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. + * @throws { BusinessError } 2300027 - Out of memory. + * @throws { BusinessError } 2300028 - Operation timeout. + * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. + * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). + * @throws { BusinessError } 2300055 - Failed to send data to the peer. + * @throws { BusinessError } 2300056 - Failed to receive data from the peer. + * @throws { BusinessError } 2300058 - Local SSL certificate error. + * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. + * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. + * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. + * @throws { BusinessError } 2300063 - Maximum file size exceeded. + * @throws { BusinessError } 2300070 - Remote disk full. + * @throws { BusinessError } 2300073 - Remote file already exists. + * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is inaccessible. + * @throws { BusinessError } 2300078 - Remote file not found. + * @throws { BusinessError } 2300094 - Authentication error. + * @throws { BusinessError } 2300997 - Cleartext traffic not permitted. + * @throws { BusinessError } 2300998 - It is not allowed to access this domain. + * @throws { BusinessError } 2300999 - Internal error. + * @syscap SystemCapability.Communication.NetStack + * @since 20 + * @arkts 1.2 + */ + requestInStreamWithOptionCallback(url: string, option: HttpRequestOptions, callback: AsyncCallback): void; + + /** + * Initiates an HTTP request to a given URL, applicable to scenarios where http response supports streaming. + * @permission ohos.permission.INTERNET + * @param { string } url - URL for initiating an HTTP request. + * @param { HttpRequestOptions } [options] - Optional parameters {@link HttpRequestOptions}. + * @returns { Promise } the promise returned by the function. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 2300001 - Unsupported protocol. + * @throws { BusinessError } 2300003 - Invalid URL format or missing URL. + * @throws { BusinessError } 2300005 - Failed to resolve the proxy name. + * @throws { BusinessError } 2300006 - Failed to resolve the host name. + * @throws { BusinessError } 2300007 - Failed to connect to the server. + * @throws { BusinessError } 2300008 - Invalid server response. + * @throws { BusinessError } 2300009 - Access to the remote resource denied. + * @throws { BusinessError } 2300016 - Error in the HTTP2 framing layer. + * @throws { BusinessError } 2300018 - Transferred a partial file. + * @throws { BusinessError } 2300023 - Failed to write the received data to the disk or application. + * @throws { BusinessError } 2300025 - Upload failed. + * @throws { BusinessError } 2300026 - Failed to open or read local data from the file or application. + * @throws { BusinessError } 2300027 - Out of memory. + * @throws { BusinessError } 2300028 - Operation timeout. + * @throws { BusinessError } 2300047 - The number of redirections reaches the maximum allowed. + * @throws { BusinessError } 2300052 - The server returned nothing (no header or data). + * @throws { BusinessError } 2300055 - Failed to send data to the peer. + * @throws { BusinessError } 2300056 - Failed to receive data from the peer. + * @throws { BusinessError } 2300058 - Local SSL certificate error. + * @throws { BusinessError } 2300059 - The specified SSL cipher cannot be used. + * @throws { BusinessError } 2300060 - Invalid SSL peer certificate or SSH remote key. + * @throws { BusinessError } 2300061 - Invalid HTTP encoding format. + * @throws { BusinessError } 2300063 - Maximum file size exceeded. + * @throws { BusinessError } 2300070 - Remote disk full. + * @throws { BusinessError } 2300073 - Remote file already exists. + * @throws { BusinessError } 2300077 - The SSL CA certificate does not exist or is inaccessible. + * @throws { BusinessError } 2300078 - Remote file not found. + * @throws { BusinessError } 2300094 - Authentication error. + * @throws { BusinessError } 2300997 - Cleartext traffic not permitted. + * @throws { BusinessError } 2300998 - It is not allowed to access this domain. + * @throws { BusinessError } 2300999 - Internal error. + * @syscap SystemCapability.Communication.NetStack + * @since 20 + * @arkts 1.2 + */ + requestInStreamWithOptionsReturnsPromise(url: string, options?: HttpRequestOptions): Promise; + + /** + * @arkts 1.2 + */ + overload requestInStream { + requestInStreamWithCallback, + requestInStreamWithOptionCallback, + requestInStreamWithOptionsReturnsPromise }; + /** * Destroys an HTTP request. * @syscap SystemCapability.Communication.NetStack @@ -4379,8 +4519,7 @@ declare namespace http { * @syscap SystemCapability.Communication.NetStack * @crossplatform * @atomicservice - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ delete(callback: AsyncCallback): void; @@ -4403,10 +4542,32 @@ declare namespace http { * @syscap SystemCapability.Communication.NetStack * @crossplatform * @atomicservice - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ delete(): Promise; + + /** + * Disables a cache and deletes the data in it. + * @param { AsyncCallback } callback - the callback of delete. + * @syscap SystemCapability.Communication.NetStack + * @since 20 + * @arkts 1.2 + */ + deleteWithCallback(callback: AsyncCallback): void; + + /** + * Disables a cache and deletes the data in it. + * @returns { Promise } The promise returned by the delete. + * @syscap SystemCapability.Communication.NetStack + * @since 20 + * @arkts 1.2 + */ + deleteReturnsPromise(): Promise; + + /** + * @arkts 1.2 + */ + overload delete { deleteWithCallback, deleteReturnsPromise }; } } diff --git a/api/@ohos.net.sharing.d.ts b/api/@ohos.net.sharing.d.ts index 01c43106da124ddae3e6529a441bf0ebf0bf51fb..a95ebbe1a194160319e650c058ecbc6cd4785b1b 100644 --- a/api/@ohos.net.sharing.d.ts +++ b/api/@ohos.net.sharing.d.ts @@ -50,8 +50,7 @@ declare namespace sharing { * @throws { BusinessError } 2202011 - Cannot get network sharing configuration. * @syscap SystemCapability.Communication.NetManager.NetSharing * @systemapi Hide this for inner system use. - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ function isSharingSupported(callback: AsyncCallback): void; @@ -66,11 +65,48 @@ declare namespace sharing { * @throws { BusinessError } 2202011 - Cannot get network sharing configuration. * @syscap SystemCapability.Communication.NetManager.NetSharing * @systemapi Hide this for inner system use. - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ function isSharingSupported(): Promise; + /** + * Checks whether this device allows for network sharing. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @param { AsyncCallback } callback - Returns {@code true} indicating network sharing is supported; + * returns {@code false} otherwise. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @throws { BusinessError } 2200002 - Failed to connect to the service. + * @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. + * @since 20 + * @arkts 1.2 + */ + function isSharingSupportedWithCallback(callback: AsyncCallback): void; + + /** + * Checks whether this device allows for network sharing. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @throws { BusinessError } 2200002 - Failed to connect to the service. + * @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. + * @since 20 + * @arkts 1.2 + */ + function isSharingSupportedReturnsPromise(): Promise; + + /** + * @arkts 1.2 + */ + overload isSharingSupported { isSharingSupportedWithCallback, isSharingSupportedReturnsPromise }; + /** * Return the global network sharing state. * @permission ohos.permission.CONNECTIVITY_INTERNAL @@ -83,8 +119,7 @@ declare namespace sharing { * @throws { BusinessError } 2202011 - Cannot get network sharing configuration. * @syscap SystemCapability.Communication.NetManager.NetSharing * @systemapi Hide this for inner system use. - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ function isSharing(callback: AsyncCallback): void; @@ -99,11 +134,48 @@ declare namespace sharing { * @throws { BusinessError } 2202011 - Cannot get network sharing configuration. * @syscap SystemCapability.Communication.NetManager.NetSharing * @systemapi Hide this for inner system use. - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ function isSharing(): Promise; + /** + * Return the global network sharing state. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @param { AsyncCallback } callback - Returns {@code true} indicating network sharing is running; + * returns {@code false} otherwise. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @throws { BusinessError } 2200002 - Failed to connect to the service. + * @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. + * @since 20 + * @arkts 1.2 + */ + function isSharingWithCallback(callback: AsyncCallback): void; + + /** + * Return the global network sharing state. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @throws { BusinessError } 2200002 - Failed to connect to the service. + * @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. + * @since 20 + * @arkts 1.2 + */ + function isSharingReturnsPromise(): Promise; + + /** + * @arkts 1.2 + */ + overload isSharing { isSharingWithCallback, isSharingReturnsPromise }; + /** * Start network sharing for given type. * @permission ohos.permission.CONNECTIVITY_INTERNAL @@ -122,8 +194,7 @@ declare namespace sharing { * @throws { BusinessError } 2202011 - Cannot get network sharing configuration. * @syscap SystemCapability.Communication.NetManager.NetSharing * @systemapi Hide this for inner system use. - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ function startSharing(type: SharingIfaceType, callback: AsyncCallback): void; @@ -145,11 +216,61 @@ declare namespace sharing { * @throws { BusinessError } 2202011 - Cannot get network sharing configuration. * @syscap SystemCapability.Communication.NetManager.NetSharing * @systemapi Hide this for inner system use. - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ function startSharing(type: SharingIfaceType): Promise; + /** + * Start network sharing for given type. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @param { SharingIfaceType } type - Enumeration of shareable interface types. + * @param { AsyncCallback } callback - the callback of startSharing. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 2200001 - Invalid parameter value. + * @throws { BusinessError } 2200002 - Failed to connect to the service. + * @throws { BusinessError } 2200003 - System internal error. + * @throws { BusinessError } 2202004 - Try to share an unavailable iface. + * @throws { BusinessError } 2202005 - WiFi sharing failed. + * @throws { BusinessError } 2202006 - Bluetooth sharing failed. + * @throws { BusinessError } 2202009 - Failed to enable forwarding for network sharing. + * @throws { BusinessError } 2202011 - Cannot get network sharing configuration. + * @syscap SystemCapability.Communication.NetManager.NetSharing + * @systemapi Hide this for inner system use. + * @since 20 + * @arkts 1.2 + */ + function startSharingWithCallback(type: SharingIfaceType, callback: AsyncCallback): void; + + /** + * Start network sharing for given type. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @param { SharingIfaceType } type - Enumeration of shareable interface types. + * @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. + * @throws { BusinessError } 2200001 - Invalid parameter value. + * @throws { BusinessError } 2200002 - Failed to connect to the service. + * @throws { BusinessError } 2200003 - System internal error. + * @throws { BusinessError } 2202004 - Try to share an unavailable iface. + * @throws { BusinessError } 2202005 - WiFi sharing failed. + * @throws { BusinessError } 2202006 - Bluetooth sharing failed. + * @throws { BusinessError } 2202009 - Failed to enable forwarding for network sharing. + * @throws { BusinessError } 2202011 - Cannot get network sharing configuration. + * @syscap SystemCapability.Communication.NetManager.NetSharing + * @systemapi Hide this for inner system use. + * @since 20 + * @arkts 1.2 + */ + function startSharingReturnsPromise(type: SharingIfaceType): Promise; + + /** + * @arkts 1.2 + */ + overload startSharing { startSharingWithCallback, startSharingReturnsPromise }; + /** * Stop network sharing for given type. * @permission ohos.permission.CONNECTIVITY_INTERNAL @@ -167,8 +288,7 @@ declare namespace sharing { * @throws { BusinessError } 2202011 - Cannot get network sharing configuration. * @syscap SystemCapability.Communication.NetManager.NetSharing * @systemapi Hide this for inner system use. - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ function stopSharing(type: SharingIfaceType, callback: AsyncCallback): void; @@ -189,11 +309,59 @@ declare namespace sharing { * @throws { BusinessError } 2202011 - Cannot get network sharing configuration. * @syscap SystemCapability.Communication.NetManager.NetSharing * @systemapi Hide this for inner system use. - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ function stopSharing(type: SharingIfaceType): Promise; + /** + * Stop network sharing for given type. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @param { SharingIfaceType } type - Enumeration of shareable interface types. + * @param { AsyncCallback } callback - the callback of startSharing. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 2200001 - Invalid parameter value. + * @throws { BusinessError } 2200002 - Failed to connect to the service. + * @throws { BusinessError } 2200003 - System internal error. + * @throws { BusinessError } 2202004 - Try to share an unavailable iface. + * @throws { BusinessError } 2202005 - WiFi sharing failed. + * @throws { BusinessError } 2202006 - Bluetooth sharing failed. + * @throws { BusinessError } 2202011 - Cannot get network sharing configuration. + * @syscap SystemCapability.Communication.NetManager.NetSharing + * @systemapi Hide this for inner system use. + * @since 20 + * @arkts 1.2 + */ + function stopSharingWithCallback(type: SharingIfaceType, callback: AsyncCallback): void; + + /** + * Stop network sharing for given type. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @param { SharingIfaceType } type - Enumeration of shareable interface types. + * @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. + * @throws { BusinessError } 2200001 - Invalid parameter value. + * @throws { BusinessError } 2200002 - Failed to connect to the service. + * @throws { BusinessError } 2200003 - System internal error. + * @throws { BusinessError } 2202004 - Try to share an unavailable iface. + * @throws { BusinessError } 2202005 - WiFi sharing failed. + * @throws { BusinessError } 2202006 - Bluetooth sharing failed. + * @throws { BusinessError } 2202011 - Cannot get network sharing configuration. + * @syscap SystemCapability.Communication.NetManager.NetSharing + * @systemapi Hide this for inner system use. + * @since 20 + * @arkts 1.2 + */ + function stopSharingReturnsPromise(type: SharingIfaceType): Promise; + + /** + * @arkts 1.2 + */ + overload stopSharing { stopSharingWithCallback, stopSharingReturnsPromise }; + /** * Obtains the number of downlink data bytes of the sharing network interfaces. * @permission ohos.permission.CONNECTIVITY_INTERNAL @@ -205,8 +373,7 @@ declare namespace sharing { * @throws { BusinessError } 2200003 - System internal error. * @syscap SystemCapability.Communication.NetManager.NetSharing * @systemapi Hide this for inner system use. - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ function getStatsRxBytes(callback: AsyncCallback): void; @@ -220,11 +387,47 @@ declare namespace sharing { * @throws { BusinessError } 2200003 - System internal error. * @syscap SystemCapability.Communication.NetManager.NetSharing * @systemapi Hide this for inner system use. - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ function getStatsRxBytes(): Promise; + /** + * 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. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 2200002 - Failed to connect to the service. + * @throws { BusinessError } 2200003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.NetSharing + * @systemapi Hide this for inner system use. + * @since 20 + * @arkts 1.2 + */ + function getStatsRxBytesWithCallback(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. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @throws { BusinessError } 2200002 - Failed to connect to the service. + * @throws { BusinessError } 2200003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.NetSharing + * @systemapi Hide this for inner system use. + * @since 20 + * @arkts 1.2 + */ + function getStatsRxBytesReturnsPromise(): Promise; + + /** + * @arkts 1.2 + */ + overload getStatsRxBytes { getStatsRxBytesWithCallback, getStatsRxBytesReturnsPromise }; + /** * Obtains the number of uplink data bytes of the sharing network interfaces. * @permission ohos.permission.CONNECTIVITY_INTERNAL @@ -236,8 +439,7 @@ declare namespace sharing { * @throws { BusinessError } 2200003 - System internal error. * @syscap SystemCapability.Communication.NetManager.NetSharing * @systemapi Hide this for inner system use. - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ function getStatsTxBytes(callback: AsyncCallback): void; @@ -251,11 +453,47 @@ declare namespace sharing { * @throws { BusinessError } 2200003 - System internal error. * @syscap SystemCapability.Communication.NetManager.NetSharing * @systemapi Hide this for inner system use. - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ function getStatsTxBytes(): 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. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 2200002 - Failed to connect to the service. + * @throws { BusinessError } 2200003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.NetSharing + * @systemapi Hide this for inner system use. + * @since 20 + * @arkts 1.2 + */ + function getStatsTxBytesWithCallback(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. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @throws { BusinessError } 2200002 - Failed to connect to the service. + * @throws { BusinessError } 2200003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.NetSharing + * @systemapi Hide this for inner system use. + * @since 20 + * @arkts 1.2 + */ + function getStatsTxBytesReturnsPromise(): Promise; + + /** + * @arkts 1.2 + */ + overload getStatsTxBytes { getStatsTxBytesWithCallback, getStatsTxBytesReturnsPromise }; + /** * Obtains the number of total data bytes of the sharing network interfaces. * @permission ohos.permission.CONNECTIVITY_INTERNAL @@ -267,8 +505,7 @@ declare namespace sharing { * @throws { BusinessError } 2200003 - System internal error. * @syscap SystemCapability.Communication.NetManager.NetSharing * @systemapi Hide this for inner system use. - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ function getStatsTotalBytes(callback: AsyncCallback): void; @@ -282,11 +519,46 @@ declare namespace sharing { * @throws { BusinessError } 2200003 - System internal error. * @syscap SystemCapability.Communication.NetManager.NetSharing * @systemapi Hide this for inner system use. - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ function getStatsTotalBytes(): 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. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 2200002 - Failed to connect to the service. + * @throws { BusinessError } 2200003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.NetSharing + * @systemapi Hide this for inner system use. + * @since 20 + * @arkts 1.2 + */ + function getStatsTotalBytesWithCallback(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. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @throws { BusinessError } 2200002 - Failed to connect to the service. + * @throws { BusinessError } 2200003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.NetSharing + * @systemapi Hide this for inner system use. + * @since 20 + * @arkts 1.2 + */ + function getStatsTotalBytesReturnsPromise(): Promise; + + /** + * @arkts 1.2 + */ + overload getStatsTotalBytes { getStatsTotalBytesWithCallback, getStatsTotalBytesReturnsPromise }; + /** * Obtains the names of interfaces in each sharing state. * @permission ohos.permission.CONNECTIVITY_INTERNAL @@ -300,8 +572,7 @@ declare namespace sharing { * @throws { BusinessError } 2200003 - System internal error. * @syscap SystemCapability.Communication.NetManager.NetSharing * @systemapi Hide this for inner system use. - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ function getSharingIfaces(state: SharingIfaceState, callback: AsyncCallback>): void; @@ -318,11 +589,51 @@ declare namespace sharing { * @throws { BusinessError } 2200003 - System internal error. * @syscap SystemCapability.Communication.NetManager.NetSharing * @systemapi Hide this for inner system use. - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ function getSharingIfaces(state: SharingIfaceState): Promise>; + /** + * Obtains the names of interfaces in each sharing state. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @param { SharingIfaceState } state - Is the network sharing state. + * @param { AsyncCallback> } callback - Returns an array of interface names that meet this status. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 2200001 - Invalid parameter value. + * @throws { BusinessError } 2200002 - Failed to connect to the service. + * @throws { BusinessError } 2200003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.NetSharing + * @systemapi Hide this for inner system use. + * @since 20 + * @arkts 1.2 + */ + function getSharingIfacesWithCallback(state: SharingIfaceState, callback: AsyncCallback>): void; + + /** + * Obtains the names of interfaces in each sharing state. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @param { SharingIfaceState } state - Is the network sharing state. + * @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. + * @throws { BusinessError } 2200001 - Invalid parameter value. + * @throws { BusinessError } 2200002 - Failed to connect to the service. + * @throws { BusinessError } 2200003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.NetSharing + * @systemapi Hide this for inner system use. + * @since 20 + * @arkts 1.2 + */ + function getSharingIfacesReturnsPromise(state: SharingIfaceState): Promise>; + + /** + * @arkts 1.2 + */ + overload getSharingIfaces { getSharingIfacesWithCallback, getSharingIfacesReturnsPromise }; + /** * Obtains the network sharing state for given type. * @permission ohos.permission.CONNECTIVITY_INTERNAL @@ -336,8 +647,7 @@ declare namespace sharing { * @throws { BusinessError } 2200003 - System internal error. * @syscap SystemCapability.Communication.NetManager.NetSharing * @systemapi Hide this for inner system use. - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ function getSharingState(type: SharingIfaceType, callback: AsyncCallback): void; @@ -354,11 +664,51 @@ declare namespace sharing { * @throws { BusinessError } 2200003 - System internal error. * @syscap SystemCapability.Communication.NetManager.NetSharing * @systemapi Hide this for inner system use. - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ function getSharingState(type: SharingIfaceType): Promise; + /** + * Obtains the network sharing state for given type. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @param { SharingIfaceType } type - Is the enumeration of shareable interface types. + * @param { AsyncCallback } callback - the callback of getSharingState. {@code SharingIfaceState}. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 2200001 - Invalid parameter value. + * @throws { BusinessError } 2200002 - Failed to connect to the service. + * @throws { BusinessError } 2200003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.NetSharing + * @systemapi Hide this for inner system use. + * @since 20 + * @arkts 1.2 + */ + function getSharingStateWithCallback(type: SharingIfaceType, callback: AsyncCallback): void; + + /** + * Obtains the network sharing state for given type. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @param { SharingIfaceType } type - Is the enumeration of shareable interface types. + * @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. + * @throws { BusinessError } 2200001 - Invalid parameter value. + * @throws { BusinessError } 2200002 - Failed to connect to the service. + * @throws { BusinessError } 2200003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.NetSharing + * @systemapi Hide this for inner system use. + * @since 20 + * @arkts 1.2 + */ + function getSharingStateReturnsPromise(type: SharingIfaceType): Promise; + + /** + * @arkts 1.2 + */ + overload getSharingState { getSharingStateWithCallback, getSharingStateReturnsPromise }; + /** * Get a list regular expression that defines any interface that can support network sharing. * @permission ohos.permission.CONNECTIVITY_INTERNAL @@ -372,8 +722,7 @@ declare namespace sharing { * @throws { BusinessError } 2200003 - System internal error. * @syscap SystemCapability.Communication.NetManager.NetSharing * @systemapi Hide this for inner system use. - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ function getSharableRegexes(type: SharingIfaceType, callback: AsyncCallback>): void; @@ -390,11 +739,51 @@ declare namespace sharing { * @throws { BusinessError } 2200003 - System internal error. * @syscap SystemCapability.Communication.NetManager.NetSharing * @systemapi Hide this for inner system use. - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ function getSharableRegexes(type: SharingIfaceType): Promise>; + /** + * 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. + * @param { AsyncCallback> } callback - the callback of getSharableRegexes. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 2200001 - Invalid parameter value. + * @throws { BusinessError } 2200002 - Failed to connect to the service. + * @throws { BusinessError } 2200003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.NetSharing + * @systemapi Hide this for inner system use. + * @since 20 + * @arkts 1.2 + */ + function getSharableRegexesWtihCallback(type: SharingIfaceType, callback: AsyncCallback>): void; + + /** + * 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. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 2200001 - Invalid parameter value. + * @throws { BusinessError } 2200002 - Failed to connect to the service. + * @throws { BusinessError } 2200003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.NetSharing + * @systemapi Hide this for inner system use. + * @since 20 + * @arkts 1.2 + */ + function getSharableRegexesReturnsPromise(type: SharingIfaceType): Promise>; + + /** + * @arkts 1.2 + */ + overload getSharableRegexes { getSharableRegexesWtihCallback, getSharableRegexesReturnsPromise }; + /** * Register a callback for the global network sharing state change. * @permission ohos.permission.CONNECTIVITY_INTERNAL @@ -405,11 +794,25 @@ declare namespace sharing { * @throws { BusinessError } 401 - Parameter error. * @syscap SystemCapability.Communication.NetManager.NetSharing * @systemapi Hide this for inner system use. - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ function on(type: 'sharingStateChange', callback: Callback): void; + /** + * Register a callback for the global network sharing state change. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @param { 'sharingStateChange' } type - Indicates Event name. + * @param { Callback } callback - the callback function that returns the status. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @throws { BusinessError } 401 - Parameter error. + * @syscap SystemCapability.Communication.NetManager.NetSharing + * @systemapi Hide this for inner system use. + * @since 20 + * @arkts 1.2 + */ + function onSharingStateChangeWithCallback(type: 'sharingStateChange', callback: Callback): void; + /** * Unregister a callback for the global network sharing state change. * @permission ohos.permission.CONNECTIVITY_INTERNAL @@ -420,11 +823,25 @@ declare namespace sharing { * @throws { BusinessError } 401 - Parameter error. * @syscap SystemCapability.Communication.NetManager.NetSharing * @systemapi Hide this for inner system use. - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ function off(type: 'sharingStateChange', callback?: Callback): void; + /** + * Unregister a callback for the global network sharing state change. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @param { 'sharingStateChange' } type Indicates Event name. + * @param { Callback } callback - the callback function that returns the status. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @throws { BusinessError } 401 - Parameter error. + * @syscap SystemCapability.Communication.NetManager.NetSharing + * @systemapi Hide this for inner system use. + * @since 20 + * @arkts 1.2 + */ + function offSharingStateChangeWithOptionalCallback(type: 'sharingStateChange', callback?: Callback): void; + /** * Register a callback for the interface network sharing state change. * @permission ohos.permission.CONNECTIVITY_INTERNAL @@ -447,11 +864,26 @@ declare namespace sharing { * @throws { BusinessError } 401 - Parameter error. * @syscap SystemCapability.Communication.NetManager.NetSharing * @systemapi Hide this for inner system use. - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ function on(type: 'interfaceSharingStateChange', callback: Callback): void; + /** + * Register a callback for the interface network sharing state change. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @param { 'interfaceSharingStateChange' } type - Indicates Event name. + * @param { Callback } callback - the callback function that returns the message. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @throws { BusinessError } 401 - Parameter error. + * @syscap SystemCapability.Communication.NetManager.NetSharing + * @systemapi Hide this for inner system use. + * @since 20 + * @arkts 1.2 + */ + function onInterfaceSharingStateChangeWithCallback( + type: 'interfaceSharingStateChange', callback: Callback): void; + /** * Unregister a callback for the interface network sharing state change. * @permission ohos.permission.CONNECTIVITY_INTERNAL @@ -474,11 +906,26 @@ declare namespace sharing { * @throws { BusinessError } 401 - Parameter error. * @syscap SystemCapability.Communication.NetManager.NetSharing * @systemapi Hide this for inner system use. - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ function off(type: 'interfaceSharingStateChange', callback?: Callback): void; + /** + * Unregister a callback for the interface network sharing state change. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @param { 'interfaceSharingStateChange' } type - Indicates Event name. + * @param { Callback } callback - the callback function that returns the message. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @throws { BusinessError } 401 - Parameter error. + * @syscap SystemCapability.Communication.NetManager.NetSharing + * @systemapi Hide this for inner system use. + * @since 20 + * @arkts 1.2 + */ + function offInterfaceSharingStateChangeWithOptionalCallback( + type: 'interfaceSharingStateChange', callback?: Callback): void; + /** * Register a callback for the sharing upstream network change. * @permission ohos.permission.CONNECTIVITY_INTERNAL @@ -489,11 +936,33 @@ declare namespace sharing { * @throws { BusinessError } 401 - Parameter error. * @syscap SystemCapability.Communication.NetManager.NetSharing * @systemapi Hide this for inner system use. - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ function on(type: 'sharingUpstreamChange', callback: Callback): void; + /** + * Register a callback for the sharing upstream network change. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @param { 'sharingUpstreamChange' } type - Indicates Event name. + * @param { Callback } callback - the callback function that returns the network handle. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @throws { BusinessError } 401 - Parameter error. + * @syscap SystemCapability.Communication.NetManager.NetSharing + * @systemapi Hide this for inner system use. + * @since 20 + * @arkts 1.2 + */ + function onSharingUpstreamChangeWithCallback(type: 'sharingUpstreamChange', callback: Callback): void; + + /** + * @arkts 1.2 + */ + overload on { + onSharingStateChangeWithCallback, + onInterfaceSharingStateChangeWithCallback, + onSharingUpstreamChangeWithCallback }; + /** * Unregister a callback for the sharing upstream network change. * @permission ohos.permission.CONNECTIVITY_INTERNAL @@ -504,11 +973,34 @@ declare namespace sharing { * @throws { BusinessError } 401 - Parameter error. * @syscap SystemCapability.Communication.NetManager.NetSharing * @systemapi Hide this for inner system use. - * @since arkts {'1.1':'9','1.2':'20'} - * @arkts 1.1&1.2 + * @since 9 */ function off(type: 'sharingUpstreamChange', callback?: Callback): void; + /** + * Unregister a callback for the sharing upstream network change. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @param { 'sharingUpstreamChange' } type - Indicates Event name. + * @param { Callback } callback - the callback function that returns the network handle. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @throws { BusinessError } 401 - Parameter error. + * @syscap SystemCapability.Communication.NetManager.NetSharing + * @systemapi Hide this for inner system use. + * @since 20 + * @arkts 1.2 + */ + function offSharingUpstreamChangeWithOptionalCallback( + type: 'sharingUpstreamChange', callback?: Callback): void; + + /** + * @arkts 1.2 + */ + overload off { + offSharingStateChangeWithOptionalCallback, + offInterfaceSharingStateChangeWithOptionalCallback, + offSharingUpstreamChangeWithOptionalCallback }; + /** * Enumerates the network sharing states of an NIC. * @enum {int} diff --git a/api/@ohos.net.statistics.d.ts b/api/@ohos.net.statistics.d.ts index 84fed33d04044631d44acc2b8085fbbfac8e201b..18798b9d738fe59f170583cf6e7812c6e74fe3fd 100644 --- a/api/@ohos.net.statistics.d.ts +++ b/api/@ohos.net.statistics.d.ts @@ -55,8 +55,7 @@ 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 arkts {'1.1':'10','1.2':'20'} - * @arkts 1.1&1.2 + * @since 10 */ function getIfaceRxBytes(nic: string, callback: AsyncCallback): void; @@ -71,11 +70,47 @@ 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 arkts {'1.1':'10','1.2':'20'} - * @arkts 1.1&1.2 + * @since 10 */ function getIfaceRxBytes(nic: string): Promise; + /** + * 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. + * @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. + * @throws { BusinessError } 2103012 - Failed to obtain the NIC name. + * @syscap SystemCapability.Communication.NetManager.Core + * @since 20 + * @arkts 1.2 + */ + function getIfaceRxBytesWithCallback(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. + * @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. + * @throws { BusinessError } 2103012 - Failed to obtain the NIC name. + * @syscap SystemCapability.Communication.NetManager.Core + * @since 20 + * @arkts 1.2 + */ + function getIfaceRxBytesReturnsPromise(nic: string): Promise; + + /** + * @arkts 1.2 + */ + overload getIfaceRxBytes { getIfaceRxBytesWithCallback, getIfaceRxBytesReturnsPromise }; + /** * Queries the data traffic (including all TCP and UDP data packets) sent through a specified NIC. * @param { string } nic - Network interface card. @@ -87,8 +122,7 @@ 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 arkts {'1.1':'10','1.2':'20'} - * @arkts 1.1&1.2 + * @since 10 */ function getIfaceTxBytes(nic: string, callback: AsyncCallback): void; @@ -103,11 +137,47 @@ 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 arkts {'1.1':'10','1.2':'20'} - * @arkts 1.1&1.2 + * @since 10 */ function getIfaceTxBytes(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. + * @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. + * @throws { BusinessError } 2103012 - Failed to obtain the NIC name. + * @syscap SystemCapability.Communication.NetManager.Core + * @since 20 + * @arkts 1.2 + */ + function getIfaceTxBytesWithCallback(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. + * @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. + * @throws { BusinessError } 2103012 - Failed to obtain the NIC name. + * @syscap SystemCapability.Communication.NetManager.Core + * @since 20 + * @arkts 1.2 + */ + function getIfaceTxBytesReturnsPromise(nic: string): Promise; + + /** + * @arkts 1.2 + */ + overload getIfaceTxBytes { getIfaceTxBytesWithCallback, getIfaceTxBytesReturnsPromise }; + /** * 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. @@ -117,8 +187,7 @@ 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 arkts {'1.1':'10','1.2':'20'} - * @arkts 1.1&1.2 + * @since 10 */ function getCellularRxBytes(callback: AsyncCallback): void; @@ -131,11 +200,43 @@ 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 arkts {'1.1':'10','1.2':'20'} - * @arkts 1.1&1.2 + * @since 10 */ function getCellularRxBytes(): 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. + * @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 20 + * @arkts 1.2 + */ + function getCellularRxBytesWithCallback(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. + * @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 20 + * @arkts 1.2 + */ + function getCellularRxBytesReturnsPromise(): Promise; + + /** + * @arkts 1.2 + */ + overload getCellularRxBytes { getCellularRxBytesWithCallback, getCellularRxBytesReturnsPromise }; + /** * 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. @@ -145,8 +246,7 @@ 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 arkts {'1.1':'10','1.2':'20'} - * @arkts 1.1&1.2 + * @since 10 */ function getCellularTxBytes(callback: AsyncCallback): void; @@ -159,11 +259,43 @@ 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 arkts {'1.1':'10','1.2':'20'} - * @arkts 1.1&1.2 + * @since 10 */ function getCellularTxBytes(): 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. + * @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 20 + * @arkts 1.2 + */ + function getCellularTxBytesWithCallback(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. + * @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 20 + * @arkts 1.2 + */ + function getCellularTxBytesReturnsPromise(): Promise; + + /** + * @arkts 1.2 + */ + overload getCellularTxBytes { getCellularTxBytesWithCallback, getCellularTxBytesReturnsPromise }; + /** * 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. @@ -183,8 +315,7 @@ declare namespace statistics { * @throws { BusinessError } 2103011 - Failed to create a system map. * @syscap SystemCapability.Communication.NetManager.Core * @atomicservice - * @since arkts {'1.1':'15','1.2':'20'} - * @arkts 1.1&1.2 + * @since 15 */ function getAllRxBytes(callback: AsyncCallback): void; @@ -207,11 +338,41 @@ declare namespace statistics { * @throws { BusinessError } 2103011 - Failed to create a system map. * @syscap SystemCapability.Communication.NetManager.Core * @atomicservice - * @since arkts {'1.1':'15','1.2':'20'} - * @arkts 1.1&1.2 + * @since 15 */ function getAllRxBytes(): 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. + * @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 20 + * @arkts 1.2 + */ + function getAllRxBytesWithCallback(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. + * @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 20 + * @arkts 1.2 + */ + function getAllRxBytesReturnsPromise(): Promise; + + /** + * @arkts 1.2 + */ + overload getAllRxBytes { getAllRxBytesWithCallback, getAllRxBytesReturnsPromise }; + /** * 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. @@ -231,8 +392,7 @@ declare namespace statistics { * @throws { BusinessError } 2103011 - Failed to create a system map. * @syscap SystemCapability.Communication.NetManager.Core * @atomicservice - * @since arkts {'1.1':'15','1.2':'20'} - * @arkts 1.1&1.2 + * @since 15 */ function getAllTxBytes(callback: AsyncCallback): void; @@ -255,11 +415,41 @@ declare namespace statistics { * @throws { BusinessError } 2103011 - Failed to create a system map. * @syscap SystemCapability.Communication.NetManager.Core * @atomicservice - * @since arkts {'1.1':'15','1.2':'20'} - * @arkts 1.1&1.2 + * @since 15 */ function getAllTxBytes(): 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. + * @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 20 + * @arkts 1.2 + */ + function getAllTxBytesWithCallback(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. + * @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 20 + * @arkts 1.2 + */ + function getAllTxBytesReturnsPromise(): Promise; + + /** + * @arkts 1.2 + */ + overload getAllTxBytes { getAllTxBytesWithCallback, getAllTxBytesReturnsPromise }; + /** * Queries the data traffic (including all TCP and UDP data packets) received by a specified application. * @param { int } uid - Indicates the process ID of the application. @@ -270,8 +460,7 @@ declare namespace statistics { * @throws { BusinessError } 2103005 - Failed to read the system map. * @throws { BusinessError } 2103011 - Failed to create a system map. * @syscap SystemCapability.Communication.NetManager.Core - * @since arkts {'1.1':'10','1.2':'20'} - * @arkts 1.1&1.2 + * @since 15 */ function getUidRxBytes(uid: int, callback: AsyncCallback): void; @@ -285,11 +474,45 @@ declare namespace statistics { * @throws { BusinessError } 2103005 - Failed to read the system map. * @throws { BusinessError } 2103011 - Failed to create a system map. * @syscap SystemCapability.Communication.NetManager.Core - * @since arkts {'1.1':'10','1.2':'20'} - * @arkts 1.1&1.2 + * @since 15 */ function getUidRxBytes(uid: int): Promise; + /** + * Queries the data traffic (including all TCP and UDP data packets) received by a 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 20 + * @arkts 1.2 + */ + function getUidRxBytesWithCallback(uid: int, callback: AsyncCallback): void; + + /** + * Queries the data traffic (including all TCP and UDP data packets) received by a specified application. + * @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 20 + * @arkts 1.2 + */ + function getUidRxBytesReturnsPromise(uid: int): Promise; + + /** + * @arkts 1.2 + */ + overload getUidRxBytes { getUidRxBytesWithCallback, getUidRxBytesReturnsPromise }; + /** * Queries the data traffic (including all TCP and UDP data packets) sent by a specified application. * @param { int } uid - Indicates the process ID of the application. @@ -300,8 +523,7 @@ declare namespace statistics { * @throws { BusinessError } 2103005 - Failed to read the system map. * @throws { BusinessError } 2103011 - Failed to create a system map. * @syscap SystemCapability.Communication.NetManager.Core - * @since arkts {'1.1':'10','1.2':'20'} - * @arkts 1.1&1.2 + * @since 15 */ function getUidTxBytes(uid: int, callback: AsyncCallback): void; @@ -315,11 +537,45 @@ declare namespace statistics { * @throws { BusinessError } 2103005 - Failed to read the system map. * @throws { BusinessError } 2103011 - Failed to create a system map. * @syscap SystemCapability.Communication.NetManager.Core - * @since arkts {'1.1':'10','1.2':'20'} - * @arkts 1.1&1.2 + * @since 15 */ function getUidTxBytes(uid: int): Promise; + /** + * Queries the data traffic (including all TCP and UDP data packets) sent by a 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 20 + * @arkts 1.2 + */ + function getUidTxBytesWithCallback(uid: int, callback: AsyncCallback): void; + + /** + * Queries the data traffic (including all TCP and UDP data packets) sent by a specified application. + * @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 20 + * @arkts 1.2 + */ + function getUidTxBytesReturnsPromise(uid: int): Promise; + + /** + * @arkts 1.2 + */ + overload getUidTxBytes { getUidTxBytesWithCallback, getUidTxBytesReturnsPromise }; + /** * Register notifications of network traffic updates. * @permission ohos.permission.GET_NETWORK_STATS @@ -465,8 +721,7 @@ declare namespace statistics { * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ function getSockfdRxBytes(sockfd: int, callback: AsyncCallback): void; @@ -479,11 +734,43 @@ declare namespace statistics { * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ function getSockfdRxBytes(sockfd: int): Promise; + /** + * Queries the data traffic (including all TCP and UDP data packets) received through a 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 20 + * @arkts 1.2 + */ + function getSockfdRxBytesWithCallback(sockfd: int, callback: AsyncCallback): void; + + /** + * Queries the data traffic (including all TCP and UDP data packets) received through a 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 20 + * @arkts 1.2 + */ + function getSockfdRxBytesReturnsPromise(sockfd: int): Promise; + + /** + * @arkts 1.2 + */ + overload getSockfdRxBytes { getSockfdRxBytesWithCallback, getSockfdRxBytesReturnsPromise }; + /** * Queries the data traffic (including all TCP and UDP data packets) sent through a specified sockfd. * @param { int } sockfd - Indicates the file descriptor of the given socket. @@ -493,8 +780,7 @@ declare namespace statistics { * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ function getSockfdTxBytes(sockfd: int, callback: AsyncCallback): void; @@ -507,11 +793,43 @@ declare namespace statistics { * @throws { BusinessError } 2100002 - Failed to connect to the service. * @throws { BusinessError } 2100003 - System internal error. * @syscap SystemCapability.Communication.NetManager.Core - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ function getSockfdTxBytes(sockfd: int): Promise; + /** + * Queries the data traffic (including all TCP and UDP data packets) sent through a 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 20 + * @arkts 1.2 + */ + function getSockfdTxBytesWithCallback(sockfd: int, callback: AsyncCallback): void; + + /** + * Queries the data traffic (including all TCP and UDP data packets) sent through a 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 20 + * @arkts 1.2 + */ + function getSockfdTxBytesReturnsPromise(sockfd: int): Promise; + + /** + * @arkts 1.2 + */ + overload getSockfdTxBytes { getSockfdTxBytesWithCallback, getSockfdTxBytesReturnsPromise }; + /** * Parameters for obtaining detailed information on network interface traffic usage. * @interface IfaceInfo diff --git a/api/@ohos.net.webSocket.d.ts b/api/@ohos.net.webSocket.d.ts index e582a5f2edc446444a307ec222ad33fd60c302cd..d0f5079767ee322584d44221282d3701ab82c87b 100644 --- a/api/@ohos.net.webSocket.d.ts +++ b/api/@ohos.net.webSocket.d.ts @@ -464,8 +464,7 @@ declare namespace webSocket { * @syscap SystemCapability.Communication.NetStack * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ connect(url: string, callback: AsyncCallback): void; @@ -523,8 +522,7 @@ declare namespace webSocket { * @syscap SystemCapability.Communication.NetStack * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ connect(url: string, options: WebSocketRequestOptions, callback: AsyncCallback): void; @@ -582,11 +580,72 @@ declare namespace webSocket { * @syscap SystemCapability.Communication.NetStack * @crossplatform * @atomicservice - * @since arkts {'1.1':'12','1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 */ connect(url: string, options?: WebSocketRequestOptions): Promise; + /** + * Initiates a WebSocket request to establish a WebSocket connection to a given URL. + * @permission ohos.permission.INTERNET + * @param { string } url URL for establishing a WebSocket connection. + * @param { AsyncCallback } callback - the callback of connect. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 2302001 - Websocket url error. + * @throws { BusinessError } 2302002 - Websocket certificate file does not exist. + * @throws { BusinessError } 2302003 - Websocket connection already exists. + * @throws { BusinessError } 2302998 - It is not allowed to access this domain. + * @throws { BusinessError } 2302999 - Internal error. + * @syscap SystemCapability.Communication.NetStack + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.2 + */ + connectWithCallback(url: string, callback: AsyncCallback): void; + + /** + * Initiates a WebSocket request to establish a WebSocket connection to a given URL. + * @permission ohos.permission.INTERNET + * @param { string } url URL for establishing a WebSocket connection. + * @param { WebSocketRequestOptions } options - Optional parameters {@link WebSocketRequestOptions}. + * @param { AsyncCallback } callback - the callback of connect. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 2302001 - Websocket url error. + * @throws { BusinessError } 2302002 - Websocket certificate file does not exist. + * @throws { BusinessError } 2302003 - Websocket connection already exists. + * @throws { BusinessError } 2302998 - It is not allowed to access this domain. + * @throws { BusinessError } 2302999 - Internal error. + * @syscap SystemCapability.Communication.NetStack + * @since 20 + * @arkts 1.2 + */ + connectWithOptionsCallback(url: string, options: WebSocketRequestOptions, callback: AsyncCallback): void; + + /** + * Initiates a WebSocket request to establish a WebSocket connection to a given URL. + * @permission ohos.permission.INTERNET + * @param { string } url URL for establishing a WebSocket connection. + * @param { WebSocketRequestOptions } options - Optional parameters {@link WebSocketRequestOptions}. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2302001 - Websocket url error. + * @throws { BusinessError } 2302002 - Websocket certificate file does not exist. + * @throws { BusinessError } 2302003 - Websocket connection already exists. + * @throws { BusinessError } 2302998 - It is not allowed to access this domain. + * @throws { BusinessError } 2302999 - Internal error. + * @syscap SystemCapability.Communication.NetStack + * @since 20 + * @arkts 1.2 + */ + connectWithOptionsReturnsPromise(url: string, options?: WebSocketRequestOptions): Promise; + + /** + * @arkts 1.2 + */ + overload connect { connectWithCallback, connectWithOptionsCallback, connectWithOptionsReturnsPromise }; + /** * Sends data through a WebSocket connection. * @permission ohos.permission.INTERNET @@ -618,8 +677,7 @@ declare namespace webSocket { * @syscap SystemCapability.Communication.NetStack * @crossplatform * @atomicservice - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ send(data: string | ArrayBuffer, callback: AsyncCallback): void; @@ -654,11 +712,41 @@ declare namespace webSocket { * @syscap SystemCapability.Communication.NetStack * @crossplatform * @atomicservice - * @since arkts {'1.1':'11','1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 */ send(data: string | ArrayBuffer): Promise; + /** + * Sends data through a WebSocket connection. + * @permission ohos.permission.INTERNET + * @param { string | ArrayBuffer } data - Data to send. It can be a string(API 6) or an ArrayBuffer(API 8). + * @param { AsyncCallback } callback - the callback of send. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Parameter error. + * @syscap SystemCapability.Communication.NetStack + * @since 20 + * @arkts 1.2 + */ + sendWithCallback(data: string | ArrayBuffer, callback: AsyncCallback): void; + + /** + * Sends data through a WebSocket connection. + * @permission ohos.permission.INTERNET + * @param { string | ArrayBuffer } data - Data to send. It can be a string(API 6) or an ArrayBuffer(API 8). + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Parameter error. + * @syscap SystemCapability.Communication.NetStack + * @since 20 + * @arkts 1.2 + */ + sendReturnsPromise(data: string | ArrayBuffer): Promise; + + /** + * @arkts 1.2 + */ + overload send { sendWithCallback, sendReturnsPromise }; + /** * Closes a WebSocket connection. * @permission ohos.permission.INTERNET diff --git a/api/@ohos.telephony.data.d.ts b/api/@ohos.telephony.data.d.ts index dfb0635eba4753b5aa6a0709259985dd9d1678ae..5e7023c1596b92bec68caea91402f8833b1bec92 100644 --- a/api/@ohos.telephony.data.d.ts +++ b/api/@ohos.telephony.data.d.ts @@ -136,8 +136,7 @@ declare namespace data { *
  • {@code DataConnectState#DATA_STATE_SUSPENDED} * * @syscap SystemCapability.Telephony.CellularData - * @since arkts {'1.1':'7','1.2':'20'} - * @arkts 1.1&1.2 + * @since 7 */ function getCellularDataState(callback: AsyncCallback): void; @@ -153,11 +152,50 @@ declare namespace data { *
  • {@code DataConnectState#DATA_STATE_SUSPENDED} * * @syscap SystemCapability.Telephony.CellularData - * @since arkts {'1.1':'7','1.2':'20'} - * @arkts 1.1&1.2 + * @since 7 */ function getCellularDataState(): Promise; + /** + * Obtain the connection state of the PS domain. + * + * @param { AsyncCallback } callback - Indicates the callback for getting the connection state, + * which can be any of the following: + *
      + *
    • {@code DataConnectState#DATA_STATE_UNKNOWN} + *
    • {@code DataConnectState#DATA_STATE_DISCONNECTED} + *
    • {@code DataConnectState#DATA_STATE_CONNECTING} + *
    • {@code DataConnectState#DATA_STATE_CONNECTED} + *
    • {@code DataConnectState#DATA_STATE_SUSPENDED} + *
    + * @syscap SystemCapability.Telephony.CellularData + * @since 20 + * @arkts 1.2 + */ + function getCellularDataStateWithCallback(callback: AsyncCallback): void; + + /** + * Obtain the connection state of the PS domain. + * + * @returns { Promise } Returns the connection state, which can be any of the following: + *
      + *
    • {@code DataConnectState#DATA_STATE_UNKNOWN} + *
    • {@code DataConnectState#DATA_STATE_DISCONNECTED} + *
    • {@code DataConnectState#DATA_STATE_CONNECTING} + *
    • {@code DataConnectState#DATA_STATE_CONNECTED} + *
    • {@code DataConnectState#DATA_STATE_SUSPENDED} + *
    + * @syscap SystemCapability.Telephony.CellularData + * @since 20 + * @arkts 1.2 + */ + function getCellularDataStateReturnsPromise(): Promise; + + /** + * @arkts 1.2 + */ + overload getCellularDataState { getCellularDataStateWithCallback, getCellularDataStateReturnsPromise }; + /** * Check whether cellular data services are enabled. * @@ -172,8 +210,7 @@ declare namespace data { * @throws { BusinessError } 8300003 - System internal error. * @throws { BusinessError } 8300999 - Internal error. * @syscap SystemCapability.Telephony.CellularData - * @since arkts {'1.1':'7','1.2':'20'} - * @arkts 1.1&1.2 + * @since 7 */ function isCellularDataEnabled(callback: AsyncCallback): void; @@ -188,11 +225,50 @@ declare namespace data { * @throws { BusinessError } 8300003 - System internal error. * @throws { BusinessError } 8300999 - Internal error. * @syscap SystemCapability.Telephony.CellularData - * @since arkts {'1.1':'7','1.2':'20'} - * @arkts 1.1&1.2 + * @since 7 */ function isCellularDataEnabled(): Promise; + /** + * Check whether cellular data services are enabled. + * + * @permission ohos.permission.GET_NETWORK_INFO + * @param { AsyncCallback } callback - Indicates the callback for checking whether cellular data services + * are enabled. Returns {@code true} if cellular data services are enabled; returns {@code false} otherwise. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * @throws { BusinessError } 8300001 - Invalid parameter value. + * @throws { BusinessError } 8300002 - Service connection failed. + * @throws { BusinessError } 8300003 - System internal error. + * @throws { BusinessError } 8300999 - Internal error. + * @syscap SystemCapability.Telephony.CellularData + * @since 20 + * @arkts 1.2 + */ + function isCellularDataEnabledWithCallback(callback: AsyncCallback): void; + + /** + * Check whether cellular data services are enabled. + * + * @permission ohos.permission.GET_NETWORK_INFO + * @returns { Promise } Returns {@code true} if cellular data services are enabled. + * Returns {@code false} otherwise. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 8300002 - Service connection failed. + * @throws { BusinessError } 8300003 - System internal error. + * @throws { BusinessError } 8300999 - Internal error. + * @syscap SystemCapability.Telephony.CellularData + * @since 20 + * @arkts 1.2 + */ + function isCellularDataEnabledReturnsPromise(): Promise; + + /** + * @arkts 1.2 + */ + overload isCellularDataEnabled { isCellularDataEnabledWithCallback, isCellularDataEnabledReturnsPromise }; + /** * Check whether cellular data services are enabled. * @@ -223,8 +299,7 @@ declare namespace data { * @throws { BusinessError } 8300999 - Internal error. * @syscap SystemCapability.Telephony.CellularData * @systemapi Hide this for inner system use. - * @since arkts {'1.1':'7','1.2':'20'} - * @arkts 1.1&1.2 + * @since 7 */ function enableCellularData(callback: AsyncCallback): void; @@ -240,11 +315,52 @@ declare namespace data { * @throws { BusinessError } 8300999 - Internal error. * @syscap SystemCapability.Telephony.CellularData * @systemapi Hide this for inner system use. - * @since arkts {'1.1':'7','1.2':'20'} - * @arkts 1.1&1.2 + * @since 7 */ function enableCellularData(): Promise; + /** + * Enable cellular data services. + * + * @permission ohos.permission.SET_TELEPHONY_STATE + * @param { AsyncCallback } callback - The callback of enableCellularData. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * @throws { BusinessError } 8300001 - Invalid parameter value. + * @throws { BusinessError } 8300002 - Service connection failed. + * @throws { BusinessError } 8300003 - System internal error. + * @throws { BusinessError } 8300999 - Internal error. + * @syscap SystemCapability.Telephony.CellularData + * @systemapi Hide this for inner system use. + * @since 20 + * @arkts 1.2 + */ + function enableCellularDataWithCallback(callback: AsyncCallback): void; + + /** + * Enable cellular data services. + * + * @permission ohos.permission.SET_TELEPHONY_STATE + * @returns { Promise } The promise returned by the enableCellularData. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @throws { BusinessError } 8300002 - Service connection failed. + * @throws { BusinessError } 8300003 - System internal error. + * @throws { BusinessError } 8300999 - Internal error. + * @syscap SystemCapability.Telephony.CellularData + * @systemapi Hide this for inner system use. + * @since 20 + * @arkts 1.2 + */ + function enableCellularDataReturnsPromise(): Promise; + + /** + * @arkts 1.2 + */ + overload enableCellularData { enableCellularDataWithCallback, enableCellularDataReturnsPromise }; + /** * Disable cellular data services. * @@ -260,8 +376,7 @@ declare namespace data { * @throws { BusinessError } 8300999 - Internal error. * @syscap SystemCapability.Telephony.CellularData * @systemapi Hide this for inner system use. - * @since arkts {'1.1':'7','1.2':'20'} - * @arkts 1.1&1.2 + * @since 7 */ function disableCellularData(callback: AsyncCallback): void; @@ -277,11 +392,52 @@ declare namespace data { * @throws { BusinessError } 8300999 - Internal error. * @syscap SystemCapability.Telephony.CellularData * @systemapi Hide this for inner system use. - * @since arkts {'1.1':'7','1.2':'20'} - * @arkts 1.1&1.2 + * @since 7 */ function disableCellularData(): Promise; + /** + * Disable cellular data services. + * + * @permission ohos.permission.SET_TELEPHONY_STATE + * @param { AsyncCallback } callback - The callback of disableCellularData. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * @throws { BusinessError } 8300001 - Invalid parameter value. + * @throws { BusinessError } 8300002 - Service connection failed. + * @throws { BusinessError } 8300003 - System internal error. + * @throws { BusinessError } 8300999 - Internal error. + * @syscap SystemCapability.Telephony.CellularData + * @systemapi Hide this for inner system use. + * @since 20 + * @arkts 1.2 + */ + function disableCellularDataWithCallback(callback: AsyncCallback): void; + + /** + * Disable cellular data services. + * + * @permission ohos.permission.SET_TELEPHONY_STATE + * @returns { Promise } The promise returned by the disableCellularData. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @throws { BusinessError } 8300002 - Service connection failed. + * @throws { BusinessError } 8300003 - System internal error. + * @throws { BusinessError } 8300999 - Internal error. + * @syscap SystemCapability.Telephony.CellularData + * @systemapi Hide this for inner system use. + * @since 20 + * @arkts 1.2 + */ + function disableCellularDataReturnsPromise(): Promise; + + /** + * @arkts 1.2 + */ + overload disableCellularData { disableCellularDataWithCallback, disableCellularDataReturnsPromise }; + /** * Check whether roaming is enabled for cellular data services. *