From 4207140dbdab3782aceca34b1794ef4fb5c86072 Mon Sep 17 00:00:00 2001 From: pjie131 Date: Mon, 4 Aug 2025 15:51:13 +0800 Subject: [PATCH] Added netPacFileUrlChange JS callback and implemented PAC JS interface Signed-off-by: pjie131 --- api/@ohos.net.connection.d.ts | 44 +++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/api/@ohos.net.connection.d.ts b/api/@ohos.net.connection.d.ts index f22c9e7ee0..5b5d3497ab 100644 --- a/api/@ohos.net.connection.d.ts +++ b/api/@ohos.net.connection.d.ts @@ -897,6 +897,39 @@ declare namespace connection { */ function getPacUrl(): string; + /** + * Set the URL {@link pacFileUrl} of the current PAC script. + * To invoke this method, you must have the {@code ohos.permission.SET_PAC_URL} permission. + * @permission ohos.permission.SET_PAC_URL + * @param { string } pacFileUrl - Indicates the URL of the current PAC script. + * @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 + */ + function setPacFileUrl(pacFileUrl: string): void; + + /** + * Obtain the URL {@link pacFileUrl} of the current PAC script. + * @returns { string } Returns the URL of the current PAC script or empty string if there is no PAC script. + * @throws { BusinessError } 2100002 - Failed to connect to the service. + * @throws { BusinessError } 2100003 - System internal error. + * @syscap SystemCapability.Communication.NetManager.Core + * @since 20 + */ + function getPacFileUrl(): string; + + /** + * find pac proxy info for the url + * @param url the url + * @returns { string } Returns the proxy infomation. + * @syscap SystemCapability.Communication.NetManager.Core + * @since 20 + */ + function findProxyForUrl(url: string): string; + /** * Add a custom {@link host} and corresponding {@link ip} mapping for current application. * @permission ohos.permission.INTERNET @@ -1108,6 +1141,17 @@ declare namespace connection { */ on(type: 'netAvailable', callback: Callback): void; + /** + * Registers a listener for pac file url change event. + * @param { 'netPacFileUrlChange' } type - Indicates Event name. + * @param { Callback } callback - the callback used to return the result. + * @syscap SystemCapability.Communication.NetManager.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + on(type: 'netPacFileUrlChange', callback: Callback): void; + /** * Registers a listener for netBlockStatusChange events. * @param { 'netBlockStatusChange' } type - Indicates Event name. -- Gitee