From 68d84bc84708823086a0cabd0809e9e4cb56d202 Mon Sep 17 00:00:00 2001 From: xuzhenhai <282052309@qq.com> Date: Mon, 21 Jul 2025 19:26:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0pac=20c=E8=AF=AD=E8=A8=80NDK?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xuzhenhai <282052309@qq.com> Change-Id: Ifd59012ae541500fd12017027201a6cec87c3566 --- network/netmanager/include/net_connection.h | 71 +++++++++++++++++++ network/netmanager/libnet_connection.ndk.json | 12 ++++ 2 files changed, 83 insertions(+) diff --git a/network/netmanager/include/net_connection.h b/network/netmanager/include/net_connection.h index 0ab63a06308..7516318384a 100644 --- a/network/netmanager/include/net_connection.h +++ b/network/netmanager/include/net_connection.h @@ -401,6 +401,77 @@ int32_t OH_NetConn_QueryProbeResult(char *destination, int32_t duration, NetConn int32_t OH_NetConn_QueryTraceRoute(char *destination, NetConn_TraceRouteOption *option, NetConn_TraceRouteInfo *traceRouteInfo); +/** + * @brief Sets the URL of the current PAC file script. + * + * @param pacUrl the URL of the current PAC script. + * @return the result defines in {@link NetConn_ErrorCode}. + * {@link NETCONN_SUCCESS} Success. + * {@link NETCONN_PERMISSION_DENIED} Permission denied. + * {@link NETCONN_PARAMETER_ERROR} Parameter check failed. + * {@link NETCONN_OPERATION_FAILED} Failed to connect to the service. + * {@link NETCONN_INTERNAL_ERROR} System internal error. + * @permission ohos.permission.SET_PAC_URL + * @since 20 + */ +NetConn_ErrorCode OH_NetConn_SetPacFileUrl(const char *pacUrl); + +/** + * @brief find the proxy infomation for the url + * @param url the url link + * @param proxy the pac proxy infomation + * @return the proxy result + * @since 20 + */ +NetConn_ErrorCode OH_NetConn_FindProxyForURL(const char *url,char *proxy); + +/** + * @brief Obtains the URL of the current PAC file script. + * + * @param pacUrl the URL of the current PAC script. + * @return the result defines in {@link NetConn_ErrorCode}. + * {@link NETCONN_SUCCESS} Success. + * {@link NETCONN_PARAMETER_ERROR} Parameter check failed. + * {@link NETCONN_OPERATION_FAILED} Failed to connect to the service. + * {@link NETCONN_INTERNAL_ERROR} System internal error. + * @since 20 + */ +NetConn_ErrorCode OH_NetConn_GetPacFileUrl(char *pacUrl); + +/** + * @brief Registers a callback to listen the pac file url changed. + * + * @param pacFileUrlChange The callback needed to be registered. + * @param callbackId out param, corresponding to a registered callback. + * @return 0 - Success. + * 201 - Permission denied. + * 401 - Parameter error. + * 2100002 - Failed to connect to the service. + * 2100003 - System internal error. + * 2101008 - The callback already exists. + * 2101022 - The number of requests exceeded the maximum allowed. + * @syscap SystemCapability.Communication.NetManager.Core + * @since 20 + * @version 1.0 + */ +int32_t OH_NetConn_RegisterPacFileUrlCallback(OH_NetConn_PacFileUrlChange *pacFileUrlChange, uint32_t *callbackId); + +/** + * @brief Unregisters pac file url change callback. + * + * @param callBackId the id corresponding to a registered callback. + * @return 0 - Success. + * 201 - Permission denied. + * 401 - Parameter error. + * 2100002 - Failed to connect to the service. + * 2100003 - System internal error. + * 2101007 - The callback does not exists. + * @permission ohos.permission.GET_NETWORK_INFO + * @syscap SystemCapability.Communication.NetManager.Core + * @since 20 + * @version 1.0 + */ +int32_t OH_NetConn_UnregisterPacFileUrlCallback(uint32_t callBackId); #ifdef __cplusplus } #endif diff --git a/network/netmanager/libnet_connection.ndk.json b/network/netmanager/libnet_connection.ndk.json index ed2a1613159..493aebabe05 100644 --- a/network/netmanager/libnet_connection.ndk.json +++ b/network/netmanager/libnet_connection.ndk.json @@ -94,5 +94,17 @@ { "first_introduced": "20", "name": "OH_NetConn_QueryTraceRoute" + }, + { + "first_introduced": "20", + "name": "OH_NetConn_SetPacFileUrl" + }, + { + "first_introduced": "20", + "name": "OH_NetConn_GetPacFileUrl" + }, + { + "first_introduced": "20", + "name": "OH_NetConn_FindProxyForURL" } ] \ No newline at end of file -- Gitee