#include <package_manager.h>
#include <package-manager.h>
#include <pkgmgr-info.h>
+#include <tzplatform_config.h>
+#include <unistd.h>
#include <memory>
#include <utility>
namespace {
+const uid_t GLOBAL_USER = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
+
void SetErrorMessage(picojson::object& error,
const std::string& property_name) {
std::string error_message = "Fail to get " + property_name;
static PkgMgrHandle* Create(const std::string& app_id,
picojson::object& error) {
pkgmgrinfo_appinfo_h appinfo_handle;
- int ret = pkgmgrinfo_appinfo_get_appinfo(app_id.c_str(), &appinfo_handle);
+ uid_t uid = getuid();
+ int ret = (uid != GLOBAL_USER) ?
+ pkgmgrinfo_appinfo_get_usr_appinfo(app_id.c_str(),
+ uid, &appinfo_handle) :
+ pkgmgrinfo_appinfo_get_appinfo(app_id.c_str(),
+ &appinfo_handle);
if (ret != PMINFO_R_OK) {
SetErrorMessage(error, "appinfo");
return NULL;
}
pkgmgrinfo_pkginfo_h pkginfo_handle;
- ret = pkgmgrinfo_pkginfo_get_pkginfo(pkg_id, &pkginfo_handle);
+ uid_t uid = getuid();
+ ret = (uid != GLOBAL_USER) ?
+ pkgmgrinfo_pkginfo_get_usr_pkginfo(pkg_id, uid, &pkginfo_handle) :
+ pkgmgrinfo_pkginfo_get_pkginfo(pkg_id, &pkginfo_handle);
if (ret != PMINFO_R_OK) {
SetErrorMessage(error, "pkginfo");
pkgmgrinfo_appinfo_destroy_appinfo(appinfo_handle);
return NULL;
}
-
return new PkgMgrHandle(app_id, pkg_id, appinfo_handle,
pkginfo_handle, owns_appinfo_handle);
}
void RetrieveAllInstalledAppInfo(picojson::array& data,
picojson::object& error) {
- int ret = pkgmgrinfo_appinfo_get_installed_list(GetAllAppInfoCallback, &data);
+ uid_t uid = getuid();
+ int ret = (uid != GLOBAL_USER) ?
+ pkgmgrinfo_appinfo_get_usr_installed_list(GetAllAppInfoCallback,
+ uid, &data) :
+ pkgmgrinfo_appinfo_get_installed_list(GetAllAppInfoCallback,
+ &data);
if (ret != PMINFO_R_OK) {
SetErrorMessage(error, "installed");
return;
#include <app_manager.h>
#include <aul.h>
#include <pkgmgr-info.h>
+#include <tzplatform_config.h>
#include <unistd.h>
#include <algorithm>
namespace {
+const uid_t GLOBAL_USER = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
+
// Application information events.
const char kOkayEvent[] = "ok";
const char kInstallEvent[] = "install";
picojson::value* ApplicationManager::GetAppMetaData(const std::string& app_id) {
pkgmgrinfo_appinfo_h handle;
- if (pkgmgrinfo_appinfo_get_appinfo(app_id.c_str(), &handle) != PMINFO_R_OK)
+ uid_t uid = getuid();
+ int ret = (uid != GLOBAL_USER) ?
+ pkgmgrinfo_appinfo_get_usr_appinfo(app_id.c_str(),
+ uid, &handle) :
+ pkgmgrinfo_appinfo_get_appinfo(app_id.c_str(),
+ &handle);
+ if (ret != PMINFO_R_OK)
return CreateResultMessage(WebApiAPIErrors::NOT_FOUND_ERR);
-
// The first boolean will set to false if AppMetaDataCallback fail.
auto data = std::make_tuple(true, picojson::array());
- int ret = pkgmgrinfo_appinfo_foreach_metadata(
- handle, AppMetaDataCallback, &data);
+ ret = pkgmgrinfo_appinfo_foreach_metadata(handle, AppMetaDataCallback, &data);
pkgmgrinfo_appinfo_destroy_appinfo(handle);
if (ret != PMINFO_R_OK || !std::get<0>(data))
return CreateResultMessage(WebApiAPIErrors::UNKNOWN_ERR);
#include <pkgmgr-info.h>
#include <tzplatform_config.h>
+#include <unistd.h>
#include <cassert>
#include <algorithm>
namespace {
+const uid_t GLOBAL_USER = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
+
const char kInternalStorage[] = "internal";
const char kRemovableStorage[] = "removable";
std::string VirtualFS::GetAppId(const std::string& package_id) {
char* appid = NULL;
pkgmgrinfo_pkginfo_h pkginfo_handle;
- int ret = pkgmgrinfo_pkginfo_get_pkginfo(package_id.c_str(), &pkginfo_handle);
+ uid_t uid = getuid();
+ int ret = (uid != GLOBAL_USER) ?
+ pkgmgrinfo_pkginfo_get_usr_pkginfo(package_id.c_str(),
+ uid, &pkginfo_handle) :
+ pkgmgrinfo_pkginfo_get_pkginfo(package_id.c_str(),
+ &pkginfo_handle);
if (ret != PMINFO_R_OK)
return std::string();
ret = pkgmgrinfo_pkginfo_get_mainappid(pkginfo_handle, &appid);
std::string VirtualFS::GetExecPath(const std::string& app_id) {
char* exec_path = NULL;
pkgmgrinfo_appinfo_h appinfo_handle;
- int ret = pkgmgrinfo_appinfo_get_appinfo(app_id.c_str(), &appinfo_handle);
+ uid_t uid = getuid();
+ int ret = (uid != GLOBAL_USER) ?
+ pkgmgrinfo_appinfo_get_usr_appinfo(app_id.c_str(),
+ uid, &appinfo_handle) :
+ pkgmgrinfo_appinfo_get_appinfo(app_id.c_str(),
+ &appinfo_handle);
if (ret != PMINFO_R_OK)
return std::string();
ret = pkgmgrinfo_appinfo_get_exec(appinfo_handle, &exec_path);