Do not restart widget when uninstalling
authorhyunho <hhstark.kang@samsung.com>
Wed, 6 Jan 2021 10:28:57 +0000 (19:28 +0900)
committerhyunho <hhstark.kang@samsung.com>
Wed, 6 Jan 2021 10:58:38 +0000 (19:58 +0900)
Change-Id: Ibfdd71a6e38fec26382368242a5e4c6125e525e1
Signed-off-by: hyunho <hhstark.kang@samsung.com>
src/lib/amd_appinfo.c
src/lib/amd_appinfo.h
src/lib/api/amd_api_appinfo.cc
src/lib/api/amd_api_appinfo.h
src/modules/widget/src/amd_widget.c

index ea60f957750223309a8fdddd8e546a8853d00976..ff75e16b580b634f5254bed10c2419e8ed1bf583 100644 (file)
@@ -2265,6 +2265,20 @@ bool _appinfo_is_pkg_updating(const char *pkgid)
        return false;
 }
 
+bool _appinfo_is_pkg_uninstalling(const char *pkgid)
+{
+       char *op;
+
+       if (pkg_pending == NULL)
+               return false;
+
+       op = g_hash_table_lookup(pkg_pending, pkgid);
+       if (op != NULL && !strcasecmp(op, "uninstall"))
+               return true;
+
+       return false;
+}
+
 static char *__get_cert_value_from_pkginfo(const char *pkgid, uid_t uid)
 {
        int ret;
index 3e3950a3932bc276d4e0e612dfa5293e02ed17f9..6419adcbe3e6b42db2269d27eedb63f4e9df60c4 100644 (file)
@@ -139,6 +139,8 @@ int _appinfo_splash_image_get_color_depth(struct appinfo_splash_image *s);
 
 bool _appinfo_is_pkg_updating(const char *pkgid);
 
+bool _appinfo_is_pkg_uninstalling(const char *pkgid);
+
 int _appinfo_get_cert_visibility(const char *pkgid, uid_t uid);
 
 bool _appinfo_is_platform_app(const char *appid, uid_t uid);
index 4558fc7cd149778a654dcb7105b545f8630df64d..f588c734ecf1ea7849721ae51e720a402ead39a5 100644 (file)
@@ -104,6 +104,12 @@ extern "C" EXPORT_API bool amd_appinfo_is_pkg_updating(const char* pkgid) {
        return _appinfo_is_pkg_updating(pkgid);
 }
 
+
+extern "C" EXPORT_API bool amd_appinfo_is_pkg_uninstalling(const char* pkgid) {
+       return _appinfo_is_pkg_uninstalling(pkgid);
+}
+
+
 extern "C" EXPORT_API int amd_appinfo_get_cert_visibility(const char* pkgid,
     uid_t uid) {
        return _appinfo_get_cert_visibility(pkgid, uid);
index 355f5cc84458f62f1a9948aeefaa5452c4d7e683..c6c083ec66fb3f4297b272df7515b6884829bff6 100644 (file)
@@ -120,6 +120,8 @@ int amd_appinfo_splash_image_get_color_depth(amd_appinfo_splash_image_h h);
 
 bool amd_appinfo_is_pkg_updating(const char *pkgid);
 
+bool amd_appinfo_is_pkg_uninstalling(const char* pkgid);
+
 int amd_appinfo_get_cert_visibility(const char *pkgid, uid_t uid);
 
 bool amd_appinfo_is_platform_app(const char *appid, uid_t uid);
index d1c25dbd14b3bd95d85dd0e5297ca8516b8796eb..7c740d54da99002b405a580eb4a35d10458ec2e2 100644 (file)
@@ -514,6 +514,27 @@ static int __widget_update(const char *widget_id, amd_request_h req)
        return ret;
 }
 
+
+static int __uninstall_widget_cleanup(int pid, uid_t uid)
+{
+       GList *widget_list = __widgets;
+       widget_t *widget;
+
+       while (widget_list) {
+               widget = (widget_t *)widget_list->data;
+               widget_list = widget_list->next;
+               if (widget->pid == pid && widget->uid == uid) {
+                       __widgets = g_list_remove(__widgets, widget);
+                       __free_widget(widget);
+                       LOGW("remove widget(%d) from list", pid);
+               }
+       }
+
+       LOGW("cleanup widget %d:%d", pid, uid);
+
+       return 0;
+}
+
 static int __widget_cleanup(int pid, uid_t uid, int viewer_pid)
 {
        GList *widget_list = __widgets;
@@ -1738,6 +1759,9 @@ static int __on_app_dead(const char *msg, int arg1, int arg2, void *arg3,
 
                __widget_send_dead_signal(pid, uid, pkgid, is_faulted);
                return 0;
+       } else if (amd_appinfo_is_pkg_uninstalling(pkgid)) {
+               __widget_send_dead_signal(pid, uid, pkgid, false);
+               __uninstall_widget_cleanup(pid, uid);
        }
 
        __widget_send_restart_signal(pid, uid, viewer_pid, pkgid,