Adapt bt_device_get_id_address API into BT-HAL framework 95/224295/4
authorhimanshu <h.himanshu@samsung.com>
Fri, 7 Feb 2020 11:38:07 +0000 (17:08 +0530)
committerPyun DoHyun <dh79.pyun@samsung.com>
Tue, 11 Feb 2020 00:49:28 +0000 (00:49 +0000)
Change-Id: I40a822320d719f7da6c8312ff90158c98b9d0884
Signed-off-by: himanshu <h.himanshu@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 1cba249..afefed3 100644 (file)
@@ -383,6 +383,12 @@ static int get_trusted_profile(bt_bdaddr_t *bd_addr, bt_trusted_profile_t profil
        return _bt_hal_device_get_trusted_profile(bd_addr, profile, trusted);
 }
 
+static int get_device_ida(bt_bdaddr_t *bd_addr, bt_bdaddr_t *id_addr)
+{
+       DBG("");
+       return _bt_hal_device_get_ida(bd_addr, id_addr);
+}
+
 static int get_connected_link_rssi_strength(bt_bdaddr_t *bd_addr, uint32_t conn_link_type)
 {
        DBG("");
@@ -481,6 +487,7 @@ static const bt_interface_t bluetooth_if = {
        .unregister_agent_osp_server = unregister_agent_osp_server,
        .set_trusted_profile = set_trusted_profile,
        .get_trusted_profile = get_trusted_profile,
+       .get_device_ida = get_device_ida,
        .enable_rssi_monitoring = enable_rssi_monitoring,
        .get_connected_link_rssi_strength = get_connected_link_rssi_strength,
        .enable_gap_auth_notifications = enable_gap_auth_notifications,
index c705a9e..54f9339 100644 (file)
@@ -1596,6 +1596,75 @@ int _bt_hal_device_get_trusted_profile(const bt_bdaddr_t *bd_addr,
                        trusted_flag, trusted);
 }
 
+int _bt_hal_device_get_ida(bt_bdaddr_t *bd_addr, bt_bdaddr_t *id_addr)
+{
+       char address[BT_HAL_ADDRESS_STRING_SIZE] = { 0 };
+       gchar *device_path = NULL;
+       const gchar *idaddress = NULL;
+       GDBusProxy *device_proxy;
+       GError *error = NULL;
+       GVariant *result = NULL;
+       GDBusConnection *conn;
+       int ret = BT_STATUS_SUCCESS;
+
+       if (bd_addr == NULL)
+               return BT_STATUS_PARM_INVALID;
+
+       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);
+
+       DBG("The device_address is: [%s]", address);
+
+       device_path = _bt_hal_get_device_object_path(address);
+
+       if (!device_path) {
+               ERR("_bt_hal_get_device_object_path failed");
+               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("Unable to get proxy");
+               return BT_STATUS_FAIL;
+       }
+
+       result = g_dbus_proxy_call_sync(device_proxy, "GetIDAddress", NULL,
+                       G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+       if (result == NULL) {
+               ERR("Failed to get device ID address");
+
+               ret = BT_STATUS_FAIL;
+               if (error != NULL) {
+                       g_dbus_error_strip_remote_error(error);
+                       ERR("Error occured in Proxy call [%s]", error->message);
+                       if (g_strcmp0(error->message, "Does Not Exist") == 0)
+                               ERR("Device does not exist");
+                       g_error_free(error);
+               }
+               g_object_unref(device_proxy);
+               return ret;
+       }
+
+       g_variant_get(result , "(&s)", &idaddress);
+
+       DBG_SECURE("ID Address : %s", idaddress);
+       _bt_hal_convert_addr_string_to_type(id_addr->address, idaddress);
+
+       g_variant_unref(result);
+       g_object_unref(device_proxy);
+
+       return ret;
+}
+
 int _bt_hal_device_enable_rssi_monitoring(bt_bdaddr_t *bd_addr, uint32_t link_type,
                    int low_threshold, int in_range_threshold, int high_threshold)
 {
index 9cea7bb..9aaf84a 100644 (file)
@@ -75,6 +75,8 @@ int _bt_hal_device_set_trusted_profile(const bt_bdaddr_t *bd_addr,
 int _bt_hal_device_get_trusted_profile(const bt_bdaddr_t *bd_addr,
                bt_trusted_profile_t profile, uint32_t *trusted);
 
+int _bt_hal_device_get_ida(bt_bdaddr_t *bd_addr, bt_bdaddr_t *id_addr);
+
 int _bt_hal_device_enable_rssi_monitoring(bt_bdaddr_t *bd_addr, uint32_t conn_link_type,
                    int low_threshold, int in_range_threshold, int high_threshold);
 
index b365a20..e9515c3 100644 (file)
@@ -882,6 +882,11 @@ typedef struct {
        int (*get_trusted_profile)(bt_bdaddr_t *bd_addr, bt_trusted_profile_t profile, uint32_t *trusted);
 
        /**
+        * Gets the identity address of the remote device
+        */
+       int (*get_device_ida)(bt_bdaddr_t *bd_addr, bt_bdaddr_t *id_addr);
+
+       /**
         * Get raw RSSI strength of remote device for connected link type
         * conn_link_type: (0 = BR/EDR link, 1 = LE link, 0xFF = Any (Default))
         */
index 2d1d583..dca40dc 100755 (executable)
@@ -379,6 +379,19 @@ oal_status_t device_unregister_osp_server(oal_osp_server_type_e type, char *uuid
 oal_status_t device_set_trust_profile(bt_address_t *addr, oal_trusted_profile_e profile, gboolean trust);
 
 /**
+ * @brief Gets the identity address for remote device
+ *
+ * @details This API is used to get the identity address for the remote device
+ *
+ * @param[in] device_address: Remote device address.
+ *
+ * @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
+ * @retval #OAL_STATUS_SUCCESS  Successful
+ *
+ */
+oal_status_t device_get_ida(bt_address_t *addr, bt_address_t *id_addr);
+
+/**
  * @brief Set profile trust info for remote device
  *
  * @details This API is used to set profile as trusted/blocked for remote device
index aedbd1a..d3da0d3 100755 (executable)
@@ -179,6 +179,25 @@ oal_status_t device_stop_bond(bt_address_t * addr)
        return OAL_STATUS_SUCCESS;
 }
 
+oal_status_t device_get_ida(bt_address_t *device_address, bt_address_t *id_address)
+{
+       int res;
+
+       CHECK_OAL_INITIALIZED();
+
+       OAL_CHECK_PARAMETER(device_address, return);
+
+       API_TRACE();
+
+       res = blued_api->get_device_ida((bt_bdaddr_t*) device_address, (bt_bdaddr_t*) id_address);
+
+       if (res != BT_STATUS_SUCCESS)
+               BT_ERR("get_device_IDA failed: [%s]",status2string(res));
+
+       res = convert_to_oal_status(res);
+       return res;
+}
+
 oal_status_t device_accept_pin_request(bt_address_t * addr, const char * pin)
 {
        int res;
index cdd32e6..4c0eef7 100644 (file)
@@ -2644,6 +2644,21 @@ int __bt_bluez_request(int function_name,
                }
                break;
        }
+       case BT_GET_DEVICE_IDA: {
+               bluetooth_device_address_t address = { {0} };
+               bluetooth_device_address_t id_addr = { {0} };
+
+               __bt_service_get_parameters(in_param1,
+                               &address, sizeof(bluetooth_device_address_t));
+
+               result = _bt_device_get_ida(&address, &id_addr);
+
+               if (result == BLUETOOTH_ERROR_NONE) {
+                       g_array_append_vals(*out_param1, &id_addr,
+                                       sizeof(bluetooth_device_address_t));
+               }
+               break;
+       }
        case BT_SET_LE_STATIC_RANDOM_ADDRESS: {
                gboolean is_enable;
 
index c20d330..68c55a7 100644 (file)
@@ -2309,6 +2309,25 @@ int _bt_unset_pin_code(bluetooth_device_address_t *device_address)
        return BLUETOOTH_ERROR_NONE;
 }
 
+int _bt_device_get_ida(bluetooth_device_address_t *device_address, bluetooth_device_address_t *id_address)
+{
+       int result = BLUETOOTH_ERROR_NONE;
+       char address[BT_ADDRESS_STRING_SIZE] = { 0 };
+
+       _bt_convert_addr_type_to_string(address, device_address->addr);
+
+       BT_DBG("getting IDA for remote device: [%s]", address);
+
+       result = device_get_ida((bt_address_t*)device_address, (bt_address_t*)id_address);
+
+       if (result != OAL_STATUS_SUCCESS) {
+               BT_ERR("device_get_ida Failed %d", result);
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+
+       return result;
+}
+
 #ifdef TIZEN_GATT_CLIENT
 static bt_connected_le_dev_t *__bt_get_le_connected_dev_info(const char *address)
 {
index 301cdb6..f9a6a93 100755 (executable)
@@ -125,6 +125,8 @@ int _bt_disconnect_device(bluetooth_device_address_t *device_addr);
 
 int _bt_get_le_connection_parameter(bluetooth_le_connection_mode_t mode,
                bluetooth_le_connection_param_t *param);
+int _bt_device_get_ida(bluetooth_device_address_t *device_address,
+               bluetooth_device_address_t *id_address);
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */