From 06d4aa79af7c22e9d4427e138db5ce9734c6e21f Mon Sep 17 00:00:00 2001 From: Deokhyun Kim Date: Wed, 19 Dec 2018 14:02:48 +0900 Subject: [PATCH] Improve inefficiency Change-Id: Icd2b33c68d384680e24eec64de9256efb60c1084 Signed-off-by: Deokhyun Kim --- bt-service/bt-service-event-receiver.c | 146 ++++++++++++------------- 1 file changed, 73 insertions(+), 73 deletions(-) diff --git a/bt-service/bt-service-event-receiver.c b/bt-service/bt-service-event-receiver.c index c66c1c51..77404c3d 100644 --- a/bt-service/bt-service-event-receiver.c +++ b/bt-service/bt-service-event-receiver.c @@ -1953,95 +1953,95 @@ void _bt_handle_device_event(GVariant *msg, const char *member, const char *path _bt_convert_uuid_to_string(profile_uuid), _bt_convert_profile_state_to_string(state), secure_address); - if ((strcmp(profile_uuid, A2DP_SINK_UUID) == 0) && - (state == BT_PROFILE_STATE_CONNECTED)) { + if (strcmp(profile_uuid, A2DP_SINK_UUID) == 0) { + if (state == BT_PROFILE_STATE_CONNECTED) { - int event = BLUETOOTH_EVENT_AV_CONNECTED; - char connected_address[BT_ADDRESS_STRING_SIZE + 1]; - bluetooth_device_address_t device_address; - gboolean connected; - bt_headset_wait_t *wait_list; - guint restricted = 0x0; + int event = BLUETOOTH_EVENT_AV_CONNECTED; + char connected_address[BT_ADDRESS_STRING_SIZE + 1]; + bluetooth_device_address_t device_address; + gboolean connected; + bt_headset_wait_t *wait_list; + guint restricted = 0x0; - __bt_set_device_values(TRUE, - VCONFKEY_BT_DEVICE_A2DP_HEADSET_CONNECTED); + __bt_set_device_values(TRUE, + VCONFKEY_BT_DEVICE_A2DP_HEADSET_CONNECTED); - __bt_connection_manager_set_state(address, event); + __bt_connection_manager_set_state(address, event); - _bt_get_restrict_profile(&bd_addr, RESTRICTED_PROFILE_HFP_HS, &restricted); + _bt_get_restrict_profile(&bd_addr, RESTRICTED_PROFILE_HFP_HS, &restricted); - if (_bt_headset_get_local_connection() == FALSE) { - if (restricted == 0x0) /* not restricted*/ - _bt_start_timer_for_connection(address, BT_AUDIO_HSP); - } else { - /* Connection Started from local device therefore no need to - * intiate connection for pending profile */ - _bt_headset_set_local_connection(FALSE); - } - param = g_variant_new("(is)", result, address); - _bt_send_event(BT_HEADSET_EVENT, event, - param); - connected = _bt_is_headset_type_connected(BT_AUDIO_A2DP, - connected_address); - if (connected) { - if (g_strcmp0(connected_address, address) != 0) { - _bt_convert_addr_string_to_type( - device_address.addr, - connected_address); - _bt_audio_disconnect(0, BT_AUDIO_A2DP, - &device_address, NULL); + if (_bt_headset_get_local_connection() == FALSE) { + if (restricted == 0x0) /* not restricted*/ + _bt_start_timer_for_connection(address, BT_AUDIO_HSP); + } else { + /* Connection Started from local device therefore no need to + * intiate connection for pending profile */ + _bt_headset_set_local_connection(FALSE); + } + param = g_variant_new("(is)", result, address); + _bt_send_event(BT_HEADSET_EVENT, event, + param); + connected = _bt_is_headset_type_connected(BT_AUDIO_A2DP, + connected_address); + if (connected) { + if (g_strcmp0(connected_address, address) != 0) { + _bt_convert_addr_string_to_type( + device_address.addr, + connected_address); + _bt_audio_disconnect(0, BT_AUDIO_A2DP, + &device_address, NULL); + } } - } - _bt_add_headset_to_list(BT_AUDIO_A2DP, - BT_STATE_CONNECTED, address); + _bt_add_headset_to_list(BT_AUDIO_A2DP, + BT_STATE_CONNECTED, address); - wait_list = _bt_get_audio_wait_data(); - if (wait_list != NULL && - (g_strcmp0(wait_list->address, address) == 0)) - _bt_rel_wait_data(); + wait_list = _bt_get_audio_wait_data(); + if (wait_list != NULL && + (g_strcmp0(wait_list->address, address) == 0)) + _bt_rel_wait_data(); - } else if ((strcmp(profile_uuid, A2DP_SINK_UUID) == 0) && - (state == BT_PROFILE_STATE_DISCONNECTED)) { + } else if (state == BT_PROFILE_STATE_DISCONNECTED) { - int event = BLUETOOTH_EVENT_AV_DISCONNECTED; + int event = BLUETOOTH_EVENT_AV_DISCONNECTED; - if (!_bt_is_service_connected(address, BT_AUDIO_A2DP)) { - g_free(address); - g_free(profile_uuid); - return; - } + if (!_bt_is_service_connected(address, BT_AUDIO_A2DP)) { + g_free(address); + g_free(profile_uuid); + return; + } - __bt_set_device_values(FALSE, - VCONFKEY_BT_DEVICE_A2DP_HEADSET_CONNECTED); + __bt_set_device_values(FALSE, + VCONFKEY_BT_DEVICE_A2DP_HEADSET_CONNECTED); - __bt_connection_manager_set_state(address, event); - param = g_variant_new("(is)", result, address); - _bt_send_event(BT_HEADSET_EVENT, event, - param); - /* Remove data from the connected list */ - _bt_remove_headset_from_list(BT_AUDIO_A2DP, address); - wait_list = _bt_get_audio_wait_data(); + __bt_connection_manager_set_state(address, event); + param = g_variant_new("(is)", result, address); + _bt_send_event(BT_HEADSET_EVENT, event, + param); + /* Remove data from the connected list */ + _bt_remove_headset_from_list(BT_AUDIO_A2DP, address); + wait_list = _bt_get_audio_wait_data(); - if (wait_list == NULL) { - g_free(address); - g_free(profile_uuid); - return; - } + if (wait_list == NULL) { + g_free(address); + g_free(profile_uuid); + return; + } - if (((wait_list->type == BT_AUDIO_ALL) && - (wait_list->ag_flag == TRUE)) || - (wait_list->type == BT_AUDIO_A2DP) || - (wait_list->disconnection_type == BT_AUDIO_A2DP)) { - bluetooth_device_address_t device_address; - _bt_convert_addr_string_to_type( - device_address.addr, - wait_list->address); + if (((wait_list->type == BT_AUDIO_ALL) && + (wait_list->ag_flag == TRUE)) || + (wait_list->type == BT_AUDIO_A2DP) || + (wait_list->disconnection_type == BT_AUDIO_A2DP)) { + bluetooth_device_address_t device_address; + _bt_convert_addr_string_to_type( + device_address.addr, + wait_list->address); - _bt_audio_connect(wait_list->req_id, - wait_list->type, - &device_address, - NULL); + _bt_audio_connect(wait_list->req_id, + wait_list->type, + &device_address, + NULL); + } } } else if (strcmp(profile_uuid, AVRCP_TARGET_UUID) == 0) { -- 2.34.1