App wise data transaction details 74/214374/2
authorSudipto <sudipto.bal@samsung.com>
Fri, 20 Sep 2019 16:10:09 +0000 (21:40 +0530)
committerSudipto <sudipto.bal@samsung.com>
Tue, 24 Sep 2019 11:55:13 +0000 (17:25 +0530)
Providing details of data transaction by apps in
a particular bluetooth session

Change-Id: Ia6e7f31784bd40186ec6f0374e0d5b1583bbec72
Signed-off-by: Sudipto <sudipto.bal@samsung.com>
include/bluetooth_type_internal.h
src/bluetooth-adapter.c
test/bt_unit_test.c

index 333414d..259e1d9 100644 (file)
@@ -290,6 +290,13 @@ typedef struct {
         GSList *atm_list;
 } bt_battery_info_s;
 
+typedef struct {
+       uid_t uid;
+       pid_t pid;
+       uint16_t rx_bytes;
+       uint16_t tx_bytes;
+} bt_battery_app_info_s;
+
 typedef bt_map_client_list_folders_filter_s *bt_map_client_list_folders_filter_h;
 
 typedef bt_map_client_list_messages_filter_s *bt_map_client_list_messages_filter_h;
index b314830..1c3b588 100644 (file)
@@ -69,6 +69,8 @@ int bt_adapter_read_battery_info(bt_battery_info_s *battery_data)
        BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON);
        BT_CHECK_INIT_STATUS();
        BT_CHECK_INPUT_PARAMETER(battery_data);
+       memset(&data, 0, sizeof(bt_battery_data));
+
        error_code = _bt_get_error_code(bluetooth_read_battery_data(&data));
 
        if (error_code != BT_ERROR_NONE) { /* LCOV_EXCL_LINE */
@@ -81,10 +83,22 @@ int bt_adapter_read_battery_info(bt_battery_info_s *battery_data)
        battery_data->session_end_time = data.session_end_time;
        battery_data->session_scan_time = data.session_scan_time;
        battery_data->session_connected_time = data.session_connected_time;
+       battery_data->atm_list = data.atm_list;
 
        BT_DBG("Battery Data in application layer: %ld %ld %d %d",
                battery_data->session_start_time, battery_data->session_end_time,
                        battery_data->session_scan_time, battery_data->session_connected_time);
+
+       if(data.atm_list == NULL) {
+               BT_DBG("No data transaction in this session");
+               return error_code;
+       }
+
+       BT_DBG("App-wise data transaction details:");
+       for (GSList *l = battery_data->atm_list; l != NULL; l = g_slist_next(l)) {
+               bt_battery_app_info_s *t = (bt_battery_app_info_s *)(l->data);
+               BT_DBG("%ld %ld %d %d", (long int)(t->uid), (long int)(t->pid), t->rx_bytes, t->tx_bytes);
+       }
         return error_code;
 }
 
index 1676782..6388213 100644 (file)
@@ -4187,12 +4187,25 @@ int test_input_callback(void *data)
                }
                case BT_UNIT_TEST_FUNCTION_ADAPTER_READ_BATTERY_INFO: {
                        bt_battery_info_s data;
+                       memset(&data, 0, sizeof(bt_battery_info_s));
                         ret = bt_adapter_read_battery_info(&data);
-                       if (ret < 0)
+                       if (ret < 0) {
                                TC_PRT("returns %s\n", __bt_get_error_message(ret));
-                       else
+                       } else {
                                TC_PRT("Battery data: %ld %ld %d %d", data.session_start_time,
                                        data.session_end_time, data.session_scan_time, data.session_connected_time);
+                               if(data.atm_list == NULL) {
+                                       TC_PRT("No data transaction in this session");
+                                       break;
+                               }
+
+                               TC_PRT("Displaying app-wise transaction details");
+                               for (GSList *l = data.atm_list; l != NULL; l = g_slist_next(l)) {
+                                       bt_battery_app_info_s *t = (bt_battery_app_info_s *)(l->data);
+                                       TC_PRT("uid: %ld, pid: %ld, received bytes: %d, sent bytes: %d",
+                                               (long int)(t->uid), (long int)(t->pid), t->rx_bytes, t->tx_bytes);
+                               }
+                       }
                         break;
                }
                case BT_UNIT_TEST_FUNCTION_ADAPTER_SET_REMOTE_OOB_EXT_DATA: {