Add audio type converting function to debug 65/230465/2 accepted/tizen/unified/20200414.135759 submit/tizen/20200410.064409
authorWootak Jung <wootak.jung@samsung.com>
Thu, 9 Apr 2020 08:20:27 +0000 (17:20 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Fri, 10 Apr 2020 06:03:28 +0000 (15:03 +0900)
Change-Id: I6facec76215195842b97d5175da54f57ab03bf3a
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
bt-service-adaptation/services/audio/bt-service-audio.c
bt-service-adaptation/services/bt-service-event-sender.c

index 49a59c3..bf485ea 100644 (file)
@@ -94,6 +94,30 @@ gboolean _bt_headset_get_local_connection()
 }
 #endif
 
+static const char *__convert_audio_type_to_string(bt_audio_type_t type)
+{
+       switch (type) {
+       case BT_AUDIO_HSP:
+               return "AUDIO_HSP";
+       case BT_AUDIO_A2DP:
+               return "AUDIO_A2DP";
+       case BT_AUDIO_ALL:
+               return "AUDIO_ALL";
+       case BT_AVRCP_TARGET:
+               return "AVRCP_TARGET";
+       case BT_AVRCP:
+               return "AVRCP";
+       case BT_AUDIO_A2DP_SOURCE:
+               return "A2DP_SOURCE";
+       case BT_AUDIO_HFP_SOURCE:
+               return "HFP_SOURCE";
+       case BT_AUDIO_AG:
+               return "AUDIO_AG";
+       default:
+               return "Invalid";
+       }
+}
+
 void _bt_set_audio_wait_data_flag(gboolean flag)
 {
        BT_DBG("_bt_set_audio_wait_data_flag \n");
@@ -291,20 +315,21 @@ static int __bt_is_headset_connected(int current_conn_type, const char *address)
 #endif
 
        /* Check if any other headset is connected */
-       GList *node = NULL;;
+       GList *node = NULL;
 
-       BT_INFO("Checking  if any Headset connected or not: current device [%s] current dev type [%d]", address, current_conn_type);
+       BT_INFO("Checking if any Headset connected or not: current device [%s] current audio type [%s]",
+                       address, __convert_audio_type_to_string(current_conn_type));
        node = g_list_first(g_connected_list);
        while (node != NULL) {
                connected_device = node->data;
-               BT_INFO(" A Device is already connected found in list [%s] conn type [%d]",
-                               connected_device->device_address, connected_device->type);
+               BT_INFO("A Device is already connected found in list [%s] audio type [%s]",
+                               connected_device->device_address, __convert_audio_type_to_string(connected_device->type));
                if ((connected_device->type & current_conn_type)) {
                        g_strlcpy(connected_address, connected_device->device_address,
                                        BT_ADDRESS_STRING_SIZE + 1);
 #ifdef TIZEN_SUPPORT_DUAL_HF
                        is_companion_device = __bt_is_companion_device(connected_address);
-                       BT_INFO(" is_companion_device[%d]", is_companion_device);
+                       BT_INFO("is_companion_device[%d]", is_companion_device);
 
                        if (!is_companion_device) {
                                connected = TRUE;
@@ -319,7 +344,8 @@ static int __bt_is_headset_connected(int current_conn_type, const char *address)
        }
 
        if (!connected) {
-               BT_INFO("There is no connected device with connection type [%d]", current_conn_type);
+               BT_INFO("There is no connected device with connection type [%s]",
+                               __convert_audio_type_to_string(current_conn_type));
                return BLUETOOTH_ERROR_NOT_CONNECTED;
        }
 
@@ -335,10 +361,12 @@ static int __bt_is_headset_connected(int current_conn_type, const char *address)
        /* Convert BD address from string type */
        _bt_convert_addr_string_to_type(device_address.addr, connected_address);
        int value = BLUETOOTH_ERROR_NONE;
-       BT_DBG("Already connected headset addr  [%s] connected headset type [0x%x] current dev conn type [0x%x]",
-                               connected_address, connected_device->type, current_conn_type);
+       BT_DBG("Already headset connected. addr [%s] connected type [%s] current audio type [%s]",
+                       connected_address, __convert_audio_type_to_string(connected_device->type),
+                       __convert_audio_type_to_string(current_conn_type));
        disconn_type = connected_device->type & current_conn_type;
-       BT_DBG("Attempt disconnection of Type [0x%x] of already connected device" , disconn_type);
+       BT_DBG("Attempt disconnection of Type [%s] of already connected device",
+                       __convert_audio_type_to_string(disconn_type));
        value = _bt_audio_disconnect(disconn_type, &device_address);
 
        /* If already one device is waiting, remove current waiting device and add new */
@@ -429,9 +457,9 @@ static int __bt_process_audio_profile_connect(bt_audio_type_t type, bluetooth_de
                //_bt_headset_set_local_connection(TRUE);
                /* Add data to the connected list */
                _bt_add_headset_to_list(type, BT_STATE_CONNECTING, addr);
-               BT_PERMANENT_LOG("Connect %d", type);
+               BT_PERMANENT_LOG("Connect %s", __convert_audio_type_to_string(type));
        } else {
-               BT_ERR("Profile [%d] connect failed!!", type);
+               BT_ERR("Profile [%s] connect failed!!", __convert_audio_type_to_string(type));
        }
        BT_INFO("-");
        return result;
@@ -477,7 +505,9 @@ static int __bt_process_audio_profile_disconnect(bt_audio_type_t type, bluetooth
                        bt_connected_headset_data_t *connected_device = node->data;
 
                        if (g_strcmp0(connected_device->device_address, addr) == 0) {
-                               BT_DBG("Connection type update");
+                               BT_DBG("Connection type update. old type[%s] -> new type[%s]",
+                                               __convert_audio_type_to_string(connected_device->type),
+                                               __convert_audio_type_to_string(type));
                                type = connected_device->type;
                                break;
                        }
@@ -486,9 +516,9 @@ static int __bt_process_audio_profile_disconnect(bt_audio_type_t type, bluetooth
 
                /* Update device status in connected list */
                _bt_add_headset_to_list(type, BT_STATE_DISCONNECTING, addr);
-               BT_PERMANENT_LOG("Disconnect %d", type);
+               BT_PERMANENT_LOG("Disconnect %s", __convert_audio_type_to_string(type));
        } else {
-               BT_ERR("Profile [%d] connect failed!!", type);
+               BT_ERR("Profile [%s] disconnect failed!!", __convert_audio_type_to_string(type));
        }
        BT_INFO("-");
        return result;
@@ -756,14 +786,17 @@ void _bt_audio_check_pending_disconnection(char *address, int type)
        BT_INFO("+");
 
        if (_bt_is_service_connected(address, type)) {
-               BT_INFO("Service [%d] is connected with device [%s], disconnect it...", type, address);
+               BT_INFO("Service [%s] is connected with device [%s], disconnect it...",
+                               __convert_audio_type_to_string(type), address);
                _bt_convert_addr_string_to_type(device_address.addr, address);
                ret = __bt_process_audio_profile_disconnect(type, &device_address);
 
                if (ret != BLUETOOTH_ERROR_NONE)
-                       BT_ERR("Disconnecting service [%d] with device [%s] failed!!", type, address);
+                       BT_ERR("Disconnecting service [%s] with device [%s] failed!!",
+                                       __convert_audio_type_to_string(type), address);
        } else {
-               BT_INFO("Service [%d] is Not connected with device [%s],..", type, address);
+               BT_INFO("Service [%s] is Not connected with device [%s],..",
+                               __convert_audio_type_to_string(type), address);
        }
        BT_INFO("-");
 }
@@ -848,7 +881,7 @@ int __bt_handle_audio_all_connect(bt_pending_audio_conn_t *info)
                        goto fail;
                }
 
-               BT_PERMANENT_LOG("Connect %d", info->type);
+               BT_PERMANENT_LOG("Connect %s", __convert_audio_type_to_string(info->type));
                /* If multiple profiles are supported, queue pending connection info */
                if ((info->is_hfp_supported && info->is_a2dp_sink_supported) ||
                                (info->is_hfp_supported && info->is_a2dp_src_supported)) {
@@ -937,7 +970,8 @@ int _bt_audio_connect(int type,     bluetooth_device_address_t *device_address)
        BT_CHECK_PARAMETER(device_address, return);
 
        _bt_convert_addr_type_to_string(address, device_address->addr);
-       BT_INFO("Adderss: [%s], request type: [%d]", address, type);
+       BT_INFO("Audio Connect Request: type[%s] address [%s]",
+                       __convert_audio_type_to_string(type), address);
 
        /*
         * If type is BT_AUDIO_ALL or BT_AUDIO_HFP_SOURCE, enqueue search info in
@@ -998,7 +1032,8 @@ int _bt_audio_disconnect(int type, bluetooth_device_address_t *device_address)
        char address[BT_ADDRESS_STRING_SIZE] = { 0 };
 
        _bt_convert_addr_type_to_string(address, device_address->addr);
-       BT_INFO("Audio Diconnect Request: type[%d] address [%s]", type, address);
+       BT_INFO("Audio Diconnect Request: type[%s] address [%s]",
+                       __convert_audio_type_to_string(type), address);
 
        if (type == BT_AUDIO_ALL) {
                if (_bt_is_service_connected(address, BT_AUDIO_A2DP)) {
@@ -1064,9 +1099,8 @@ void _bt_remove_headset_from_list(int type, const char *address)
                        continue;
                }
 
-               BT_DBG("Address match \n");
-
-               BT_DBG("Connection type = %x\n", connected_device->type);
+               BT_DBG("Address match. Connection type = %s",
+                               __convert_audio_type_to_string(connected_device->type));
 
                switch (type) {
                case BT_AUDIO_A2DP:
@@ -1097,8 +1131,6 @@ void _bt_remove_headset_from_list(int type, const char *address)
                        break;
                }
 
-               BT_DBG("Connection type = %x\n", connected_device->type);
-
                if (connected_device->type == 0x00) {
                        BT_INFO("Device will be completely removed from connected list as the only profile connected or connecting got disconnected");
                        g_connected_list = g_list_remove(g_connected_list, connected_device);
index 758949f..f71a524 100644 (file)
@@ -244,27 +244,27 @@ int _bt_send_event(int event_type, int event, GVariant *param)
                break;
        case BLUETOOTH_HID_CONNECTED:
                signal = BT_INPUT_CONNECTED;
-               BT_INFO_C("Connected [HID]");
+               BT_INFO_C("### Connected [HID]");
                break;
        case BLUETOOTH_HID_DISCONNECTED:
                signal = BT_INPUT_DISCONNECTED;
-               BT_INFO_C("Disconnected [HID]");
+               BT_INFO_C("### Disconnected [HID]");
                break;
        case BLUETOOTH_HID_DEVICE_CONNECTED:
                signal = BT_INPUT_HID_DEVICE_CONNECTED;
-               BT_INFO_C("Connected [HIDDevice]");
+               BT_INFO_C("### Connected [HIDDevice]");
                break;
        case BLUETOOTH_HID_DEVICE_DISCONNECTED:
                signal = BT_INPUT_HID_DEVICE_DISCONNECTED;
-               BT_INFO_C("Disconnected [HIDDevice]");
+               BT_INFO_C("### Disconnected [HIDDevice]");
                break;
        case BLUETOOTH_PBAP_CONNECTED:
                signal = BT_PBAP_CONNECTED;
-               BT_INFO_C("Connected [PBAP Client]");
+               BT_INFO_C("### Connected [PBAP Client]");
                break;
        case BLUETOOTH_PBAP_DISCONNECTED:
                signal = BT_PBAP_DISCONNECTED;
-               BT_INFO_C("Disconnected [PBAP Client]");
+               BT_INFO_C("### Disconnected [PBAP Client]");
                break;
        case BLUETOOTH_PBAP_PHONEBOOK_SIZE:
                signal = BT_PBAP_PHONEBOOK_SIZE;
@@ -283,35 +283,35 @@ int _bt_send_event(int event_type, int event, GVariant *param)
                break;
        case BLUETOOTH_EVENT_AG_CONNECTED:
                signal = BT_HEADSET_CONNECTED;
-               BT_INFO_C("Connected [HSP/HFP]");
+               BT_INFO_C("### Connected [HSP/HFP]");
                break;
        case BLUETOOTH_EVENT_AG_DISCONNECTED:
                signal = BT_HEADSET_DISCONNECTED;
-               BT_INFO_C("Disconnected [HSP/HFP]");
+               BT_INFO_C("### Disconnected [HSP/HFP]");
                break;
        case BLUETOOTH_EVENT_AV_CONNECTED:
                signal = BT_STEREO_HEADSET_CONNECTED;
-               BT_INFO_C("Connected [A2DP]");
+               BT_INFO_C("### Connected [A2DP]");
                break;
        case BLUETOOTH_EVENT_AV_DISCONNECTED:
                signal = BT_STEREO_HEADSET_DISCONNECTED;
-               BT_INFO_C("Disconnected [A2DP]");
+               BT_INFO_C("### Disconnected [A2DP]");
                break;
        case BLUETOOTH_EVENT_AV_SOURCE_CONNECTED:
                signal = BT_A2DP_SOURCE_CONNECTED;
-               BT_INFO_C("Connected [A2DP Source]");
+               BT_INFO_C("### Connected [A2DP Source]");
                break;
        case BLUETOOTH_EVENT_AV_SOURCE_DISCONNECTED:
                signal = BT_A2DP_SOURCE_DISCONNECTED;
-               BT_INFO_C("Disconnected [A2DP Source]");
+               BT_INFO_C("### Disconnected [A2DP Source]");
                break;
        case BLUETOOTH_EVENT_AG_AUDIO_CONNECTED:
                signal = BT_SCO_CONNECTED;
-               BT_INFO_C("Connected [SCO]");
+               BT_INFO_C("### Connected [SCO]");
                break;
        case BLUETOOTH_EVENT_AG_AUDIO_DISCONNECTED:
                signal = BT_SCO_DISCONNECTED;
-               BT_INFO_C("Disonnected [SCO]");
+               BT_INFO_C("### Disonnected [SCO]");
                break;
        case BLUETOOTH_EVENT_AG_SPEAKER_GAIN:
                signal = BT_SPEAKER_GAIN;