Menu

Bluetooth

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 trueor false. This completely disables Bluetooth background services, even if triggered remotely.

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

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 theEnterpriseDeviceManager object.
  2. Create the BluetoothPolicy object.
  3. Add trusted Bluetooth devices using hardware ID
  4. Blacklist all Bluetooth devices by using a * wild card and addBluetoothDevicestoBlackList
  5. Whitelist the hardware ID's you stored in step 3.
  6. set activateBluetoothDeviceRestrictionto 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 blacklist and whitelist
bluetoothPolicy.addBluetoothDevicesToBlackList(".*");
bluetoothPolicy.addBluetoothDevicesToWhiteList(AudioDeviceHardwareId);
bluetoothPolicy.activateBluetoothDeviceRestriction(true);

Only Bluetooth to only 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)