Fix abnormal behavior of appinfo 70/104670/2 accepted/tizen/3.0/common/20161216.122442 accepted/tizen/3.0/ivi/20161216.013342 accepted/tizen/3.0/mobile/20161216.013201 accepted/tizen/3.0/tv/20161216.013249 accepted/tizen/3.0/wearable/20161216.013310 submit/tizen_3.0/20161214.072903
authorJunghyun Yeon <jungh.yeon@samsung.com>
Wed, 14 Dec 2016 05:11:38 +0000 (14:11 +0900)
committerjongmyeong ko <jongmyeong.ko@samsung.com>
Wed, 14 Dec 2016 07:23:51 +0000 (23:23 -0800)
- When app_disable filter is not exists in app filter,
app_disable filter will be added with 'false'
- Fix to use tmp_filter at pkginfo filter to work properly
(It was missed at previous change)

Change-Id: I847d98a24794604097dc99a83840468532f7eb9f
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
src/pkgmgrinfo_appinfo.c
src/pkgmgrinfo_pkginfo.c

index 7d69e85..5f44f9c 100644 (file)
@@ -433,6 +433,30 @@ static void __free_applications(gpointer data)
        pkgmgrinfo_basic_free_application((application_x *)data);
 }
 
+static gint __app_disable_chk_func(gconstpointer data1, gconstpointer data2)
+{
+       pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)data1;
+
+       if (node->prop == E_PMINFO_APPINFO_PROP_APP_DISABLE)
+               return 0;
+       else
+               return 1;
+}
+
+static bool __check_disable_filter_exist(pkgmgrinfo_filter_x *filter)
+{
+       GSList *link;
+
+       if (filter == NULL)
+               return false;
+
+       link = g_slist_find_custom(filter->list, NULL, __app_disable_chk_func);
+       if (link)
+               return true;
+
+       return false;
+}
+
 static int __bind_params(sqlite3_stmt *stmt, GList *params)
 {
        GList *tmp_list = NULL;
@@ -1260,6 +1284,7 @@ static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
        char *locale;
        application_x *app;
        pkgmgr_appinfo_x info;
+       pkgmgrinfo_filter_x *tmp_filter = NULL;
        GHashTable *list;
        GHashTableIter iter;
        gpointer value;
@@ -1275,14 +1300,30 @@ static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
                return PMINFO_R_ERROR;
        }
 
-       ret = _appinfo_get_applications(uid, uid, locale, filter, flag, list);
+       if (filter != NULL) {
+               tmp_filter = filter;
+       } else {
+               ret = pkgmgrinfo_appinfo_filter_create((void *)&tmp_filter);
+               if (ret != PMINFO_R_OK) {
+                       _LOGE("Failed to create filter");
+                       return PMINFO_R_ERROR;
+               }
+       }
+
+       if (__check_disable_filter_exist(tmp_filter) == false)
+               pkgmgrinfo_appinfo_filter_add_bool(tmp_filter,
+                               PMINFO_APPINFO_PROP_APP_DISABLE, false);
+
+       ret = _appinfo_get_applications(uid, uid, locale, tmp_filter, flag, list);
        if (ret == PMINFO_R_OK && uid != GLOBAL_USER)
                ret = _appinfo_get_applications(GLOBAL_USER, uid, locale,
-                               filter, flag, list);
+                               tmp_filter, flag, list);
 
        if (ret != PMINFO_R_OK) {
                g_hash_table_destroy(list);
                free(locale);
+               if (filter != NULL)
+                       pkgmgrinfo_pkginfo_filter_destroy(tmp_filter);
                return ret;
        }
 
@@ -1298,6 +1339,9 @@ static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
        g_hash_table_destroy(list);
        free(locale);
 
+       if (filter == NULL)
+               pkgmgrinfo_pkginfo_filter_destroy(tmp_filter);
+
        return PMINFO_R_OK;
 }
 
index 2944e65..8ecb9ab 100644 (file)
@@ -613,9 +613,9 @@ static int _pkginfo_get_filtered_foreach_pkginfo(uid_t uid,
                pkgmgrinfo_pkginfo_filter_add_bool(tmp_filter,
                                PMINFO_PKGINFO_PROP_PACKAGE_DISABLE, false);
 
-       ret = _pkginfo_get_packages(uid, locale, filter, flag, list);
+       ret = _pkginfo_get_packages(uid, locale, tmp_filter, flag, list);
        if (ret == PMINFO_R_OK && uid != GLOBAL_USER)
-               ret = _pkginfo_get_packages(GLOBAL_USER, locale, filter,
+               ret = _pkginfo_get_packages(GLOBAL_USER, locale, tmp_filter,
                                flag, list);
 
        if (ret != PMINFO_R_OK) {