PKG_CHECK_MODULES(UUID_DEPS REQUIRED uuid)
PKG_CHECK_MODULES(VCONF_DEPS REQUIRED vconf)
PKG_CHECK_MODULES(XDGMIME_DEPS REQUIRED xdgmime)
+PKG_CHECK_MODULES(LIBSESSIOND_DEPS REQUIRED libsessiond)
## Target sources
AUX_SOURCE_DIRECTORY(src SRCS)
UUID_DEPS
VCONF_DEPS
XDGMIME_DEPS
+ LIBSESSIOND_DEPS
)
INSTALL(TARGETS ${TARGET_AUL} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
return *this;
}
+AppInfo::Builder& AppInfo::Builder::SetLightUserSwitchMode(std::string mode) {
+ light_user_switch_mode_ = std::move(mode);
+ return *this;
+}
+
AppInfo::Builder::operator AppInfo*() const {
- return new (std::nothrow) AppInfo(app_id_, pkg_id_, root_path_);
+ return new (std::nothrow) AppInfo(app_id_, pkg_id_,
+ root_path_, light_user_switch_mode_);
}
AppInfo* AppInfo::Get(const std::string& app_id, uid_t uid) {
return nullptr;
}
- return Builder().SetAppId(app_id).SetPkgId(pkg_id).SetRootPath(root_path);
+ char* mode;
+ ret = pkgmgrinfo_appinfo_get_light_user_switch_mode(handle, &mode);
+ if (ret != PMINFO_R_OK) {
+ _E("Failed to get light user switch mode. error(%d)", ret);
+ return nullptr;
+ }
+
+ return Builder().SetAppId(app_id).SetPkgId(pkg_id)
+ .SetRootPath(root_path).SetLightUserSwitchMode(mode);
}
AppInfo* AppInfo::Get(int pid) {
return Builder().SetAppId(app_id).SetPkgId(pkg_id).SetRootPath(root_path);
}
-AppInfo::AppInfo(std::string app_id, std::string pkg_id, std::string root_path)
+AppInfo::AppInfo(std::string app_id, std::string pkg_id,
+ std::string root_path, std::string light_user_switch_mode)
: app_id_(std::move(app_id)),
pkg_id_(std::move(pkg_id)),
- root_path_(std::move(root_path)) {
+ root_path_(std::move(root_path)),
+ light_user_switch_mode_(std::move(light_user_switch_mode)) {
}
const std::string& AppInfo::GetAppId() const {
return root_path_;
}
+const std::string& AppInfo::GetLightUserSwitchMode() const {
+ return light_user_switch_mode_;
+}
+
} // namespace aul
Builder& SetAppId(std::string app_id);
Builder& SetPkgId(std::string pkg_id);
Builder& SetRootPath(std::string root_path);
+ Builder& SetLightUserSwitchMode(std::string mode);
operator AppInfo*() const;
private:
std::string app_id_;
std::string pkg_id_;
std::string root_path_;
+ std::string light_user_switch_mode_;
};
static AppInfo* Get(const std::string& app_id, uid_t uid);
AppInfo(std::string app_id,
std::string pkg_id,
- std::string root_path);
+ std::string root_path,
+ std::string light_user_switch_mode);
const std::string& GetAppId() const;
const std::string& GetPkgId() const;
const std::string& GetRootPath() const;
+ const std::string& GetLightUserSwitchMode() const;
private:
std::string app_id_;
std::string pkg_id_;
std::string root_path_;
+ std::string light_user_switch_mode_;
};
} // namespace aul
*
*/
+#include <sessiond.h>
#include <sys/types.h>
#include <tzplatform_config.h>
#include <unistd.h>
constexpr const char kSharedDataDir[] = "shared/data/";
constexpr const char kSharedTrustedDir[] = "shared/trusted/";
constexpr const char kSharedResourceDir[] = "shared/res/";
-
-std::string GetRWPath(const std::string& pkg_id, uid_t uid) {
+constexpr const char kSubssesionDir[] = "subsessions/";
+constexpr const char kAppRWDir[] = "apps_rw/";
+constexpr const char kLightUserSwitchModeDefault[] = "default";
+
+std::string GetCurrentLightUser(uid_t uid) {
+ int user = 0;
+ int supported = 0;
+ int ret = subsession_is_supported(&supported);
+ if (ret != TIZEN_ERROR_NONE) {
+ _E("Failed to get subsession supported. error(%d)", ret);
+ return "";
+ }
+
+ if (!supported) {
+ _D("subsession is not supported");
+ return "";
+ }
+
+ ret = subsession_get_current_user(uid, &user);
+ if (ret != TIZEN_ERROR_NONE) {
+ _E("Failed to get subsession current user. error(%d)", ret);
+ return "";
+ }
+
+ return std::to_string(user);
+}
+
+std::string GetRWPath(const std::string& pkg_id,
+ const std::string& light_user_switch_mode, uid_t uid) {
+ std::string path;
tzplatform_set_user(uid);
- std::string path = std::string(tzplatform_getenv(TZ_USER_APP)) + "/" + pkg_id;
+
+ if (light_user_switch_mode != kLightUserSwitchModeDefault) {
+ std::string current_user = GetCurrentLightUser(uid);
+ if (!current_user.empty()) {
+ path = std::string(tzplatform_getenv(TZ_USER_HOME)) + "/" + kSubssesionDir
+ + current_user + "/" + kAppRWDir + pkg_id;
+ }
+ }
+
+ if (path.empty())
+ path = std::string(tzplatform_getenv(TZ_USER_APP)) + "/" + pkg_id;
+
tzplatform_reset_user();
return path;
}
return nullptr;
std::string root_path = info->GetRootPath();
- std::string rw_path = GetRWPath(info->GetPkgId(), uid);
+ std::string rw_path = GetRWPath(info->GetPkgId(),
+ info->GetLightUserSwitchMode(), uid);
return Builder().SetRootPath(info->GetRootPath())
.SetDataPath(GetPath(rw_path, kDataDir))
.SetCachePath(GetPath(rw_path, kCacheDir))
BuildRequires: pkgconfig(libsmack)
BuildRequires: pkgconfig(gmock)
BuildRequires: pkgconfig(parcel)
+BuildRequires: pkgconfig(libsessiond)
%if 0%{?gcov:1}
BuildRequires: lcov