It is very expensive cost that access the sqlite db.
If getting pkg or app info query is called,
the server caches the info lists.
The cache data is released, when the set query was called.
Change-Id: I83380e1726bd7ae2acac6860cce05ce04326830e
Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
${CMAKE_SOURCE_DIR}/src/common/parcel
${CMAKE_SOURCE_DIR}/src/server
${CMAKE_SOURCE_DIR}/src/server/cynara_checker
+ ${CMAKE_SOURCE_DIR}/src/server/filter_checker
${CMAKE_SOURCE_DIR}/src/server/database
${CMAKE_SOURCE_DIR}/src/server/request_handler
)
GList *appcontrol; /*element*/
GList *splashscreens; /*element*/
GList *res_control; /*element*/
+ GList *privileges; /*element*/
} application_x;
typedef struct package_x {
char *locale; /*no xml part*/
char *res_type; /**< res type, attr*/
char *res_version; /**< res version, attr*/
+ char *is_disabled; /**< Flag that indicates if the package is disabled or not, no xml part*/
GList *icon; /**< package icon, element*/
GList *label; /**< package label, element*/
GList *author; /**< package author, element*/
Type=notify
User=app_fw
Group=app_fw
-CPUSchedulingPriority=1
-CPUSchedulingPolicy=rr
[Install]
WantedBy=basic.target
static void* (*dl_func)(int, unsigned char*, int, const char *);
if (handle == nullptr) {
- handle = dlopen(LIBPKGMGR_INFO, RTLD_LOCAL | RTLD_LAZY);
+ handle = dlopen(LIBPKGMGR_INFO, RTLD_GLOBAL | RTLD_LAZY);
if (!handle) {
LOG(ERROR) << "Failed to open library: " << LIBPKGMGR_INFO
<< ", : " << dlerror();
: AbstractParcelable(0, ParcelableType::AppInfo), auto_release_(true) {}
AppInfoParcelable::AppInfoParcelable(int ret,
- std::vector<application_x*>&& app_list, bool auto_release)
+ std::vector<std::shared_ptr<application_x>>&& app_list, bool auto_release)
: AbstractParcelable(0, ParcelableType::AppInfo, ret),
app_list_(std::move(app_list)), auto_release_(auto_release) {}
AppInfoParcelable::~AppInfoParcelable() {
- if (!auto_release_)
- return;
-
- for (auto app : app_list_)
- pkgmgrinfo_basic_free_application(app);
}
-const std::vector<application_x*>& AppInfoParcelable::GetAppInfo() {
+const std::vector<std::shared_ptr<application_x>>&
+ AppInfoParcelable::GetAppInfo() {
return app_list_;
}
-std::vector<application_x*> AppInfoParcelable::ExtractAppInfo() {
+std::vector<std::shared_ptr<application_x>>
+ AppInfoParcelable::ExtractAppInfo() {
return std::move(app_list_);
}
AbstractParcelable::WriteToParcel(parcel);
WriteInt(parcel, app_list_.size());
- for (const auto app : app_list_)
- WriteApplication(parcel, app);
+ for (auto& app : app_list_)
+ WriteApplication(parcel, app.get());
}
void AppInfoParcelable::ReadFromParcel(tizen_base::Parcel* parcel) {
ReadInt(parcel, &len);
for (int i = 0; i < len ; ++i)
- app_list_.emplace_back(ReadApplication(parcel));
+ app_list_.emplace_back(ReadApplication(parcel),
+ [] (application_x*) -> void {});
}
} // namespace parcel
class EXPORT_API AppInfoParcelable : public AbstractParcelable {
public:
AppInfoParcelable();
- AppInfoParcelable(int ret, std::vector<application_x*>&& app_list,
+ AppInfoParcelable(int ret,
+ std::vector<std::shared_ptr<application_x>>&& app_list,
bool auto_release = true);
~AppInfoParcelable();
- const std::vector<application_x*>& GetAppInfo();
- std::vector<application_x*> ExtractAppInfo();
+ const std::vector<std::shared_ptr<application_x>>& GetAppInfo();
+ std::vector<std::shared_ptr<application_x>> ExtractAppInfo();
void WriteToParcel(tizen_base::Parcel* parcel) const override;
void ReadFromParcel(tizen_base::Parcel* parcel) override;
void ReadResControl(tizen_base::Parcel* parcel, GList** list);
application_x* ReadApplication(tizen_base::Parcel* parcel);
- std::vector<application_x*> app_list_;
+ std::vector<std::shared_ptr<application_x>> app_list_;
bool auto_release_;
};
void PkgInfoParcelable::WriteApplication(tizen_base::Parcel* parcel,
GList* application) const {
- std::vector<application_x*> app_vt;
+ std::vector<std::shared_ptr<application_x>> app_vt;
for (GList* tmp = application; tmp; tmp = tmp->next) {
application_x* ptr = reinterpret_cast<application_x*>(tmp->data);
- app_vt.push_back(ptr);
+ app_vt.emplace_back(ptr, [] (application_x*) -> void {});
}
AppInfoParcelable apps(0, std::move(app_vt), false);
WriteString(parcel, package->locale);
WriteString(parcel, package->res_type);
WriteString(parcel, package->res_version);
+ WriteString(parcel, package->is_disabled);
WriteIcon(parcel, package->icon);
WriteLabel(parcel, package->label);
WriteAuthor(parcel, package->author);
AppInfoParcelable apps;
parcel->ReadParcelable(&apps);
- std::vector<application_x*> vt = apps.ExtractAppInfo();
+ std::vector<std::shared_ptr<application_x>> vt = apps.ExtractAppInfo();
- for (application_x* application : vt)
- *list = g_list_append(*list, application);
+ for (auto& application : vt)
+ *list = g_list_append(*list, application.get());
}
void PkgInfoParcelable::ReadCompatibility(
ReadString(parcel, &package->locale);
ReadString(parcel, &package->res_type);
ReadString(parcel, &package->res_version);
+ ReadString(parcel, &package->is_disabled);
ReadIcon(parcel, &package->icon);
ReadLabel(parcel, &package->label);
ReadAuthor(parcel, &package->author);
write_type_(PkgWriteType::None), auto_release_(true) {}
PkgInfoParcelable::PkgInfoParcelable(
- uid_t uid, std::vector<package_x*>&& pkg_list,
+ uid_t uid, std::vector<std::shared_ptr<package_x>>&& pkg_list,
PkgWriteType write_type, bool auto_release)
: AbstractParcelable(uid, ParcelableType::PkgInfo),
pkg_list_(std::move(pkg_list)), write_type_(write_type),
auto_release_(auto_release) {}
PkgInfoParcelable::PkgInfoParcelable(
- int ret, std::vector<package_x*>&& pkg_list, bool auto_release)
+ int ret, std::vector<std::shared_ptr<package_x>>&& pkg_list,
+ bool auto_release)
: AbstractParcelable(0, ParcelableType::PkgInfo, ret),
pkg_list_(std::move(pkg_list)), write_type_(PkgWriteType::None),
auto_release_(auto_release) {}
PkgInfoParcelable::~PkgInfoParcelable() {
- if (!auto_release_)
- return;
-
- for (auto pkg : pkg_list_)
- pkgmgrinfo_basic_free_package(pkg);
}
-const std::vector<package_x*>& PkgInfoParcelable::GetPkgInfo() {
+const std::vector<std::shared_ptr<package_x>>& PkgInfoParcelable::GetPkgInfo() {
return pkg_list_;
}
-std::vector<package_x*> PkgInfoParcelable::ExtractPkgInfo() {
+std::vector<std::shared_ptr<package_x>> PkgInfoParcelable::ExtractPkgInfo() {
return std::move(pkg_list_);
}
WriteInt(parcel, pkg_list_.size());
- for (auto pkg : pkg_list_)
- WritePackage(parcel, pkg);
+ for (auto& pkg : pkg_list_)
+ WritePackage(parcel, pkg.get());
}
void PkgInfoParcelable::ReadFromParcel(tizen_base::Parcel* parcel) {
ReadInt(parcel, &len);
for (int i = 0; i < len ; ++i)
- pkg_list_.emplace_back(ReadPackage(parcel));
+ pkg_list_.emplace_back(ReadPackage(parcel), [] (package_x*) -> void {});
}
} // namespace parcel
class EXPORT_API PkgInfoParcelable : public AbstractParcelable {
public:
PkgInfoParcelable();
- PkgInfoParcelable(uid_t uid, std::vector<package_x*>&& pkg_list,
+ PkgInfoParcelable(uid_t uid,
+ std::vector<std::shared_ptr<package_x>>&& pkg_list,
PkgWriteType write_type, bool auto_release = true);
- PkgInfoParcelable(int ret, std::vector<package_x*>&& pkg_list,
+ PkgInfoParcelable(int ret, std::vector<std::shared_ptr<package_x>>&& pkg_list,
bool auto_release = true);
~PkgInfoParcelable();
- const std::vector<package_x*>& GetPkgInfo();
- std::vector<package_x*> ExtractPkgInfo();
+ const std::vector<std::shared_ptr<package_x>>& GetPkgInfo();
+ std::vector<std::shared_ptr<package_x>> ExtractPkgInfo();
PkgWriteType GetWriteType();
void WriteToParcel(tizen_base::Parcel* parcel) const override;
void ReadResAllowedPackages(tizen_base::Parcel* parcel, GList** list);
package_x* ReadPackage(tizen_base::Parcel* parcel);
- std::vector<package_x*> pkg_list_;
+ std::vector<std::shared_ptr<package_x>> pkg_list_;
PkgWriteType write_type_;
bool auto_release_;
};
}
if (parcel->GetType() != parcel_type) {
- LOG(ERROR) << "Invalid parcelable Type";
+ LOG(ERROR) << "Invalid parcelable Type " << parcel->GetType() << ' ' << parcel_type;
return PMINFO_R_ERROR;
}
LOG(DEBUG) << "No packages meets given condition for user " << uid;
return PMINFO_R_ENOENT;
}
- for (auto pkginfo : result_list)
- g_hash_table_insert(packages, (gpointer)pkginfo->package,
- (gpointer)pkginfo);
+ for (auto& pkginfo : result_list)
+ g_hash_table_insert(packages, reinterpret_cast<gpointer>(pkginfo->package),
+ reinterpret_cast<gpointer>(pkginfo.get()));
return PMINFO_R_OK;
}
std::shared_ptr<pcp::AppInfoParcelable> return_parcel(
std::static_pointer_cast<pcp::AppInfoParcelable>(ptr));
- std::vector<application_x*> result_list = return_parcel->ExtractAppInfo();
- for (application_x* app : result_list)
- g_hash_table_insert(packages, (gpointer)app->appid,
- (gpointer)app);
+ std::vector<std::shared_ptr<application_x>> result_list = return_parcel->ExtractAppInfo();
+ for (auto& app : result_list)
+ g_hash_table_insert(packages, reinterpret_cast<gpointer>(app->appid),
+ reinterpret_cast<gpointer>(app.get()));
return PMINFO_R_OK;
}
manifest_x* mfx, uid_t uid) {
auto parcelable =
std::make_shared<pcp::PkgInfoParcelable>(uid,
- std::vector<package_x*>{mfx},
- pkgmgr_common::PkgWriteType::Insert, false);
+ std::vector<std::shared_ptr<package_x>>(1,
+ std::shared_ptr<package_x>(mfx, [] (package_x*) -> void {})),
+ pkgmgr_common::PkgWriteType::Insert, false);
pkgmgr_client::PkgInfoClient client(parcelable, uid,
pkgmgr_common::ReqType::SET_PKG_INFO);
manifest_x* mfx, uid_t uid) {
auto parcelable =
std::make_shared<pcp::PkgInfoParcelable>(uid,
- std::vector<package_x*>{mfx},
- pkgmgr_common::PkgWriteType::Update, false);
+ std::vector<std::shared_ptr<package_x>>(1,
+ std::shared_ptr<package_x>(mfx, [] (package_x*) -> void {})),
+ pkgmgr_common::PkgWriteType::Update, false);
pkgmgr_client::PkgInfoClient client(parcelable, uid,
pkgmgr_common::ReqType::SET_PKG_INFO);
manifest_x* mfx, uid_t uid) {
auto parcelable =
std::make_shared<pcp::PkgInfoParcelable>(uid,
- std::vector<package_x*>{mfx},
- pkgmgr_common::PkgWriteType::Delete, false);
+ std::vector<std::shared_ptr<package_x>>(1,
+ std::shared_ptr<package_x>(mfx, [] (package_x*) -> void {})),
+ pkgmgr_common::PkgWriteType::Delete, false);
pkgmgr_client::PkgInfoClient client(parcelable, uid,
pkgmgr_common::ReqType::SET_PKG_INFO);
free((void *)package->res_type);
if (package->res_version)
free((void *)package->res_version);
+ if (package->is_disabled)
+ free((void *)package->is_disabled);
/*Free Icon*/
g_list_free_full(package->icon, __ps_free_icon);
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SERVER_SRCS)
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/cynara_checker CYNARA_CHECKER_SRCS)
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/filter_checker/ FILTER_CHECKER_SRCS)
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/filter_checker/pkg_filter_checker/ PKG_FILTER_CHECKER_SRCS)
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/filter_checker/app_filter_checker/ APP_FILTER_CHECKER_SRCS)
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/database DATABASE_SRCS)
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/request_handler REQUEST_HANDLER_SRCS)
AUX_SOURCE_DIRECTORY(${CMAKE_SOURCE_DIR}/src/utils/ UTIL_SRCS)
ADD_LIBRARY(pkgmgr-info-server SHARED
${CYNARA_CHECKER_SRCS}
+ ${FILTER_CHECKER_SRCS}
+ ${PKG_FILTER_CHECKER_SRCS}
+ ${APP_FILTER_CHECKER_SRCS}
${SERVER_SRCS}
${DATABASE_SRCS}
${REQUEST_HANDLER_SRCS}
SET_TARGET_PROPERTIES(${PKGINFO_SERVER} PROPERTIES LINKER_LANGUAGE CXX)
INSTALL(TARGETS ${PKGINFO_SERVER} DESTINATION bin)
-
if (!filter)
return PMINFO_R_OK;
+
+ if (g_slist_length(filter->list) == 0) {
+ joined = E_PMINFO_APPINFO_JOIN_LOCALIZED_INFO |
+ E_PMINFO_APPINFO_JOIN_CATEGORY |
+ E_PMINFO_APPINFO_JOIN_APP_CONTROL |
+ E_PMINFO_APPINFO_JOIN_METADATA |
+ E_PMINFO_APPINFO_JOIN_PRIVILEGE;
+ }
+
strncat(buf, " WHERE 1=1", sizeof(buf) - strlen(buf) - 1);
for (list = filter->list; list; list = list->next) {
virtual bool Connect();
int GetPID();
uid_t GetUID();
+ std::vector<std::pair<std::string, uid_t>> GetDBPath();
virtual std::vector<std::pair<sqlite3*, uid_t>> GetConnection();
void ClearDBHandle();
const std::string& GetLocale();
static std::shared_timed_mutex lock_;
private:
- std::vector<std::pair<std::string, uid_t>> GetDBPath();
pkgmgr_common::DBType db_type_;
pkgmgr_common::DBOperationType op_type_;
} // namespace pkgmgr_server
#endif // ABSTRACT_DB_HANDLER_HH_
-
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "appinfo_cache_db_handler.hh"
+
+#include <shared_mutex>
+#include <vector>
+
+#include "db_handle_provider.hh"
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_debug.h"
+#include "utils/logging.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+AppInfoCacheDBHandler::AppInfoCacheDBHandler(uid_t uid, int pid)
+ : AppInfoDBHandler(uid, pid) {}
+
+int AppInfoCacheDBHandler::Execute() {
+ std::shared_lock<std::shared_timed_mutex> s(lock_);
+ SetOpType(pkgmgr_common::DBOperationType::OPERATION_TYPE_READ);
+ SetDBType(pkgmgr_common::DBType::DB_TYPE_FILE_PKGDB);
+ bool write =
+ GetOpType() == pkgmgr_common::DBOperationType::OPERATION_TYPE_WRITE;
+
+ std::vector<std::pair<sqlite3*, uid_t>> conn_list;
+ if (!Connect())
+ return PMINFO_R_ERROR;
+
+ conn_list = GetConnection();
+
+ int ret = PMINFO_R_OK;
+ std::string application;
+
+ for (auto* it = filter_->list; it != nullptr; it = g_slist_next(it)) {
+ auto node = reinterpret_cast<pkgmgrinfo_node_x*>(it->data);
+ if (node->prop == E_PMINFO_APPINFO_PROP_APP_ID) {
+ application = node->value;
+ break;
+ }
+ }
+
+ std::vector<std::shared_ptr<application_x>> app_list;
+ for (auto& conn : conn_list) {
+ ret = DBHandleProvider::GetInst(conn.second)
+ .UpdateCache(conn.first, GetPID(), uid_, write, GetLocale());
+ if (ret != PMINFO_R_OK) {
+ LOG(DEBUG) << "Failed to update appinfo cache: " << ret;
+ break;
+ }
+
+ app_list = DBHandleProvider::GetInst(conn.second)
+ .GetApplications(GetPID(), write, filter_, application);
+
+ handle_list_.reserve(app_list.size() + handle_list_.size());
+ std::move(std::begin(app_list), std::end(app_list),
+ std::back_inserter(handle_list_));
+ }
+
+ if (handle_list_.empty())
+ ret = PMINFO_R_ENOENT;
+
+ return ret;
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef APPINFO_CACHE_DB_HANDLER_HH_
+#define APPINFO_CACHE_DB_HANDLER_HH_
+
+#include <vector>
+
+#include <sys/types.h>
+
+#include "appinfo_db_handler.hh"
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__((visibility("default")))
+#endif
+
+class EXPORT_API AppInfoCacheDBHandler : public AppInfoDBHandler {
+ public:
+ AppInfoCacheDBHandler(uid_t uid, int pid);
+ int Execute() override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // APPINFO_CACHE_DB_HANDLER_HH_
namespace {
gboolean _move_func(gpointer key, gpointer value, gpointer user_data) {
- application_x* appinfo = static_cast<application_x*>(value);
- std::vector<application_x*>* app_list =
- static_cast<std::vector<application_x*>*>(user_data);
- app_list->emplace_back(appinfo);
+ application_x* info = static_cast<application_x*>(value);
+ std::vector<std::shared_ptr<application_x>>* app_list =
+ static_cast<std::vector<std::shared_ptr<application_x>>*>(user_data);
+ app_list->push_back(
+ std::shared_ptr<application_x>(info, pkgmgrinfo_basic_free_application));
return true;
}
-void __free_applications(gpointer data) {
- pkgmgrinfo_basic_free_application(reinterpret_cast<application_x*>(data));
-}
-
} // namespace
namespace pkgmgr_server {
AppInfoDBHandler::~AppInfoDBHandler() {}
-std::vector<application_x*> AppInfoDBHandler::GetAppHandle() {
+std::vector<std::shared_ptr<application_x>> AppInfoDBHandler::GetAppHandle() {
return std::move(handle_list_);
}
if (!Connect())
return PMINFO_R_ERROR;
- GHashTable* list = g_hash_table_new_full(g_str_hash, g_str_equal,
- NULL, __free_applications);
+ GHashTable* list =
+ g_hash_table_new_full(g_str_hash, g_str_equal, nullptr, nullptr);
std::vector<std::pair<sqlite3*, uid_t>> conn_list = GetConnection();
int ret = PMINFO_R_OK;
for (auto& conn : conn_list) {
#ifndef APPINFO_DB_HANDLER_HH_
#define APPINFO_DB_HANDLER_HH_
-#include <vector>
-
#include <sys/types.h>
+#include <memory>
+#include <vector>
+
#include "abstract_db_handler.hh"
#include "pkgmgrinfo_basic.h"
#include "pkgmgrinfo_private.h"
public:
AppInfoDBHandler(uid_t uid, int pid);
~AppInfoDBHandler();
- std::vector<application_x*> GetAppHandle();
+ std::vector<std::shared_ptr<application_x>> GetAppHandle();
void SetFilter(pkgmgrinfo_filter_x* filter);
- int Execute() override;
+ virtual int Execute();
- private:
+ protected:
pkgmgrinfo_filter_x* filter_;
- std::vector<application_x*> handle_list_;
+ std::vector<std::shared_ptr<application_x>> handle_list_;
uid_t uid_;
};
} // namespace pkgmgr_server
#endif // APPINFO_DB_HANDLER_HH_
-
#include "db_handle_provider.hh"
#include <fcntl.h>
+#include <glib.h>
#include <sys/types.h>
#include <tzplatform_config.h>
#include "utils/logging.hh"
-#include "pkgmgrinfo_debug.h"
#include "pkgmgr-info.h"
+#include "pkgmgrinfo_debug.h"
+#include "pkgmgrinfo_internal.h"
+#include "pkgmgrinfo_private.h"
#ifdef LOG_TAG
#undef LOG_TAG
namespace {
-constexpr uid_t REGULAR_USER = 5000;
-
uid_t globaluser_uid = -1;
uid_t GetGlobalUID() {
DBHandleProvider::provider_;
bool DBHandleProvider::is_memory_global_ = false;
std::unique_ptr<sqlite3, decltype(sqlite3_close_v2)*>
- DBHandleProvider::global_parser_memory_db_handle_(
- nullptr, sqlite3_close_v2);
+ DBHandleProvider::global_parser_memory_db_handle_(nullptr,
+ sqlite3_close_v2);
std::unique_ptr<sqlite3, decltype(sqlite3_close_v2)*>
DBHandleProvider::cert_memory_db_handle_(nullptr, sqlite3_close_v2);
std::string DBHandleProvider::global_parser_file_db_path_;
std::unordered_set<pid_t> DBHandleProvider::pid_list_;
std::recursive_mutex DBHandleProvider::lock_;
-DBHandleProvider::DBHandleProvider(uid_t uid) : uid_(uid),
- is_memory_(false), parser_memory_db_handle_(nullptr, sqlite3_close_v2) {
+DBHandleProvider::DBHandleProvider(uid_t uid)
+ : uid_(uid),
+ is_memory_(false),
+ parser_memory_db_handle_(nullptr, sqlite3_close_v2) {
char* tmp_path;
if (global_parser_file_db_path_.empty()) {
free(tmp_path);
parser_memory_db_path_ = "file:parserdb" +
- std::to_string(static_cast<int>(uid_)) + "?mode=memory&cache=shared";
+ std::to_string(static_cast<int>(uid_)) +
+ "?mode=memory&cache=shared";
}
DBHandleProvider& DBHandleProvider::GetInst(uid_t uid) {
- static std::mutex singleton_lock;
- std::unique_lock<std::mutex> u(singleton_lock);
+ static std::mutex singleton_lock_;
+ std::unique_lock<std::mutex> u(singleton_lock_);
uid = ConvertUID(uid);
auto& prov = provider_[uid];
}
sqlite3* DBHandleProvider::GetMemoryDBHandle(const std::string& filedb_path,
- const std::string& memorydb_path) {
+ const std::string& memorydb_path) {
sqlite3* memorydb = nullptr;
sqlite3* filedb = nullptr;
int ret = sqlite3_open_v2(memorydb_path.c_str(), &memorydb,
- SQLITE_OPEN_READONLY | SQLITE_OPEN_URI, nullptr);
+ SQLITE_OPEN_READONLY | SQLITE_OPEN_URI, nullptr);
if (ret != SQLITE_OK) {
LOG(ERROR) << "Failed to open memory DB " << ret << ": " << memorydb_path;
return nullptr;
}
- ret = sqlite3_open_v2(filedb_path.c_str(), &filedb,
- SQLITE_OPEN_READONLY, nullptr);
+ ret = sqlite3_open_v2(filedb_path.c_str(), &filedb, SQLITE_OPEN_READONLY,
+ nullptr);
if (ret != SQLITE_OK) {
LOG(ERROR) << "Failed to open file DB " << ret << ": " << filedb_path;
sqlite3_close_v2(memorydb);
return nullptr;
}
- sqlite3_backup* backup = sqlite3_backup_init(memorydb, "main",
- filedb, "main");
+ sqlite3_backup* backup =
+ sqlite3_backup_init(memorydb, "main", filedb, "main");
if (backup == nullptr) {
LOG(ERROR) << "Failed to backup for memory DB";
sqlite3_close_v2(memorydb);
if (is_memory_global_ && is_memory_)
return;
- sqlite3* parser_db = GetMemoryDBHandle(parser_file_db_path_,
- parser_memory_db_path_);
+ sqlite3* parser_db =
+ GetMemoryDBHandle(parser_file_db_path_, parser_memory_db_path_);
if (parser_db != nullptr)
parser_memory_db_handle_.reset(parser_db);
- if (is_memory_ == is_memory_global_) { /* first call */
+ if (is_memory_ == is_memory_global_) {
sqlite3* global_parser_file_db = GetMemoryDBHandle(
global_parser_file_db_path_, global_parser_memory_db_path);
if (global_parser_file_db)
global_parser_memory_db_handle_.reset(global_parser_file_db);
- sqlite3* cert_db = GetMemoryDBHandle(cert_file_db_path_,
- cert_memory_db_path);
+ sqlite3* cert_db =
+ GetMemoryDBHandle(cert_file_db_path_, cert_memory_db_path);
if (cert_db != nullptr)
cert_memory_db_handle_.reset(cert_db);
is_memory_ = true;
is_memory_global_ = true;
+ old_pkg_map_ = std::move(pkg_map_);
+ old_app_map_ = std::move(app_map_);
+ released_ = true;
LOG(DEBUG) << "Set Memory mode : Memory";
}
is_memory_ = false;
is_memory_global_ = false;
+ old_pkg_map_.clear();
+ old_app_map_.clear();
LOG(DEBUG) << "Set Memory mode : File";
}
return (is_memory_ && pid_list_.find(pid) == pid_list_.end() && !write);
}
+void DBHandleProvider::TrimCache() {
+ std::unique_lock<std::recursive_mutex> u(lock_);
+ if (!released_)
+ ReleaseCache();
+}
+
+void DBHandleProvider::ReleaseCache() {
+ app_map_.clear();
+ pkg_map_.clear();
+ released_ = true;
+}
+
+bool DBHandleProvider::NeedUpdate(pid_t pid, bool write,
+ const std::string& locale) {
+ std::unique_lock<std::recursive_mutex> u(lock_);
+ return (!IsMemoryDBActive(pid, write) && (locale_ != locale || released_));
+}
+
+int DBHandleProvider::UpdateCache(sqlite3* db, pid_t pid, uid_t uid, bool write,
+ const std::string& locale) {
+ if (!NeedUpdate(pid, write, locale))
+ return PMINFO_R_OK;
+
+ std::unique_lock<std::recursive_mutex> u(lock_);
+ if (!released_)
+ ReleaseCache();
+
+ locale_ = locale;
+
+ GHashTable* list = g_hash_table_new(g_str_hash, g_str_equal);
+ if (list == nullptr) {
+ LOG(ERROR) << "Out of memory";
+ return PMINFO_R_ERROR;
+ }
+
+ auto tmp_filter = reinterpret_cast<pkgmgrinfo_filter_x*>(
+ calloc(1, sizeof(pkgmgrinfo_filter_x)));
+ if (tmp_filter == nullptr) {
+ LOG(ERROR) << "Out of memory";
+ g_hash_table_destroy(list);
+ return PMINFO_R_ERROR;
+ }
+
+ int ret = pkginfo_internal_filter_get_list(db, tmp_filter, uid_,
+ locale_.c_str(), list);
+ if (ret == PMINFO_R_OK) {
+ GHashTableIter iter;
+ gpointer value;
+ g_hash_table_iter_init(&iter, list);
+ while (g_hash_table_iter_next(&iter, nullptr, &value)) {
+ auto* pkg = reinterpret_cast<package_x*>(value);
+ AddPackage(pkg->package, pkg);
+ }
+ }
+
+ g_hash_table_destroy(list);
+ if (ret == PMINFO_R_ERROR) {
+ free(tmp_filter);
+ return ret;
+ }
+
+ list = g_hash_table_new(g_str_hash, g_str_equal);
+ ret = appinfo_internal_filter_get_list(db, tmp_filter, uid_, uid,
+ locale_.c_str(), list);
+ free(tmp_filter);
+ if (ret == PMINFO_R_OK) {
+ GHashTableIter iter;
+ gpointer value;
+ g_hash_table_iter_init(&iter, list);
+ while (g_hash_table_iter_next(&iter, nullptr, &value)) {
+ auto* app = reinterpret_cast<application_x*>(value);
+ app->privileges = pkg_map_[app->package].front()->privileges;
+ AddApplication(app->appid, app);
+ }
+ }
+ g_hash_table_destroy(list);
+ released_ = false;
+
+ return ret;
+}
+
+std::vector<std::shared_ptr<package_x>> DBHandleProvider::GetPackages(
+ pid_t pid, bool write, pkgmgrinfo_filter_x* filter,
+ const std::string& package) {
+ auto& pkg_map = (IsMemoryDBActive(pid, write) ? old_pkg_map_ : pkg_map_);
+
+ std::vector<std::shared_ptr<package_x>> ret;
+ for (auto& info : pkg_map[package]) {
+ bool pass = true;
+ for (auto* it = filter->list; it != nullptr; it = g_slist_next(it)) {
+ auto node = reinterpret_cast<pkgmgrinfo_node_x*>(it->data);
+ auto* checker = FilterCheckerProvider::GetInst().
+ GetPkgFilterChecker(node->prop);
+ if (!checker->CheckFilter(node, info.get())) {
+ pass = false;
+ break;
+ }
+ }
+ if (pass)
+ ret.push_back(info);
+ }
+
+ return ret;
+}
+
+void DBHandleProvider::AddPackage(std::string package, package_x* info) {
+ auto ptr = std::shared_ptr<package_x>(info, pkgmgrinfo_basic_free_package);
+ pkg_map_[package].push_back(ptr);
+ pkg_map_[""].push_back(std::move(ptr));
+}
+
+std::vector<std::shared_ptr<application_x>> DBHandleProvider::GetApplications(
+ pid_t pid, bool write, pkgmgrinfo_filter_x* filter,
+ const std::string& app) {
+ auto& app_map = (IsMemoryDBActive(pid, write) ? old_app_map_ : app_map_);
+
+ /* make metadata filter map */
+ std::unordered_map<std::string, std::string> metadata_map;
+ for (auto* it = filter->list_metadata; it != nullptr; it = g_slist_next(it)) {
+ auto node = reinterpret_cast<pkgmgrinfo_metadata_node_x*>(it->data);
+ if (node->key == nullptr)
+ continue;
+
+ metadata_map[node->key] = (node->value ? node->value : "");
+ }
+
+ std::vector<std::shared_ptr<application_x>> ret;
+ for (auto& info : app_map[app]) {
+ bool pass = true;
+ for (auto* it = filter->list; it != nullptr; it = g_slist_next(it)) {
+ auto node = reinterpret_cast<pkgmgrinfo_node_x*>(it->data);
+ auto* checker = FilterCheckerProvider::GetInst().
+ GetAppFilterChecker(node->prop);
+ if (!checker->CheckFilter(node, info.get())) {
+ pass = false;
+ break;
+ }
+ }
+ if (!pass)
+ continue;
+
+ if (!metadata_map.empty()) {
+ pass = false;
+ for (auto* it = info->metadata; it != nullptr; it = g_list_next(it)) {
+ auto* node = reinterpret_cast<metadata_x*>(it->data);
+ if (node->key != nullptr) {
+ auto metadata = metadata_map.find(node->key);
+ if (metadata != metadata_map.end() &&
+ strstr(node->value ? node->value : "",
+ metadata->second.c_str()) != nullptr) {
+ pass = true;
+ break;
+ }
+ }
+ }
+ }
+
+ if (pass)
+ ret.push_back(info);
+ }
+ return ret;
+}
+
+void DBHandleProvider::AddApplication(std::string app, application_x* info) {
+ auto ptr =
+ std::shared_ptr<application_x>(info, pkgmgrinfo_basic_free_application);
+ app_map_[app].push_back(ptr);
+ app_map_[""].push_back(std::move(ptr));
+}
+
} // namespace database
} // namespace pkgmgr_server
#include <stdlib.h>
#include <sys/types.h>
-#include <string>
#include <memory>
#include <mutex>
+#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
+#include "filter_checker_provider.hh"
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
#include "shared_object.hh"
namespace pkgmgr_server {
~DBHandleProvider() = default;
static DBHandleProvider& GetInst(uid_t uid);
static bool IsCrashedWriteRequest();
- std::vector<std::pair<std::string, uid_t>> GetParserDBPath(
- int pid, bool write);
+ std::vector<std::pair<std::string, uid_t>> GetParserDBPath(int pid,
+ bool write);
std::string GetCertDBPath(int pid, bool write);
void SetMemoryMode(pid_t pid);
void UnsetMemoryMode(pid_t pid);
+ bool NeedUpdate(pid_t pid, bool write, const std::string& locale);
+ int UpdateCache(sqlite3* db, pid_t pid, uid_t uid, bool write,
+ const std::string& locale);
+ std::vector<std::shared_ptr<package_x>> GetPackages(
+ pid_t pid, bool write, pkgmgrinfo_filter_x* filter,
+ const std::string& package);
+ std::vector<std::shared_ptr<application_x>> GetApplications(
+ pid_t pid, bool write, pkgmgrinfo_filter_x* filter,
+ const std::string& app);
+ void TrimCache();
private:
- DBHandleProvider(uid_t uid);
+ explicit DBHandleProvider(uid_t uid);
sqlite3* GetMemoryDBHandle(const std::string& filedb_path,
- const std::string& memorydb_path);
+ const std::string& memorydb_path);
bool IsMemoryDBActive(pid_t pid, bool write);
+ void ReleaseCache();
+ void AddPackage(std::string package, package_x* info);
+ void AddApplication(std::string app, application_x* info);
private:
- static std::unordered_map<uid_t,
- std::unique_ptr<DBHandleProvider>> provider_;
+ static std::unordered_map<uid_t, std::unique_ptr<DBHandleProvider>> provider_;
static bool is_memory_global_;
static std::unique_ptr<sqlite3, decltype(sqlite3_close_v2)*>
global_parser_memory_db_handle_;
uid_t uid_;
bool is_memory_;
- std::unique_ptr<sqlite3,
- decltype(sqlite3_close_v2)*> parser_memory_db_handle_;
+ std::unique_ptr<sqlite3, decltype(sqlite3_close_v2)*>
+ parser_memory_db_handle_;
std::string parser_memory_db_path_;
std::string parser_file_db_path_;
+ std::string locale_;
+ bool released_ = true;
+ std::unordered_map<std::string, std::vector<std::shared_ptr<package_x>>>
+ pkg_map_;
+ std::unordered_map<std::string, std::vector<std::shared_ptr<package_x>>>
+ old_pkg_map_;
+ std::unordered_map<std::string, std::vector<std::shared_ptr<application_x>>>
+ app_map_;
+ std::unordered_map<std::string, std::vector<std::shared_ptr<application_x>>>
+ old_app_map_;
};
} // namespace database
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "pkg_get_cache_db_handler.hh"
+
+#include <shared_mutex>
+#include <vector>
+
+#include "utils/logging.hh"
+
+#include "db_handle_provider.hh"
+#include "pkgmgrinfo_debug.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+PkgGetCacheDBHandler::PkgGetCacheDBHandler(uid_t uid, int pid)
+ : PkgGetDBHandler(uid, pid) {}
+
+int PkgGetCacheDBHandler::Execute() {
+ std::shared_lock<std::shared_timed_mutex> s(lock_);
+ SetOpType(pkgmgr_common::DBOperationType::OPERATION_TYPE_READ);
+ SetDBType(pkgmgr_common::DBType::DB_TYPE_FILE_PKGDB);
+ bool write =
+ GetOpType() == pkgmgr_common::DBOperationType::OPERATION_TYPE_WRITE;
+
+ std::vector<std::pair<sqlite3*, uid_t>> conn_list;
+ if (!Connect())
+ return PMINFO_R_ERROR;
+
+ conn_list = GetConnection();
+
+ int ret = PMINFO_R_OK;
+ std::string package;
+
+ for (auto* it = filter_->list; it != nullptr; it = g_slist_next(it)) {
+ auto node = reinterpret_cast<pkgmgrinfo_node_x*>(it->data);
+ if (node->prop == E_PMINFO_PKGINFO_PROP_PACKAGE_ID) {
+ package = node->value;
+ break;
+ }
+ }
+
+ std::vector<std::shared_ptr<package_x>> pkg_list;
+ for (auto& conn : conn_list) {
+ ret = DBHandleProvider::GetInst(conn.second)
+ .UpdateCache(conn.first, GetPID(), uid_, write, GetLocale());
+ if (ret != PMINFO_R_OK) {
+ LOG(ERROR) << "Failed to update pkginfo cache : " << ret;
+ break;
+ }
+
+ pkg_list = DBHandleProvider::GetInst(conn.second)
+ .GetPackages(GetPID(), write, filter_, package);
+
+ handle_list_.reserve(pkg_list.size() + handle_list_.size());
+ std::move(std::begin(pkg_list), std::end(pkg_list),
+ std::back_inserter(handle_list_));
+ }
+
+ if (handle_list_.empty())
+ return PMINFO_R_ENOENT;
+
+ return ret;
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PKG_GET_CACHE_DB_HANDLER_HH_
+#define PKG_GET_CACHE_DB_HANDLER_HH_
+
+#include <sys/types.h>
+
+#include <vector>
+
+#include "pkg_get_db_handler.hh"
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__((visibility("default")))
+#endif
+
+class EXPORT_API PkgGetCacheDBHandler : public PkgGetDBHandler {
+ public:
+ PkgGetCacheDBHandler(uid_t uid, int pid);
+ int Execute() override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // PKG_GET_CACHE_DB_HANDLER_HH_
#include <shared_mutex>
#include <vector>
-#include "utils/logging.hh"
-
#include "pkgmgrinfo_debug.h"
#include "pkgmgrinfo_internal.h"
+#include "utils/logging.hh"
namespace {
gboolean _move_func(gpointer key, gpointer value, gpointer user_data) {
- package_x* appinfo = static_cast<package_x*>(value);
- std::vector<package_x*>* app_list =
- static_cast<std::vector<package_x*>*>(user_data);
- app_list->emplace_back(appinfo);
+ package_x* info = static_cast<package_x*>(value);
+ std::vector<std::shared_ptr<package_x>>* app_list =
+ static_cast<std::vector<std::shared_ptr<package_x>>*>(user_data);
+ app_list->emplace_back(info, pkgmgrinfo_basic_free_package);
return true;
}
-void __free_packages(gpointer data) {
- pkgmgrinfo_basic_free_package(reinterpret_cast<package_x*>(data));
-}
-
} // namespace
namespace pkgmgr_server {
PkgGetDBHandler::~PkgGetDBHandler() {}
-std::vector<package_x*> PkgGetDBHandler::GetPkgHandle() {
+std::vector<std::shared_ptr<package_x>> PkgGetDBHandler::GetPkgHandle() {
return std::move(handle_list_);
}
return PMINFO_R_ERROR;
}
- GHashTable* list = g_hash_table_new_full(g_str_hash, g_str_equal,
- NULL, __free_packages);
+ GHashTable* list =
+ g_hash_table_new_full(g_str_hash, g_str_equal, nullptr, nullptr);
std::vector<std::pair<sqlite3*, uid_t>> conn_list = GetConnection();
int ret = PMINFO_R_OK;
for (auto& conn : conn_list) {
ret = pkginfo_internal_filter_get_list(conn.first, filter_, conn.second,
- GetLocale().c_str(), list);
+ GetLocale().c_str(), list);
if (ret == PMINFO_R_ERROR) {
LOG(ERROR) << "Failed to pkginfo_internal_filter_get_list : " << ret;
break;
public:
PkgGetDBHandler(uid_t uid, int pid);
~PkgGetDBHandler();
- std::vector<package_x*> GetPkgHandle();
+ std::vector<std::shared_ptr<package_x>> GetPkgHandle();
void SetFilter(pkgmgrinfo_filter_x* filter);
- int Execute() override;
+ virtual int Execute();
- private:
+ protected:
pkgmgrinfo_filter_x* filter_ = nullptr;
- std::vector<package_x*> handle_list_;
+ std::vector<std::shared_ptr<package_x>> handle_list_;
uid_t uid_;
};
} // namespace pkgmgr_server
#endif // PKG_GET_DB_HANDLER_HH_
-
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "app_disable_app_filter_checker.hh"
+
+#include <string.h>
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool AppDisableAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* info) {
+ return (node->value != nullptr && info->is_disabled != nullptr &&
+ strcasecmp(node->value, info->is_disabled) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef APP_DISABLE_APP_FILTER_CHECKER_HH_
+#define APP_DISABLE_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class AppDisableAppFilterChecker: public IAppFilterChecker {
+ public:
+ AppDisableAppFilterChecker() = default;
+ ~AppDisableAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // APP_DISABLE_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "appid_app_filter_checker.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool AppIdAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* info) {
+ return (node->value != nullptr && info->appid != nullptr &&
+ strcmp(node->value, info->appid) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef APPID_APP_FILTER_CHECKER_HH_
+#define APPID_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class AppIdAppFilterChecker: public IAppFilterChecker {
+ public:
+ AppIdAppFilterChecker() = default;
+ ~AppIdAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // APPID_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+
+#include "category_app_filter_checker.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool CategoryAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* info) {
+ for (auto* it = info->category; it != nullptr; it = g_list_next(it)) {
+ char* value = reinterpret_cast<char*>(it->data);
+ if (value != nullptr && strcmp(value, node->value) == 0) return true;
+ }
+
+ return false;
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef CATEGORY_APP_FILTER_CHECKER_HH_
+#define CATEGORY_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class CategoryAppFilterChecker: public IAppFilterChecker {
+ public:
+ CategoryAppFilterChecker() = default;
+ ~CategoryAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // CATEGORY_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "component_app_filter_checker.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool ComponentAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* info) {
+ return (node->value != nullptr && info->component != nullptr &&
+ strcmp(node->value, info->component) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef COMPONENT_APP_FILTER_CHECKER_HH_
+#define COMPONENT_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class ComponentAppFilterChecker: public IAppFilterChecker {
+ public:
+ ComponentAppFilterChecker() = default;
+ ~ComponentAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // COMPONENT_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "default_app_filter_checker.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool DefaultAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* info) {
+ return true;
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DEFAULT_APP_FILTER_CHECKER_HH_
+#define DEFAULT_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class DefaultAppFilterChecker: public IAppFilterChecker {
+ public:
+ DefaultAppFilterChecker() = default;
+ ~DefaultAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // DEFAULT_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "exec_app_filter_checker.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool ExecAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* info) {
+ return (node->value != nullptr && info->exec != nullptr &&
+ strcmp(node->value, info->exec) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef EXEC_APP_FILTER_CHECKER_HH_
+#define EXEC_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class ExecAppFilterChecker: public IAppFilterChecker {
+ public:
+ ExecAppFilterChecker() = default;
+ ~ExecAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // EXEC_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "nodisplay_app_filter_checker.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool NoDisplayAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* info) {
+ return (node->value != nullptr && info->nodisplay != nullptr &&
+ strcasecmp(node->value, info->nodisplay) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef NODISPLAY_DISABLE_APP_FILTER_CHECKER_HH_
+#define NODISPLAY_DISABLE_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class NoDisplayAppFilterChecker: public IAppFilterChecker {
+ public:
+ NoDisplayAppFilterChecker() = default;
+ ~NoDisplayAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // NODISPLAY_DISABLE_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "operation_app_filter_checker.hh"
+
+#include <glib.h>
+
+namespace pkgmgr_server {
+namespace database {
+
+bool OperationAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* info) {
+ for (auto* it = info->appcontrol; it != nullptr; it = g_list_next(it)) {
+ char* value = reinterpret_cast<appcontrol_x*>(it->data)->operation;
+ if (value != nullptr && strcmp(value, node->value) == 0)
+ return true;
+ }
+
+ return false;
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef OPERATION_APP_FILTER_CHECKER_HH_
+#define OPERATION_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class OperationAppFilterChecker: public IAppFilterChecker {
+ public:
+ OperationAppFilterChecker() = default;
+ ~OperationAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // OPERATION_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "pkg_disable_app_filter_checker.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool PkgDisableAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* info) {
+ return (node->value != nullptr && strcasecmp(node->value, "false") == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PKG_DISABLE_APP_FILTER_CHECKER_HH_
+#define PKG_DISABLE_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class PkgDisableAppFilterChecker: public IAppFilterChecker {
+ public:
+ PkgDisableAppFilterChecker() = default;
+ ~PkgDisableAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // PKG_DISABLE_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "pkgid_app_filter_checker.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool PkgIdAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* info) {
+ return (node->value != nullptr && info->package != nullptr &&
+ strcmp(node->value, info->package) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PKGID_APP_FILTER_CHECKER_HH_
+#define PKGID_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class PkgIdAppFilterChecker: public IAppFilterChecker {
+ public:
+ PkgIdAppFilterChecker() = default;
+ ~PkgIdAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // PKGID_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "privilege_app_filter_checker.hh"
+
+#include <glib.h>
+
+namespace pkgmgr_server {
+namespace database {
+
+bool PrivilegeAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* info) {
+ for (auto* it = info->privileges; it != nullptr; it = g_list_next(it)) {
+ char* value = reinterpret_cast<privilege_x*>(it->data)->value;
+ if (value != nullptr && strcmp(value, node->value) == 0) return true;
+ }
+
+ return false;
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PRIVILEGE_APP_FILTER_CHECKER_HH_
+#define PRIVILEGE_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class PrivilegeAppFilterChecker: public IAppFilterChecker {
+ public:
+ PrivilegeAppFilterChecker() = default;
+ ~PrivilegeAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // PRIVILEGE_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "storage_app_filter_checker.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool StorageAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* info) {
+ return (node->value != nullptr && info->installed_storage != nullptr &&
+ strcasecmp(node->value, info->installed_storage) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef STORAGE_APP_FILTER_CHECKER_HH_
+#define STORAGE_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class StorageAppFilterChecker: public IAppFilterChecker {
+ public:
+ StorageAppFilterChecker() = default;
+ ~StorageAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // STORAGE_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "type_app_filter_checker.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool TypeAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* info) {
+ return (node->value != nullptr && info->type != nullptr &&
+ strcmp(node->value, info->type) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef TYPE_APP_FILTER_CHECKER_HH_
+#define TYPE_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class TypeAppFilterChecker: public IAppFilterChecker {
+ public:
+ TypeAppFilterChecker() = default;
+ ~TypeAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // TYPE_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef APP_FILTER_CHECKER_BASE_HH_
+#define APP_FILTER_CHECKER_BASE_HH_
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class IAppFilterChecker {
+ public:
+ IAppFilterChecker() = default;
+ virtual ~IAppFilterChecker() = default;
+ virtual bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) = 0;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // APP_FILTER_CHECKER_BASE_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FILTER_CHECKER_LIST_HH_
+#define FILTER_CHECKER_LIST_HH_
+
+#include "app_filter_checker/app_disable_app_filter_checker.hh"
+#include "app_filter_checker/appid_app_filter_checker.hh"
+#include "app_filter_checker/category_app_filter_checker.hh"
+#include "app_filter_checker/component_app_filter_checker.hh"
+#include "app_filter_checker/default_app_filter_checker.hh"
+#include "app_filter_checker/exec_app_filter_checker.hh"
+#include "app_filter_checker/nodisplay_app_filter_checker.hh"
+#include "app_filter_checker/operation_app_filter_checker.hh"
+#include "app_filter_checker/pkg_disable_app_filter_checker.hh"
+#include "app_filter_checker/pkgid_app_filter_checker.hh"
+#include "app_filter_checker/privilege_app_filter_checker.hh"
+#include "app_filter_checker/storage_app_filter_checker.hh"
+#include "app_filter_checker/type_app_filter_checker.hh"
+
+#include "pkg_filter_checker/check_storage_pkg_filter_checker.hh"
+#include "pkg_filter_checker/default_pkg_filter_checker.hh"
+#include "pkg_filter_checker/disable_pkg_filter_checker.hh"
+#include "pkg_filter_checker/pkgid_pkg_filter_checker.hh"
+#include "pkg_filter_checker/preload_pkg_filter_checker.hh"
+#include "pkg_filter_checker/privilege_pkg_filter_checker.hh"
+#include "pkg_filter_checker/removable_pkg_filter_checker.hh"
+#include "pkg_filter_checker/restype_pkg_filter_checker.hh"
+
+#endif // FILTER_CHECKER_LIST_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "filter_checker_provider.hh"
+
+#include <memory>
+
+#include "filter_checker_list.hh"
+#include "pkgmgrinfo_debug.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+FilterCheckerProvider::FilterCheckerProvider() {
+ pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_ID] =
+ std::make_unique<PkgIdPkgFilterChecker>();
+ pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_PRIVILEGE] =
+ std::make_unique<PrivilegePkgFilterChecker>();
+ pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE] =
+ std::make_unique<RemovablePkgFilterChecker>();
+ pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD] =
+ std::make_unique<PreloadPkgFilterChecker>();
+ pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_DISABLE] =
+ std::make_unique<DisablePkgFilterChecker>();
+ pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_RES_TYPE] =
+ std::make_unique<ResTypePkgFilterChecker>();
+ pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_CHECK_STORAGE] =
+ std::make_unique<CheckStoragePkgFilterChecker>();
+
+ app_checker_map_[E_PMINFO_APPINFO_PROP_APP_ID] =
+ std::make_unique<AppIdAppFilterChecker>();
+ app_checker_map_[E_PMINFO_APPINFO_PROP_APP_COMPONENT] =
+ std::make_unique<ComponentAppFilterChecker>();
+ app_checker_map_[E_PMINFO_APPINFO_PROP_APP_EXEC] =
+ std::make_unique<ExecAppFilterChecker>();
+ app_checker_map_[E_PMINFO_APPINFO_PROP_APP_TYPE] =
+ std::make_unique<TypeAppFilterChecker>();
+ app_checker_map_[E_PMINFO_APPINFO_PROP_APP_OPERATION] =
+ std::make_unique<OperationAppFilterChecker>();
+ app_checker_map_[E_PMINFO_APPINFO_PROP_APP_CATEGORY] =
+ std::make_unique<CategoryAppFilterChecker>();
+ app_checker_map_[E_PMINFO_APPINFO_PROP_APP_PACKAGE] =
+ std::make_unique<PkgIdAppFilterChecker>();
+ app_checker_map_[E_PMINFO_APPINFO_PROP_APP_INSTALLED_STORAGE] =
+ std::make_unique<StorageAppFilterChecker>();
+ app_checker_map_[E_PMINFO_APPINFO_PROP_PRIVILEGE] =
+ std::make_unique<PrivilegeAppFilterChecker>();
+ app_checker_map_[E_PMINFO_APPINFO_PROP_APP_NODISPLAY] =
+ std::make_unique<NoDisplayAppFilterChecker>();
+ app_checker_map_[E_PMINFO_APPINFO_PROP_APP_DISABLE] =
+ std::make_unique<AppDisableAppFilterChecker>();
+ app_checker_map_[E_PMINFO_APPINFO_PROP_PKG_DISABLE] =
+ std::make_unique<PkgDisableAppFilterChecker>();
+
+ default_pkg_checker = std::make_unique<DefaultPkgFilterChecker>();
+ default_app_checker = std::make_unique<DefaultAppFilterChecker>();
+}
+
+FilterCheckerProvider& FilterCheckerProvider::GetInst() {
+ static FilterCheckerProvider inst;
+ return inst;
+}
+
+IPkgFilterChecker* FilterCheckerProvider::GetPkgFilterChecker(int id) {
+ auto it = pkg_checker_map_.find(id);
+ if (it == pkg_checker_map_.end()) {
+ _LOGE("Invalid filter id %d", id);
+ return default_pkg_checker.get();
+ }
+ return it->second.get();
+}
+
+IAppFilterChecker* FilterCheckerProvider::GetAppFilterChecker(int id) {
+ auto it = app_checker_map_.find(id);
+ if (it == app_checker_map_.end()) {
+ _LOGE("Invalid filter id %d", id);
+ return default_app_checker.get();
+ }
+ return it->second.get();
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FILTER_CHECKER_FACTORY_HH_
+#define FILTER_CHECKER_FACTORY_HH_
+
+#include <memory>
+#include <unordered_map>
+
+#include "pkg_filter_checker_base.hh"
+#include "app_filter_checker_base.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+class FilterCheckerProvider {
+ public:
+ static FilterCheckerProvider& GetInst();
+ ~FilterCheckerProvider() = default;
+ IPkgFilterChecker* GetPkgFilterChecker(int id);
+ IAppFilterChecker* GetAppFilterChecker(int id);
+
+ private:
+ FilterCheckerProvider();
+ std::unordered_map<int, std::unique_ptr<IPkgFilterChecker>> pkg_checker_map_;
+ std::unordered_map<int, std::unique_ptr<IAppFilterChecker>> app_checker_map_;
+
+ std::unique_ptr<IPkgFilterChecker> default_pkg_checker;
+ std::unique_ptr<IAppFilterChecker> default_app_checker;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // FILTER_CHECKER_BASE_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "check_storage_pkg_filter_checker.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool CheckStoragePkgFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ package_x* info) {
+ return (node->value == nullptr || strcasecmp(node->value, "true") != 0 ||
+ __pkginfo_check_installed_storage(info) == PMINFO_R_OK);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef CHECK_STORAGE_PKG_FILTER_CHECKER_HH_
+#define CHECK_STORAGE_PKG_FILTER_CHECKER_HH_
+
+#include "pkg_filter_checker_base.hh"
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class CheckStoragePkgFilterChecker : public IPkgFilterChecker {
+ public:
+ CheckStoragePkgFilterChecker() = default;
+ ~CheckStoragePkgFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, package_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // CHECK_STORAGE_PKG_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "default_pkg_filter_checker.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool DefaultPkgFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ package_x* info) {
+ return true;
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DEFAULT_PKG_FILTER_CHECKER_HH_
+#define DEFAULT_PKG_FILTER_CHECKER_HH_
+
+#include "pkg_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class DefaultPkgFilterChecker: public IPkgFilterChecker {
+ public:
+ DefaultPkgFilterChecker() = default;
+ ~DefaultPkgFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, package_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // DEFAULT_PKG_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "disable_pkg_filter_checker.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool DisablePkgFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ package_x* info) {
+ return (node->value != nullptr && info->is_disabled != nullptr &&
+ strcasecmp(node->value, info->is_disabled) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DISABLE_PKG_FILTER_CHECKER_HH_
+#define DISABLE_PKG_FILTER_CHECKER_HH_
+
+#include "pkg_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class DisablePkgFilterChecker: public IPkgFilterChecker {
+ public:
+ DisablePkgFilterChecker() = default;
+ ~DisablePkgFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, package_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // DISABLE_PKG_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "pkgid_pkg_filter_checker.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool PkgIdPkgFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ package_x* info) {
+ return (node->value != nullptr && info->package != nullptr &&
+ strcmp(node->value, info->package) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PKGID_PKG_FILTER_CHECKER_HH_
+#define PKGID_PKG_FILTER_CHECKER_HH_
+
+#include "pkg_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class PkgIdPkgFilterChecker: public IPkgFilterChecker {
+ public:
+ PkgIdPkgFilterChecker() = default;
+ ~PkgIdPkgFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, package_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // PKGID_PKG_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "preload_pkg_filter_checker.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool PreloadPkgFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ package_x* info) {
+ return (node->value != nullptr && info->preload != nullptr &&
+ strcasecmp(node->value, info->preload) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PRELOAD_PKG_FILTER_CHECKER_HH_
+#define PRELOAD_PKG_FILTER_CHECKER_HH_
+
+#include "pkg_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class PreloadPkgFilterChecker: public IPkgFilterChecker {
+ public:
+ PreloadPkgFilterChecker() = default;
+ ~PreloadPkgFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, package_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // PRELOAD_PKG_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "privilege_pkg_filter_checker.hh"
+
+#include <glib.h>
+
+namespace pkgmgr_server {
+namespace database {
+
+bool PrivilegePkgFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ package_x* info) {
+ for (auto* it = info->privileges; it != nullptr; it = g_list_next(it)) {
+ char* value = reinterpret_cast<privilege_x*>(it->data)->value;
+ if (value != nullptr && strcmp(value, node->value) == 0)
+ return true;
+ }
+
+ return false;
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PRIVILEGE_PKG_FILTER_CHECKER_HH_
+#define PRIVILEGE_PKG_FILTER_CHECKER_HH_
+
+#include "pkg_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class PrivilegePkgFilterChecker: public IPkgFilterChecker {
+ public:
+ PrivilegePkgFilterChecker() = default;
+ ~PrivilegePkgFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, package_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // PRIVILEGE_PKG_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "removable_pkg_filter_checker.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool RemovablePkgFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ package_x* info) {
+ return (node->value != nullptr && info->removable != nullptr &&
+ strcasecmp(node->value, info->removable) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef REMOVABLE_PKG_FILTER_CHECKER_HH_
+#define REMOVABLE_PKG_FILTER_CHECKER_HH_
+
+#include "pkg_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class RemovablePkgFilterChecker: public IPkgFilterChecker {
+ public:
+ RemovablePkgFilterChecker() = default;
+ ~RemovablePkgFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, package_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // REMOVABLE_PKG_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "restype_pkg_filter_checker.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool ResTypePkgFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ package_x* info) {
+ return (info->removable == nullptr || info->removable[0] == '\0' ||
+ strcasecmp(node->value, info->removable) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef RESTYPE_PKG_FILTER_CHECKER_HH_
+#define RESTYPE_PKG_FILTER_CHECKER_HH_
+
+#include "pkg_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class ResTypePkgFilterChecker: public IPkgFilterChecker {
+ public:
+ ResTypePkgFilterChecker() = default;
+ ~ResTypePkgFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, package_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // RESTYPE_PKG_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PKG_FILTER_CHECKER_BASE_HH_
+#define PKG_FILTER_CHECKER_BASE_HH_
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class IPkgFilterChecker {
+ public:
+ IPkgFilterChecker() = default;
+ virtual ~IPkgFilterChecker() = default;
+ virtual bool CheckFilter(pkgmgrinfo_node_x* node, package_x* info) = 0;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // PKG_FILTER_CHECKER_BASE_HH_
char *condition = NULL;
GSList *list = NULL;
- if (filter == NULL)
+ if (!filter)
return PMINFO_R_OK;
+ if (g_slist_length(filter->list) == 0) {
+ joined = E_PMINFO_PKGINFO_JOIN_LOCALIZED_INFO |
+ E_PMINFO_PKGINFO_JOIN_PRIVILEGE_INFO |
+ E_PMINFO_PKGINFO_JOIN_RES_INFO;
+ }
+
snprintf(buf, sizeof(buf), "%s", " WHERE 1=1 ");
for (list = filter->list; list; list = list->next) {
joined |= __get_filter_condition(list->data, uid, &condition,
"pi.storeclient_id, pi.mainapp_id, pi.package_url, pi.root_path, "
"pi.csc_path, pi.package_nodisplay, pi.package_api_version, "
"pi.package_support_disable, pi.package_tep_name, "
- "pi.package_zip_mount_file, pi.package_support_mode";
+ "pi.package_zip_mount_file, pi.package_support_mode, pi.package_disable";
static const char query_author[] =
", pi.author_name, pi.author_email, pi.author_href";
static const char query_label[] =
_save_column_str(stmt, idx++, &info->tep_name);
_save_column_str(stmt, idx++, &info->zip_mount_file);
_save_column_str(stmt, idx++, &info->support_mode);
+ _save_column_str(stmt, idx++, &info->is_disabled);
}
info->for_all_users =
#include <string>
+#include "appinfo_cache_db_handler.hh"
#include "appinfo_db_handler.hh"
#include "filter_parcelable.hh"
#include "parcelable_factory.hh"
-#include "utils/logging.hh"
-
#include "pkgmgrinfo_debug.h"
+#include "utils/logging.hh"
namespace pcp = pkgmgr_common::parcel;
namespace psd = pkgmgr_server::database;
namespace pkgmgr_server {
namespace request_handler {
+GetAppinfoRequestHandler::GetAppinfoRequestHandler(bool cache)
+ : cache_(cache) {
+}
+
bool GetAppinfoRequestHandler::HandleRequest(unsigned char* data, int size,
const std::string& locale) {
auto abstract_parcel =
abstract_parcel->GetType() != pcp::ParcelableType::Filter) {
LOG(ERROR) << "Invalid parcel or type";
result_ = std::make_shared<pcp::AppInfoParcelable>(
- PMINFO_R_ERROR, std::vector<application_x*>{});
+ PMINFO_R_ERROR, std::vector<std::shared_ptr<application_x>>{});
return false;
}
if (parcel == nullptr) {
LOG(ERROR) << "Parcel is empty";
result_ = std::make_shared<pcp::AppInfoParcelable>(
- PMINFO_R_ERROR, std::vector<application_x*>{});
+ PMINFO_R_ERROR, std::vector<std::shared_ptr<application_x>>{});
return false;
}
- psd::AppInfoDBHandler db(parcel->GetUid(), GetPID());
- db.SetLocale(locale);
- db.SetFilter(const_cast<pkgmgrinfo_filter_x*>(parcel->GetFilter()));
- int ret = db.Execute();
+ psd::AppInfoDBHandler* db;
+ if (cache_)
+ db = new psd::AppInfoCacheDBHandler(parcel->GetUid(), GetPID());
+ else
+ db = new psd::AppInfoDBHandler(parcel->GetUid(), GetPID());
+
+ db->SetLocale(locale);
+ db->SetFilter(const_cast<pkgmgrinfo_filter_x*>(parcel->GetFilter()));
+ int ret = db->Execute();
- result_ = std::make_shared<pcp::AppInfoParcelable>(ret, db.GetAppHandle());
+ result_ = std::make_shared<pcp::AppInfoParcelable>(ret, db->GetAppHandle());
+ delete db;
return true;
}
class EXPORT_API GetAppinfoRequestHandler : public AbstractRequestHandler {
public:
- bool HandleRequest(unsigned char* data, int size,
- const std::string& locale) override;
+ explicit GetAppinfoRequestHandler(bool cache = false);
+ bool HandleRequest(unsigned char *data, int size,
+ const std::string &locale) override;
std::vector<uint8_t> ExtractResult() override;
private:
std::shared_ptr<pkgmgr_common::parcel::AppInfoParcelable> result_;
+ bool cache_;
};
} // namespace request_handler
#include "filter_parcelable.hh"
#include "parcelable_factory.hh"
+#include "pkg_get_cache_db_handler.hh"
#include "pkg_get_db_handler.hh"
-#include "utils/logging.hh"
-
#include "pkgmgrinfo_debug.h"
-
+#include "utils/logging.hh"
namespace pcp = pkgmgr_common::parcel;
namespace psd = pkgmgr_server::database;
namespace pkgmgr_server {
namespace request_handler {
+GetPkginfoRequestHandler::GetPkginfoRequestHandler(bool cache)
+ : cache_(cache) {
+}
+
bool GetPkginfoRequestHandler::HandleRequest(unsigned char* data, int size,
- const std::string& locale) {
+ const std::string& locale) {
auto abstract_parcel =
pcp::ParcelableFactory::GetInst().CreateParcel(data, size);
abstract_parcel->GetType() != pcp::ParcelableType::Filter) {
LOG(ERROR) << "Invalid parcel or type";
result_ = std::make_shared<pcp::PkgInfoParcelable>(
- PMINFO_R_ERROR, std::vector<package_x*>{});
+ PMINFO_R_ERROR, std::vector<std::shared_ptr<package_x>>{});
return false;
}
if (parcel == nullptr) {
LOG(ERROR) << "Parcel is empty";
result_ = std::make_shared<pcp::PkgInfoParcelable>(
- PMINFO_R_ERROR, std::vector<package_x*>{});
+ PMINFO_R_ERROR, std::vector<std::shared_ptr<package_x>>{});
return false;
}
- psd::PkgGetDBHandler db(parcel->GetUid(), GetPID());
- db.SetLocale(locale);
- db.SetFilter(const_cast<pkgmgrinfo_filter_x*>(parcel->GetFilter()));
- int ret = db.Execute();
+ psd::PkgGetDBHandler* db;
+ if (cache_)
+ db = new psd::PkgGetCacheDBHandler(parcel->GetUid(), GetPID());
+ else
+ db = new psd::PkgGetDBHandler(parcel->GetUid(), GetPID());
+
+ db->SetLocale(locale);
+ db->SetFilter(const_cast<pkgmgrinfo_filter_x*>(parcel->GetFilter()));
+ int ret = db->Execute();
- result_ = std::make_shared<pcp::PkgInfoParcelable>(ret, db.GetPkgHandle());
+ result_ = std::make_shared<pcp::PkgInfoParcelable>(ret, db->GetPkgHandle());
+ delete db;
return true;
}
class EXPORT_API GetPkginfoRequestHandler : public AbstractRequestHandler {
public:
+ explicit GetPkginfoRequestHandler(bool cache = false);
bool HandleRequest(unsigned char* data, int size,
const std::string& locale) override;
private:
std::shared_ptr<pkgmgr_common::parcel::PkgInfoParcelable> result_;
+ bool cache_;
};
} // namespace request_handler
int ret = PM_PARSER_R_ERROR;
for (auto& i : parcel->GetPkgInfo()) {
- db.SetPkgInfo(i);
+ db.SetPkgInfo(i.get());
ret = db.Execute();
if (ret != PM_PARSER_R_OK) {
LOG(ERROR) << "Failed to set pkginfo";
}
}
+ for (auto& i : parcel->GetPkgInfo())
+ pkgmgrinfo_basic_free_package(i.get());
+
result_ = std::make_shared<pcp::ResultParcelable>(
ret, std::vector<pcp::StrArgs>{});
if (val)
*str = strdup(val);
}
+
+void _save_column_bool(sqlite3_stmt *stmt, int idx, bool *bool_value)
+{
+ const char *val;
+
+ val = (const char *)sqlite3_column_text(stmt, idx);
+ if (!val)
+ return;
+
+ if (strcasecmp(val, "true") == 0)
+ *bool_value = true;
+ else if (strcasecmp(val, "false") == 0)
+ *bool_value = false;
+}
std::unique_ptr<request_handler::AbstractRequestHandler>
handler[pkgmgr_common::ReqType::MAX];
handler[pkgmgr_common::ReqType::GET_PKG_INFO].reset(
- new request_handler::GetPkginfoRequestHandler());
+ new request_handler::GetPkginfoRequestHandler(true));
handler[pkgmgr_common::ReqType::GET_APP_INFO].reset(
- new request_handler::GetAppinfoRequestHandler());
+ new request_handler::GetAppinfoRequestHandler(true));
handler[pkgmgr_common::ReqType::SET_PKG_INFO].reset(
new request_handler::SetPkginfoRequestHandler());
handler[pkgmgr_common::ReqType::SET_CERT_INFO].reset(
database::DBHandleProvider::
GetInst(getuid()).UnsetMemoryMode(getpid());
+ database::DBHandleProvider::
+ GetInst(getuid()).TrimCache();
+
return false;
}
}
bool IsEqualApplicationsStructure(
- const std::vector<application_x*>& applicationsA,
- const std::vector<application_x*>& applicationsB) {
+ const std::vector<std::shared_ptr<application_x>>& applicationsA,
+ const std::vector<std::shared_ptr<application_x>>& applicationsB) {
for (unsigned int i = 0; i < applicationsA.size(); ++i) {
- if (!IsEqualApplication(applicationsA[i], applicationsB[i]))
+ if (!IsEqualApplication(applicationsA[i].get(), applicationsB[i].get()))
return false;
- if (!IsEqualApplicationExtraInfo(applicationsA[i], applicationsB[i]))
+ if (!IsEqualApplicationExtraInfo(applicationsA[i].get(),
+ applicationsB[i].get()))
return false;
}
return true;
}
-bool IsEqualApplicationsInfo(const std::vector<application_x*>& applicationsA,
- const std::vector<application_x*>& applicationsB) {
+bool IsEqualApplicationsInfo(
+ const std::vector<std::shared_ptr<application_x>>& applicationsA,
+ const std::vector<std::shared_ptr<application_x>>& applicationsB) {
for (unsigned int i = 0; i < applicationsA.size(); ++i) {
- if (!IsEqualApplication(applicationsA[i], applicationsB[i]))
+ if (!IsEqualApplication(applicationsA[i].get(), applicationsB[i].get()))
return false;
}
return true;
}
-bool IsEqualPackagesStructure(const std::vector<package_x*>& packagesA,
- const std::vector<package_x*>&packagesB) {
+bool IsEqualPackagesStructure(
+ const std::vector<std::shared_ptr<package_x>>& packagesA,
+ const std::vector<std::shared_ptr<package_x>>& packagesB) {
if (packagesA.size() != packagesB.size())
return false;
for (unsigned int i = 0; i < packagesA.size(); ++i) {
- if (!IsEqualPackage(packagesA[i], packagesB[i]))
+ if (!IsEqualPackage(packagesA[i].get(), packagesB[i].get()))
return false;
- if (!IsEqualPackageExtraInfo(packagesA[i], packagesB[i]))
+ if (!IsEqualPackageExtraInfo(packagesA[i].get(), packagesB[i].get()))
return false;
}
return true;
}
-bool IsEqualPackagesInfo(const std::vector<package_x*>& packagesA,
- const std::vector<package_x*>&packagesB) {
+bool IsEqualPackagesInfo(
+ const std::vector<std::shared_ptr<package_x>>& packagesA,
+ const std::vector<std::shared_ptr<package_x>>& packagesB) {
if (packagesA.size() != packagesB.size())
return false;
for (unsigned int i = 0; i < packagesA.size(); ++i) {
- if (!IsEqualPackage(packagesA[i], packagesB[i]))
+ if (!IsEqualPackage(packagesA[i].get(), packagesB[i].get()))
return false;
}
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
#include <string>
#include <vector>
+#include <memory>
#include "pkgmgrinfo_basic.h"
#include "pkgmgrinfo_private.h"
application_x *GetTestApplication(std::string appid);
-bool IsEqualApplicationsStructure(const std::vector<application_x*>& applicationsA,
- const std::vector<application_x*>& applicationsB);
+bool IsEqualApplicationsStructure(const std::vector<std::shared_ptr<application_x>>& applicationsA,
+ const std::vector<std::shared_ptr<application_x>>& applicationsB);
-bool IsEqualApplicationsInfo(const std::vector<application_x*>& applicationsA,
- const std::vector<application_x*>& applicationsB);
+bool IsEqualApplicationsInfo(const std::vector<std::shared_ptr<application_x>>& applicationsA,
+ const std::vector<std::shared_ptr<application_x>>& applicationsB);
package_x *GetTestPackage(std::string pkgid);
package_x* GetUpdatedTestPackage(std::string pkgid);
-bool IsEqualPackagesStructure(const std::vector<package_x*>&packagesA,
- const std::vector<package_x*>&packagesB);
+bool IsEqualPackagesStructure(const std::vector<std::shared_ptr<package_x>>& packagesA,
+ const std::vector<std::shared_ptr<package_x>>&packagesB);
-bool IsEqualPackagesInfo(const std::vector<package_x*>&packagesA,
- const std::vector<package_x*>&packagesB);
+bool IsEqualPackagesInfo(const std::vector<std::shared_ptr<package_x>>& packagesA,
+ const std::vector<std::shared_ptr<package_x>>& packagesB);
pkgmgrinfo_filter_x *GetTestFilter();
TEST_F(ParcelTest, AppInfoParcelable) {
tizen_base::Parcel parcel;
- std::vector<application_x *> origin_applications;
+ std::vector<std::shared_ptr<application_x>> origin_applications;
origin_applications.emplace_back(GetTestApplication("test_appid1"));
origin_applications.emplace_back(GetTestApplication("test_appid2"));
TEST_F(ParcelTest, PkgInfoParcelable) {
tizen_base::Parcel parcel;
- std::vector<package_x *> origin_packages;
+ std::vector<std::shared_ptr<package_x>> origin_packages;
origin_packages.emplace_back(GetTestPackage("test_pkgid1"));
origin_packages.emplace_back(GetTestPackage("test_pkgid2"));
ASSERT_EQ(lpkginfo_list.size(), 1);
auto test_pkginfo = GetTestPackage(pkgid);
- std::vector<package_x*> rpkginfo_list;
+ std::vector<std::shared_ptr<package_x>> rpkginfo_list;
rpkginfo_list.emplace_back(test_pkginfo);
ASSERT_EQ(IsEqualPackagesInfo(lpkginfo_list, rpkginfo_list), true);
ASSERT_EQ(lappinfo_list.size(), 1);
auto test_appinfo = GetTestApplication(appid);
- std::vector<application_x*> rappinfo_list;
+ std::vector<std::shared_ptr<application_x>> rappinfo_list;
rappinfo_list.emplace_back(test_appinfo);
ASSERT_EQ(IsEqualApplicationsInfo(lappinfo_list, rappinfo_list), true);