[Bluetooth-Frwk] TCT Fixes over Latest Tizen branch 25/168225/6
authorAbhishek Chandra <abhishek.ch@samsung.com>
Thu, 25 Jan 2018 05:47:04 +0000 (11:17 +0530)
committerAbhishek Chandra <abhishek.ch@samsung.com>
Thu, 25 Jan 2018 08:11:23 +0000 (13:41 +0530)
Fixed issues in the TCT failures on Tizen branch
Fixed SVACE warnings and errors
Change-Id: Iab509cabfe0472954119a31bb0bfc88a8e8a1395
Signed-off-by: Abhishek Chandra <abhishek.ch@samsung.com>
15 files changed:
bt-oal/bluez_hal/src/bt-hal-adapter-le.c
bt-oal/bluez_hal/src/bt-hal-bluetooth.c
bt-oal/bluez_hal/src/bt-hal-event-receiver.c
bt-oal/hardware/bluetooth.h
bt-oal/include/oal-adapter-mgr.h
bt-oal/oal-adapter-mgr.c
bt-oal/oal-gatt.c
bt-service-adaptation/services/adapter/bt-service-core-adapter-le.c
bt-service-adaptation/services/adapter/bt-service-core-adapter.c
bt-service-adaptation/services/bt-request-handler.c
bt-service-adaptation/services/include/bt-service-common.h
bt-service-adaptation/services/include/bt-service-core-adapter-le.h
bt-service-adaptation/services/ipsp/bt-service-ipsp-event-receiver.c [changed mode: 0755->0644]
bt-service-adaptation/services/obex/bt-service-obex-event-receiver.c [changed mode: 0755->0644]
bt-service-adaptation/services/obex/bt-service-obex-server.c [changed mode: 0755->0644]

index a489902..56066cb 100644 (file)
@@ -178,15 +178,14 @@ void _bt_hal_set_advertising_status(int slot_id, gboolean mode)
 
 gboolean _bt_hal_is_advertising(void)
 {
-       gboolean status = FALSE;
        int i;
 
        for (i = 0; i < le_feature_info.adv_inst_max; i++) {
                if (le_adv_slot[i].is_advertising == TRUE)
-                       status = TRUE;
+                       return TRUE;
        }
 
-       return status;
+       return FALSE;
 }
 
 int _bt_hal_le_init(void)
index 3aeb35a..489e2d1 100644 (file)
@@ -401,6 +401,7 @@ static const bt_interface_t bluetooth_if = {
        .le_disable = _bt_hal_le_disable,
        .le_init = _bt_hal_le_init,
        .le_deinit = _bt_hal_le_deinit,
+       .is_advertising = _bt_hal_is_advertising,
 #endif
        .cleanup = cleanup,
 #ifdef TIZEN_BT_HAL
index 1d2eaff..4adffbe 100644 (file)
@@ -233,7 +233,6 @@ static void __bt_hal_adapter_property_changed_event(GVariant *msg)
                        size += __bt_insert_hal_properties(buf + size,
                                        HAL_PROP_ADAPTER_NAME, strlen(name) + 1, name);
                        ev->num_props++;
-                       g_free(name);
                } else if (!g_strcmp0(key, "Class")) {
                        cod = g_variant_get_uint32(value);
                        DBG("##Class [%d]", cod);
@@ -274,7 +273,6 @@ static void __bt_hal_adapter_property_changed_event(GVariant *msg)
                        size += __bt_insert_hal_properties(buf + size,
                                        HAL_PROP_ADAPTER_NAME, strlen(name) + 1, name);
                        ev->num_props++;
-                       g_free(name);
                } else if (!g_strcmp0(key, "Powered")) {
                        powered = g_variant_get_boolean(value);
                        DBG("##Powered = %d", powered);
@@ -441,7 +439,6 @@ static void __bt_hal_adapter_property_changed_event(GVariant *msg)
                        while (g_variant_iter_next(iter, "&s", &name) &&
                                g_variant_iter_next(iter, "&s", &val)) {
                                DBG("name = %s, Value = %s", name, val);
-                               g_variant_iter_loop(iter, "s", &val);
                                if (FALSE == _bt_hal_update_le_feature_support(name, val))
                                        ERR("Failed to update LE feature (name = %s, value = %s)", name, val);
                        }
index 2d3c4fa..2971117 100644 (file)
@@ -660,6 +660,8 @@ typedef struct {
        int (*le_init)(void);
 
        void (*le_deinit)(void);
+
+       int (*is_advertising) (void);
 #endif
 
        /** Closes the interface. */
index 801f930..0dfacf0 100644 (file)
@@ -429,6 +429,19 @@ oal_status_t adapter_ble_multi_adv_enable(int instance_id);
  */
 oal_status_t adapter_ble_multi_adv_disable(int instance_id);
 
+/**
+ * @brief Check if the advertising is enable
+ *
+ * @param void
+ *
+ * @details check from the LE adv list if the Advertising is enabled on the server created.
+ *
+ * @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 is_advertising(void);
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index 94148f6..f12a508 100644 (file)
@@ -261,6 +261,27 @@ oal_status_t le_deinit(void)
 #endif
        return ret;
 }
+oal_status_t is_advertising(void)
+{
+       int ret = BT_STATUS_SUCCESS;
+       API_TRACE();
+       CHECK_OAL_INITIALIZED();
+#ifdef TIZEN_BT_HAL
+       if (OAL_STATUS_SUCCESS != hw_is_module_ready()) {
+               g_timeout_add(200, retry_enable_le, NULL);
+               return OAL_STATUS_PENDING;
+       }
+       int r = blued_api->is_advertising();
+       if (r == TRUE)
+               ret = BT_STATUS_SUCCESS;
+       else
+               ret = BT_STATUS_FAIL;
+#else
+       BT_INFO("Not Supported");
+       ret = OAL_STATUS_NOT_SUPPORT;
+#endif
+       return ret;
+}
 oal_status_t adapter_start_custom_inquiry(discovery_type_t disc_type)
 {
        int ret;
@@ -732,7 +753,7 @@ static void cb_adapter_properties(bt_status_t status,
                                char * adap_name = g_strdup(local_name);
 
                                /* Application has requested this property SET/GET hence send EVENT */
-                               send_event(OAL_EVENT_ADAPTER_PROPERTY_NAME, adap_name, strlen(adap_name));
+                               send_event(OAL_EVENT_ADAPTER_PROPERTY_NAME, adap_name, strlen(adap_name)+1);
                        }
                        break;
                }
index 8d7772f..d204a86 100644 (file)
@@ -773,11 +773,6 @@ oal_status_t gatts_add_service(int instance_id, oal_gatt_srvc_id_t *gatt_serv_id
        CHECK_SERVER_INSTANCE(instance_id);
        CHECK_SERVER_REGISTRATION(instance_id);
 
-       if (gatt_servers[instance_id - 1].server_id < 0)        {
-               BT_INFO("GATT server registeration is not done for server Instance : %d", instance_id);
-               return gatts_register(&gatt_servers[instance_id - 1].uuid);
-       }
-
        if (gatt_serv_id != NULL) {
                uuid_to_stringname(&(gatt_serv_id->id.uuid), str);
                API_TRACE("Service uuid: [%s]", str);
index eafce27..353ae2c 100644 (file)
@@ -234,8 +234,9 @@ static void __bt_adapter_le_handle_pending_request_info(int result,
        invocation_info_t *req_info = NULL;
        BT_DBG("+");
 
-       for (l = _bt_get_invocation_list(); l != NULL; l = g_slist_next(l)) {
+       for (l = _bt_get_invocation_list(); l != NULL; ) {
                req_info = l->data;
+               l = g_slist_next(l);
                if (req_info == NULL || req_info->service_function != service_function)
                        continue;
 
@@ -317,7 +318,6 @@ static void __bt_le_handle_server_instance_registered(event_gatts_register_t *da
        /* Get sender and adv handle for the server instance */
        _bt_get_adv_handle_from_instance(data->server_inst, &adv_handle);
 
-       if (adv_handle > 0) {
                /* Check if pending Adv Data set or Scan response data set request is pending*/
                for (l = adv_data_pending_list; l != NULL; l = l->next) {
                        info = l->data;
@@ -366,7 +366,6 @@ static void __bt_le_handle_server_instance_registered(event_gatts_register_t *da
                                                                (void*)info, sizeof(bt_pending_adv_data_set_t));
                                                }
                                                goto data_free;
-                                       }
                                }
                        }
                }
@@ -991,7 +990,7 @@ int _bt_get_advertising_data(char *sender, int adv_handle, bluetooth_advertising
        }
 
        _bt_get_previous_adv_data(adv, length, server_instance);
-       BT_DBG("ADV Data length [%d] Server Instance [%d] Adv handle [%d]", length, server_instance, adv_handle);
+       BT_DBG("ADV Data length [%d] Server Instance [%d] Adv handle [%d]", *length, server_instance, adv_handle);
 
        return BLUETOOTH_ERROR_NONE;
 }
@@ -1012,7 +1011,7 @@ int _bt_get_scan_response_data(char *sender, int adv_handle, bluetooth_scan_resp
        }
 
        _bt_get_previous_scan_rsp_data(response, length, server_instance);
-       BT_DBG("SCAN RSP Data length [%d] Server Instance [%d] Adv handle [%d]", length, server_instance, adv_handle);
+       BT_DBG("SCAN RSP Data length [%d] Server Instance [%d] Adv handle [%d]", *length, server_instance, adv_handle);
 
        return BLUETOOTH_ERROR_NONE;
 }
@@ -1556,5 +1555,14 @@ void _bt_service_le_deinit(void)
        le_deinit();
 }
 
+int _bt_is_advertising(void)
+{
+       int ret = is_advertising();
+
+       if (ret == BLUETOOTH_ERROR_NONE)
+               return TRUE;
+       else
+               return FALSE;
+}
 
 /*************************************** LE Scan APIs *********************************************/
index 3053ac7..e97f016 100644 (file)
@@ -960,53 +960,41 @@ int _bt_init_profiles()
 
        /*TODO: Init bluetooth profiles */
        ret = _bt_hidhost_initialize();
-       if (ret != BLUETOOTH_ERROR_NONE) {
+       if (ret != BLUETOOTH_ERROR_NONE)
                BT_ERR("_bt_hidhost_initialize Failed");
-               return ret;
-       }
 
        ret = _bt_socket_init();
-       if (ret != BLUETOOTH_ERROR_NONE) {
+       if (ret != BLUETOOTH_ERROR_NONE)
                BT_ERR("_bt_socket_init Failed");
-               return ret;
-       }
 
        /*
         * Query local adapter services and based on a2dp service uuids initialized
         * in bluetooth stack, enable A2DP sourec or A2DP sink role.
         */
        ret =  adapter_get_service_uuids();
-       if (ret != OAL_STATUS_SUCCESS) {
+       if (ret != OAL_STATUS_SUCCESS)
                BT_ERR("adapter_get_service_uuids failed: %d", ret);
-               return BLUETOOTH_ERROR_INTERNAL;
-       } else {
+       else
                a2dp_init_pending = TRUE;
-       }
+
 
        /* Initialize HFP Audio Gateway */
        ret = _bt_audio_initialize(BT_AG_MODULE);
-       if (ret != BLUETOOTH_ERROR_NONE) {
+       if (ret != BLUETOOTH_ERROR_NONE)
                BT_ERR("_bt_audio_initialize(BT_AG_MODULE) Failed");
-               return ret;
-       }
+
        /* Registering callback for receiving audio services searched */
        ret = _bt_audio_initialize(BT_AUDIO_ALL_MODULE);
-       if (ret != BLUETOOTH_ERROR_NONE) {
+       if (ret != BLUETOOTH_ERROR_NONE)
                BT_ERR("_bt_audio_initialize(BT_AUDIO_ALL_MODULE) Failed");
-               return ret;
-       }
 
        ret = _bt_hdp_init();
-       if (ret != BLUETOOTH_ERROR_NONE) {
+       if (ret != BLUETOOTH_ERROR_NONE)
                BT_ERR("_bt_hdp_init Failed");
-               return ret;
-       }
 
        ret = _bt_gatt_init();
-       if (ret != BLUETOOTH_ERROR_NONE) {
+       if (ret != BLUETOOTH_ERROR_NONE)
                BT_ERR("_bt_gatt_init Failed");
-               return ret;
-       }
 
        return BLUETOOTH_ERROR_NONE;
 }
index 22e6ea1..c649e36 100644 (file)
@@ -2403,6 +2403,13 @@ int __bt_bluez_request(int function_name,
                break;
        }
 #endif
+       case BT_IS_ADVERTISING: {
+               gboolean advertising = FALSE;
+               advertising = _bt_is_advertising();
+               g_array_append_vals(*out_param1, &advertising,
+                               sizeof(gboolean));
+               break;
+       }
        default:
                BT_INFO("UnSupported function [%d]", function_name);
                result = BLUETOOTH_ERROR_NOT_SUPPORT;
index e5e8e3d..04e7d32 100644 (file)
@@ -180,6 +180,7 @@ extern "C" {
 #define BT_OBEX_CLIENT_INTERFACE "org.bluez.obex.Client1"
 #ifdef TIZEN_FEATURE_BT_OBEX
 #define BT_OBEX_MESSAGE_INTERFACE "org.bluez.obex.MessageAccess1"
+#define BT_EVENT_FREEDESKTOP "org.freedesktop.DBus"
 #endif
 
 #define BT_OBEX_TRANSFER_INTERFACE "org.bluez.obex.Transfer1"
index 3fc1bd6..5e41fb1 100644 (file)
@@ -51,6 +51,7 @@ int _bt_le_init(void);
 
 void _bt_le_deinit(void);
 
+int _bt_is_advertising(void);
 int _bt_set_advertising(const char *sender, int adv_handle, gboolean enable, gboolean use_reserved_slot);
 
 int _bt_set_custom_advertising(const char *sender, int adv_handle, gboolean enable, bluetooth_advertising_params_t *params, gboolean use_reserved_slot);
old mode 100755 (executable)
new mode 100644 (file)
index bfcd6b6..cc7575b
@@ -184,11 +184,9 @@ static  void __bt_manager_event_filter(GDBusConnection *connection,
        if (signal_name == NULL)
                return;
 
-       BT_DBG("IPSP __bt_manager_event_filter Interface Name [%s]", interface_name);
 
 
        g_variant_get(parameters, "(&s@a{sv}@as)", &inf_name, &val, NULL);
-       BT_DBG("Interface Name [%s] Signal Name : [%s] ", inf_name, signal_name);
 
        if (g_strcmp0(interface_name, BT_PROPERTIES_INTERFACE) == 0) {
 
old mode 100755 (executable)
new mode 100644 (file)
index 5ee6f6e..47ff0e5
@@ -1419,7 +1419,6 @@ static  void __bt_obexd_event_filter(GDBusConnection *connection,
 
                _bt_handle_property_changed_event(parameters, path);
        }
-       BT_DBG("-");
        return;
 }
 
@@ -1601,6 +1600,7 @@ int _bt_register_manager_subscribe_signal(GDBusConnection *conn,
 
        static int subs_interface_added_id = -1;
        static int subs_interface_removed_id = -1;
+       static int subs_name_owner_changed = -1;
 
        if (subscribe) {
                if (subs_interface_added_id == -1) {
@@ -1617,6 +1617,12 @@ int _bt_register_manager_subscribe_signal(GDBusConnection *conn,
                                __bt_manager_event_filter,
                                NULL, NULL);
                }
+               if (subs_name_owner_changed == -1) {
+                       subs_name_owner_changed = g_dbus_connection_signal_subscribe(conn,
+                               NULL, BT_EVENT_FREEDESKTOP,
+                               BT_NAME_OWNER_CHANGED, NULL, NULL, 0,
+                               __bt_manager_event_filter, NULL, NULL);
+               }
 
        } else {
                if (subs_interface_added_id != -1) {
@@ -1629,6 +1635,12 @@ int _bt_register_manager_subscribe_signal(GDBusConnection *conn,
                                        subs_interface_removed_id);
                        subs_interface_removed_id = -1;
                }
+               if (subs_name_owner_changed != -1) {
+                       g_dbus_connection_signal_unsubscribe(conn,
+                                       subs_name_owner_changed);
+                       subs_name_owner_changed = -1;
+               }
+
        }
        return 0;
 }
old mode 100755 (executable)
new mode 100644 (file)
index ff1f02e..88c4c85
@@ -1163,6 +1163,7 @@ int _bt_obex_server_deallocate(int app_pid, gboolean is_native)
                retv_if(agent_info.custom_server->app_pid != app_pid,
                                BLUETOOTH_ERROR_ACCESS_DENIED);
 
+
                __bt_free_server_info(agent_info.custom_server);
                agent_info.custom_server = NULL;