Fix uid behavior on appinfo related functions 60/255660/3
authorJunghyun Yeon <jungh.yeon@samsung.com>
Mon, 22 Mar 2021 07:08:52 +0000 (16:08 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Wed, 24 Mar 2021 01:41:09 +0000 (01:41 +0000)
To support features like "disable global app for certain user only",
uid for database and uid to be used in query should be delivered
simultaneously.

Change-Id: Ie7f15a71821dc7418dc781faf350a445128c9ac6
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
src/appinfo_internal.c
src/common/database/appinfo_db_handler.cc
src/manager/pkginfo_manager.cc
src/manager/pkginfo_manager.h
src/pkgmgrinfo_appinfo.c
src/pkgmgrinfo_internal.h

index fe2ad83..2de2546 100644 (file)
@@ -703,7 +703,7 @@ catch:
 }
 
 API int appinfo_internal_filter_get_list(sqlite3 *db,
-               pkgmgrinfo_appinfo_filter_h filter, uid_t uid,
+               pkgmgrinfo_appinfo_filter_h filter, uid_t db_uid, uid_t uid,
                const char *locale, GHashTable *appinfo_list)
 {
        int ret;
@@ -713,7 +713,7 @@ API int appinfo_internal_filter_get_list(sqlite3 *db,
                return PMINFO_R_EINVAL;
        }
 
-       ret = _appinfo_get_applications(db, uid, uid, locale, filter,
+       ret = _appinfo_get_applications(db, db_uid, uid, locale, filter,
                        PMINFO_APPINFO_GET_ALL, appinfo_list);
        return ret;
 }
index 09e9c83..ee23cc8 100644 (file)
@@ -68,7 +68,7 @@ int AppInfoDBHandler::Execute() {
   int ret = PMINFO_R_OK;
   for (auto conn : conn_list) {
     ret = appinfo_internal_filter_get_list(conn.first, filter_, conn.second,
-        GetLocale().c_str(), list);
+        uid_, GetLocale().c_str(), list);
     if (ret == PMINFO_R_ERROR) {
       _LOGD("Failed to appinfo_internal_filter_get_list (%d)", ret);
       break;
index 35c0580..76ea616 100644 (file)
@@ -136,8 +136,7 @@ extern "C" EXPORT_API int _pkginfo_get_depends_on(uid_t uid,
   return PMINFO_R_OK;
 }
 
-// TODO: Need to add target db uid to identify which database to be searched
-extern "C" EXPORT_API int _appinfo_get_applications(uid_t db_uid, uid_t uid,
+extern "C" EXPORT_API int _appinfo_get_applications(uid_t uid,
     pkgmgrinfo_filter_x* filter, int flag, GHashTable* packages) {
   std::shared_ptr<pcp::AbstractParcelable> parcelable(
       new pcp::FilterParcelable(uid,
index e4f7be4..25536b5 100644 (file)
@@ -33,7 +33,7 @@ int _pkginfo_get_packages(uid_t uid,
 int _pkginfo_get_depends_on(uid_t uid,
                const char *pkgid, GList **dependencies);
 
-int _appinfo_get_applications(uid_t db_uid, uid_t uid,
+int _appinfo_get_applications(uid_t uid,
                pkgmgrinfo_filter_x *filter, int flag, GHashTable *packages);
 
 char *_appinfo_get_localed_label(const char *appid, const char *locale,
index cf577a6..801318b 100644 (file)
@@ -90,7 +90,7 @@ static int _pkgmgrinfo_get_appinfo(const char *appid, uid_t uid,
        if (list == NULL)
                return PMINFO_R_ERROR;
 
-       ret = _appinfo_get_applications(uid, uid, filter,
+       ret = _appinfo_get_applications(uid, filter,
                        PMINFO_APPINFO_GET_ALL, list);
        if (ret != PMINFO_R_OK) {
                g_hash_table_destroy(list);
@@ -642,7 +642,7 @@ static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
        if (list == NULL)
                return PMINFO_R_ERROR;
 
-       ret = _appinfo_get_applications(uid, uid, filter,
+       ret = _appinfo_get_applications(uid, filter,
                        flag | PMINFO_APPINFO_GET_BASICINFO, list);
        if (ret == PMINFO_R_ERROR) {
                g_hash_table_destroy(list);
@@ -2497,7 +2497,7 @@ API int pkgmgrinfo_appinfo_usr_filter_count(
                }
        }
 
-       ret = _appinfo_get_applications(uid, uid, filter, 0, list);
+       ret = _appinfo_get_applications(uid, filter, 0, list);
        query_count = g_hash_table_size(list);
        g_hash_table_destroy(list);
        if (ret == PMINFO_R_ERROR)
index 0fd5c5e..b212137 100644 (file)
@@ -32,7 +32,7 @@ extern "C" {
 #endif
 
 int pkginfo_internal_filter_get_list(sqlite3 *db, pkgmgrinfo_pkginfo_filter_h filter, uid_t uid, const char *locale, GHashTable *list);
-int appinfo_internal_filter_get_list(sqlite3 *db, pkgmgrinfo_appinfo_filter_h filter, uid_t uid, const char *locale, GHashTable *list);
+int appinfo_internal_filter_get_list(sqlite3 *db, pkgmgrinfo_appinfo_filter_h filter, uid_t db_uid, uid_t uid, const char *locale, GHashTable *list);
 int certinfo_internal_get(sqlite3 *db, const char *pkgid, uid_t uid, pkgmgrinfo_certinfo_h certinfo);
 int certinfo_internal_set(sqlite3 *db, const char *pkgid, pkgmgrinfo_instcertinfo_h handle, uid_t uid);
 int certinfo_internal_delete(sqlite3 *db, const char *pkgid);