目录

DeviceBluetoothManager

Class Info

public class DeviceBluetoothManager

蓝牙相关的管理类。

术语解释

涉及接口禁止/允许蓝牙设备可被发现模式setDiscoverableDisabled。

禁止/允许蓝牙设备有限可被发现模式setLimitedDiscoverableDisabled。

Allow Bluetooth Discoverable Mode

enable

disable

Allow Bluetooth Limited Discoverable Mode

enable

disable

enable(不可用)

disable(不可用)

最终结果

蓝牙打开时,蓝牙是可被发现(有时间限制,缺省120s)。

蓝牙打开时,蓝牙是可被发现(没有时间限制)。

蓝牙不可被发现。

安全性

一般

最差

最高

设置菜单的行为表现

注意:

8.X以后版本无此项,不适用。

对应设置菜单的:2分钟超时。与现在默认一样,有开放检测和倒计时。

更多里的检测超时设置:与默认是一样的。

对应设置菜单的:从不超时

有开放检测对附近所有蓝牙设备可见(与用户在设置菜单主动设置为永不超时一致)。

更多里的检测超时设置:置灰。

对应设置菜单的:开放检测都是置灰的。

更多里的检测超时设置:置灰。

Public Method Summary

Qualifier and Type

Method Name and Description

boolean

addBluetoothDevicesToBlockList(ComponentName admin, ArrayList<String> devices)

配置蓝牙黑名单。

boolean

addBluetoothDevicesToBlackList(ComponentName admin, ArrayList<String> devices)

EMUI 11.0.0该方法已废弃,请使用boolean addBluetoothDevicesToBlockList(ComponentName admin, ArrayList<String> devices)。

boolean

addBluetoothDevicesToTrustList(ComponentName admin, ArrayList<String> devices)

配置蓝牙白名单。

boolean

addBluetoothDevicesToWhiteList(ComponentName admin, ArrayList<String> devices)

EMUI 11.0.0该方法已废弃,请使用boolean addBluetoothDevicesToTrustList(ComponentName admin, ArrayList<String> devices)。

boolean

removeBluetoothDevicesFromBlockList(ComponentName admin, ArrayList<String> devices)

从蓝牙黑名单中移除蓝牙设备。

boolean

removeBluetoothDevicesFromBlackList(ComponentName admin, ArrayList<String> devices)

EMUI 11.0.0该方法已废弃,请使用boolean removeBluetoothDevicesFromBlockList(ComponentName admin, ArrayList<String> devices)。

boolean

removeBluetoothDevicesFromTrustList(ComponentName admin, ArrayList<String> devices)

从蓝牙白名单中移除蓝牙设备。

boolean

removeBluetoothDevicesFromWhiteList(ComponentName admin, ArrayList<String> devices)

EMUI 11.0.0该方法已废弃,请使用boolean removeBluetoothDevicesFromTrustList(ComponentName admin, ArrayList<String> devices)。

ArrayList<String>

getBluetoothDevicesFromBlockList(ComponentName admin)

获取蓝牙黑名单。

ArrayList<String>

getBluetoothDevicesFromBlackLists(ComponentName admin)

EMUI 11.0.0该方法已废弃,请使用ArrayList<String> getBluetoothDevicesFromBlockList(ComponentName admin)。

ArrayList<String>

getBluetoothDevicesFromTrustList(ComponentName admin)

获取蓝牙允许清单。

ArrayList<String>

getBluetoothDevicesFromWhiteLists(ComponentName admin)

EMUI 11.0.0该方法已废弃,请使用ArrayList<String> getBluetoothDevicesFromTrustList(ComponentName admin)。

boolean

isDeviceInBlockList(ComponentName admin, String device)

判断某个蓝牙设备是否在蓝牙黑名单中。

boolean

isBlackListedDevice(ComponentName admin, String device)

EMUI 11.0.0该方法已废弃,请使用boolean isDeviceInBlockList(ComponentName admin, String device)。

boolean

isDeviceInTrustList(ComponentName admin, String device)

判断某个蓝牙设备是否在蓝牙白名单中。

boolean

isWhiteListedDevice(ComponentName admin, String device)

EMUI 11.0.0该方法已废弃,请使用boolean isDeviceInTrustList(ComponentName admin, String device)。

boolean

setBluetoothDisabledProfiles(ComponentName admin, ArrayList<Integer> disabledProfiles)

配置蓝牙安全模式。

boolean

removeBluetoothDisabledProfiles(ComponentName admin, ArrayList<Integer> disabledProfiles)

移除蓝牙安全模式。

ArrayList<Integer>

getBluetoothDisabledProfiles(ComponentName admin)

获取蓝牙安全模式。

boolean

setBluetoothDataTransferDisable(ComponentName admin, boolean isDisabled)

配置蓝牙文件传输状态。

boolean

isBluetoothDataTransferDisabled(ComponentName admin)

获取蓝牙文件传输状态。

boolean

setBluetoothPairingDisable(ComponentName admin, boolean isDisabled)

配置蓝牙配对状态。

boolean

isBluetoothPairingDisabled(ComponentName admin)

获取蓝牙配对状态

boolean

setBluetoothOutGoingCallDisable(ComponentName admin, boolean isDisabled)

配置蓝牙外设通话策略。

boolean

isBluetoothOutGoingCallDisabled(ComponentName admin)

获取蓝牙外设通话策略。

boolean

setDiscoverableDisabled(ComponentName admin, boolean isDisabled)

禁止/允许蓝牙设备可被发现模式。

boolean

isDiscoverableDisabled(ComponentName admin)

查询是否禁用蓝牙设备可被发现模式。

boolean

setLimitedDiscoverableDisabled(ComponentName admin, boolean isDisabled)

禁止/允许蓝牙设备有限可被发现模式。

boolean

isLimitedDiscoverableDisabled(ComponentName admin)

查询是否禁用蓝牙设备有限可被发现模式。

Public Methods

[h2]addBluetoothDevicesToBlockList

Supported Devices

Device Type

OS Version

手机、平板

EMUI 11.0或HarmonyOS 2.0及以上

Method

public boolean addBluetoothDevicesToBlockList(ComponentName admin, ArrayList<String> devices)

配置蓝牙禁止清单,禁止清单上的蓝牙设备将不能被连接。

注意:

  1. 需要申请com.huawei.permission.sec.MDM_BLUETOOTH权限。
  2. 如果有多个应用设置了蓝牙黑名单,取所有黑名单的合集。
  3. 如果某个设备已被添加到蓝牙黑名单,就不能再被任何应用添加至蓝牙白名单。

Parameters

Name

Description

admin

调用该接口的组件名称。

devices

  • 蓝牙MAC地址列表。如果列表为空或者列表中的地址不符合MAC地址的格式,则返回false。
  • 单个APK的蓝牙黑名单中包含的设备数目不能超过200。

Return

Type

Description

boolean

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

Throws

Name

Description

SecurityException

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

[h2]addBluetoothDevicesToBlackList

Supported Devices

Device Type

OS Version

手机、平板

EMUI 5.1~EMUI 10.1

Method

public boolean addBluetoothDevicesToBlackList(ComponentName admin, ArrayList<String> devices)

EMUI 11.0.0该方法废弃,请使用addBluetoothDevicesToBlockList。

配置蓝牙禁止清单,禁止清单上的蓝牙设备将不能被连接。

注意:

  1. 需要申请com.huawei.permission.sec.MDM_BLUETOOTH权限。
  2. 如果有多个应用设置了蓝牙黑名单,取所有黑名单的合集。
  3. 如果某个设备已被添加到蓝牙黑名单,就不能再被任何应用添加至蓝牙白名单。

Parameters

Name

Description

admin

调用该接口的组件名称。

devices

蓝牙MAC地址列表。如果列表为空或者列表中的地址不符合MAC地址的格式,则返回false。单个APK的蓝牙黑名单中包含的设备数目不能超过200。

Return

Type

Description

boolean

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

Throws

Name

Description

SecurityException

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

[h2]addBluetoothDevicesToTrustList

Supported Devices

Device Type

OS Version

手机、平板

EMUI 11.0或HarmonyOS 2.0及以上

Method

public boolean addBluetoothDevicesToTrustList(ComponentName admin, ArrayList<String> devices)

配置蓝牙白名单,只有白名单中的设备才能被连接。

注意:

  1. 需要申请com.huawei.permission.sec.MDM_BLUETOOTH权限。
  2. 需要与接口setBluetoothPairingDisable一起调用。
  3. 如果有多个应用设置了,取各个应用设置的合集。
  4. 如果某个设备已被某个应用设置成白名单,不能再被任何应用设置成黑名单。

Parameters

Name

Description

admin

调用该接口的组件名称。

devices

蓝牙MAC地址列表。如果列表为空或者列表中的地址不符合MAC地址的格式,则返回false。单个APK的蓝牙白名单中包含的设备数目不能超过200。

Return

Type

Description

boolean

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

Throws

Name

Description

SecurityException

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

[h2]addBluetoothDevicesToWhiteList

Supported Devices

Device Type

OS Version

手机、平板

EMUI 5.1~EMUI 10.1

Method

public boolean addBluetoothDevicesToWhiteList(ComponentName admin, ArrayList<String> devices)

EMUI 11.0.0该方法废弃,请使用addBluetoothDevicesToTrustList。

配置蓝牙白名单,只有白名单中的设备才能被连接。

注意:

  1. 需要申请com.huawei.permission.sec.MDM_BLUETOOTH权限。
  2. 需要与接口setBluetoothPairingDisable一起调用。
  3. 如果有多个应用设置了,取各个应用设置的合集。
  4. 如果某个设备已被某个应用设置成白名单,不能再被任何应用设置成黑名单。

Parameters

Name

Description

admin

调用该接口的组件名称。

devices

蓝牙MAC地址列表。如果列表为空或者列表中的地址不符合MAC地址的格式,则返回false。单个APK的蓝牙白名单中包含的设备数目不能超过200。

Return

Type

Description

boolean

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

Throws

Name

Description

SecurityException

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

[h2]removeBluetoothDevicesFromBlockList

Supported Devices

Device Type

OS Version

手机、平板

EMUI 11.0或HarmonyOS 2.0及以上

Method

public boolean removeBluetoothDevicesFromBlockList(ComponentName admin, ArrayList<String> devices)

将设备从蓝牙黑名单中移除。如果devices取值为空,表示删除蓝牙黑名单中的所有设备,否则删除指定的设备。

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

Parameters

Name

Description

admin

调用该接口的组件名称。

devices

蓝牙MAC地址列表。如果列表为空或者列表中的地址不符合MAC地址的格式,则返回false。

Return

Type

Description

boolean

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

Throws

Name

Description

SecurityException

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

[h2]removeBluetoothDevicesFromBlackList

Supported Devices

Device Type

OS Version

手机、平板

EMUI 5.1~EMUI 10.1

Method

public boolean removeBluetoothDevicesFromBlackList(ComponentName admin, ArrayList<String> devices)

EMUI 11.0.0该方法废弃,请使用removeBluetoothDevicesFromBlockList。

将设备从蓝牙黑名单中移除。如果devices取值为空,表示删除蓝牙黑名单中的所有设备,否则删除指定的设备。

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

Parameters

Name

Description

admin

调用该接口的组件名称。

devices

蓝牙MAC地址列表。如果列表为空或者列表中的地址不符合MAC地址的格式,则返回false。

Return

Type

Description

boolean

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

Throws

Name

Description

SecurityException

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

[h2]removeBluetoothDevicesFromTrustList

Supported Devices

Device Type

OS Version

手机、平板

EMUI 11.0或HarmonyOS 2.0及以上

Method

public boolean removeBluetoothDevicesFromTrustList(ComponentName admin, ArrayList<String> devices)

删除蓝牙允许连接的白名单,如果devices传入为null,表示删除所有,否则删除指定的设备。

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

Parameters

Name

Description

admin

调用该接口的组件名称。

devices

蓝牙MAC地址列表。如果列表为空或者列表中的地址不符合MAC地址的格式,则返回false。

Return

Type

Description

boolean

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

Throws

Name

Description

SecurityException

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

[h2]removeBluetoothDevicesFromWhiteList

Supported Devices

Device Type

OS Version

手机、平板

EMUI 5.1~EMUI 10.1

Method

public boolean removeBluetoothDevicesFromWhiteList(ComponentName admin, ArrayList<String> devices)

EMUI 11.0.0该方法废弃,请使用removeBluetoothDevicesFromTrustList。

删除蓝牙允许连接的白名单,如果devices传入为null,表示删除所有,否则删除指定的设备。

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

Parameters

Name

Description

admin

调用该接口的组件名称。

devices

蓝牙MAC地址列表。如果列表为空或者列表中的地址不符合mac地址的格式,则返回false。

Return

Type

Description

boolean

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

Throws

Name

Description

SecurityException

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

[h2]getBluetoothDevicesFromBlockList

Supported Devices

Device Type

OS Version

手机、平板

EMUI 11.0或HarmonyOS 2.0及以上

Method

public ArrayList<String> getBluetoothDevicesFromBlockList(ComponentName admin)

获取当前已经配置的蓝牙黑名单列表。

Parameters

Name

Description

admin

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

Return

Type

Description

ArrayList<String>

返回配置的黑名单列表,不存在则返回null。

[h2]getBluetoothDevicesFromBlackLists

Supported Devices

Device Type

OS Version

手机、平板

EMUI 5.1~EMUI 10.1

Method

public ArrayList<String> getBluetoothDevicesFromBlackLists(ComponentName admin)

EMUI 11.0.0该方法废弃,请使用getBluetoothDevicesFromBlockList。

获取当前已经配置的蓝牙黑名单列表。

Parameters

Name

Description

admin

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

Return

Type

Description

ArrayList<String>

返回配置的黑名单列表,不存在则返回null。

[h2]getBluetoothDevicesFromTrustList

Supported Devices

Device Type

OS Version

手机、平板

EMUI 11.0或HarmonyOS 2.0及以上

Method

public ArrayList<String> getBluetoothDevicesFromTrustList(ComponentName admin)

获取当前已经配置的蓝牙白名单列表。

Parameters

Name

Description

admin

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

Return

Type

Description

ArrayList<String>

返回配置的白名单列表,不存在则返回null。

[h2]getBluetoothDevicesFromWhiteLists

Supported Devices

Device Type

OS Version

手机、平板

EMUI 5.1~EMUI 10.1

Method

public ArrayList<String> getBluetoothDevicesFromWhiteLists(ComponentName admin)

EMUI 11.0.0该方法废弃,请使用getBluetoothDevicesFromTrustList。

获取当前已经配置的蓝牙白名单列表。

Parameters

Name

Description

admin

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

Return

Type

Description

ArrayList<String>

返回配置的白名单列表,不存在则返回null。

[h2]isDeviceInBlockList

Supported Devices

Device Type

OS Version

手机、平板

EMUI 11.0或HarmonyOS 2.0及以上

Method

public boolean isDeviceInBlockList(ComponentName admin, String device)

判断某个蓝牙设备(MAC地址)是否在蓝牙黑名单中。

Parameters

Name

Description

admin

调用该接口的组件名称。

device

待查询的蓝牙设备的MAC地址。

Return

Type

Description

boolean

如果在黑名单中返回true,否则返回false。

[h2]isBlackListedDevice

Supported Devices

Device Type

OS Version

手机、平板

EMUI 5.1~EMUI 10.1

Method

public boolean isBlackListedDevice(ComponentName admin, String device)

EMUI 11.0.0该方法废弃,请使用isDeviceInBlockList。

判断某个蓝牙设备(MAC地址)是否在蓝牙黑名单中。

Parameters

Name

Description

admin

调用该接口的组件名称。

device

待查询的蓝牙设备的MAC地址。

Return

Type

Description

boolean

如果在黑名单中返回true,否则返回false。

[h2]isDeviceInTrustList

Supported Devices

Device Type

OS Version

手机、平板

EMUI 11.0或HarmonyOS 2.0及以上

Method

public boolean isDeviceInTrustList(ComponentName admin, String device)

判断某个蓝牙设备(MAC地址)是否在白名单中。

Parameters

Name

Description

admin

调用该接口的组件名称。

device

待查询的蓝牙设备的MAC地址。

Return

Type

Description

boolean

如果在白名单中返回true,否则返回false。

[h2]isWhiteListedDevice

Supported Devices

Device Type

OS Version

手机、平板

EMUI 5.1~EMUI 10.1

Method

public boolean isWhiteListedDevice(ComponentName admin, String device)

EMUI 11.0.0该方法废弃,请使用isDeviceInTrustList。

判断某个蓝牙设备(MAC地址)是否在白名单中。

Parameters

Name

Description

admin

调用该接口的组件名称。

device

待查询的蓝牙设备的MAC地址。

Return

Type

Description

boolean

如果在白名单中返回true,否则返回false。

[h2]setBluetoothDisabledProfiles

Supported Devices

Device Type

OS Version

手机、平板

EMUI 8.0及以上或HarmonyOS 2.0及以上

Method

public boolean setBluetoothDisabledProfiles(ComponentName admin, ArrayList<Integer> disabledProfiles)

配置需要被禁用的profiles。

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

Parameters

Name

Description

admin

调用该接口的组件名称。

disabledProfiles

被禁用的profiles,对应profile参考BluetoothProfile。

Return

Type

Description

boolean

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

Throws

Name

Description

SecurityException

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

[h2]removeBluetoothDisabledProfiles

Supported Devices

Device Type

OS Version

手机、平板

EMUI 8.0及以上或HarmonyOS 2.0及以上

Method

public boolean removeBluetoothDisabledProfiles(ComponentName admin, ArrayList<Integer> disabledProfiles)

移除被禁用的profiles。

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

Parameters

Name

Description

admin

调用该接口的组件名称。

disabledProfiles

需要移除的profiles,对应profile参考BluetoothProfile。

Return

Type

Description

boolean

  • true:移除成功。
  • false:移除失败。

Throws

Name

Description

SecurityException

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

[h2]getBluetoothDisabledProfiles

Supported Devices

Device Type

OS Version

手机、平板

EMUI 8.0及以上或HarmonyOS 2.0及以上

Method

public ArrayList<Integer> getBluetoothDisabledProfiles(ComponentName admin)

获取被禁用的profiles。

Parameters

Name

Description

admin

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

Return

Type

Description

ArrayList<Integer>

返回获取的profile。

Throws

Name

Description

SecurityException

此APK未经设备管理激活。

[h2]setBluetoothDataTransferDisable

Supported Devices

Device Type

OS Version

手机、平板

EMUI 8.0及以上或HarmonyOS 2.0及以上

Method

public boolean setBluetoothDataTransferDisable(ComponentName admin, boolean isDisabled)

禁止/允许蓝牙文件传输。

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

Parameters

Name

Description

admin

调用该接口的组件名称。

isDisabled

是否禁用蓝牙传输。

Return

Type

Description

boolean

配置成功返回true,否则返回false。

Throws

Name

Description

SecurityException

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

[h2]isBluetoothDataTransferDisabled

Supported Devices

Device Type

OS Version

手机、平板

EMUI 8.0及以上或HarmonyOS 2.0及以上

Method

public boolean isBluetoothDataTransferDisabled(ComponentName admin)

获取当前是否禁用蓝牙传输文件。

Parameters

Name

Description

admin

调用该接口的组件名称,查询该应用配置的策略。

Return

Type

Description

boolean

蓝牙传输文件被禁用返回true,否则返回false。

Throws

Name

Description

SecurityException

此APK未经设备管理激活。

[h2]setBluetoothPairingDisable

Supported Devices

Device Type

OS Version

手机、平板

EMUI 8.0及以上或HarmonyOS 2.0及以上

Method

public boolean setBluetoothPairingDisable(ComponentName admin, boolean isDisabled)

配置蓝牙配对状态。

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

Parameters

Name

Description

admin

调用该接口的组件名称。

isDisabled

是否禁用蓝牙配对。

Return

Type

Description

boolean

配置成功返回true,否则返回false。

Throws

Name

Description

SecurityException

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

[h2]isBluetoothPairingDisabled

Supported Devices

Device Type

OS Version

手机、平板

EMUI 8.0及以上或HarmonyOS 2.0及以上

Method

public boolean isBluetoothPairingDisabled(ComponentName admin)

获取蓝牙配对状态。

Parameters

Name

Description

admin

调用该接口的组件名称,查询该应用配置的策略。

Return

Type

Description

boolean

蓝牙配对状态被禁用返回true,否则返回false。

Throws

Name

Description

SecurityException

此APK未经设备管理激活。

[h2]setBluetoothOutGoingCallDisable

Supported Devices

Device Type

OS Version

手机、平板

EMUI 8.0及以上或HarmonyOS 2.0及以上

Method

public boolean setBluetoothOutGoingCallDisable(ComponentName admin, boolean isDisabled)

配置蓝牙外设通话策略。

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

Parameters

Name

Description

admin

调用该接口的组件名称。

isDisabled

配置是否禁用外设通话。

Return

Type

Description

boolean

配置成功返回true,否则返回false。

Throws

Name

Description

SecurityException

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

[h2]isBluetoothOutGoingCallDisabled

Supported Devices

Device Type

OS Version

手机、平板

EMUI 8.0及以上或HarmonyOS 2.0及以上

Method

public boolean isBluetoothOutGoingCallDisabled(ComponentName admin)

获取蓝牙外设通话策略。

Parameters

Name

Description

admin

调用该接口的组件名称,查询该应用配置的策略。

Return

Type

Description

boolean

外设通话被禁用返回true,否则返回false。

Throws

Name

Description

SecurityException

此APK未经设备管理激活。

[h2]setDiscoverableDisabled

Supported Devices

Device Type

OS Version

手机、平板

EMUI 8.0及以上或HarmonyOS 2.0及以上

Method

public boolean setDiscoverableDisabled(ComponentName admin, boolean isDisabled)

设置蓝牙可被发现模式是否被禁用。

注意:

  1. 需要申请com.huawei.permission.sec.MDM_BLUETOOTH权限。
  2. 重启蓝牙之后策略生效。

Parameters

Name

Description

admin

调用该接口的组件名称。

isDisabled

可被发现模式是否被禁用。

Return

Type

Description

boolean

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

Throws

Name

Description

SecurityException

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

IllegalArgumentException

参数admin为null。

[h2]isDiscoverableDisabled

Supported Devices

Device Type

OS Version

手机、平板

EMUI 8.0及以上或HarmonyOS 2.0及以上

Method

public boolean isDiscoverableDisabled(ComponentName admin)

查询蓝牙设备可被发现模式是否被禁用。

Parameters

Name

Description

admin

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

Return

Type

Description

boolean

如果可被发现模式被禁用返回true,否则返回false。

Throws

Name

Description

SecurityException

此APK未经设备管理激活。

[h2]setLimitedDiscoverableDisabled

Supported Devices

Device Type

OS Version

手机、平板

EMUI 8.0及以上或HarmonyOS 2.0及以上

Method

public boolean setLimitedDiscoverableDisabled(ComponentName admin, boolean isDisabled)

设置禁用/允许某个蓝牙设备有限可被发现模式。

注意:

  1. 需要申请com.huawei.permission.sec.MDM_BLUETOOTH权限。
  2. 重启蓝牙之后策略生效。

Parameters

Name

Description

admin

调用该接口的组件名称。

isDisabled

有限可被发现模式是否被禁用。

Return

Type

Description

boolean

true:配置成功。

false:配置失败。

Throws

Name

Description

SecurityException

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

IllegalArgumentException

参数admin为null。

[h2]isLimitedDiscoverableDisabled

Supported Devices

Device Type

OS Version

手机、平板

EMUI 8.0及以上或HarmonyOS 2.0及以上

Method

public boolean isLimitedDiscoverableDisabled(ComponentName admin)

查询蓝牙设备有限可被发现模式是否被禁用。

Parameters

Name

Description

admin

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

Return

Type

Description

boolean

如果有限可被发现模式被禁用返回true,否则返回false。

Throws

Name

Description

SecurityException

此APK未经设备管理激活。