display: modified to support consecutive sessions 66/219766/6
authorsanghyeok.oh <sanghyeok.oh@samsung.com>
Tue, 10 Dec 2019 02:03:13 +0000 (11:03 +0900)
committersanghyeok.oh <sanghyeok.oh@samsung.com>
Wed, 11 Dec 2019 00:22:13 +0000 (09:22 +0900)
Change-Id: I12b132c73e1e0fb9a6bde75827b225af4668e031
Signed-off-by: sanghyeok.oh <sanghyeok.oh@samsung.com>
plugin/display/src/bm_display_plugin.c

index 0faf1a7..c62a81b 100644 (file)
@@ -104,7 +104,9 @@ static void _bds_list_free(gpointer data)
 
 static bm_display_st *_variant_to_bds(GVariant *param)
 {
+       bm_display_st *bds_header = NULL;
        bm_display_st *bds = NULL;
+       GSList *bds_list = NULL;
        app_time_map_st1 *atm = NULL;
        GVariantIter *iter = NULL;
        GVariantIter *sub_iter = NULL;
@@ -137,7 +139,7 @@ static bm_display_st *_variant_to_bds(GVariant *param)
                        atm = (app_time_map_st1 *)malloc(sizeof(app_time_map_st1));
                        if (!atm) {
                                _E("failed to allocate memory");
-                               goto err_atm;
+                               goto err;
                        }
 
                        atm->app_id = g_strdup(app_id);
@@ -149,7 +151,8 @@ static bm_display_st *_variant_to_bds(GVariant *param)
                bds = (bm_display_st *)malloc(sizeof(bm_display_st));
                if (!bds) {
                        _E("failed to allocate memory");
-                       goto err_atm;
+                       g_slist_free_full(atm_list, _atm_list_free);
+                       goto err;
                }
 
                bds->high = vals[0];
@@ -157,25 +160,31 @@ static bm_display_st *_variant_to_bds(GVariant *param)
                bds->med = vals[2];
                bds->start = t_start;
                bds->stop = t_end;
-               bds->atm_list = atm_list;
+               bds->atm_list = g_slist_reverse(atm_list);
                bds->display_list = NULL;
-               //bds->display_list = g_slist_prepend(bds->display_list, bds);
+
+               bds_list = g_slist_prepend(bds_list, bds);
+       }
+
+       bds_header = (bm_display_st *)calloc(1, sizeof(bm_display_st));
+       if (!bds_header) {
+               _E("failed to allocate memory");
+               goto err;
        }
 
+       bds_header->display_list = g_slist_reverse(bds_list);
+
        g_variant_iter_free(iter);
 
        EXIT;
 
-       return bds;
+       return bds_header;
 
-err_atm:
-       if (atm_list)
-               g_slist_free_full(atm_list, _atm_list_free);
 err:
        if (iter)
                g_variant_iter_free(iter);
-       if (bds && bds->display_list)
-               g_slist_free_full(bds->display_list, _bds_list_free);
+       if (bds_list)
+               g_slist_free_full(bds_list, _bds_list_free);
 
        EXIT;
        return NULL;