Add BTFW name to permanent logs 74/234274/2
authorDeokhyun Kim <dukan.kim@samsung.com>
Tue, 19 May 2020 06:14:59 +0000 (15:14 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Mon, 25 May 2020 06:04:25 +0000 (06:04 +0000)
Change-Id: I32f83dc6525b6f32ec9f3f7a938fa463eb49eebd
Signed-off-by: Deokhyun Kim <dukan.kim@samsung.com>
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
bt-service-adaptation/services/bt-service-common.c

index 13d268bdd83ed7af7b67c77916f733e3d4d52e5f..4eda6a8f041842ad847033cfa2050a9a9eddbc5f 100644 (file)
@@ -1648,7 +1648,29 @@ void _bt_copy_remote_dev_info(bt_remote_dev_info_t *dest, bt_remote_dev_info_t *
 
 #define BT_PERMANENT_LOG_FILE_PATH "/opt/usr/home/owner/media/Downloads/.bt_dump/permanent_log.txt"
 #define BT_PERMANENT_LOG_OLD_FILE_PATH "/opt/usr/home/owner/media/Downloads/.bt_dump/permanent_log_old.txt"
+#define BT_PERMANENT_LOG_FIRMWARE_DIR_PATH "/usr/lib/firmware"
 #define PERMANENT_LOG_MAX (128 * 1024)
+
+static void __bt_write_firmware_name(FILE *fp)
+{
+       DIR *pDir;
+       struct dirent *pEntry;
+
+       pDir = opendir(BT_PERMANENT_LOG_FIRMWARE_DIR_PATH);
+       if (pDir == NULL) {
+               BT_ERR("Read directory failed");
+               return;
+       }
+
+       pEntry = readdir(pDir);
+       while (pEntry) {
+               if (!strncmp(pEntry->d_name, "BCM", 3))
+                       fprintf(fp, "BTFW: %s\n", pEntry->d_name);
+               pEntry = readdir(pDir);
+       }
+       closedir(pDir);
+}
+
 void _bt_permanent_log(const char *fmt, ...)
 {
        FILE *fp;
@@ -1657,6 +1679,7 @@ void _bt_permanent_log(const char *fmt, ...)
        char time_buf[32];
        long lsize = 0;
        va_list ap;
+       gboolean is_first = FALSE;
 
 #ifndef TIZEN_FEATURE_BT_PERMANENT_LOG
        return;
@@ -1686,14 +1709,20 @@ void _bt_permanent_log(const char *fmt, ...)
                fclose(fp);
                fclose(fp2);
                fp = fopen(BT_PERMANENT_LOG_FILE_PATH, "w");
+               is_first = TRUE;
        } else {
-               if (fp != NULL)
+               if (fp == NULL)
+                       is_first = TRUE;
+               else
                        fclose(fp);
                fp = fopen(BT_PERMANENT_LOG_FILE_PATH, "a");
        }
 
        if (fp != NULL) {
                char buf[100];
+               if (is_first == TRUE)
+                       __bt_write_firmware_name(fp);
+
                va_start(ap, fmt);
                vsnprintf(buf, 100, fmt, ap);
                va_end(ap);