Remove wrong dependency in the systemd service file
[platform/core/connectivity/bluetooth-frwk.git] / bt-api / bt-dpm.c
index 3c78062..b7767b2 100644 (file)
@@ -248,14 +248,11 @@ static bt_dpm_status_e _bt_check_dpm_spp_restriction(void)
 int _bt_check_dpm(int service, void *param)
 {
        bt_dpm_status_e status = BT_DPM_ALLOWED;
-       int ret = BLUETOOTH_ERROR_NONE;
-       BT_CHECK_ENABLED_ANY(return);
 
        switch (service) {
        case BT_DPM_HF_ONLY:
                status = _bt_check_dpm_handsfree_only();
                break;
-
        case BT_DPM_PAIRING:
                status = _bt_check_dpm_pairing_restriction();
                break;
@@ -288,21 +285,12 @@ int _bt_check_dpm(int service, void *param)
        case BT_DPM_SPP:
                status = _bt_check_dpm_spp_restriction();
                break;
-
        default:
                BT_ERR("Unknown service");
                return status;
        }
 
-       if (status == BT_DPM_RESTRICTED) {
-               BT_INFO("Service [%d], DPM permission denied", service);
-               ret = BLUETOOTH_ERROR_PERMISSION_DEINED;
-       } else if (status == BT_DPM_NO_SERVICE) {
-               BT_DBG("DPM no service [%d]", status);
-               ret = BLUETOOTH_ERROR_SERVICE_NOT_FOUND;
-       }
-
-       return ret;
+       return status;
 }
 
 BT_EXPORT_API int bluetooth_dpm_set_allow_mode(bt_dpm_allow_t value)
@@ -313,18 +301,20 @@ BT_EXPORT_API int bluetooth_dpm_set_allow_mode(bt_dpm_allow_t value)
 #endif
 
 #ifdef TIZEN_FEATURE_BT_DPM
-       if (vconf_get_int(VCONFKEY_BT_STATUS, &bt_status) < 0)
-               BT_ERR("Error in reading VCONFKEY_BT_STATUS");
-
-       if (bt_status == VCONFKEY_BT_STATUS_ON) {
+       if (value >= BLUETOOTH_DPM_BT_ALLOWED &&
+               value <= BLUETOOTH_DPM_BT_RESTRICTED) {
                if (vconf_set_int(VCONFKEY_BT_DPM_STATUS, value) != 0) {
                        BT_ERR("Set VCONFKEY_BT_DPM_STATUS failed\n");
                        result = BLUETOOTH_ERROR_INTERNAL;
-               } else {
-                       BT_ERR("Set VCONFKEY_BT_DPM_STATUS success\n");
+               } else
                        result = BLUETOOTH_ERROR_NONE;
-               }
+       } else
+               result = BLUETOOTH_ERROR_INVALID_PARAM;
 
+       if (vconf_get_int(VCONFKEY_BT_STATUS, &bt_status) < 0)
+               BT_ERR("Error in reading VCONFKEY_BT_STATUS");
+
+       if (bt_status == VCONFKEY_BT_STATUS_ON) {
                BT_INIT_PARAMS();
                BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
@@ -339,16 +329,6 @@ BT_EXPORT_API int bluetooth_dpm_set_allow_mode(bt_dpm_allow_t value)
                        value == BLUETOOTH_DPM_BT_RESTRICTED) {
                        result = bluetooth_disable_adapter();
                }
-       } else {
-               if (value >= BLUETOOTH_DPM_BT_ALLOWED &&
-                       value <= BLUETOOTH_DPM_BT_RESTRICTED) {
-                       if (vconf_set_int(VCONFKEY_BT_DPM_STATUS, value) != 0) {
-                               BT_ERR("Set VCONFKEY_BT_DPM_STATUS failed\n");
-                               result = BLUETOOTH_ERROR_INTERNAL;
-                       } else
-                               result = BLUETOOTH_ERROR_NONE;
-               } else
-                       result = BLUETOOTH_ERROR_INVALID_PARAM;
        }
 #else
        BT_INIT_PARAMS();
@@ -371,7 +351,10 @@ BT_EXPORT_API int bluetooth_dpm_get_allow_mode(bt_dpm_allow_t *value)
        int result;
 
 #ifdef TIZEN_FEATURE_BT_DPM
-       *value = bluetooth_dpm_is_mode_allowed();
+       if (vconf_get_int(VCONFKEY_BT_DPM_STATUS, value) != 0) {
+               BT_ERR("fail to get vconf key!");
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
        result = BLUETOOTH_ERROR_NONE;
 #else
        BT_CHECK_ENABLED_ANY(return);