if (result != BLUETOOTH_ERROR_NONE) {
BT_ERR("Battery data not collected");
+ g_free(data);
+ return;
}
- else {
- bt_battery_dbus_data_t dbus_data;
- memset(&dbus_data, 0, sizeof(bt_battery_dbus_data_t));
- dbus_data.session_start_time = data->session_start_time;
- dbus_data.session_end_time = data->session_end_time;
- dbus_data.session_scan_time = data->session_scan_time;
- dbus_data.session_connected_time = data->session_connected_time;
- dbus_data.tx_time = data->tx_time;
- dbus_data.rx_time = data->rx_time;
- dbus_data.idle_time = data->idle_time;
-
- /*Populating app data*/
- int n = 0;
- for (GSList *l = data->atm_list; l != NULL; l = g_slist_next(l)) {
- bt_battery_app_data *t = (bt_battery_app_data *)(l->data);
- memcpy(&dbus_data.app_data[n], t, sizeof(bt_battery_app_data));
- n++;
- }
- dbus_data.num_app = n;
- info = g_array_new(FALSE, FALSE, sizeof(gchar));
- g_array_append_vals(info, &dbus_data, sizeof(bt_battery_dbus_data_t));
+ bt_battery_dbus_data_t dbus_data;
+ memset(&dbus_data, 0, sizeof(bt_battery_dbus_data_t));
+ dbus_data.session_start_time = data->session_start_time;
+ dbus_data.session_end_time = data->session_end_time;
+ dbus_data.session_scan_time = data->session_scan_time;
+ dbus_data.session_connected_time = data->session_connected_time;
+ dbus_data.tx_time = data->tx_time;
+ dbus_data.rx_time = data->rx_time;
+ dbus_data.idle_time = data->idle_time;
- out_var = g_variant_new_from_data((const GVariantType *)"ay",
- info->data, info->len,
- TRUE, NULL, NULL);
+ /*Populating app data*/
+ int n = 0;
+ for (GSList *l = data->atm_list; l != NULL; l = g_slist_next(l)) {
+ bt_battery_app_data *t = (bt_battery_app_data *)(l->data);
+ memcpy(&dbus_data.app_data[n], t, sizeof(bt_battery_app_data));
+ n++;
}
+ dbus_data.num_app = n;
+
+ info = g_array_new(FALSE, FALSE, sizeof(gchar));
+ g_array_append_vals(info, &dbus_data, sizeof(bt_battery_dbus_data_t));
+
+ out_var = g_variant_new_from_data((const GVariantType *)"ay",
+ info->data, info->len,
+ TRUE, NULL, NULL);
+
param = g_variant_new("(iv)", result, out_var);
_bt_send_event(BT_ADAPTER_EVENT,
BLUETOOTH_EVENT_DISABLED_BATTERY_DATA,