Add function call for remove badge data when package is unintalled 91/123191/1 submit/tizen_3.0/20170405.024223 submit/tizen_3.0/20170412.001257
authorseungha.son <seungha.son@samsung.com>
Tue, 4 Apr 2017 04:42:56 +0000 (13:42 +0900)
committerseungha.son <seungha.son@samsung.com>
Wed, 5 Apr 2017 01:53:36 +0000 (10:53 +0900)
Signed-off-by: seungha.son <seungha.son@samsung.com>
Change-Id: Id0322ba4a5563de6dc44a7a1723626ae0153b081

src/badge_service.c
src/service_common.c

index 8296fb5..24d01c1 100755 (executable)
@@ -241,10 +241,15 @@ int badge_get_badge_existing(GVariant *parameters, GVariant **reply_body, uid_t
        if (ret != BADGE_ERROR_NONE)
                return ret;
 
-       if (pkgname != NULL)
+       if (pkgname != NULL) {
+               if (need_to_reload_pkginfo_for_badge) {
+                       badge_setting_refresh_setting_table(tzplatform_getuid(TZ_SYS_DEFAULT_USER));
+                       need_to_reload_pkginfo_for_badge = 0;
+               }
                ret = badge_db_is_existing(pkgname, &existing, param_uid);
-       else
+       } else {
                return BADGE_ERROR_INVALID_PARAMETER;
+       }
 
        if (ret != BADGE_ERROR_NONE) {
                ErrPrint("failed to get badge existing :%d\n", ret);
@@ -321,20 +326,22 @@ int badge_insert(GVariant *parameters, GVariant **reply_body, uid_t uid)
        if (ret != BADGE_ERROR_NONE)
                return ret;
 
-       if (pkgname != NULL && writable_pkg != NULL && caller != NULL)
+       if (pkgname != NULL && writable_pkg != NULL && caller != NULL) {
+               if (need_to_reload_pkginfo_for_badge) {
+                       badge_setting_refresh_setting_table(tzplatform_getuid(TZ_SYS_DEFAULT_USER));
+                       need_to_reload_pkginfo_for_badge = 0;
+               }
                ret = badge_db_insert(pkgname, writable_pkg, caller, param_uid);
-       else
+       } else {
                return BADGE_ERROR_INVALID_PARAMETER;
+       }
 
        if (ret != BADGE_ERROR_NONE) {
                ErrPrint("failed to insert badge :%d\n", ret);
                return ret;
        }
 
-       if (need_to_reload_pkginfo_for_badge) {
-               badge_setting_refresh_setting_table(tzplatform_getuid(TZ_SYS_DEFAULT_USER));
-               need_to_reload_pkginfo_for_badge = 0;
-       }
+
 
        ret = badge_db_get_allow_to_display_by_appid(pkgname, &allow_to_display, param_uid);
        if (ret != BADGE_ERROR_NONE) {
@@ -437,10 +444,15 @@ int badge_set_badge_count(GVariant *parameters, GVariant **reply_body, uid_t uid
        if (ret != BADGE_ERROR_NONE)
                return ret;
 
-       if (pkgname != NULL && caller != NULL)
+       if (pkgname != NULL && caller != NULL) {
+               if (need_to_reload_pkginfo_for_badge) {
+                       badge_setting_refresh_setting_table(tzplatform_getuid(TZ_SYS_DEFAULT_USER));
+                       need_to_reload_pkginfo_for_badge = 0;
+               }
                ret = badge_db_set_count(pkgname, caller, count, param_uid);
-       else
+       } else {
                return BADGE_ERROR_INVALID_PARAMETER;
+       }
 
        if (ret != BADGE_ERROR_NONE) {
                ErrPrint("failed to set badge :%d\n", ret);
index 88812b0..301de2e 100755 (executable)
@@ -24,6 +24,7 @@
 #include <notification_noti.h>
 #include <badge_setting.h>
 #include <badge_setting_service.h>
+#include <badge_db.h>
 #include <package-manager.h>
 #include <tzplatform_config.h>
 
@@ -464,6 +465,7 @@ static int _package_uninstall_cb(uid_t uid, const char *pkgname, enum pkgmgr_sta
                if (uid == tzplatform_getuid(TZ_SYS_GLOBALAPP_USER))
                        uid = tzplatform_getuid(TZ_SYS_DEFAULT_USER);
                notification_setting_delete_package_for_uid(pkgname, uid);
+               badge_db_delete_by_pkgname(pkgname, uid);
                badge_setting_delete_package_for_uid(pkgname, uid);
                notification_noti_delete_template(pkgname);
        }