class ScopedTzipInterface {
public:
explicit ScopedTzipInterface(const std::string& pkgid)
- : pkg_path_(bf::path(ci::GetRootAppPath(false)) / pkgid),
+ : pkg_path_(bf::path(ci::GetRootAppPath(false,
+ tzplatform_getuid(TZ_SYS_DEFAULT_USER))) / pkgid),
interface_(ci::GetMountLocation(pkg_path_)) {
interface_.MountZip(ci::GetZipPackageLocation(pkg_path_, pkgid));
}
}
void RemoveAllRecoveryFiles() {
- bf::path root_path = ci::GetRootAppPath(false);
+ bf::path root_path = ci::GetRootAppPath(false,
+ tzplatform_getuid(TZ_SYS_DEFAULT_USER));
if (!bf::exists(root_path))
return;
for (auto& dir_entry : boost::make_iterator_range(
}
bf::path FindRecoveryFile() {
- bf::path root_path = ci::GetRootAppPath(false);
+ bf::path root_path = ci::GetRootAppPath(false,
+ tzplatform_getuid(TZ_SYS_DEFAULT_USER));
for (auto& dir_entry : boost::make_iterator_range(
bf::directory_iterator(root_path), bf::directory_iterator())) {
if (bf::is_regular_file(dir_entry)) {
bool ValidateFileContentInPackage(const std::string& pkgid,
const std::string& relative,
const std::string& expected) {
- bf::path root_path = ci::GetRootAppPath(false);
+ bf::path root_path = ci::GetRootAppPath(false,
+ tzplatform_getuid(TZ_SYS_DEFAULT_USER));
bf::path file_path = root_path / pkgid / relative;
if (!bf::exists(file_path)) {
LOG(ERROR) << file_path << " doesn't exist";
void ValidatePackageFS(const std::string& pkgid,
const std::vector<std::string>& appids) {
- bf::path root_path = ci::GetRootAppPath(false);
+ bf::path root_path = ci::GetRootAppPath(false,
+ tzplatform_getuid(TZ_SYS_DEFAULT_USER));
bf::path package_path = root_path / pkgid;
bf::path data_path = package_path / "data";
bf::path shared_path = package_path / "shared";
ASSERT_TRUE(bf::exists(cache_path));
bf::path manifest_path =
- bf::path(getUserManifestPath(getuid(), false)) / (pkgid + ".xml");
+ bf::path(getUserManifestPath(
+ tzplatform_getuid(TZ_SYS_DEFAULT_USER), false)) / (pkgid + ".xml");
ASSERT_TRUE(bf::exists(manifest_path));
for (auto& appid : appids) {
void PackageCheckCleanup(const std::string& pkgid,
const std::vector<std::string>&) {
- bf::path root_path = ci::GetRootAppPath(false);
+ bf::path root_path = ci::GetRootAppPath(
+ false, tzplatform_getuid(TZ_SYS_DEFAULT_USER));
bf::path package_path = root_path / pkgid;
ASSERT_FALSE(bf::exists(package_path));
bf::path manifest_path =
- bf::path(getUserManifestPath(getuid(), false)) / (pkgid + ".xml");
+ bf::path(getUserManifestPath(
+ tzplatform_getuid(TZ_SYS_DEFAULT_USER), false)) / (pkgid + ".xml");
ASSERT_FALSE(bf::exists(manifest_path));
// backups should not exist
void ValidatePackage(const std::string& pkgid,
const std::vector<std::string>& appids) {
- ASSERT_TRUE(ci::QueryIsPackageInstalled(pkgid, ci::GetRequestMode()));
+ ASSERT_TRUE(ci::QueryIsPackageInstalled(
+ pkgid, ci::GetRequestMode(tzplatform_getuid(TZ_SYS_DEFAULT_USER)),
+ tzplatform_getuid(TZ_SYS_DEFAULT_USER)));
ValidatePackageFS(pkgid, appids);
}
void CheckPackageNonExistance(const std::string& pkgid,
const std::vector<std::string>& appids) {
- ASSERT_FALSE(ci::QueryIsPackageInstalled(pkgid, ci::GetRequestMode()));
+ ASSERT_FALSE(ci::QueryIsPackageInstalled(
+ pkgid, ci::GetRequestMode(tzplatform_getuid(TZ_SYS_DEFAULT_USER)),
+ tzplatform_getuid(TZ_SYS_DEFAULT_USER)));
PackageCheckCleanup(pkgid, appids);
}
ValidatePackage(pkgid, {appid});
// Check delta modifications
- bf::path root_path = ci::GetRootAppPath(false);
+ bf::path root_path = ci::GetRootAppPath(false,
+ tzplatform_getuid(TZ_SYS_DEFAULT_USER));
ASSERT_FALSE(bf::exists(root_path / pkgid / "res" / "wgt" / "DELETED"));
ASSERT_TRUE(bf::exists(root_path / pkgid / "res" / "wgt" / "ADDED"));
ValidateFileContentInPackage(pkgid, "res/wgt/MODIFIED", "2\n");
ASSERT_EQ(EnablePackage(pkgid, PackageType::WGT),
ci::AppInstaller::Result::OK);
- ASSERT_TRUE(ci::QueryIsPackageInstalled(pkgid, ci::GetRequestMode()));
+ ASSERT_TRUE(ci::QueryIsPackageInstalled(pkgid,
+ ci::GetRequestMode(tzplatform_getuid(TZ_SYS_DEFAULT_USER)),
+ tzplatform_getuid(TZ_SYS_DEFAULT_USER)));
}
TEST_F(SmokeTest, DisablePkg) {
ci::AppInstaller::Result::OK);
ASSERT_EQ(DisablePackage(pkgid, PackageType::WGT),
ci::AppInstaller::Result::OK);
- ASSERT_FALSE(ci::QueryIsPackageInstalled(pkgid, ci::GetRequestMode()));
+ ASSERT_FALSE(ci::QueryIsPackageInstalled(pkgid,
+ ci::GetRequestMode(tzplatform_getuid(TZ_SYS_DEFAULT_USER)),
+ tzplatform_getuid(TZ_SYS_DEFAULT_USER)));
ValidatePackageFS(pkgid, {appid});
}
std::string appid = "smokeapp20.ClearMode";
ASSERT_EQ(Install(path, PackageType::WGT),
ci::AppInstaller::Result::OK);
- bf::path root_path = ci::GetRootAppPath(false);
+ bf::path root_path = ci::GetRootAppPath(false,
+ tzplatform_getuid(TZ_SYS_DEFAULT_USER));
bs::error_code error;
bf::create_directory(root_path / pkgid / "data" / "dir", error);
ASSERT_FALSE(error);
ValidatePackage(pkgid, {appid});
// Check delta modifications
- bf::path root_path = ci::GetRootAppPath(false);
+ bf::path root_path = ci::GetRootAppPath(false,
+ tzplatform_getuid(TZ_SYS_DEFAULT_USER));
ASSERT_FALSE(bf::exists(root_path / pkgid / "res" / "wgt" / "DELETED"));
ASSERT_TRUE(bf::exists(root_path / pkgid / "res" / "wgt" / "ADDED"));
ASSERT_TRUE(bf::exists(root_path / pkgid / "res" / "wgt" / "css" / "style.css")); // NOLINT
ValidatePackage(pkgid, {appid1, appid2});
// Check delta modifications
- bf::path root_path = ci::GetRootAppPath(false);
+ bf::path root_path = ci::GetRootAppPath(false,
+ tzplatform_getuid(TZ_SYS_DEFAULT_USER));
ASSERT_FALSE(bf::exists(root_path / pkgid / "res" / "wgt" / "DELETED"));
ASSERT_TRUE(bf::exists(root_path / pkgid / "res" / "wgt" / "ADDED"));
ASSERT_FALSE(bf::exists(root_path / pkgid / "lib" / "DELETED"));
const char kHybridConfigLocation[] = "res/wgt/config.xml";
const char kTizenManifestLocation[] = "tizen-manifest.xml";
+uid_t GetUid(int argc, char** argv) {
+ uid_t uid = 0;
+ for (int i = 0; i < argc; ++i) {
+ if (!strcmp(argv[i], "-u")) {
+ if (i + 1 < argc) {
+ uid = atoi(argv[i + 1]);
+ break;
+ }
+ }
+ }
+
+ return uid;
+}
+
std::string GetInstallationRequestInfo(int argc, char** argv) {
std::string path;
for (int i = 0; i < argc; ++i) {
if (arg.empty())
return false;
+ uid_t uid = GetUid(argc, argv);
// argument from commandline is package id
- if (ci::QueryIsPackageInstalled(arg, ci::GetRequestMode()))
+ if (ci::QueryIsPackageInstalled(arg, ci::GetRequestMode(uid), uid))
return true;
// argument from commandline is path to file
std::string pkg_id = GetPkgIdFromPath(arg);
if (pkg_id.empty())
return false;
- return ci::QueryIsPackageInstalled(pkg_id, ci::GetRequestMode());
+ return ci::QueryIsPackageInstalled(pkg_id, ci::GetRequestMode(uid), uid);
}
bool WgtAppQueryInterface::IsHybridApplication(int argc, char** argv) {
std::string arg = GetInstallationRequestInfo(argc, argv);
if (arg.find("apps_rw/recovery-") != std::string::npos)
arg = ReadPkgidFromRecovery(arg);
- if (ci::QueryIsPackageInstalled(arg, ci::GetRequestMode())) {
- bf::path package_directory(ci::GetRootAppPath(false));
+
+ uid_t uid = GetUid(argc, argv);
+ if (ci::QueryIsPackageInstalled(arg, ci::GetRequestMode(uid), uid)) {
+ bf::path package_directory(ci::GetRootAppPath(false, uid));
if (bf::exists(package_directory / arg / kTizenManifestLocation) &&
bf::exists(package_directory / arg / kHybridConfigLocation))
return true;