From fb965f7415c7b5f1338defe10d5ca69e74a0fc6c Mon Sep 17 00:00:00 2001 From: jxw Date: Fri, 15 Aug 2025 08:18:58 +0000 Subject: [PATCH 1/3] update api/@ohos.net.connection.d.ts. Signed-off-by: jxw --- api/@ohos.net.connection.d.ts | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/api/@ohos.net.connection.d.ts b/api/@ohos.net.connection.d.ts index f22c9e7ee0..a4d8690cf1 100644 --- a/api/@ohos.net.connection.d.ts +++ b/api/@ohos.net.connection.d.ts @@ -897,6 +897,37 @@ declare namespace connection { */ function getPacUrl(): string; + /** + * Set the URL {@link pacFileUrl} of the current PAC script. + * Proxy information can be obtained through parsing the script address. + * 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 } 2100002 - Failed to connect to the service. + * @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. + * @syscap SystemCapability.Communication.NetManager.Core + * @since 20 + */ + function getPacFileUrl(): string; + + /** + * find pac proxy info for the url + * @param { string } 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 -- Gitee From f7c5d537fec84c73b8a5ebbc9ea376bc5ec4fb1e Mon Sep 17 00:00:00 2001 From: jxw Date: Fri, 15 Aug 2025 08:32:43 +0000 Subject: [PATCH 2/3] update api/@ohos.net.connection.d.ts. Signed-off-by: jxw --- api/@ohos.net.connection.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/@ohos.net.connection.d.ts b/api/@ohos.net.connection.d.ts index a4d8690cf1..8d08e3b645 100644 --- a/api/@ohos.net.connection.d.ts +++ b/api/@ohos.net.connection.d.ts @@ -897,7 +897,7 @@ declare namespace connection { */ function getPacUrl(): string; - /** + /** * Set the URL {@link pacFileUrl} of the current PAC script. * Proxy information can be obtained through parsing the script address. * To invoke this method, you must have the {@code ohos.permission.SET_PAC_URL} permission. -- Gitee From fdc6c1eb6cf0c564155fe9d1abda3923e5c7660b Mon Sep 17 00:00:00 2001 From: jxw Date: Fri, 15 Aug 2025 09:45:20 +0000 Subject: [PATCH 3/3] update api/@ohos.net.connection.d.ts. Signed-off-by: jxw --- api/@ohos.net.connection.d.ts | 54 +++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/api/@ohos.net.connection.d.ts b/api/@ohos.net.connection.d.ts index 8d08e3b645..42a579bf00 100644 --- a/api/@ohos.net.connection.d.ts +++ b/api/@ohos.net.connection.d.ts @@ -920,14 +920,39 @@ declare namespace connection { function getPacFileUrl(): string; /** - * find pac proxy info for the url - * @param { string } url - the url + * Find pac proxy info for the url. + * @param { string } url - the url. * @returns { string } Returns the proxy infomation. * @syscap SystemCapability.Communication.NetManager.Core * @since 20 */ function findProxyForUrl(url: string): string; + /** + * Set the proxy mode {@link ProxyMode}. + * @permission ohos.permission.CONNECTIVITY_INTERNAL + * @param { ProxyMode } mode - Indicates the proxy mode. + * @returns { Promise } the promise returned by the function. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications use system APIs. + * @syscap SystemCapability.Communication.NetManager.Core + * @systemapi Hide this for inner system use. Only used for system app. + * @since 20 + */ + function setProxyMode(mode: ProxyMode): Promise; + + /** + * Obtain the proxy mode {@link ProxyMode}. + * @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. + * @syscap SystemCapability.Communication.NetManager.Core + * @systemapi Hide this for inner system use. Only used for system app. + * @since 20 + */ + function getProxyMode(): Promise; + /** * Add a custom {@link host} and corresponding {@link ip} mapping for current application. * @permission ohos.permission.INTERNET @@ -1916,6 +1941,31 @@ declare namespace connection { BEARER_VPN = 4, } + /** + * Enumerates proxy modes. + * @enum {number} + * @syscap SystemCapability.Communication.NetManager.Core + * @systemapi Hide this for inner system use. Only used for system app. + * @since 20 + */ + export enum ProxyMode{ + /** + * Off proxy mode. + * @syscap SystemCapability.Communication.NetManager.Core + * @systemapi Hide this for inner system use. Only used for system app. + * @since 20 + */ + PROXY_MODE_OFF = 0, + + /** + * Auto proxy mode. + * @syscap SystemCapability.Communication.NetManager.Core + * @systemapi Hide this for inner system use. Only used for system app. + * @since 20 + */ + PROXY_MODE_AUTO = 1 + } + /** * Defines the network connection properties. * @interface ConnectionProperties -- Gitee