Disallow BT headset pairing for DPM mode
[platform/core/connectivity/bluetooth-frwk.git] / bt-service / bt-service-device.c
index 004ca7a..fc9bb95 100644 (file)
 #include "bt-service-gap-agent.h"
 #include "bt-service-pbap.h"
 
+#ifdef TIZEN_FEATURE_BT_DPM
+#include "bt-service-dpm.h"
+#endif
+
 #define BT_SYSPOPUP_IPC_RESPONSE_OBJECT "/org/projectx/bt_syspopup_res"
 #define BT_SYSPOPUP_INTERFACE "User.Bluetooth.syspopup"
 #define BT_SYSPOPUP_METHOD_RESPONSE "Response"
@@ -944,6 +948,16 @@ int _bt_bond_device(int request_id,
 
        BT_CHECK_PARAMETER(device_address, return);
 
+#ifdef TIZEN_FEATURE_BT_DPM
+       int pairing_state = DPM_STATUS_ERROR;
+
+       _bt_dpm_get_bluetooth_pairing_state(&pairing_state);
+       if (pairing_state == DPM_RESTRICTED) {
+               BT_ERR("Not allow to pair the device");
+               return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION;
+       }
+#endif
+
        if (bonding_info) {
                BT_ERR("Bonding in progress");