Revert the previous SR commit for binary stabilization 67/163367/1
authorDoHyun Pyun <dh79.pyun@samsung.com>
Mon, 11 Dec 2017 00:10:09 +0000 (09:10 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Mon, 11 Dec 2017 00:10:09 +0000 (09:10 +0900)
Change-Id: Ia659d1a04857a515d9f880c0bc573a80e898844b
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
13 files changed:
bt-api/bt-common.c
bt-api/bt-device.c
bt-api/bt-gatt-client.c
bt-api/bt-gatt-service.c
bt-service/bt-request-handler.c
bt-service/bt-service-audio.c
bt-service/bt-service-common.c
bt-service/bt-service-device.c
bt-service/bt-service-event-receiver.c
bt-service/bt-service-hid.c
bt-service/include/bt-service-device.h
include/bluetooth-api.h
include/bt-internal-types.h

index df06657..02e1c90 100644 (file)
@@ -247,7 +247,6 @@ void _bt_convert_addr_string_to_secure_string(char *addr, const char *address)
        ret_if(len != BT_ADDRESS_STRING_SIZE - 1);
 
        strncpy(addr, address, len);
-       addr[len] = '\0';
 
        addr[len-1] = 'X';
        addr[len-2] = 'X';
@@ -441,6 +440,8 @@ const char *_bt_convert_service_function_to_string(int function)
                {BT_UPDATE_LE_CONNECTION_MODE, "BT_UPDATE_LE_CONNECTION_MODE"},
                {BT_SET_PROFILE_TRUSTED, "BT_SET_PROFILE_TRUSTED"},
                {BT_GET_PROFILE_TRUSTED, "BT_GET_PROFILE_TRUSTED"},
+               {BT_SET_PROFILE_RESTRICTED, "BT_SET_PROFILE_RESTRICTED"},
+               {BT_GET_PROFILE_RESTRICTED, "BT_GET_PROFILE_RESTRICTED"},
                {BT_HID_CONNECT, "BT_HID_CONNECT"},
                {BT_HID_DISCONNECT, "BT_HID_DISCONNECT"},
                {BT_HID_DEVICE_ACTIVATE, "BT_HID_DEVICE_ACTIVATE"},
index 815f8dc..8bb283d 100644 (file)
@@ -739,6 +739,62 @@ BT_EXPORT_API int bluetooth_get_profile_trusted(
        return result;
 }
 
+BT_EXPORT_API int bluetooth_set_profile_restricted(
+               const bluetooth_device_address_t *device_address,
+               int profile, int restricted)
+{
+       int result;
+
+       BT_CHECK_PARAMETER(device_address, return);
+       BT_CHECK_ENABLED(return);
+
+       BT_INIT_PARAMS();
+       BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+       g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
+       g_array_append_vals(in_param2, &profile, sizeof(int));
+       g_array_append_vals(in_param3, &restricted, sizeof(int));
+
+       result = _bt_send_request(BT_BLUEZ_SERVICE, BT_SET_PROFILE_RESTRICTED,
+                       in_param1, in_param2, in_param3, in_param4, &out_param);
+
+       if (result == BLUETOOTH_ERROR_NONE)
+               BT_DBG("SUCCESSFUL");
+
+       BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+       return result;
+}
+
+BT_EXPORT_API int bluetooth_get_profile_restricted(
+               const bluetooth_device_address_t *device_address,
+               int profile, int *restricted)
+{
+       int result;
+       int restrict_profile = 0;
+       BT_CHECK_PARAMETER(device_address, return);
+       BT_CHECK_ENABLED(return);
+
+       BT_INIT_PARAMS();
+       BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+       g_array_append_vals(in_param1, device_address, sizeof(bluetooth_device_address_t));
+       g_array_append_vals(in_param2, &profile, sizeof(int));
+
+       result = _bt_send_request(BT_BLUEZ_SERVICE, BT_GET_PROFILE_RESTRICTED,
+                       in_param1, in_param2, in_param3, in_param4, &out_param);
+
+       if (result == BLUETOOTH_ERROR_NONE) {
+               restrict_profile = g_array_index(out_param, guint, 0);
+               BT_DBG("SUCCESSFUL");
+       }
+       BT_DBG("Restricted %d", restrict_profile);
+       *restricted = restrict_profile;
+       BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+       return result;
+}
+
 BT_EXPORT_API int bluetooth_passkey_reply(char *passkey, gboolean reply)
 {
        int result;
index bc85dcb..af3c69f 100644 (file)
@@ -229,35 +229,31 @@ BT_EXPORT_API int bluetooth_gatt_get_service_property(const char *service_handle
 
                } else if (!g_strcmp0(key, "Includes")) {
                        g_variant_get(value, "ao", &char_iter);
-                       if (char_iter != NULL) {
-                               gp_array = g_ptr_array_new();
-                               while (g_variant_iter_loop(char_iter, "&o", &char_handle))
-                                       g_ptr_array_add(gp_array, (gpointer)char_handle);
-
-                               if (gp_array->len != 0) {
-                                       service->include_handles.count = gp_array->len;
-                                       service->include_handles.handle =
-                                                       __get_string_array_from_gptr_array(gp_array);
-                               }
-                               g_ptr_array_free(gp_array, TRUE);
-                               g_variant_iter_free(char_iter);
+                       gp_array = g_ptr_array_new();
+                       while (g_variant_iter_loop(char_iter, "&o", &char_handle))
+                               g_ptr_array_add(gp_array, (gpointer)char_handle);
+
+                       if (gp_array->len != 0) {
+                               service->include_handles.count = gp_array->len;
+                               service->include_handles.handle =
+                                               __get_string_array_from_gptr_array(gp_array);
                        }
+                       g_ptr_array_free(gp_array, TRUE);
+                       g_variant_iter_free(char_iter);
                } else if (!g_strcmp0(key, "Characteristics")) {
                        g_variant_get(value, "ao", &char_iter);
-                       if (char_iter != NULL) {
-                               gp_array = g_ptr_array_new();
-                               while (g_variant_iter_loop(char_iter, "&o", &char_handle))
-                                       g_ptr_array_add(gp_array, (gpointer)char_handle);
-
-                               if (gp_array->len != 0) {
-                                       service->char_handle.count = gp_array->len;
-                                       service->char_handle.handle =
-                                                       __get_string_array_from_gptr_array(gp_array);
-                               }
-                               g_ptr_array_free(gp_array, TRUE);
-                               g_variant_iter_free(char_iter);
+                       gp_array = g_ptr_array_new();
+                       while (g_variant_iter_loop(char_iter, "&o", &char_handle))
+                               g_ptr_array_add(gp_array, (gpointer)char_handle);
+
+                       if (gp_array->len != 0) {
+                               service->char_handle.count = gp_array->len;
+                               service->char_handle.handle =
+                                               __get_string_array_from_gptr_array(gp_array);
                        }
                        BT_DBG("Characteristics count : %d", service->char_handle.count);
+                       g_ptr_array_free(gp_array, TRUE);
+                       g_variant_iter_free(char_iter);
                }
        }
 
@@ -1467,7 +1463,6 @@ static void __bluetooth_internal_write_desc_cb(GObject *source_object,
                                BLUETOOTH_ERROR_INTERNAL, resp_data,
                                user_info->cb, user_info->user_data);
                g_free(resp_data);
-               return;
        }
 
        g_variant_get(value, "(y)", &att_ecode);
index b727239..b46357d 100644 (file)
@@ -815,8 +815,6 @@ static void __bt_gatt_char_method_call(GDBusConnection *connection,
                                        user_info->cb, user_info->user_data);
                        }
                }
-               g_object_unref(invocation);
-               return;
        } else if (g_strcmp0(method_name, "StopNotify") == 0) {
                bt_user_info_t *user_info = NULL;
                bt_gatt_char_notify_change_t notify_change = {0, };
@@ -835,8 +833,6 @@ static void __bt_gatt_char_method_call(GDBusConnection *connection,
                                        user_info->cb, user_info->user_data);
                        }
                }
-               g_object_unref(invocation);
-               return;
        } else if (g_strcmp0(method_name, "IndicateConfirm") == 0) {
                gchar *addr = NULL;
                bt_gatt_indicate_confirm_t confirm = {0, };
index e391e6d..f955a97 100644 (file)
@@ -1027,6 +1027,37 @@ int __bt_bluez_request(int function_name,
 
                break;
        }
+       case BT_SET_PROFILE_RESTRICTED: {
+               bluetooth_device_address_t bd_addr = { {0} };
+               int profile;
+               int restricted;
+
+               __bt_service_get_parameters(in_param1, &bd_addr,
+                               sizeof(bluetooth_device_address_t));
+               __bt_service_get_parameters(in_param2, &profile, sizeof(int));
+               __bt_service_get_parameters(in_param3, &restricted, sizeof(int));
+
+               result = _bt_set_restrict_profile(&bd_addr, profile, restricted);
+               break;
+       }
+       case BT_GET_PROFILE_RESTRICTED: {
+               bluetooth_device_address_t bd_addr = { {0} };
+               int profile;
+               guint restricted_profile = 0;
+
+               __bt_service_get_parameters(in_param1, &bd_addr,
+                               sizeof(bluetooth_device_address_t));
+               __bt_service_get_parameters(in_param2, &profile, sizeof(int));
+
+               result = _bt_get_restrict_profile(&bd_addr, profile, &restricted_profile);
+               BT_DBG("Restricted %d", restricted_profile);
+               if (result == BLUETOOTH_ERROR_NONE) {
+                       g_array_append_vals(*out_param1, &restricted_profile,
+                                       sizeof(guint));
+               }
+
+               break;
+       }
        case BT_HID_CONNECT: {
                bluetooth_device_address_t address = { {0} };
 
@@ -3103,6 +3134,7 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_REMOVE_WHITE_LIST:
        case BT_CLEAR_WHITE_LIST:
        case BT_SET_MANUFACTURER_DATA:
+       case BT_SET_PROFILE_RESTRICTED:
 
        case BT_CANCEL_SEARCH_SERVICE:
        case BT_ENABLE_RSSI:
@@ -3111,8 +3143,6 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_RFCOMM_REJECT_CONNECTION:
        case BT_RFCOMM_LISTEN:
 
-       case BT_HID_ENABLE_BARCODE_FEATURE:
-
        case BT_AVRCP_CONTROL_GET_PROPERTY:
        case BT_AVRCP_GET_TRACK_INFO:
 
@@ -3201,6 +3231,7 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_GET_ADVERTISING_DATA:
        case BT_GET_SCAN_RESPONSE_DATA:
        case BT_IS_ADVERTISING:
+       case BT_GET_PROFILE_RESTRICTED:
        case BT_REGISTER_SCAN_FILTER:
        case BT_UNREGISTER_SCAN_FILTER:
        case BT_UNREGISTER_ALL_SCAN_FILTERS:
index 46b2230..53fe754 100644 (file)
@@ -734,8 +734,8 @@ int _bt_audio_connect(int request_id, int type,
        char *uuid = NULL;
        int value = BLUETOOTH_ERROR_NONE;
        bt_audio_function_data_t *func_data;
-       guint hfp_hs_trusted = TRUE; /* set default "allowed" */
-       guint a2dp_trusted = TRUE;
+       guint hfp_hs_restricted = 0x0; /* set default "allowed" */
+       guint a2dp_restricted = 0x0;
 
        BT_CHECK_PARAMETER(device_address, return);
 
@@ -753,11 +753,11 @@ int _bt_audio_connect(int request_id, int type,
        func_data->type = type;
        func_data->pending = BT_PENDING_NONE;
 
-       result = _bt_get_trust_profile(device_address, TRUSTED_PROFILE_HFP_HF, &hfp_hs_trusted);
+       result = _bt_get_restrict_profile(device_address, RESTRICTED_PROFILE_HFP_HS, &hfp_hs_restricted);
        if (result != BLUETOOTH_ERROR_NONE)
                BT_ERR("Can't get hfp_hs restriction info");
 
-       result = _bt_get_trust_profile(device_address, TRUSTED_PROFILE_A2DP, &a2dp_trusted);
+       result = _bt_get_restrict_profile(device_address, RESTRICTED_PROFILE_A2DP, &a2dp_restricted);
        if (result != BLUETOOTH_ERROR_NONE)
                BT_ERR("Can't get a2dp restriction info");
 
@@ -775,7 +775,7 @@ int _bt_audio_connect(int request_id, int type,
                uuid = A2DP_SOURCE_UUID;
                break;
        case BT_AUDIO_ALL:
-               if ((hfp_hs_trusted == TRUE) && (a2dp_trusted == TRUE)) { /* in case of both profiles are not restricted */
+               if ((hfp_hs_restricted == 0x0) && (a2dp_restricted == 0x0)) { /* in case of both profiles are not restricted */
                        if (__bt_device_support_uuid(address, BT_AUDIO_HSP)) {
                                uuid = HFP_HS_UUID;
                                func_data->pending = BT_PENDING_CONNECT;
@@ -788,11 +788,11 @@ int _bt_audio_connect(int request_id, int type,
                                result = BLUETOOTH_ERROR_SERVICE_NOT_FOUND;
                                goto fail;
                        }
-               } else if ((hfp_hs_trusted == FALSE) && (a2dp_trusted == FALSE)) { /* in case of both profiles are restricted */
+               } else if ((hfp_hs_restricted == 0x1) && (a2dp_restricted == 0x1)) { /* in case of both profiles are restricted */
                        BT_ERR("All profiles are restricted");
                        result = BLUETOOTH_ERROR_INTERNAL;
                        goto fail;
-               } else if (a2dp_trusted == FALSE) { /* in case of a2dp is restricted, only connection for hfp_hs */
+               } else if (a2dp_restricted == 0x01) { /* in case of a2dp is restricted, only connection for hfp_hs */
                        if (__bt_device_support_uuid(address, BT_AUDIO_HSP)) {
                                uuid = HFP_HS_UUID;
                                type = BT_AUDIO_HSP;
@@ -801,7 +801,7 @@ int _bt_audio_connect(int request_id, int type,
                                result = BLUETOOTH_ERROR_SERVICE_NOT_FOUND;
                                goto fail;
                        }
-               } else if (hfp_hs_trusted == FALSE) { /* in case of hfp_hs is restricted, only connection for a2dp */
+               } else if (hfp_hs_restricted == 0x01) { /* in case of hfp_hs is restricted, only connection for a2dp */
                        if (__bt_device_support_uuid(address, BT_AUDIO_A2DP)) {
                                uuid = A2DP_SINK_UUID;
                                type = BT_AUDIO_A2DP;
index 7384bb9..2617c66 100644 (file)
@@ -481,7 +481,6 @@ void _bt_convert_addr_string_to_secure_string(char *addr,
        ret_if(len != BT_ADDRESS_STRING_SIZE - 1);
 
        strncpy(addr, address, len);
-       addr[len] = '\0';
 
        addr[len-1] = 'X';
        addr[len-2] = 'X';
@@ -1117,6 +1116,8 @@ const char *_bt_convert_service_function_to_string(int function)
                {BT_UPDATE_LE_CONNECTION_MODE, "BT_UPDATE_LE_CONNECTION_MODE"},
                {BT_SET_PROFILE_TRUSTED, "BT_SET_PROFILE_TRUSTED"},
                {BT_GET_PROFILE_TRUSTED, "BT_GET_PROFILE_TRUSTED"},
+               {BT_SET_PROFILE_RESTRICTED, "BT_SET_PROFILE_RESTRICTED"},
+               {BT_GET_PROFILE_RESTRICTED, "BT_GET_PROFILE_RESTRICTED"},
                {BT_HID_CONNECT, "BT_HID_CONNECT"},
                {BT_HID_DISCONNECT, "BT_HID_DISCONNECT"},
                {BT_HID_DEVICE_ACTIVATE, "BT_HID_DEVICE_ACTIVATE"},
index cdcaac2..c129901 100644 (file)
@@ -71,9 +71,6 @@
 #define BT_LE_CONN_PARAM_LOW_POWER_SLAVE_LATENCY       2       /* event */
 
 #define PROFILE_SUPPORTED 0x3 /* This corresponds to binary 0b11*/
-#define PROFILE_TRUSTED 0x2 /* This corresponds to binary 0b10*/
-#define PROFILE_BLOCKED 0x1 /* This corresponds to binary 0b01*/
-#define PROFILE_SHOW_AUTH 0x0 /* This corresponds to binary 0b00*/
 
 typedef struct {
        int req_id;
@@ -2983,7 +2980,7 @@ int _bt_get_le_connection_parameter(bluetooth_le_connection_mode_t mode,
 int _bt_get_trusted_profile_from_flag(bluetooth_trusted_profile_t profile,
                guint trusted_profile_flag, guint *trusted)
 {
-       int trust_profile = FALSE;
+       int trust_profile;
        *trusted = FALSE;
 
        switch (profile) {
@@ -3005,24 +3002,6 @@ int _bt_get_trusted_profile_from_flag(bluetooth_trusted_profile_t profile,
                else
                        return BLUETOOTH_ERROR_NOT_SUPPORT;
                break;
-       case TRUSTED_PROFILE_HFP_HF: {
-               guint flag = (trusted_profile_flag & (PROFILE_SUPPORTED << 6)) >> 6;
-               BT_DBG("trusted_profile_flag %x", trusted_profile_flag);
-               if (flag != PROFILE_BLOCKED)
-                       trust_profile = TRUE;
-               else
-                       *trusted = FALSE;
-               break;
-       }
-       case TRUSTED_PROFILE_A2DP: {
-               guint flag = (trusted_profile_flag & (PROFILE_SUPPORTED << 8)) >> 8;
-               BT_DBG("trusted_profile_flag %x", trusted_profile_flag);
-               if (flag != PROFILE_BLOCKED)
-                       trust_profile = TRUE;
-               else
-                       *trusted = FALSE;
-               break;
-       }
        case TRUSTED_PROFILE_ALL: /* Return Flag for All profiles*/
                *trusted = trusted_profile_flag;
                return BLUETOOTH_ERROR_NONE;
@@ -3036,6 +3015,29 @@ int _bt_get_trusted_profile_from_flag(bluetooth_trusted_profile_t profile,
        return BLUETOOTH_ERROR_NONE;
 }
 
+int _bt_get_restricted_profile_from_flag(bluetooth_restricted_profile_t profile,
+               guint restricted_profile_flag, guint *restricted)
+{
+       int restrict_profile;
+       *restricted = FALSE;
+
+       switch (profile) {
+       case RESTRICTED_PROFILE_HFP_HS:
+                       restrict_profile = restricted_profile_flag & (1 << 0);
+               break;
+       case RESTRICTED_PROFILE_A2DP:
+                       restrict_profile = restricted_profile_flag & (1 << 2);
+               break;
+       default:
+               return BLUETOOTH_ERROR_NOT_SUPPORT;
+       }
+
+       if (restrict_profile)
+               *restricted = TRUE;
+
+       return BLUETOOTH_ERROR_NONE;
+}
+
 char *_bt_get_trusted_profile_uuid(bluetooth_trusted_profile_t profile)
 {
        switch (profile) {
@@ -3045,10 +3047,6 @@ char *_bt_get_trusted_profile_uuid(bluetooth_trusted_profile_t profile)
                return g_strdup("00001134-0000-1000-8000-00805f9b34fb");
        case TRUSTED_PROFILE_SAP:
                return g_strdup("0000112D-0000-1000-8000-00805f9b34fb");
-       case TRUSTED_PROFILE_HFP_HF:
-               return g_strdup("0000111e-0000-1000-8000-00805f9b34fb");
-       case TRUSTED_PROFILE_A2DP:
-               return g_strdup("0000110b-0000-1000-8000-00805f9b34fb");
        case TRUSTED_PROFILE_ALL:
                return NULL;
        }
@@ -3056,6 +3054,18 @@ char *_bt_get_trusted_profile_uuid(bluetooth_trusted_profile_t profile)
        return NULL;
 }
 
+char *_bt_get_restricted_profile_uuid(bluetooth_restricted_profile_t profile)
+{
+       switch (profile) {
+       case RESTRICTED_PROFILE_HFP_HS:
+               return g_strdup("0000111e-0000-1000-8000-00805f9b34fb");
+       case RESTRICTED_PROFILE_A2DP:
+               return g_strdup("0000110b-0000-1000-8000-00805f9b34fb");
+       }
+
+       return NULL;
+}
+
 bluetooth_trusted_profile_t _bt_get_trusted_profile_enum(const char *uuid)
 {
        if (g_strcmp0("0000112f-0000-1000-8000-00805f9b34fb", uuid) == 0)
@@ -3194,6 +3204,132 @@ int _bt_get_trust_profile(bluetooth_device_address_t *bd_addr,
        return ret;
 }
 
+int _bt_set_restrict_profile(bluetooth_device_address_t *bd_addr,
+               bluetooth_restricted_profile_t profile, gboolean restricted)
+{
+       int ret = BLUETOOTH_ERROR_NONE;
+       GDBusConnection *conn;
+       GDBusProxy *proxy;
+       GError *error = NULL;
+       char *device_path = NULL;
+       char *uuid = NULL;
+       char address[BT_ADDRESS_STRING_SIZE] = { 0 };
+       GVariant *reply;
+
+       BT_CHECK_PARAMETER(bd_addr, return);
+       BT_DBG("BD Address [%2.2X %2.2X %2.2X %2.2X %2.2X %2.2X] profile[%d] restricted[%d]",
+                       bd_addr->addr[0], bd_addr->addr[1],
+                       bd_addr->addr[2], bd_addr->addr[3],
+                       bd_addr->addr[4], bd_addr->addr[5],
+                       profile, restricted);
+
+       conn = _bt_gdbus_get_system_gconn();
+       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+       _bt_convert_addr_type_to_string(address, bd_addr->addr);
+
+       device_path = _bt_get_device_object_path(address);
+       retv_if(device_path == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+       proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                       NULL, BT_BLUEZ_NAME, device_path,
+                       BT_DEVICE_INTERFACE, NULL, NULL);
+
+       g_free(device_path);
+       retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+       uuid = _bt_get_restricted_profile_uuid(profile);
+       if (uuid == NULL) {
+               g_object_unref(proxy);
+               return BLUETOOTH_ERROR_NOT_SUPPORT;
+       }
+
+       reply = g_dbus_proxy_call_sync(proxy, "SetRestrictedProfile",
+                       g_variant_new("(sb)", uuid, restricted),
+                       G_DBUS_CALL_FLAGS_NONE, -1,
+                       NULL, &error);
+       g_object_unref(proxy);
+
+       if (reply == NULL) {
+               BT_ERR("Failed to Set Profile Restricted");
+               ret = BLUETOOTH_ERROR_INTERNAL;
+               if (error) {
+                       BT_ERR("Error %s[%s]", error->message, address);
+                       g_error_free(error);
+               }
+               goto finish;
+       }
+       g_variant_unref(reply);
+
+finish:
+       g_free(uuid);
+       return ret;
+}
+
+int _bt_get_restrict_profile(bluetooth_device_address_t *bd_addr,
+               bluetooth_restricted_profile_t profile, guint *restricted)
+{
+       int ret = BLUETOOTH_ERROR_NONE;
+       GDBusConnection *conn;
+       GDBusProxy *proxy;
+       GError *error = NULL;
+       char *device_path = NULL;
+       guint restricted_profile_flag;
+       char address[BT_ADDRESS_STRING_SIZE] = { 0 };
+       GVariant *reply;
+
+       BT_CHECK_PARAMETER(bd_addr, return);
+       BT_DBG("BD Address [%2.2X %2.2X %2.2X %2.2X %2.2X %2.2X] profile[%d] restricted[%d]",
+                       bd_addr->addr[0], bd_addr->addr[1],
+                       bd_addr->addr[2], bd_addr->addr[3],
+                       bd_addr->addr[4], bd_addr->addr[5],
+                       profile, *restricted);
+
+       conn = _bt_gdbus_get_system_gconn();
+       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+       _bt_convert_addr_type_to_string(address, bd_addr->addr);
+
+       device_path = _bt_get_device_object_path(address);
+       retv_if(device_path == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+       proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                       NULL, BT_BLUEZ_NAME, device_path,
+                       BT_PROPERTIES_INTERFACE, NULL, NULL);
+
+       g_free(device_path);
+       retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+       reply = g_dbus_proxy_call_sync(proxy, "Get",
+                       g_variant_new("(ss)", BT_DEVICE_INTERFACE, "RestrictedProfiles"),
+                       G_DBUS_CALL_FLAGS_NONE, -1,
+                       NULL, &error);
+       g_object_unref(proxy);
+
+       if (reply == NULL) {
+               BT_ERR("Failed to Get Profile Restricted");
+               ret = BLUETOOTH_ERROR_INTERNAL;
+               if (error) {
+                       BT_ERR("Error %s[%s]", error->message, address);
+                       g_error_free(error);
+               }
+               *restricted = 0;
+       } else {
+               GVariant *temp;
+               g_variant_get(reply, "(v)", &temp);
+               restricted_profile_flag = g_variant_get_uint32(temp);
+               BT_DBG("Restricted_FLAG %d", restricted_profile_flag);
+
+               ret = _bt_get_restricted_profile_from_flag(profile,
+                               restricted_profile_flag, restricted);
+               g_variant_unref(temp);
+               g_variant_unref(reply);
+       }
+
+       BT_DBG("TRUST %d", *restricted);
+       return ret;
+}
+
 static void __bt_request_att_mtu_device_cb(GDBusProxy *proxy, GAsyncResult *res,
                                        gpointer user_data)
 {
index 790342f..5588e7d 100644 (file)
@@ -1944,17 +1944,17 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path
                        gboolean connected;
 #endif
                        bt_headset_wait_t *wait_list;
-                       guint trusted = TRUE;
+                       guint restricted = 0x0;
 
                        __bt_set_device_values(TRUE,
                                VCONFKEY_BT_DEVICE_A2DP_HEADSET_CONNECTED);
 
                        __bt_connection_manager_set_state(address, event);
 
-                       _bt_get_trust_profile(&bd_addr, TRUSTED_PROFILE_HFP_HF, &trusted);
+                       _bt_get_restrict_profile(&bd_addr, RESTRICTED_PROFILE_HFP_HS, &restricted);
 
                        if (_bt_headset_get_local_connection() == FALSE) {
-                               if (trusted == TRUE) /* not restricted*/
+                               if (restricted == 0x0) /* not restricted*/
                                        _bt_start_timer_for_connection(address, BT_AUDIO_HSP);
                        } else {
                                /* Connection Started from local device therefore no need to
@@ -2245,13 +2245,11 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path
                address = g_malloc0(BT_ADDRESS_STRING_SIZE);
                _bt_convert_device_path_to_address(path, address);
 
-               BT_DBG("Ipsp BT Interface Name: %s, address: %s", ifname, address);
-
+               BT_DBG("Ipsp BT Interface Name: %s", ifname);
+               BT_DBG("address: %s", address);
                param = g_variant_new("(iss)", result, address, ifname);
                ipsp_param = g_variant_new("(ss)", ifname, address);
 
-               g_free(ifname);
-
                /* Set Ipv6 Addr */
                GDBusProxy *ipsp_proxy;
                if (connected) {
@@ -2260,8 +2258,6 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path
                        if (ipsp_proxy == NULL) {
                                BT_ERR("can not get ipsp proxy");
                                g_free(address);
-                               g_variant_unref(param);
-                               g_variant_unref(ipsp_param);
                                return;
                        }
 
@@ -2269,13 +2265,11 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path
                                        ipsp_param, G_DBUS_CALL_FLAGS_NONE,
                                        -1, NULL, NULL, NULL);
                } else {
-                       g_variant_unref(ipsp_param);
                        BT_DBG("IPSP disconnected");
                        ipsp_proxy = _bt_get_ipsp_proxy();
                        if (ipsp_proxy == NULL) {
                                BT_ERR("can not get ipsp proxy");
                                g_free(address);
-                               g_variant_unref(param);
                                return;
                        }
 
@@ -2285,7 +2279,9 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path
                }
 
                /* Send event to application */
-               _bt_send_event(BT_DEVICE_EVENT, event, param);
+               _bt_send_event(BT_DEVICE_EVENT,
+                                               event,
+                                               param);
                g_free(address);
        } else if (strcasecmp(member, "AttMtuChanged") == 0) {
                int result = BLUETOOTH_ERROR_NONE;
@@ -2374,7 +2370,7 @@ void _bt_handle_headset_event(GVariant *msg, const char *path)
                int event = BLUETOOTH_EVENT_NONE;
                bt_headset_wait_t *wait_list;
                char *address;
-               guint trusted = TRUE;
+               guint restricted = 0x0;
                g_variant_get(value, "b", &property_flag);
 
                address = g_malloc0(BT_ADDRESS_STRING_SIZE);
@@ -2384,10 +2380,10 @@ void _bt_handle_headset_event(GVariant *msg, const char *path)
 
                if (property_flag == TRUE) {
                        event = BLUETOOTH_EVENT_AG_CONNECTED;
-                       _bt_get_trust_profile(&bd_addr, TRUSTED_PROFILE_A2DP, &trusted);
+                       _bt_get_restrict_profile(&bd_addr, RESTRICTED_PROFILE_A2DP, &restricted);
 
                        if (_bt_headset_get_local_connection() == FALSE) {
-                               if (trusted == TRUE) /* not restricted*/
+                               if (restricted == 0x0) /* not restricted*/
                                        _bt_start_timer_for_connection(address, BT_AUDIO_A2DP);
                        } else
                                _bt_headset_set_local_connection(FALSE);
index 2587a15..ee5949a 100644 (file)
@@ -188,8 +188,6 @@ int _bt_hid_connect(int request_id,
 
        if (ret != BLUETOOTH_ERROR_NONE) {
                BT_ERR("_bt_connect_profile Error");
-               g_free(func_data->address);
-               g_free(func_data);
                return ret;
        }
        return BLUETOOTH_ERROR_NONE;
@@ -225,8 +223,6 @@ int _bt_hid_disconnect(int request_id,
 
        if (ret != BLUETOOTH_ERROR_NONE) {
                BT_ERR("_bt_disconnect_profile Error");
-               g_free(func_data->address);
-               g_free(func_data);
                return ret;
        }
 
@@ -235,7 +231,7 @@ int _bt_hid_disconnect(int request_id,
 
 int _bt_hid_enable_barcode_feature(void)
 {
-       if (vconf_set_bool(BT_HID_BARCODE_SUPPORT, true) != 0) {
+       if (vconf_set_int(BT_HID_BARCODE_SUPPORT, 1) != 0) {
                BT_ERR("Set vconf failed\n");
                return BLUETOOTH_ERROR_INTERNAL;
        }
index 4a07f0f..671d4e9 100644 (file)
@@ -123,6 +123,12 @@ int _bt_set_trust_profile(bluetooth_device_address_t *bd_addr,
 int _bt_get_trust_profile(bluetooth_device_address_t *bd_addr,
                bluetooth_trusted_profile_t profile, guint *trust);
 
+int _bt_set_restrict_profile(bluetooth_device_address_t *bd_addr,
+               bluetooth_restricted_profile_t profile, gboolean restricted);
+
+int _bt_get_restrict_profile(bluetooth_device_address_t *bd_addr,
+               bluetooth_restricted_profile_t profile, guint *restricted);
+
 bluetooth_trusted_profile_t _bt_get_trusted_profile_enum(const char *uuid);
 
 int _bt_connect_le_ipsp_device(const bluetooth_device_address_t *bd_addr);
index 77c4eab..63b250c 100644 (file)
@@ -1742,12 +1742,18 @@ typedef enum {
        TRUSTED_PROFILE_PBAP = 1,
        TRUSTED_PROFILE_MAP,
        TRUSTED_PROFILE_SAP,
-       TRUSTED_PROFILE_HFP_HF,
-       TRUSTED_PROFILE_A2DP,
        TRUSTED_PROFILE_ALL = 0xFFFFFFFF,
 } bluetooth_trusted_profile_t;
 
 /**
+ * Restricted Profile types
+ */
+typedef enum {
+       RESTRICTED_PROFILE_HFP_HS = 1,
+       RESTRICTED_PROFILE_A2DP,
+} bluetooth_restricted_profile_t;
+
+/**
  * Structure for LE data length change params
  */
 typedef struct {
@@ -2548,6 +2554,52 @@ int bluetooth_get_profile_trusted(
                int profile, int *trust);
 
 /**
+ * @fn int bluetooth_set_profile_restricted(const bluetooth_device_address_t *device_address, int profile, int restricted)
+ * @brief Sets a profile restricted connection for a device
+ *
+ * This function is used to Set a profile as restricted for a device
+ *
+ * This function is a synchronous call.
+ *
+ * @param[in]  device_address  a device address of remote bluetooth device
+ * @param[in]  profile profile which is to be set as restricted[1-HFP_HS, 2-A2DP]
+ * @param[in]  restricted      to set as restricted or not[1-restricted 0-permitted]
+ *
+ * @return     BLUETOOTH_ERROR_NONE - Success \n
+ *             BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
+ *             BLUETOOTH_ERROR_INVALID_PARAM - Bluetooth name parameter is incorrect \n
+ *             BLUETOOTH_ERROR_INTERNAL - The dbus method call is fail \n
+ *
+ * @remark      None
+ */
+int bluetooth_set_profile_restricted(
+               const bluetooth_device_address_t *device_address,
+               int profile, int restricted);
+
+/**
+ * @fn int bluetooth_get_profile_restricted(const bluetooth_device_address_t *device_address, int profile, int *restricted)
+ * @brief Gets a restricted connection state
+ *
+ * This function is used to Get a profile is restricted or not for a device
+ *
+ * This function is a synchronous call.
+ *
+ * @param[in]  device_address  a device address of remote bluetooth device
+ * @param[in]  profile profile whose restricted status is needed[1-HFP_HS, 2-A2DP]
+ * @param[out] restricted      profile is set as restricted or not[1-restricted 0-permitted]
+ *
+ * @return     BLUETOOTH_ERROR_NONE - Success \n
+ *             BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is not enabled \n
+ *             BLUETOOTH_ERROR_INVALID_PARAM - Bluetooth name parameter is incorrect \n
+ *             BLUETOOTH_ERROR_INTERNAL - The dbus method call is fail \n
+ *
+ * @remark      None
+ */
+int bluetooth_get_profile_restricted(
+               const bluetooth_device_address_t *device_address,
+               int profile, int *restricted);
+
+/**
  * @fn int bluetooth_get_discoverable_mode(bluetooth_discoverable_mode_t *discoverable_mode_ptr)
  * @brief Get the visibility mode
  *
index f0e4342..9e3c484 100644 (file)
@@ -208,6 +208,8 @@ typedef enum {
        BT_UPDATE_LE_CONNECTION_MODE,
        BT_SET_PROFILE_TRUSTED,
        BT_GET_PROFILE_TRUSTED,
+       BT_SET_PROFILE_RESTRICTED,
+       BT_GET_PROFILE_RESTRICTED,
        BT_HID_CONNECT = BT_FUNC_HID_BASE,
        BT_HID_DISCONNECT,
        BT_HID_DEVICE_ACTIVATE,