Generate btsnoop file into log dump 67/225167/3
authorinjun.yang <injun.yang@samsung.com>
Tue, 28 Jan 2020 10:17:07 +0000 (19:17 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Tue, 18 Feb 2020 04:03:19 +0000 (13:03 +0900)
[Model] All
[BinType] AP
[Customer] OPEN

[Issue#] N/A
[Request] Internal
[Occurrence Version] N/A

[Problem]
[Cause & Measure]
[Checking Method]

[Team] Convergence BT
[Developer] Injun Yang
[Solution company] Samsung
[Change Type] Specification change

Change-Id: I760bc6be281fc4e51d98e5c055fac652420eb19c

bt-service-adaptation/services/adapter/bt-service-core-adapter.c
bt-service-adaptation/services/include/bt-service-core-adapter.h
bt-service-adaptation/services/include/bt-service-event.h
bt-service-adaptation/services/obex/bt-service-obex-event-receiver.c

index 6679aa8..22c1805 100644 (file)
@@ -220,6 +220,42 @@ int _bt_reset_adapter(void)
        return BLUETOOTH_ERROR_NONE;
 }
 
+#ifdef TIZEN_FEATURE_BT_PERMANENT_LOG
+void _bt_start_log_dump(const char *path)
+{
+       GDBusProxy *proxy;
+       GVariant *result;
+       GError *error = NULL;
+
+       ret_if(path == NULL);
+
+       BT_INFO("Start log_dump(path = %s)", path);
+
+       _bt_send_dump_signal(BT_DUMP_SERVICE_START_SIGNAL);
+
+       proxy = __bt_get_core_proxy();
+       ret_if(proxy == NULL);
+
+       result = g_dbus_proxy_call_sync(proxy, "LogDump",
+                               g_variant_new("(s)", path),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1, NULL, &error);
+
+       if (!result) {
+               if (error != NULL) {
+                       BT_ERR("Bt core call failed(Error: %s)", error->message);
+                       g_clear_error(&error);
+               } else {
+                       BT_ERR("Bt core call failed");
+               }
+       } else {
+               g_variant_unref(result);
+       }
+
+       _bt_send_dump_signal(BT_DUMP_SERVICE_FINISH_SIGNAL);
+}
+#endif
+
 int _bt_check_adapter(int *status)
 {
        BT_INFO("+");
index 1713c01..18e0375 100644 (file)
@@ -50,6 +50,8 @@ int _bt_disable_adapter(void);
 
 int _bt_reset_adapter(void);
 
+void _bt_start_log_dump(const char *path);
+
 int _bt_check_adapter(int *status);
 
 int _bt_enable_core(void);
index 79510bb..eece22b 100644 (file)
@@ -42,6 +42,8 @@ int _bt_send_hf_local_term_event(char *address);
 int _bt_init_hf_local_term_event_sender(void);
 void _bt_deinit_hf_local_term_event_sender(void);
 
+int _bt_send_dump_signal(char *signal);
+
 #ifdef TIZEN_FEATURE_BT_IPSP
 int _bt_init_ipsp_receiver(void);
 #endif
index 37769ff..e89832e 100644 (file)
@@ -786,6 +786,53 @@ void _bt_map_client_event_deinit(void)
        }
 }
 
+#ifdef TIZEN_FEATURE_BT_PERMANENT_LOG
+static void __bt_dump_event_filter(GDBusConnection *connection,
+                                       const gchar *sender_name,
+                                       const gchar *object_path,
+                                       const gchar *interface_name,
+                                       const gchar *signal_name,
+                                       GVariant *parameters,
+                                       gpointer user_data)
+{
+       if (strcasecmp(signal_name, BT_DUMP_SERVICE_SIGNAL) == 0) {
+               gchar *path = NULL;
+               int mode = 0;
+
+               g_variant_get(parameters, "(i&s)", &mode, &path);
+               _bt_start_log_dump(path);
+       }
+
+       return;
+}
+
+static int __bt_register_dump_subscribe_signal(GDBusConnection *conn,
+               gboolean subscribe)
+{
+       if (conn == NULL)
+               return -1;
+
+       static guint subs_source_id = 0;
+
+       if (subscribe) {
+               if (subs_source_id == 0) {
+                       subs_source_id = g_dbus_connection_signal_subscribe(conn,
+                               NULL, BT_DUMP_SERVICE_INTERFACE,
+                               BT_DUMP_SERVICE_SIGNAL, BT_DUMP_SERVICE_PATH, NULL, 0,
+                               __bt_dump_event_filter,
+                               NULL, NULL);
+               }
+       } else {
+               if (subs_source_id > 0) {
+                       g_dbus_connection_signal_unsubscribe(conn,
+                                       subs_source_id);
+                       subs_source_id = 0;
+               }
+       }
+       return 0;
+}
+#endif
+
 int _bt_register_manager_subscribe_signal(GDBusConnection *conn,
                int subscribe)
 {
@@ -1133,6 +1180,10 @@ static int __bt_init_manager_receiver(void)
                                BT_DEVICE_EVENT) != BLUETOOTH_ERROR_NONE)
                goto fail;
 
+#ifdef TIZEN_FEATURE_BT_PERMANENT_LOG
+       __bt_register_dump_subscribe_signal(manager_conn, TRUE);
+#endif
+
        return BLUETOOTH_ERROR_NONE;
 fail:
        if (manager_conn) {
@@ -1239,6 +1290,10 @@ void _bt_deinit_obex_event_receiver(void)
 
        _bt_unregister_service_event(obexd_conn, BT_OPP_SERVER_EVENT);
 
+#ifdef TIZEN_FEATURE_BT_PERMANENT_LOG
+       __bt_register_dump_subscribe_signal(manager_conn, FALSE);
+#endif
+
        if (manager_conn) {
                g_object_unref(manager_conn);
                manager_conn = NULL;