[BT-frwk] Added Set/Get Trusted profile APIs 84/159884/2
authorAtul Rai <a.rai@samsung.com>
Mon, 13 Nov 2017 11:33:14 +0000 (17:03 +0530)
committerAtul Rai <a.rai@samsung.com>
Mon, 13 Nov 2017 12:12:52 +0000 (17:42 +0530)
This patch adds support for Trusted profile Get/Set APIs
in bt-service, BT-OAL and BlueZHAL.

Change-Id: I72392598fa6f2bfb01b2443959267209c84339be
Signed-off-by: Atul Rai <a.rai@samsung.com>
bt-oal/bluez_hal/src/bt-hal-bluetooth.c
bt-oal/bluez_hal/src/bt-hal-device-dbus-handler.c
bt-oal/bluez_hal/src/bt-hal-device-dbus-handler.h
bt-oal/hardware/bluetooth.h
bt-oal/include/oal-device-mgr.h
bt-oal/oal-device-mgr.c
bt-service-adaptation/services/bt-request-handler.c
bt-service-adaptation/services/device/bt-service-core-device.c
bt-service-adaptation/services/include/bt-service-core-device.h

index 5258afb..72fee40 100644 (file)
@@ -351,6 +351,18 @@ static int set_agent_osp_server(uint32_t type, uint8_t enable)
        DBG("");
        return _bt_hal_device_set_osp_server(type, enable);
 }
+
+static int set_trusted_profile(bt_bdaddr_t *bd_addr, bt_trusted_profile_t profile, uint8_t trust)
+{
+       DBG("");
+       return _bt_hal_device_set_trusted_profile(bd_addr, profile, trust);
+}
+
+static int get_trusted_profile(bt_bdaddr_t *bd_addr, bt_trusted_profile_t profile, uint32_t *trusted)
+{
+       DBG("");
+       return _bt_hal_device_get_trusted_profile(bd_addr, profile, trusted);
+}
 #endif
 
 static const bt_interface_t bluetooth_if = {
@@ -402,6 +414,8 @@ static const bt_interface_t bluetooth_if = {
 #ifdef TIZEN_BT_HAL
        .get_service_connection_state = get_service_connection_state,
        .set_agent_osp_server = set_agent_osp_server,
+       .set_trusted_profile = set_trusted_profile,
+       .get_trusted_profile = get_trusted_profile,
 #endif
 };
 
index 2bef01b..448645d 100644 (file)
 #include "bt-hal-agent.h"
 #include "bt-hal-gap-agent.h"
 
+#define PROFILE_SUPPORTED 0x03
+#define PROFILE_TRUSTED 0x02
+#define PROFILE_BLOCKED 0x01
+
 static handle_stack_msg event_cb = NULL;
 
 /* Forward Delcaration */
@@ -1335,4 +1339,252 @@ int _bt_hal_device_set_osp_server(uint32_t type, gboolean enable)
        DBG("-");
        return BT_STATUS_SUCCESS;
 }
+
+static char* __bt_hal_get_trusted_profile_uuid(bt_trusted_profile_t profile)
+{
+       switch (profile) {
+       case BT_TRUSTED_PROFILE_PBAP:
+               return g_strdup("00001130-0000-1000-8000-00805f9b34fb");
+       case BT_TRUSTED_PROFILE_MAP:
+               return g_strdup("00001134-0000-1000-8000-00805f9b34fb");
+       case BT_TRUSTED_PROFILE_SAP:
+               return g_strdup("0000112D-0000-1000-8000-00805f9b34fb");
+       case BT_TRUSTED_PROFILE_HFP_HF:
+               return g_strdup("0000111e-0000-1000-8000-00805f9b34fb");
+       case BT_TRUSTED_PROFILE_A2DP:
+               return g_strdup("0000110b-0000-1000-8000-00805f9b34fb");
+       case BT_TRUSTED_PROFILE_ALL:
+               return NULL;
+       }
+
+       return NULL;
+}
+
+int _bt_hal_device_set_trusted_profile(const bt_bdaddr_t *bd_addr,
+               bt_trusted_profile_t profile, uint8_t trust)
+{
+       char address[BT_HAL_ADDRESS_STRING_SIZE];
+       gchar *device_path = NULL;
+       GDBusProxy *adapter_proxy;
+       GDBusProxy *device_proxy;
+       GError *error = NULL;
+       GDBusConnection *conn;
+       GVariant *result;
+       char *uuid = NULL;
+       gboolean trusted;
+
+       DBG("+");
+
+       if (!bd_addr) {
+               ERR("bd_addr is NULL");
+               return BT_STATUS_PARM_INVALID;
+       }
+
+       adapter_proxy = _bt_hal_get_adapter_proxy();
+       if (!adapter_proxy) {
+               ERR("Could not get Adapter Proxy");
+               return BT_STATUS_FAIL;
+       }
+
+       conn = _bt_hal_get_system_gconn();
+       if (!conn) {
+               ERR("_bt_hal_get_system_gconn failed");
+               return BT_STATUS_FAIL;
+       }
+
+       _bt_hal_convert_addr_type_to_string(address, bd_addr->address);
+       INFO("Address: %s: profile: %d, trusted: %d", address, profile, trust);
+
+       device_path = _bt_hal_get_device_object_path(address);
+       if (device_path == NULL) {
+               ERR("No paired device");
+               return BT_STATUS_FAIL;
+       }
+
+       device_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                       NULL, BT_HAL_BLUEZ_NAME, device_path,
+                       BT_HAL_DEVICE_INTERFACE, NULL, NULL);
+       g_free(device_path);
+       if (!device_proxy) {
+               ERR("Error creating device_proxy");
+               return BT_STATUS_FAIL;
+       }
+
+       uuid = __bt_hal_get_trusted_profile_uuid(profile);
+       if (!uuid) {
+               ERR("Not supported");
+               g_object_unref(device_proxy);
+               return BT_STATUS_UNSUPPORTED;
+       }
+
+       trusted = ((trust == 0) ? FALSE : TRUE);
+       DBG("uuid: %s", uuid);
+       result = g_dbus_proxy_call_sync(device_proxy, "SetTrustedProfile",
+                       g_variant_new("(sb)", uuid, trusted),
+                       G_DBUS_CALL_FLAGS_NONE,
+                       -1, NULL, &error);
+       g_free(uuid);
+       g_object_unref(device_proxy);
+       if (!result) {
+               ERR("Failed to Set Profile Trusted, Error occured in proxy call");
+               if (error != NULL) {
+                       ERR("(Error: %s)", error->message);
+                       g_clear_error(&error);
+               }
+               return BT_STATUS_FAIL;
+       }
+
+       g_variant_unref(result);
+
+       DBG("-");
+       return BT_STATUS_SUCCESS;
+}
+
+static int __hal_get_trusted_value_from_flag(bt_trusted_profile_t profile,
+               uint32_t trusted_flag, uint32_t *trusted)
+{
+       DBG("+");
+
+       *trusted = 0;
+       switch (profile) {
+       case BT_TRUSTED_PROFILE_PBAP:
+               /* Bit 0 & 1 - for PBAP Supported */
+               trusted_flag = (trusted_flag >> 0);
+
+               if (!(trusted_flag & PROFILE_SUPPORTED))
+                       return BT_STATUS_UNSUPPORTED;
+
+               *trusted = trusted_flag & PROFILE_TRUSTED;
+               DBG("Profile %d, trusted: %s", profile,
+                               ((*trusted == 0) ? "FALSE" : "TRUE"));
+               break;
+       case BT_TRUSTED_PROFILE_MAP:
+               /* Bit 2 & 3 - for MAP Supported */
+               trusted_flag = (trusted_flag >> 2);
+
+               if (!(trusted_flag & PROFILE_SUPPORTED))
+                       return BT_STATUS_UNSUPPORTED;
+
+               *trusted = trusted_flag & PROFILE_TRUSTED;
+               DBG("Profile %d, trusted: %s", profile,
+                               ((*trusted == 0) ? "FALSE" : "TRUE"));
+               break;
+       case BT_TRUSTED_PROFILE_SAP:
+               /* Bit 4 & 5 - for SAP Supported */
+               trusted_flag = (trusted_flag >> 4);
+
+               if (!(trusted_flag & PROFILE_SUPPORTED))
+                       return BT_STATUS_UNSUPPORTED;
+
+               *trusted = trusted_flag & PROFILE_TRUSTED;
+               DBG("Profile %d, trusted: %s", profile,
+                               ((*trusted == 0) ? "FALSE" : "TRUE"));
+               break;
+       case BT_TRUSTED_PROFILE_HFP_HF:
+               /* Bit 6 & 7 - for HFP_HF Supported */
+               trusted_flag = (trusted_flag >> 6);
+
+               if (PROFILE_BLOCKED != (trusted_flag & PROFILE_SUPPORTED))
+                       *trusted = 1;
+
+               DBG("Profile %d, trusted: %s", profile,
+                               ((*trusted == 0) ? "FALSE" : "TRUE"));
+               break;
+       case BT_TRUSTED_PROFILE_A2DP:
+               /* Bit 8 & 9 - for A2DP Supported */
+               trusted_flag = (trusted_flag >> 8);
+
+               if (PROFILE_BLOCKED != (trusted_flag & PROFILE_SUPPORTED))
+                       *trusted = 1;
+
+               DBG("Profile %d, trusted: %s", profile,
+                               ((*trusted == 0) ? "FALSE" : "TRUE"));
+               break;
+       case BT_TRUSTED_PROFILE_ALL:
+               /* Return Flag for All profiles*/
+               *trusted = trusted_flag;
+               return BT_STATUS_SUCCESS;
+       default:
+               return BT_STATUS_UNSUPPORTED;
+       }
+
+       if (0 != *trusted)
+               *trusted = 1;
+
+       DBG("-");
+       return BT_STATUS_SUCCESS;
+}
+
+int _bt_hal_device_get_trusted_profile(const bt_bdaddr_t *bd_addr,
+               bt_trusted_profile_t profile, uint32_t *trusted)
+{
+       char address[BT_HAL_ADDRESS_STRING_SIZE];
+       gchar *device_path = NULL;
+       GDBusProxy *adapter_proxy;
+       GDBusProxy *device_proxy;
+       GError *error = NULL;
+       GDBusConnection *conn;
+       GVariant *result;
+       GVariant *temp;
+       uint32_t trusted_flag;
+
+       if (!bd_addr) {
+               ERR("bd_addr is NULL");
+               return BT_STATUS_PARM_INVALID;
+       }
+
+       adapter_proxy = _bt_hal_get_adapter_proxy();
+       if (!adapter_proxy) {
+               ERR("Could not get Adapter Proxy");
+               return BT_STATUS_FAIL;
+       }
+
+       conn = _bt_hal_get_system_gconn();
+       if (!conn) {
+               ERR("_bt_hal_get_system_gconn failed");
+               return BT_STATUS_FAIL;
+       }
+
+       _bt_hal_convert_addr_type_to_string(address, bd_addr->address);
+       INFO("Address: %s: profile: %d", address, profile);
+
+       device_path = _bt_hal_get_device_object_path(address);
+       if (device_path == NULL) {
+               ERR("No paired device");
+               return BT_STATUS_FAIL;
+       }
+
+       device_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+                       NULL, BT_HAL_BLUEZ_NAME, device_path,
+                       BT_HAL_PROPERTIES_INTERFACE, NULL, NULL);
+       g_free(device_path);
+       if (!device_proxy) {
+               ERR("Error creating device_proxy");
+               return BT_STATUS_FAIL;
+       }
+
+       result = g_dbus_proxy_call_sync(device_proxy, "Get",
+                       g_variant_new("(ss)", BT_HAL_DEVICE_INTERFACE, "TrustedProfiles"),
+                       G_DBUS_CALL_FLAGS_NONE, -1,
+                       NULL, &error);
+       g_object_unref(device_proxy);
+       if (!result) {
+               ERR("Failed to get trusted profile, Error occured in proxy call");
+               if (error != NULL) {
+                       ERR("(Error: %s)", error->message);
+                       g_clear_error(&error);
+               }
+               *trusted = 0;
+               return BT_STATUS_FAIL;
+       }
+
+       g_variant_get(result, "(v)", &temp);
+       trusted_flag = g_variant_get_uint32(temp);
+       DBG("TRUST_FLAG 0x%X", trusted_flag);
+       g_variant_unref(temp);
+       g_variant_unref(result);
+
+       return __hal_get_trusted_value_from_flag(profile,
+                       trusted_flag, trusted);
+}
 #endif
index 8281930..3cd0e19 100644 (file)
@@ -67,6 +67,13 @@ int _bt_hal_device_get_service_connection_state(
                const bt_bdaddr_t *bd_addr, bt_service_id_t rem_svc_id);
 
 int _bt_hal_device_set_osp_server(uint32_t type, gboolean enable);
+
+
+int _bt_hal_device_set_trusted_profile(const bt_bdaddr_t *bd_addr,
+               bt_trusted_profile_t profile, uint8_t trust);
+
+int _bt_hal_device_get_trusted_profile(const bt_bdaddr_t *bd_addr,
+               bt_trusted_profile_t profile, uint32_t *trusted);
 #endif
 
 #ifdef __cplusplus
index 050f6c8..986d35a 100644 (file)
@@ -417,6 +417,15 @@ typedef enum {
     BT_DISC_ROLE_DUAL
 } bt_disc_role_type_t;
 
+/** Bluetooth Trusted Profiles */
+typedef enum {
+       BT_TRUSTED_PROFILE_PBAP = 1,
+       BT_TRUSTED_PROFILE_MAP,
+       BT_TRUSTED_PROFILE_SAP,
+       BT_TRUSTED_PROFILE_HFP_HF,
+       BT_TRUSTED_PROFILE_A2DP,
+       BT_TRUSTED_PROFILE_ALL = 0xFFFFFFFF,
+} bt_trusted_profile_t;
 #endif
 
 /** Bluetooth Interface callbacks */
@@ -751,6 +760,16 @@ typedef struct {
      * enable == 0/1 -> Register/Unregister osp server.
      */
     int (*set_agent_osp_server)(uint32_t type, uint8_t enable);
+
+    /**
+     * Set profile as trusted for remote device
+     */
+    int (*set_trusted_profile)(bt_bdaddr_t *bd_addr, bt_trusted_profile_t profile, uint8_t trust);
+
+    /**
+     * Get profile trusted status for remote device
+     */
+    int (*get_trusted_profile)(bt_bdaddr_t *bd_addr, bt_trusted_profile_t profile, uint32_t *trusted);
 #endif
 } bt_interface_t;
 
index 157e117..f9b591d 100755 (executable)
@@ -52,6 +52,20 @@ typedef enum {
 } oal_osp_server_type_e;
 
 /**
+ * @brief Trusted profile types
+ *
+ * @see  device_set_trust_profile/device_get_trust_profile
+ */
+typedef enum {
+       OAL_TRUSTED_PROFILE_PBAP = 1,
+       OAL_TRUSTED_PROFILE_MAP,
+       OAL_TRUSTED_PROFILE_SAP,
+       OAL_TRUSTED_PROFILE_HFP_HF,
+       OAL_TRUSTED_PROFILE_A2DP,
+       OAL_TRUSTED_PROFILE_ALL = 0xFFFFFFFF,
+} oal_trusted_profile_e;
+
+/**
  * @brief Request remote device attributes
  *
  * @details Attibutes such as name, vidpid, bond state etc are requested. remote_device_t is provided
@@ -317,6 +331,41 @@ gboolean device_get_svc_conn_state(bt_address_t * addr, oal_service_t svc_id);
  * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
  */
 oal_status_t device_set_osp_server(oal_osp_server_type_e type, int enable);
+
+/**
+ * @brief Set profile trust info for remote device
+ *
+ * @details This API is used to set profile as trusted/blocked for remote device
+ *
+ * @param[in] addr: Remote device address.
+ * @param[in] profile: Trusted profile enum
+ * @param[in] trust: TRUE == Trusted, FALSE == Blocked
+ *
+ * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
+ * @retval #OAL_STATUS_SUCCESS Successful
+ *
+ * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
+ *
+ */
+oal_status_t device_set_trust_profile(bt_address_t *addr, oal_trusted_profile_e profile, gboolean trust);
+
+/**
+ * @brief Set profile trust info for remote device
+ *
+ * @details This API is used to set profile as trusted/blocked for remote device
+ *
+ * @param[in] addr: Remote device address.
+ * @param[in] profile: Trusted profile enum
+ * @param[out] trusted: 0 == Blocked, non-zero: Trusted values
+ *
+ * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
+ * @retval #OAL_STATUS_SUCCESS Successful
+ *
+ * @pre Adapter must be enabled with adapter_enable() followed by OAL_EVENT_ADAPTER_ENABLED
+ *
+ */
+oal_status_t device_get_trust_profile(bt_address_t *addr, oal_trusted_profile_e profile, unsigned int *trusted);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index e80dbed..6cc5e64 100755 (executable)
@@ -418,6 +418,58 @@ oal_status_t device_set_osp_server(oal_osp_server_type_e type, int enable)
 #endif
 }
 
+oal_status_t device_set_trust_profile(bt_address_t *addr, oal_trusted_profile_e profile, gboolean trust)
+{
+       int res;
+       bdstr_t bdstr;
+
+       CHECK_OAL_INITIALIZED();
+
+       OAL_CHECK_PARAMETER(addr, return);
+
+       API_TRACE("[%s]", bdt_bd2str(addr, &bdstr));
+
+#ifdef TIZEN_BT_HAL
+       res = blued_api->set_trusted_profile((bt_bdaddr_t *)addr, profile, (trust ? 1 : 0));
+       if (res != BT_STATUS_SUCCESS) {
+               BT_ERR("set_trusted_profile error: [%s]", status2string(res));
+               return convert_to_oal_status(res);
+       }
+
+       return OAL_STATUS_SUCCESS;
+#else
+       BT_ERR("Not supported");
+       res = OAL_STATUS_NOT_SUPPORT;
+       return res;
+#endif
+}
+
+oal_status_t device_get_trust_profile(bt_address_t *addr, oal_trusted_profile_e profile, unsigned int *trusted)
+{
+       int res;
+       bdstr_t bdstr;
+
+       CHECK_OAL_INITIALIZED();
+
+       OAL_CHECK_PARAMETER(addr, return);
+
+       API_TRACE("[%s]", bdt_bd2str(addr, &bdstr));
+
+#ifdef TIZEN_BT_HAL
+       res = blued_api->get_trusted_profile((bt_bdaddr_t *)addr, profile, trusted);
+       if (res != BT_STATUS_SUCCESS) {
+               BT_ERR("set_trusted_profile error: [%s]", status2string(res));
+               return convert_to_oal_status(res);
+       }
+
+       return OAL_STATUS_SUCCESS;
+#else
+       BT_ERR("Not supported");
+       res = OAL_STATUS_NOT_SUPPORT;
+       return res;
+#endif
+}
+
 void cb_device_properties(bt_status_t status, bt_bdaddr_t *bd_addr,
                int num_properties, bt_property_t *properties)
 {
index 9f8bd3e..e4c6eff 100644 (file)
@@ -824,6 +824,37 @@ int __bt_bluez_request(int function_name,
                }
                break;
        }
+       case BT_SET_PROFILE_TRUSTED: {
+               bluetooth_device_address_t bd_addr = { {0} };
+               int profile;
+               int trust;
+
+               __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, &trust, sizeof(int));
+
+               result = _bt_set_trust_profile(&bd_addr, profile, trust);
+               break;
+       }
+       case BT_GET_PROFILE_TRUSTED: {
+               bluetooth_device_address_t bd_addr = { {0} };
+               int profile;
+               guint trusted_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_trust_profile(&bd_addr, profile, &trusted_profile);
+               BT_DBG("TRUST %d", trusted_profile);
+               if (result == BLUETOOTH_ERROR_NONE) {
+                       g_array_append_vals(*out_param1, &trusted_profile,
+                                       sizeof(guint));
+               }
+
+               break;
+       }
        case BT_HID_CONNECT: {
                bluetooth_device_address_t address = { {0} };
 
index 85229b9..1e488f7 100644 (file)
@@ -95,7 +95,6 @@ bt_pairing_data_t *trigger_pairing_info;
 bt_service_search_info_data_t *service_search_info;
 #ifdef TIZEN_FEATURE_BT_OBEX
 gboolean is_device_creating;
-static GSList *pin_info_list = NULL;
 #endif
 
 bt_incoming_bond_data_t *incoming_bond_info;
@@ -342,122 +341,76 @@ static void __bt_device_remote_properties_callback(event_dev_properties_t *oal_d
        BT_DBG("-");
 }
 
-#ifdef TIZEN_FEATURE_BT_OBEX
-char *_bt_get_trusted_profile_uuid(bluetooth_trusted_profile_t profile)
+static int __get_oal_trusted_profile(bluetooth_trusted_profile_t profile)
 {
        switch (profile) {
        case TRUSTED_PROFILE_PBAP:
-               return g_strdup("00001130-0000-1000-8000-00805f9b34fb");
+               return OAL_TRUSTED_PROFILE_PBAP;
        case TRUSTED_PROFILE_MAP:
-               return g_strdup("00001134-0000-1000-8000-00805f9b34fb");
+               return OAL_TRUSTED_PROFILE_MAP;
        case TRUSTED_PROFILE_SAP:
-               return g_strdup("0000112D-0000-1000-8000-00805f9b34fb");
+               return OAL_TRUSTED_PROFILE_SAP;
+       case TRUSTED_PROFILE_HFP_HF:
+               return OAL_TRUSTED_PROFILE_HFP_HF;
+       case TRUSTED_PROFILE_A2DP:
+               return OAL_TRUSTED_PROFILE_A2DP;
        case TRUSTED_PROFILE_ALL:
-               return NULL;
+               return OAL_TRUSTED_PROFILE_ALL;
+       default:
+               return 0;
        }
-
-       return NULL;
 }
 
-
-int _bt_set_trust_profile(bluetooth_device_address_t *bd_addr,
+int _bt_set_trust_profile(bluetooth_device_address_t *addr,
                bluetooth_trusted_profile_t profile, gboolean trust)
 {
-       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] trust[%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, trust);
-
-       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);
+       int result;
+       bt_address_t bd_addr;
+       oal_trusted_profile_e oal_profile;
 
-       g_free(device_path);
-       retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
+       BT_DBG("+");
 
-       uuid = _bt_get_trusted_profile_uuid(profile);
-       if (uuid == NULL) {
-               g_object_unref(proxy);
-               return BLUETOOTH_ERROR_NOT_SUPPORT;
-       }
+       retv_if(!addr, BLUETOOTH_ERROR_INVALID_PARAM);
 
-       reply = g_dbus_proxy_call_sync(proxy, "SetTrustedProfile",
-                       g_variant_new("(sb)", uuid, trust),
-                       G_DBUS_CALL_FLAGS_NONE, -1,
-                       NULL, &error);
-       g_object_unref(proxy);
+       memcpy(bd_addr.addr, addr, BLUETOOTH_ADDRESS_LENGTH);
+       oal_profile = __get_oal_trusted_profile(profile);
+       retv_if(0 == oal_profile, BLUETOOTH_ERROR_NOT_SUPPORT);
 
-       if (reply == NULL) {
-               BT_ERR("Failed to Set Profile Trusted");
-               ret = BLUETOOTH_ERROR_INTERNAL;
-               if (error) {
-                       BT_ERR("Error %s[%s]", error->message, address);
-                       g_error_free(error);
-               }
-               goto finish;
+       result = device_set_trust_profile(&bd_addr, oal_profile, trust);
+       if (result != OAL_STATUS_SUCCESS) {
+               BT_ERR("device_set_trust_profile error: [%d]", result);
+               return BLUETOOTH_ERROR_INTERNAL;
        }
-       g_variant_unref(reply);
-
-finish:
-       g_free(uuid);
-       return ret;
-}
 
-bluetooth_trusted_profile_t _bt_get_trusted_profile_enum(const char *uuid)
-{
-       if (g_strcmp0("0000112f-0000-1000-8000-00805f9b34fb", uuid) == 0)
-               return TRUSTED_PROFILE_PBAP;
-       else if (g_strcmp0("00001132-0000-1000-8000-00805f9b34fb", uuid) == 0)
-               return TRUSTED_PROFILE_MAP;
-       else if (g_strcmp0("0000112D-0000-1000-8000-00805f9b34fb", uuid) == 0)
-               return TRUSTED_PROFILE_SAP;
-
-       return 0; /* 0 - Unknown Profile */
+       BT_DBG("-");
+       return BLUETOOTH_ERROR_NONE;
 }
 
-
-int _bt_get_device_pin_code(const char *address, char *pin_code)
+int _bt_get_trust_profile(bluetooth_device_address_t *addr,
+               bluetooth_trusted_profile_t profile, guint *trust)
 {
-       GSList *l = NULL;
+       int result;
+       bt_address_t bd_addr;
+       oal_trusted_profile_e oal_profile;
 
-       BT_CHECK_PARAMETER(address, return);
-       BT_CHECK_PARAMETER(pin_code, return);
+       BT_DBG("+");
 
-       for (l = pin_info_list; l != NULL; l = l->next) {
-               bt_pin_code_info_t *pin_info = l->data;
+       retv_if(!addr, BLUETOOTH_ERROR_INVALID_PARAM);
 
-               if (g_strcmp0(pin_info->address, address) == 0) {
-                       g_strlcpy(pin_code, pin_info->pin_code,
-                                       BLUETOOTH_PIN_CODE_MAX_LENGTH + 1);
+       memcpy(bd_addr.addr, addr, BLUETOOTH_ADDRESS_LENGTH);
+       oal_profile = __get_oal_trusted_profile(profile);
+       retv_if(0 == oal_profile, BLUETOOTH_ERROR_NOT_SUPPORT);
 
-                       return BLUETOOTH_ERROR_NONE;
-               }
+       result = device_get_trust_profile(&bd_addr, oal_profile, trust);
+       if (result != OAL_STATUS_SUCCESS) {
+               BT_ERR("device_set_trust_profile error: [%d]", result);
+               return BLUETOOTH_ERROR_INTERNAL;
        }
 
-       return BLUETOOTH_ERROR_NOT_FOUND;
+       BT_DBG("-");
+       return BLUETOOTH_ERROR_NONE;
 }
 
-#endif
-
 static void __bt_handle_ongoing_device_service_search(bt_remote_dev_info_t *remote_dev_info)
 {
        GVariant *param = NULL;
index 7c3acb1..9ee675e 100755 (executable)
@@ -38,11 +38,6 @@ gboolean _bt_is_device_creating(void);
 
 bluetooth_trusted_profile_t _bt_get_trusted_profile_enum(const char *uuid);
 
-
-int _bt_set_trust_profile(bluetooth_device_address_t *bd_addr,
-               bluetooth_trusted_profile_t profile, gboolean trust);
-
-
 int _bt_get_device_pin_code(const char *address, char *pin_code);
 #endif
 
@@ -101,6 +96,11 @@ int _bt_is_alias_set(bluetooth_device_address_t *device_address);
 
 int _bt_get_connected_link(bluetooth_device_address_t *device_address);
 
+int _bt_set_trust_profile(bluetooth_device_address_t *bd_addr,
+               bluetooth_trusted_profile_t profile, gboolean trust);
+
+int _bt_get_trust_profile(bluetooth_device_address_t *bd_addr,
+               bluetooth_trusted_profile_t profile, guint *trust);
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */