PKG_CHECK_MODULES(XKBCOMMON_DEPS REQUIRED xkbcommon)
ADD_SUBDIRECTORY(src)
+
+INSTALL(FILES package/org.tizen.NUIGadgetViewer-1.0.0.tpk
+ DESTINATION /usr/apps/.preload-tpk)
%endif
%define _moddir %{_datadir}/amd
+%define _preload_tpk_dir %{TZ_SYS_RO_APP}/.preload-tpk
%if "%{?_prelink_enable}" == "y"
%define tizen_feature_prelink 1
%{_libdir}/libamd.so.*
%{_moddir}/conf/amd.conf
%{_sysconfdir}/resourced/vip-process.d/amd.conf
+%{_preload_tpk_dir}/org.tizen.NUIGadgetViewer-1.0.0.tpk
%files devel
%{_includedir}/amd/*.h*
#include <string>
#include <tuple>
#include <unordered_map>
+#include <utility>
#include <vector>
#include "lib/amd_app_status.h"
return 0;
}
+static int ResInfoGetGadgetResPackagesInfo(uid_t uid, GList** pkgids,
+ GList** allowed_paths, GList** global_paths) {
+ std::shared_ptr<amd::ResInfo> resinfo = amd::ResInfoManager::GetInst()
+ .GetUserResInfo(uid);
+ if (!resinfo)
+ return -1;
+
+ pkgmgrinfo_version_compare_type ver_comp;
+ std::unordered_map<std::string, std::shared_ptr<amd::ResPkgInfo>> gadget_map;
+ for (const auto& [_, res_pkginfo] : resinfo->GetGadgetResPkgs()) {
+ auto found = gadget_map.find(res_pkginfo->GetResType());
+ if (found != gadget_map.end()) {
+ if (pkgmgrinfo_compare_package_version(
+ found->second->GetResVersion().c_str(),
+ res_pkginfo->GetResVersion().c_str(),
+ &ver_comp) != PMINFO_R_OK)
+ continue;
+
+ if (ver_comp != PMINFO_VERSION_NEW)
+ continue;
+
+ gadget_map.erase(found);
+ }
+
+ gadget_map[res_pkginfo->GetResType()] = std::move(res_pkginfo);
+ }
+
+ for (const auto& [_, res_pkginfo] : gadget_map) {
+ *pkgids = g_list_append(*pkgids, strdup(res_pkginfo->GetPkgId().c_str()));
+ std::string allowed_path = res_pkginfo->GetRootPath() + "/res/allowed/";
+ *allowed_paths = g_list_append(*allowed_paths,
+ strdup(allowed_path.c_str()));
+ std::string global_path = res_pkginfo->GetRootPath() + "/res/global/";
+ *global_paths = g_list_append(*global_paths, strdup(global_path.c_str()));
+ }
+
+ return 0;
+}
+
int _resinfo_get_res_packages_info(const char* appid, uid_t uid,
GList** pkgids, GList** allowed_paths, GList** global_paths) {
+ if (!strcmp(appid, "org.tizen.NUIGadgetViewer")) {
+ return ResInfoGetGadgetResPackagesInfo(uid, pkgids, allowed_paths,
+ global_paths);
+ }
+
std::shared_ptr<amd::ResInfo> resinfo = amd::ResInfoManager::GetInst()
.GetUserResInfo(uid);
if (!resinfo)
* limitations under the License.
*/
+#include "lib/res_info/res_info.hh"
+
+#include <utility>
+
#include "lib/common/log_private.hh"
#include "lib/res_info/res_app_info.hh"
-#include "lib/res_info/res_info.hh"
namespace amd {
+namespace {
+
+constexpr const char kResTypeGadget[] = "org.tizen.appfw.gadget.";
+
+} // namespace
std::shared_ptr<ResAppInfo> ResInfo::GetResAppInfo(const std::string& appid) {
if (!res_appinfo_.count(appid))
res_pkginfo_[res_pkginfo->GetPkgId()] = std::move(res_pkginfo);
}
+void ResInfo::InsertGadgetPkgInfo(std::shared_ptr<ResPkgInfo> res_pkginfo) {
+ gadget_pkginfo_[res_pkginfo->GetPkgId()] = std::move(res_pkginfo);
+}
+
bool ResInfo::DeleteAppInfo(const std::string& appid) {
if (!res_appinfo_.count(appid))
return false;
return false;
res_pkginfo_.erase(pkgid);
+ gadget_pkginfo_.erase(pkgid);
return true;
}
return res_pkginfo_;
}
+const std::unordered_map<std::string, std::shared_ptr<ResPkgInfo>>&
+ ResInfo::GetGadgetResPkgs() {
+ return gadget_pkginfo_;
+}
+
bool ResInfo::ResPkgInit() {
pkgmgrinfo_pkginfo_filter_h filter;
if (!res_pkg_info)
return 0;
- resinfo->InsertPkgInfo(std::move(res_pkg_info));
+ char* res_type = nullptr;
+ pkgmgrinfo_pkginfo_get_res_type(handle, &res_type);
+ if (res_type != nullptr &&
+ strlen(res_type) > strlen(kResTypeGadget) &&
+ !strncmp(res_type, kResTypeGadget, strlen(kResTypeGadget)))
+ resinfo->InsertGadgetPkgInfo(res_pkg_info);
+ resinfo->InsertPkgInfo(std::move(res_pkg_info));
return 0;
}, this, uid_) != PMINFO_R_OK) {
_E("pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo() failed");
bool ResPkgInit();
void InsertAppInfo(std::shared_ptr<ResAppInfo> res_appinfo);
void InsertPkgInfo(std::shared_ptr<ResPkgInfo> res_pkginfo);
+ void InsertGadgetPkgInfo(std::shared_ptr<ResPkgInfo> res_pkginfo);
bool DeleteAppInfo(const std::string& appid);
bool DeletePkgInfo(const std::string& pkgid);
const std::unordered_map<std::string, std::shared_ptr<ResPkgInfo>>&
GetResPkgs();
+ const std::unordered_map<std::string, std::shared_ptr<ResPkgInfo>>&
+ GetGadgetResPkgs();
private:
uid_t uid_;
std::unordered_map<std::string, std::shared_ptr<ResPkgInfo>> res_pkginfo_;
std::unordered_map<std::string, std::shared_ptr<ResAppInfo>> res_appinfo_;
+ std::unordered_map<std::string, std::shared_ptr<ResPkgInfo>> gadget_pkginfo_;
};
} // namespace amd