Back to top

This topic describes how control Bluetooth using the Knox SDK.

Examples

Turn Bluetooth on / off

To prevent users from toggling Bluetooth on or off use .allowBluetooth with true or false

.allowBluetooth()

To disable Bluetooth background services, use .allowBLE with true or false. This completely disables Bluetooth background services, even if triggered remotely.

For example, using .allowBLE prevents location accuracy from accessing the connection settings.

image1.png

These APIs are dependent on each other, if you set .allowBLE to false, it also turns off regular Bluetooth functionality on the device. See the chart below for implementation logic.

allowBluetooth(true) allowbluetooth(false)
allowBLE(true) allow BT and BLE disallow BT and allow BLE
allowBLE(false) disallow BT and BLE disallow BT and BLE

Check if Bluetooth is enabled

.isBluetoothEnabled();

Only allow trusted hardware to work with Bluetooth

You want to allow a trusted Bluetooth audio device using the device hardware ID.

  1. Create the EnterpriseDeviceManager object.

  2. Create the BluetoothPolicy object.

  3. Add trusted Bluetooth devices using hardware ID.

  4. Block all Bluetooth devices by using a * wild card and addBluetoothDevicestoBlackList

  5. Add the hardware IDs you stored in step 3 to the allowlist.

  6. Set activateBluetoothDeviceRestriction to true.

    //Get BluetoothPolicy object:
    EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
    BluetoothPolicy bluetoothPolicy = edm.getBluetoothPolicy();
    
    //Add only trusted Bluetooth devices using hardware ID:
    List devices = new ArrayList();
    devices.add("00:11:22:33:AA:BB");
    devices.add("00:11:22:88:AA:CC");
    
    //add to blocklist and allowlist
    bluetoothPolicy.addBluetoothDevicesToBlackList(".*");
    bluetoothPolicy.addBluetoothDevicesToWhiteList(AudioDeviceHardwareId);
    bluetoothPolicy.activateBluetoothDeviceRestriction(true);
    

Only allow Bluetooth to work for calling and listening to music

You want to allow a trusted Bluetooth audio device using the device hardware ID.

//Get BluetoothPolicy object:
EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
BluetoothPolicy bluetoothPolicy = edm.getBluetoothPolicy();

//Allow use of Bluetooth only for calling and listening to music.
List UUIDs = new ArrayList();
UUIDs.add(BluetoothUUID.A2DP_ADVAUDIODIST_UUID);
UUIDs.add(BluetoothUUID.HFP_UUID);
bluetoothPolicy.addBluetoothUUIDsToBlackList(".*");
bluetoothPolicy.addBluetoothUUIDsToWhiteList(UUIDs);
bluetoothPolicy.activateBluetoothUUIDRestriction(true);

Enable the Share Contacts via Bluetooth feature inside the container

This enhancement adds the ability to share contact information which is stored in the container. For example, a device user can call a number from their contact list inside the container by sharing the number through a Bluetooth connection with their automobile’s hands-free phone system.

There are 2 APIs to support this feature:

  1. Create the EnterpriseKnoxManager object.

  2. Get the GetContainerConfigurationPolicy from ekm.

  3. Call setContactsSharingEnabled and set to true.

    EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
    ContainerConfigurationPolicy ccp = kcm.getContainerConfigurationPolicy();
    ccp.setContactsSharingEnabled(true)
    

Is this page helpful?