From 130f7a89fc716b04407da3009910d7bcc1ba38d8 Mon Sep 17 00:00:00 2001 From: "jiseob.jang" Date: Wed, 9 Sep 2015 23:01:13 +0900 Subject: [PATCH] apply to unregiter account_type(provider information) of User App on multi-user. Change-Id: I337f5a9f7fdace3c5fd3e0d418d985198811a443 Signed-off-by: jiseob.jang --- CMakeLists.txt | 1 + packaging/account-parser.spec | 3 ++- src/account.c | 35 +++++++++++++++++++++++++++++++---- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e5fc00..315424c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,7 @@ pkg_check_modules(account_pkgs REQUIRED glib-2.0 accounts-svc capi-appfw-app-manager + libtzplatform-config ) FOREACH(flag ${account_pkgs_CFLAGS}) diff --git a/packaging/account-parser.spec b/packaging/account-parser.spec index 4567b7e..5370ca7 100644 --- a/packaging/account-parser.spec +++ b/packaging/account-parser.spec @@ -1,6 +1,6 @@ Name: account-parser Summary: Account Parser Library -Version: 0.0.11 +Version: 0.0.12 Release: 0 Group: Social & Content/Other License: Apache-2.0 @@ -15,6 +15,7 @@ BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(pkgmgr) BuildRequires: pkgconfig(pkgmgr-info) BuildRequires: pkgconfig(capi-appfw-app-manager) +BuildRequires: pkgconfig(libtzplatform-config) %description account parser C library of package manager to install account application. diff --git a/src/account.c b/src/account.c index f9ce435..68d6817 100644 --- a/src/account.c +++ b/src/account.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "account-dlog.h" @@ -32,6 +33,8 @@ #define EXPORT_API __attribute__((visibility("default"))) #endif +#define OWNER_ROOT 0 +#define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER) static const xmlChar _NODE_ACCOUNT_PROVIDER[] = "account-provider"; static const xmlChar _NODE_ICON[] = "icon"; @@ -549,11 +552,23 @@ int PKGMGR_PARSER_PLUGIN_UNINSTALL(xmlDocPtr docPtr, const char* packageId) _D("PKGMGR_PARSER_PLUGIN_UNINSTALL"); pkgmgrinfo_pkginfo_h package_info_handle = NULL; + int ret = -1; + uid_t uid = 0; - int ret = pkgmgrinfo_pkginfo_get_pkginfo(packageId, &package_info_handle); + uid = getuid(); + if (uid == OWNER_ROOT || uid == GLOBAL_USER) { + ret = pkgmgrinfo_pkginfo_get_pkginfo(packageId, &package_info_handle); + } else { + ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(packageId, uid, &package_info_handle); + } retvm_if(ret != PMINFO_R_OK, ret, "[%d]Failed to pkgmgrinfo_pkginfo_get_pkginfo().", ret); - ret = pkgmgrinfo_appinfo_get_list(package_info_handle, PMINFO_UI_APP, _unregister_account_provider, NULL); + if (uid == OWNER_ROOT || uid == GLOBAL_USER) { + ret = pkgmgrinfo_appinfo_get_list(package_info_handle, PMINFO_ALL_APP, _unregister_account_provider, NULL); + } else { + ret = pkgmgrinfo_appinfo_get_usr_list(package_info_handle, PMINFO_ALL_APP, _unregister_account_provider, NULL, uid); + } + if(ret != PMINFO_R_OK) { _D("Failed to get the application information list."); pkgmgrinfo_pkginfo_destroy_pkginfo(package_info_handle); @@ -574,11 +589,23 @@ int PKGMGR_PARSER_PLUGIN_PRE_UPGRADE(const char* packageId) memset(__old_account_provider_app_id, 0x00, sizeof(__old_account_provider_app_id)); pkgmgrinfo_pkginfo_h package_info_handle = NULL; + int ret = -1; + uid_t uid = 0; - int ret = pkgmgrinfo_pkginfo_get_pkginfo(packageId, &package_info_handle); + uid = getuid(); + if (uid == OWNER_ROOT || uid == GLOBAL_USER) { + ret = pkgmgrinfo_pkginfo_get_pkginfo(packageId, &package_info_handle); + } else { + ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(packageId, uid, &package_info_handle); + } retvm_if(ret != PMINFO_R_OK, ret, "[%d]Failed to pkgmgrinfo_pkginfo_get_pkginfo().", ret); - ret = pkgmgrinfo_appinfo_get_list(package_info_handle, PMINFO_UI_APP, _on_package_app_list_received_cb, NULL); + if (uid == OWNER_ROOT || uid == GLOBAL_USER) { + ret = pkgmgrinfo_appinfo_get_list(package_info_handle, PMINFO_ALL_APP, _on_package_app_list_received_cb, NULL); + } else { + ret = pkgmgrinfo_appinfo_get_usr_list(package_info_handle, PMINFO_ALL_APP, _on_package_app_list_received_cb, NULL, uid); + } + if(ret != PMINFO_R_OK) { _D("Failed to get the application information list."); pkgmgrinfo_pkginfo_destroy_pkginfo(package_info_handle); -- 2.7.4