constexpr const char kSharedResourceDir[] = "shared/res/";
constexpr const char kAppRWDir[] = "apps_rw/";
constexpr const char kLightUserSwitchModeDefault[] = "default";
+constexpr const char kResControlAllowedDir[] = "res/mount/allowed/";
+constexpr const char kResControlGlobalDir[] = "res/mount/global/";
std::string GetRWPath(const std::string& pkg_id, uid_t uid) {
tzplatform_set_user(uid);
return *this;
}
+DirectoryInfo::Builder& DirectoryInfo::Builder::SetResControlAllowedPath(
+ std::string res_control_allowed_res_path) {
+ res_control_allowed_res_path_ = std::move(res_control_allowed_res_path);
+ return *this;
+}
+
+DirectoryInfo::Builder& DirectoryInfo::Builder::SetResControlGlobalPath(
+ std::string res_control_global_res_path) {
+ res_control_global_res_path_ = std::move(res_control_global_res_path);
+ return *this;
+}
+
DirectoryInfo::Builder::operator DirectoryInfo*() {
return new (std::nothrow) DirectoryInfo(std::move(root_path_),
std::move(data_path_), std::move(cache_path_),
std::move(resource_path_), std::move(tep_resource_path_),
std::move(shared_data_path_), std::move(shared_resource_path_),
- std::move(shared_trusted_path_));
+ std::move(shared_trusted_path_), std::move(res_control_allowed_res_path_),
+ std::move(res_control_global_res_path_));
}
DirectoryInfo* DirectoryInfo::Get(const std::string app_id,
.SetTepResourcePath(GetPath(root_path, kTepResourceDir))
.SetSharedDataPath(GetPath(rw_path, kSharedDataDir))
.SetSharedResourcePath(GetPath(root_path, kSharedResourceDir))
- .SetSharedTrustedPath(GetPath(rw_path, kSharedTrustedDir));
+ .SetSharedTrustedPath(GetPath(rw_path, kSharedTrustedDir))
+ .SetResControlAllowedPath(GetPath(root_path, kResControlAllowedDir))
+ .SetResControlGlobalPath(GetPath(root_path, kResControlGlobalDir));
}
DirectoryInfo* DirectoryInfo::Get() {
std::string tep_resource_path,
std::string shared_data_path,
std::string shared_resource_path,
- std::string shared_trusted_path)
+ std::string shared_trusted_path,
+ std::string res_control_allowed_res_path,
+ std::string res_control_global_res_path)
: root_path_(std::move(root_path)),
data_path_(std::move(data_path)),
cache_path_(std::move(cache_path)),
tep_resource_path_(std::move(tep_resource_path)),
shared_data_path_(std::move(shared_data_path)),
shared_resource_path_(std::move(shared_resource_path)),
- shared_trusted_path_(std::move(shared_trusted_path)) {
+ shared_trusted_path_(std::move(shared_trusted_path)),
+ res_control_allowed_res_path_(std::move(res_control_allowed_res_path)),
+ res_control_global_res_path_(std::move(res_control_global_res_path)) {
}
const std::string& DirectoryInfo::GetRootPath() const {
return shared_trusted_path_;
}
+const std::string& DirectoryInfo::GetResControlAllowedResPath() const {
+ return res_control_allowed_res_path_;
+}
+
+const std::string& DirectoryInfo::GetResControlGlobalResPath() const {
+ return res_control_global_res_path_;
+}
+
} // namespace aul
const std::string& GetSharedDataPath() const;
const std::string& GetSharedResourcePath() const;
const std::string& GetSharedTrustedPath() const;
+ const std::string& GetResControlAllowedResPath() const;
+ const std::string& GetResControlGlobalResPath() const;
private:
class Builder {
Builder& SetSharedDataPath(std::string shared_data_path);
Builder& SetSharedResourcePath(std::string shared_resource_path);
Builder& SetSharedTrustedPath(std::string shared_trusted_path);
+ Builder& SetResControlAllowedPath(std::string res_control_allowed_res_path);
+ Builder& SetResControlGlobalPath(std::string res_control_global_res_path);
operator DirectoryInfo*();
std::string shared_data_path_;
std::string shared_resource_path_;
std::string shared_trusted_path_;
+ std::string res_control_allowed_res_path_;
+ std::string res_control_global_res_path_;
};
DirectoryInfo(std::string root_path,
std::string tep_resource_path,
std::string shared_data_path,
std::string shared_resource_path,
- std::string shared_trusted_path);
+ std::string shared_trusted_path,
+ std::string res_control_allowed_res_path,
+ std::string res_control_global_res_path);
private:
std::string root_path_;
std::string shared_data_path_;
std::string shared_resource_path_;
std::string shared_trusted_path_;
+ std::string res_control_allowed_res_path_;
+ std::string res_control_global_res_path_;
};
} // namespace aul
return tzplatform_getenv(TZ_USER_APP);
}
+AUL_API int aul_get_app_res_control_allowed_resource_path(const char* res_type,
+ char** path) {
+ if (res_type == nullptr || path == nullptr) {
+ _E("Invalid parameter");
+ return AUL_R_EINVAL;
+ }
+
+ auto* context = GetCurrentContext();
+ if (context == nullptr)
+ return AUL_R_ERROR;
+
+ std::string result = context->GetResControlAllowedResPath() + res_type + "/";
+
+ if (access(result.c_str(), F_OK) != 0)
+ return AUL_R_EREJECTED;
+
+ *path = strdup(result.c_str());
+ if (*path == nullptr) {
+ LOGE("Out of memory");
+ return AUL_R_ENOMEM;
+ }
+
+ return AUL_R_OK;
+}
+
+AUL_API int aul_get_app_res_control_global_resource_path(const char* res_type,
+ char** path) {
+ if (res_type == nullptr || path == nullptr) {
+ _E("Invalid parameter");
+ return AUL_R_EINVAL;
+ }
+
+ auto* context = GetCurrentContext();
+ if (context == nullptr)
+ return AUL_R_ERROR;
+
+ std::string result = context->GetResControlGlobalResPath() + res_type + "/";
+
+ if (access(result.c_str(), F_OK) != 0)
+ return AUL_R_EREJECTED;
+
+ *path = strdup(result.c_str());
+ if (*path == nullptr) {
+ LOGE("Out of memory");
+ return AUL_R_ENOMEM;
+ }
+
+ return AUL_R_OK;
+}
+
AUL_API int aul_get_app_shared_data_path_by_appid(const char* appid,
char** path) {
if (path == nullptr)