Check previous total app number
authorHwankyu Jhun <h.jhun@samsung.com>
Wed, 28 Dec 2022 05:16:36 +0000 (05:16 +0000)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 29 Dec 2022 06:08:13 +0000 (06:08 +0000)
To reduce sending the update event to launchpad-process-pool, AMD checks
the previous total app number. AMD sends the update event to
launchpad-process-pool when the previous total is zero and the current
total is greater than zero.(or the previous total is greater than zero
and the current total is zero)

Change-Id: Id01e64111ed94c1b85a4515451440c45f03b1079
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/lib/amd_login_monitor.c

index 19e378d4e33ac73d49f69b9a4ed6eaad82d96494..a0008d75de55b6b321ed9ffc86a18cce7c7813a3 100644 (file)
@@ -78,6 +78,7 @@ struct user_s {
 struct app_counter_s {
        char *app_type;
        int number[AT_WATCH_APP + 1];
+       int total;
 };
 
 static guint sid;
@@ -240,17 +241,20 @@ static void __foreach_app_counter(gpointer data, gpointer user_data)
 {
        struct app_counter_s *ac = (struct app_counter_s *)data;
        struct user_s *user = (struct user_s *)user_data;
-       int total;
+       int previous_total = ac->total;
        int r;
 
-       total = ac->number[AT_UI_APP] + ac->number[AT_WIDGET_APP] +
+       ac->total = ac->number[AT_UI_APP] + ac->number[AT_WIDGET_APP] +
                ac->number[AT_WATCH_APP];
 
-       r = __update_app_type_info(ac->app_type, total, user->uid);
-       if (r < 0)
-               _W("Failed to update app type info");
+       if ((previous_total == 0 && ac->total > 0) ||
+                       (previous_total > 0 && ac->total == 0)) {
+               r = __update_app_type_info(ac->app_type, ac->total, user->uid);
+               if (r < 0)
+                       _W("Failed to update app type info");
+       }
 
-       _D("app type(%s), total(%d)", ac->app_type, total);
+       _D("app type(%s), total(%d)", ac->app_type, ac->total);
 }
 
 static struct app_counter_s *__find_app_counter(GList *list,