目录

DeviceFirewallManager

Class Info

public class DeviceFirewallManager

防火墙相关管理类。

Public Method Summary

Qualifier and Type

Method Name and Description

boolean

setGlobalProxy(ComponentName admin, String hostName, int proxyPort, List<String> exclusionList)

配置全局代理。

List<String>

getGlobalProxy(ComponentName admin)

获取全局代理

boolean

setPAC(ComponentName who, Uri mPacFileUrl)

设置PAC (Proxy Auto Config)。

String

getPAC(ComponentName who)

获取PAC (Proxy Auto Config)

Public Methods

[h2]setGlobalProxy

Supported Devices

Device Type

OS Version

手机、平板

EMUI 5.1及以上或HarmonyOS 2.0及以上

Method

public boolean setGlobalProxy(ComponentName admin, String hostName, int proxyPort, List<String> exclusionList)

允许调用者配置一个手机的全局代理,该代理有可能对一些三方应用不生效,其是否生效是根据三方应用的代码决定的。

注意:需要申请com.huawei.permission.sec.MDM_FIREWALL权限。

Parameters

Name

Description

admin

调用该接口的组件名称,不能为null。

hostName

全局代理的主机名。

proxyPort

全局代理的端口号。

exclusionList

不走此代理的列表。

Return

Type

Description

boolean

  • true:配置成功。
  • false:配置失败。

Throws

Name

Description

SecurityException

  • 此APK未经设备管理激活。
  • 无com.huawei.permission.sec.MDM_FIREWALL权限。

IllegalArgumentException

参数错误,或admin为null。

[h2]getGlobalProxy

Supported Devices

Device Type

OS Version

手机、平板

EMUI 5.1及以上或HarmonyOS 2.0及以上

Method

public List<String> getGlobalProxy(ComponentName admin)

获取手机中所配置的全局代理,若代理为null,则返回一个空列表。

Parameters

Name

Description

admin

调用该接口的组件名称,查询该应用配置的策略;参数为null时,获取所有应用设置的综合策略结果。

Return

Type

Description

List<String>

该List第一行为hostName:port,其它的各行为不走此代理的配置。

[h2]setPAC

Supported Devices

Device Type

OS Version

手机、平板

EMUI 9.0及以上或HarmonyOS 2.0及以上

Method

public boolean setPAC(ComponentName who, Uri mPacFileUrl)

设置PAC (Proxy Auto Config)。

注意:需要申请com.huawei.permission.sec.MDM_FIREWALL权限。

Parameters

Name

Description

who

调用该接口的的组件名称,不能为null。

mPacFileUrl

PAC的Uri。

Return

Type

Description

boolean

  • true:配置成功。
  • false:配置失败。

Throws

Name

Description

SecurityException

  • 此APK未经设备管理激活。
  • 无com.huawei.permission.sec.MDM_FIREWALL权限。
  • 此APK不属于当前用户。

IllegalArgumentException

参数错误,或admin为null。

[h2]getPAC

Supported Devices

Device Type

OS Version

手机、平板

EMUI 9.0及以上或HarmonyOS 2.0及以上

Method

public String getPAC(ComponentName who)

获取PAC (Proxy Auto Config)。

Parameters

Name

Description

who

调用该接口的组件名称。

Return

Type

Description

String

获取到的PAC。