#include <sys/types.h>
+#include <sqlite3.h>
+#include <glib.h>
+
+#include <parcel.hh>
+
#include <map>
#include <string>
-
-#include "sqlite3.h"
-#include "glib.h"
+#include <vector>
#include "pkgmgr_parser.h"
#include "pkgmgrinfo_private.h"
-#include "logging.hh"
+#include "client/pkginfo_client.hh"
#include "common/database/abstract_db_handler.hh"
#include "common/database/pkg_set_db_handler.hh"
#include "common/parcel/appinfo_parcelable.hh"
#include "common/parcel/pkginfo_parcelable.hh"
#include "common/parcel/query_parcelable.hh"
#include "common/parcel/result_parcelable.hh"
+#include "logging.hh"
-#include "client/pkginfo_client.hh"
-
-#include <parcel.hh>
#ifdef LOG_TAG
#undef LOG_TAG
#endif
#define EXPORT_API __attribute__((visibility("default")))
+namespace pcp = pkgmgr_common::parcel;
+namespace pcd = pkgmgr_common::database;
+
extern "C" EXPORT_API int _pkginfo_get_packages(uid_t uid,
- pkgmgrinfo_filter_x *filter, int flag, GHashTable *packages) {
- std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcelable(
- new pkgmgr_common::parcel::FilterParcelable(uid,
- static_cast<pkgmgrinfo_filter_x*>(filter), flag, false));
-
- pkgmgr_client::PkgInfoClient client(parcelable, uid,
- pkgmgr_common::ReqType::GET_PKG_INFO);
- if (!client.SendRequest())
- return PMINFO_R_ERROR;
+ pkgmgrinfo_filter_x* filter, int flag, GHashTable* packages) {
+ std::shared_ptr<pcp::AbstractParcelable> parcelable(
+ new pcp::FilterParcelable(uid,
+ static_cast<pkgmgrinfo_filter_x*>(filter), flag, false));
+
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
+ pkgmgr_common::ReqType::GET_PKG_INFO);
+ if (!client.SendRequest())
+ return PMINFO_R_ERROR;
+
+ auto ptr = client.GetResultParcel();
+ if (ptr == nullptr) {
+ LOG(ERROR) << "Fail to get return parcelable";
+ return PMINFO_R_ERROR;
+ }
+
+ if (ptr->GetRequestResult() != PMINFO_R_OK) {
+ LOG(ERROR) << "Request fail";
+ return ptr->GetRequestResult();
+ }
+
+ if (ptr->GetType() != pcp::ParcelableType::PkgInfo) {
+ LOG(ERROR) << "Invalid parcelable type";
+ return PMINFO_R_ERROR;
+ }
- auto ptr = client.GetResultParcel();
- if (ptr == nullptr) {
- LOG(ERROR) << "Fail to get return parcelable";
- return PMINFO_R_ERROR;
- }
-
- if (ptr->GetRequestResult() != PMINFO_R_OK) {
- LOG(ERROR) << "Request fail";
- return ptr->GetRequestResult();
- }
-
- if (ptr->GetType() != pkgmgr_common::parcel::ParcelableType::PkgInfo) {
- LOG(ERROR) << "Invalid parcelable type";
- return PMINFO_R_ERROR;
- }
-
- std::shared_ptr<pkgmgr_common::parcel::PkgInfoParcelable> return_parcel(
- std::static_pointer_cast<pkgmgr_common::parcel::PkgInfoParcelable>(
- ptr));
-
- auto result_list = return_parcel->ExtractPkgInfo();
- // TODO: check noentry error has returned if size of result_list is 0
- for (auto& pkginfo : result_list)
- g_hash_table_insert(packages, (gpointer)pkginfo->package,
- (gpointer)pkginfo);
-
- return PMINFO_R_OK;
+ std::shared_ptr<pcp::PkgInfoParcelable> return_parcel(
+ std::static_pointer_cast<pcp::PkgInfoParcelable>(
+ ptr));
+
+ auto result_list = return_parcel->ExtractPkgInfo();
+ // TODO: check noentry error has returned if size of result_list is 0
+ for (auto &pkginfo : result_list)
+ g_hash_table_insert(packages, (gpointer)pkginfo->package,
+ (gpointer)pkginfo);
+
+ return PMINFO_R_OK;
}
extern "C" EXPORT_API int _pkginfo_get_depends_on(uid_t uid,
- const char *pkgid, GList **dependencies) {
- std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcelable(
- new pkgmgr_common::parcel::DepInfoParcelable(std::string(pkgid)));
+ const char* pkgid, GList** dependencies) {
+ std::shared_ptr<pcp::AbstractParcelable> parcelable(
+ new pcp::DepInfoParcelable(std::string(pkgid)));
- pkgmgr_client::PkgInfoClient client(parcelable, uid,
- pkgmgr_common::ReqType::GET_PKG_DEP_INFO);
- if (!client.SendRequest())
- return PMINFO_R_ERROR;
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
+ pkgmgr_common::ReqType::GET_PKG_DEP_INFO);
+ if (!client.SendRequest())
+ return PMINFO_R_ERROR;
- auto ptr = client.GetResultParcel();
- if (ptr == nullptr) {
- LOG(ERROR) << "Fail to get return parcelable";
- return PMINFO_R_ERROR;
- }
-
- if (ptr->GetRequestResult() != PMINFO_R_OK) {
- LOG(ERROR) << "Request fail";
- return ptr->GetRequestResult();
- }
-
- if (ptr->GetType() != pkgmgr_common::parcel::ParcelableType::DepInfo) {
- LOG(ERROR) << "Invalid parcelable type";
- return PMINFO_R_ERROR;
- }
-
- std::shared_ptr<pkgmgr_common::parcel::DepInfoParcelable> return_parcel(
- std::static_pointer_cast<pkgmgr_common::parcel::DepInfoParcelable>(
- ptr));
-
- auto dependency_list = return_parcel->ExtractDependencyInfo();
- for (auto& dependency : dependency_list)
- *dependencies = g_list_prepend(*dependencies, dependency);
- return PMINFO_R_OK;
+ auto ptr = client.GetResultParcel();
+ if (ptr == nullptr) {
+ LOG(ERROR) << "Fail to get return parcelable";
+ return PMINFO_R_ERROR;
+ }
+
+ if (ptr->GetRequestResult() != PMINFO_R_OK) {
+ LOG(ERROR) << "Request fail";
+ return ptr->GetRequestResult();
+ }
+
+ if (ptr->GetType() != pcp::ParcelableType::DepInfo) {
+ LOG(ERROR) << "Invalid parcelable type";
+ return PMINFO_R_ERROR;
+ }
+
+ std::shared_ptr<pcp::DepInfoParcelable> return_parcel(
+ std::static_pointer_cast<pcp::DepInfoParcelable>(ptr));
+
+ auto dependency_list = return_parcel->ExtractDependencyInfo();
+ for (auto &dependency : dependency_list)
+ *dependencies = g_list_prepend(*dependencies, dependency);
+ return PMINFO_R_OK;
}
// TODO: Need to add target db uid to identify which database to be searched
extern "C" EXPORT_API int _appinfo_get_applications(uid_t db_uid, uid_t uid,
- pkgmgrinfo_filter_x *filter, int flag, GHashTable *packages) {
- std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcelable(
- new pkgmgr_common::parcel::FilterParcelable(uid,
- static_cast<pkgmgrinfo_filter_x*>(filter), flag, false));
+ pkgmgrinfo_filter_x* filter, int flag, GHashTable* packages) {
+ std::shared_ptr<pcp::AbstractParcelable> parcelable(
+ new pcp::FilterParcelable(uid,
+ static_cast<pkgmgrinfo_filter_x*>(filter), flag, false));
+
+ pkgmgr_client::PkgInfoClient client(
+ parcelable, uid, pkgmgr_common::ReqType::GET_APP_INFO);
+ if (!client.SendRequest())
+ return PMINFO_R_ERROR;
- pkgmgr_client::PkgInfoClient client(parcelable, uid, pkgmgr_common::ReqType::GET_APP_INFO);
- if (!client.SendRequest())
- return PMINFO_R_ERROR;
+ auto ptr = client.GetResultParcel();
+ if (ptr == nullptr) {
+ LOG(ERROR) << "Fail to get return parcelable";
+ return PMINFO_R_ERROR;
+ }
+
+ int ret = ptr->GetRequestResult();
+ if (ret != PMINFO_R_OK) {
+ if (ret == PMINFO_R_ENOENT)
+ LOG(DEBUG) << "No such application";
+ else
+ LOG(ERROR) << "Request fail";
+ return ret;
+ }
- auto ptr = client.GetResultParcel();
- if (ptr == nullptr) {
- LOG(ERROR) << "Fail to get return parcelable";
- return PMINFO_R_ERROR;
- }
-
- int ret = ptr->GetRequestResult();
- if (ret != PMINFO_R_OK) {
- if (ret == PMINFO_R_ENOENT) {
- LOG(DEBUG) << "No such application";
- } else {
- LOG(ERROR) << "Request fail";
- }
- return ret;
- }
-
- if (ptr->GetType() != pkgmgr_common::parcel::ParcelableType::AppInfo) {
- LOG(ERROR) << "Invalid parcelable type";
- return PMINFO_R_ERROR;
- }
-
- std::shared_ptr<pkgmgr_common::parcel::AppInfoParcelable> return_parcel(
- std::static_pointer_cast<pkgmgr_common::parcel::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);
-
- return PMINFO_R_OK;
+ if (ptr->GetType() != pcp::ParcelableType::AppInfo) {
+ LOG(ERROR) << "Invalid parcelable type";
+ return PMINFO_R_ERROR;
+ }
+
+ 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);
+
+ return PMINFO_R_OK;
}
-extern "C" EXPORT_API char *_appinfo_get_localed_label(
- const char *appid, const char *locale, uid_t uid) {
- char *query = nullptr;
- query = sqlite3_mprintf(
- "SELECT COALESCE((SELECT app_label FROM package_app_localized_info "
- "WHERE app_id=%Q AND app_locale=%Q),"
- "(SELECT app_label FROM package_app_localized_info WHERE "
- "app_id=%Q AND app_locale='No Locale'))", appid, locale, appid);
- if (query == nullptr) {
- LOG(ERROR) << "Out of memory";
- return nullptr;
- }
-
- std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcelable(
- new pkgmgr_common::parcel::QueryParcelable(uid, std::string(query),
- pkgmgr_common::database::AbstractDBHandler::DBType::DB_TYPE_FILE_PKGDB,
- pkgmgr_common::database::AbstractDBHandler::OperationType::OPERATION_TYPE_READ));
- sqlite3_free(query);
-
- pkgmgr_client::PkgInfoClient client(parcelable, uid,
- pkgmgr_common::ReqType::QUERY);
- if (!client.SendRequest()) {
- return nullptr;
- }
-
- auto ptr = client.GetResultParcel();
- if (ptr == nullptr) {
- LOG(ERROR) << "Fail to get return parcelable";
- return nullptr;
- }
-
- if (ptr->GetRequestResult() != PMINFO_R_OK) {
- LOG(ERROR) << "Request fail";
- return nullptr;
- }
-
- if (ptr->GetType() != pkgmgr_common::parcel::ParcelableType::Result) {
- LOG(ERROR) << "Invalid parcelable type";
- return nullptr;
- }
-
- std::shared_ptr<pkgmgr_common::parcel::ResultParcelable> return_parcel(
- std::static_pointer_cast<pkgmgr_common::parcel::ResultParcelable>(
- ptr));
-
- // result_list is vector of string vector
- char *label = nullptr;
- auto result_list = return_parcel->GetResult();
- for (auto result : result_list) {
- // result is string vector
- // it only has one string or not.
- if (result.front().empty() || result.front().length() == 0)
- return nullptr;
- label = strdup(result.front().c_str());
- if (label == nullptr) {
- LOG(ERROR) << "Out of memory";
- return nullptr;
- }
- return label;
- }
-
- return label;
+extern "C" EXPORT_API char* _appinfo_get_localed_label(
+ const char* appid, const char* locale, uid_t uid) {
+ char* query = nullptr;
+ query = sqlite3_mprintf(
+ "SELECT COALESCE((SELECT app_label FROM package_app_localized_info "
+ "WHERE app_id=%Q AND app_locale=%Q),"
+ "(SELECT app_label FROM package_app_localized_info WHERE "
+ "app_id=%Q AND app_locale='No Locale'))",
+ appid, locale, appid);
+ if (query == nullptr) {
+ LOG(ERROR) << "Out of memory";
+ return nullptr;
+ }
+
+ std::shared_ptr<pcp::AbstractParcelable> parcelable(
+ new pcp::QueryParcelable(uid, std::string(query),
+ pcd::AbstractDBHandler::DBType::DB_TYPE_FILE_PKGDB,
+ pcd::AbstractDBHandler::OperationType::OPERATION_TYPE_READ));
+ sqlite3_free(query);
+
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
+ pkgmgr_common::ReqType::QUERY);
+ if (!client.SendRequest())
+ return nullptr;
+ auto ptr = client.GetResultParcel();
+ if (ptr == nullptr) {
+ LOG(ERROR) << "Fail to get return parcelable";
+ return nullptr;
+ }
+
+ if (ptr->GetRequestResult() != PMINFO_R_OK) {
+ LOG(ERROR) << "Request fail";
+ return nullptr;
+ }
+
+ if (ptr->GetType() != pcp::ParcelableType::Result) {
+ LOG(ERROR) << "Invalid parcelable type";
+ return nullptr;
+ }
+
+ std::shared_ptr<pcp::ResultParcelable> return_parcel(
+ std::static_pointer_cast<pcp::ResultParcelable>(ptr));
+
+ // result_list is vector of string vector
+ char* label = nullptr;
+ auto result_list = return_parcel->GetResult();
+ for (auto result : result_list) {
+ // result is string vector
+ // it only has one string or not.
+ if (result.front().empty() || result.front().length() == 0)
+ return nullptr;
+ label = strdup(result.front().c_str());
+ if (label == nullptr) {
+ LOG(ERROR) << "Out of memory";
+ return nullptr;
+ }
+ return label;
+ }
+
+ return label;
}
extern "C" EXPORT_API int _appinfo_get_datacontrol_info(
- const char *providerid, const char *type, uid_t uid,
- char **appid, char **access) {
- char *query = nullptr;
- query = sqlite3_mprintf("SELECT app_id, access FROM "
- "package_app_data_control WHERE "
- "providerid=%Q AND type=%Q", providerid, type);
- if (query == nullptr) {
- LOG(ERROR) << "Out of memory";
- return PMINFO_R_ERROR;
- }
-
- std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcelable(
- new pkgmgr_common::parcel::QueryParcelable(uid, std::string(query),
- pkgmgr_common::database::AbstractDBHandler::DBType::DB_TYPE_FILE_PKGDB,
- pkgmgr_common::database::AbstractDBHandler::OperationType::OPERATION_TYPE_READ));
- sqlite3_free(query);
-
- pkgmgr_client::PkgInfoClient client(parcelable, uid,
- pkgmgr_common::ReqType::QUERY);
- if (!client.SendRequest()) {
- return PMINFO_R_ERROR;
- }
-
- auto ptr = client.GetResultParcel();
- if (ptr == nullptr) {
- LOG(ERROR) << "Fail to get return parcelable";
- return PMINFO_R_ERROR;
- }
-
- if (ptr->GetRequestResult() != PMINFO_R_OK) {
- LOG(ERROR) << "Request fail";
- return ptr->GetRequestResult();
- }
-
- if (ptr->GetType() != pkgmgr_common::parcel::ParcelableType::Result) {
- LOG(ERROR) << "Invalid parcelable type";
- return PMINFO_R_ERROR;
- }
-
- std::shared_ptr<pkgmgr_common::parcel::ResultParcelable> return_parcel(
- std::static_pointer_cast<pkgmgr_common::parcel::ResultParcelable>(
- ptr));
-
- // result_list is vector of string vector
- auto result_list = return_parcel->GetResult();
- if (result_list.size() == 0)
- return PMINFO_R_ENOENT;
- for (auto result : result_list) {
- if (result.size() != 2)
- return PMINFO_R_ERROR;
- if (result.front().empty() || result.front().size() == 0 ||
- result.back().empty() || result.back().size() == 0)
- return PMINFO_R_ERROR;
- *appid = strdup(result.front().c_str());
- *access = strdup(result.back().c_str());
- if (*appid == nullptr || *access == nullptr) {
- LOG(ERROR) << "Out of memory";
- return PMINFO_R_ERROR;
- }
- }
-
- return PMINFO_R_OK;
+ const char* providerid, const char* type, uid_t uid,
+ char** appid, char** access) {
+ char* query = nullptr;
+ query = sqlite3_mprintf("SELECT app_id, access FROM "
+ "package_app_data_control WHERE "
+ "providerid=%Q AND type=%Q",
+ providerid, type);
+ if (query == nullptr) {
+ LOG(ERROR) << "Out of memory";
+ return PMINFO_R_ERROR;
+ }
+
+ std::shared_ptr<pcp::AbstractParcelable> parcelable(
+ new pcp::QueryParcelable(uid, std::string(query),
+ pcd::AbstractDBHandler::DBType::DB_TYPE_FILE_PKGDB,
+ pcd::AbstractDBHandler::OperationType::OPERATION_TYPE_READ));
+ sqlite3_free(query);
+
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
+ pkgmgr_common::ReqType::QUERY);
+ if (!client.SendRequest())
+ return PMINFO_R_ERROR;
+
+ auto ptr = client.GetResultParcel();
+ if (ptr == nullptr) {
+ LOG(ERROR) << "Fail to get return parcelable";
+ return PMINFO_R_ERROR;
+ }
+
+ if (ptr->GetRequestResult() != PMINFO_R_OK) {
+ LOG(ERROR) << "Request fail";
+ return ptr->GetRequestResult();
+ }
+
+ if (ptr->GetType() != pcp::ParcelableType::Result) {
+ LOG(ERROR) << "Invalid parcelable type";
+ return PMINFO_R_ERROR;
+ }
+
+ std::shared_ptr<pcp::ResultParcelable> return_parcel(
+ std::static_pointer_cast<pcp::ResultParcelable>(ptr));
+
+ // result_list is vector of string vector
+ auto result_list = return_parcel->GetResult();
+ if (result_list.size() == 0)
+ return PMINFO_R_ENOENT;
+ for (auto result : result_list) {
+ if (result.size() != 2)
+ return PMINFO_R_ERROR;
+ if (result.front().empty() || result.front().size() == 0 ||
+ result.back().empty() || result.back().size() == 0)
+ return PMINFO_R_ERROR;
+ *appid = strdup(result.front().c_str());
+ *access = strdup(result.back().c_str());
+ if (*appid == nullptr || *access == nullptr) {
+ LOG(ERROR) << "Out of memory";
+ return PMINFO_R_ERROR;
+ }
+ }
+
+ return PMINFO_R_OK;
}
extern "C" EXPORT_API int _appinfo_get_datacontrol_appid(
- const char *providerid, uid_t uid, char **appid) {
- char *query = nullptr;
-
- query = sqlite3_mprintf("SELECT app_id FROM package_app_data_control "
- "WHERE providerid=%Q", providerid);
- if (query == nullptr) {
- LOGE("Out of memory");
- return PMINFO_R_ERROR;
- }
- std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcelable(
- new pkgmgr_common::parcel::QueryParcelable(uid, std::string(query),
- pkgmgr_common::database::AbstractDBHandler::DBType::DB_TYPE_FILE_PKGDB,
- pkgmgr_common::database::AbstractDBHandler::OperationType::OPERATION_TYPE_READ));
- sqlite3_free(query);
-
- pkgmgr_client::PkgInfoClient client(parcelable, uid,
- pkgmgr_common::ReqType::QUERY);
- if (!client.SendRequest()) {
- return PMINFO_R_ERROR;
- }
-
- auto ptr = client.GetResultParcel();
- if (ptr == nullptr) {
- LOG(ERROR) << "Fail to get return parcelable";
- return PMINFO_R_ERROR;
- }
-
- if (ptr->GetRequestResult() != PMINFO_R_OK) {
- LOG(ERROR) << "Request fail";
- return ptr->GetRequestResult();
- }
-
- if (ptr->GetType() != pkgmgr_common::parcel::ParcelableType::Result) {
- LOG(ERROR) << "Invalid parcelable type";
- return PMINFO_R_ERROR;
- }
-
- std::shared_ptr<pkgmgr_common::parcel::ResultParcelable> return_parcel(
- std::static_pointer_cast<pkgmgr_common::parcel::ResultParcelable>(
- ptr));
-
- // result_list is vector of string vector
- auto result_list = return_parcel->GetResult();
- if (result_list.size() == 0)
- return PMINFO_R_ENOENT;
- for (auto result : result_list) {
- if (result.size() != 1)
- return PMINFO_R_ERROR;
- if (result.front().empty() || result.front().size() == 0)
- return PMINFO_R_ERROR;
- *appid = strdup(result.front().c_str());
- if (*appid == nullptr) {
- LOG(ERROR) << "Out of memory";
- return PMINFO_R_ERROR;
- }
- }
-
- return PMINFO_R_OK;
+ const char* providerid, uid_t uid, char** appid) {
+ char* query = nullptr;
+
+ query = sqlite3_mprintf("SELECT app_id FROM package_app_data_control "
+ "WHERE providerid=%Q",
+ providerid);
+ if (query == nullptr) {
+ LOGE("Out of memory");
+ return PMINFO_R_ERROR;
+ }
+ std::shared_ptr<pcp::AbstractParcelable> parcelable(
+ new pcp::QueryParcelable(uid, std::string(query),
+ pcd::AbstractDBHandler::DBType::DB_TYPE_FILE_PKGDB,
+ pcd::AbstractDBHandler::OperationType::OPERATION_TYPE_READ));
+ sqlite3_free(query);
+
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
+ pkgmgr_common::ReqType::QUERY);
+ if (!client.SendRequest())
+ return PMINFO_R_ERROR;
+
+ auto ptr = client.GetResultParcel();
+ if (ptr == nullptr) {
+ LOG(ERROR) << "Fail to get return parcelable";
+ return PMINFO_R_ERROR;
+ }
+
+ if (ptr->GetRequestResult() != PMINFO_R_OK) {
+ LOG(ERROR) << "Request fail";
+ return ptr->GetRequestResult();
+ }
+
+ if (ptr->GetType() != pcp::ParcelableType::Result) {
+ LOG(ERROR) << "Invalid parcelable type";
+ return PMINFO_R_ERROR;
+ }
+
+ std::shared_ptr<pcp::ResultParcelable> return_parcel(
+ std::static_pointer_cast<pcp::ResultParcelable>(ptr));
+
+ // result_list is vector of string vector
+ auto result_list = return_parcel->GetResult();
+ if (result_list.size() == 0)
+ return PMINFO_R_ENOENT;
+ for (auto result : result_list) {
+ if (result.size() != 1)
+ return PMINFO_R_ERROR;
+ if (result.front().empty() || result.front().size() == 0)
+ return PMINFO_R_ERROR;
+ *appid = strdup(result.front().c_str());
+ if (*appid == nullptr) {
+ LOG(ERROR) << "Out of memory";
+ return PMINFO_R_ERROR;
+ }
+ }
+
+ return PMINFO_R_OK;
}
extern "C" EXPORT_API int _appinfo_get_datacontrol_trusted_info(
- const char *providerid, const char *type, uid_t uid,
- char **appid, char **trusted) {
- char *query = nullptr;
- query = sqlite3_mprintf(
- "SELECT app_id, trusted FROM package_app_data_control "
- "WHERE providerid=%Q AND type=%Q", providerid, type);
- if (query == nullptr) {
- LOGE("Out of memory");
- return PMINFO_R_ERROR;
- }
-
- std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcelable(
- new pkgmgr_common::parcel::QueryParcelable(uid, std::string(query),
- pkgmgr_common::database::AbstractDBHandler::DBType::DB_TYPE_FILE_PKGDB,
- pkgmgr_common::database::AbstractDBHandler::OperationType::OPERATION_TYPE_READ));
- sqlite3_free(query);
-
- pkgmgr_client::PkgInfoClient client(parcelable, uid,
- pkgmgr_common::ReqType::QUERY);
- if (!client.SendRequest()) {
- return PMINFO_R_ERROR;
- }
-
- auto ptr = client.GetResultParcel();
- if (ptr == nullptr) {
- LOG(ERROR) << "Fail to get return parcelable";
- return PMINFO_R_ERROR;
- }
-
- if (ptr->GetRequestResult() != PMINFO_R_OK) {
- LOG(ERROR) << "Request fail";
- return ptr->GetRequestResult();
- }
-
- if (ptr->GetType() != pkgmgr_common::parcel::ParcelableType::Result) {
- LOG(ERROR) << "Invalid parcelable type";
- return PMINFO_R_ERROR;
- }
-
- std::shared_ptr<pkgmgr_common::parcel::ResultParcelable> return_parcel(
- std::static_pointer_cast<pkgmgr_common::parcel::ResultParcelable>(
- ptr));
-
- // result_list is vector of string vector
- auto result_list = return_parcel->GetResult();
- if (result_list.size() == 0)
- return PMINFO_R_ENOENT;
- for (auto result : result_list) {
- if (result.size() != 2)
- return PMINFO_R_ERROR;
- if (result.front().empty() || result.front().size() == 0 ||
- result.back().empty() || result.back().size() == 0)
- return PMINFO_R_ERROR;
- *appid = strdup(result.front().c_str());
- *trusted = strdup(result.back().c_str());
- if (*appid == nullptr || *trusted == nullptr) {
- LOG(ERROR) << "Out of memory";
- return PMINFO_R_ERROR;
- }
- }
-
- return PMINFO_R_OK;
+ const char* providerid, const char* type, uid_t uid,
+ char** appid, char** trusted) {
+ char* query = nullptr;
+ query = sqlite3_mprintf(
+ "SELECT app_id, trusted FROM package_app_data_control "
+ "WHERE providerid=%Q AND type=%Q",
+ providerid, type);
+ if (query == nullptr) {
+ LOGE("Out of memory");
+ return PMINFO_R_ERROR;
+ }
+
+ std::shared_ptr<pcp::AbstractParcelable> parcelable(
+ new pcp::QueryParcelable(uid, std::string(query),
+ pcd::AbstractDBHandler::DBType::DB_TYPE_FILE_PKGDB,
+ pcd::AbstractDBHandler::OperationType::OPERATION_TYPE_READ));
+ sqlite3_free(query);
+
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
+ pkgmgr_common::ReqType::QUERY);
+ if (!client.SendRequest())
+ return PMINFO_R_ERROR;
+
+ auto ptr = client.GetResultParcel();
+ if (ptr == nullptr) {
+ LOG(ERROR) << "Fail to get return parcelable";
+ return PMINFO_R_ERROR;
+ }
+
+ if (ptr->GetRequestResult() != PMINFO_R_OK) {
+ LOG(ERROR) << "Request fail";
+ return ptr->GetRequestResult();
+ }
+
+ if (ptr->GetType() != pcp::ParcelableType::Result) {
+ LOG(ERROR) << "Invalid parcelable type";
+ return PMINFO_R_ERROR;
+ }
+
+ std::shared_ptr<pcp::ResultParcelable> return_parcel(
+ std::static_pointer_cast<pcp::ResultParcelable>(ptr));
+
+ // result_list is vector of string vector
+ auto result_list = return_parcel->GetResult();
+ if (result_list.size() == 0)
+ return PMINFO_R_ENOENT;
+ for (auto result : result_list) {
+ if (result.size() != 2)
+ return PMINFO_R_ERROR;
+ if (result.front().empty() || result.front().size() == 0 ||
+ result.back().empty() || result.back().size() == 0)
+ return PMINFO_R_ERROR;
+ *appid = strdup(result.front().c_str());
+ *trusted = strdup(result.back().c_str());
+ if (*appid == nullptr || *trusted == nullptr) {
+ LOG(ERROR) << "Out of memory";
+ return PMINFO_R_ERROR;
+ }
+ }
+
+ return PMINFO_R_OK;
}
extern "C" EXPORT_API int _appinfo_get_datacontrol_privileges(
- const char *providerid, const char *type, uid_t uid,
- GList **privileges) {
- char *query = nullptr;
- query = sqlite3_mprintf(
- "SELECT privilege FROM package_app_data_control_privilege "
- "WHERE providerid=%Q AND type=%Q", providerid, type);
- if (query == nullptr) {
- LOGE("Out of memory");
- return PMINFO_R_ERROR;
- }
-
- std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcelable(
- new pkgmgr_common::parcel::QueryParcelable(uid, std::string(query),
- pkgmgr_common::database::AbstractDBHandler::DBType::DB_TYPE_FILE_PKGDB,
- pkgmgr_common::database::AbstractDBHandler::OperationType::OPERATION_TYPE_READ));
- sqlite3_free(query);
-
- pkgmgr_client::PkgInfoClient client(parcelable, uid,
- pkgmgr_common::ReqType::QUERY);
- if (!client.SendRequest()) {
- return PMINFO_R_ERROR;
- }
-
- auto ptr = client.GetResultParcel();
- if (ptr == nullptr) {
- LOG(ERROR) << "Fail to get return parcelable";
- return PMINFO_R_ERROR;
- }
-
- if (ptr->GetRequestResult() != PMINFO_R_OK) {
- LOG(ERROR) << "Request fail";
- return ptr->GetRequestResult();
- }
-
- if (ptr->GetType() != pkgmgr_common::parcel::ParcelableType::Result) {
- LOG(ERROR) << "Invalid parcelable type";
- return PMINFO_R_ERROR;
- }
-
- std::shared_ptr<pkgmgr_common::parcel::ResultParcelable> return_parcel(
- std::static_pointer_cast<pkgmgr_common::parcel::ResultParcelable>(
- ptr));
-
- // result_list is vector of string vector
- auto result_list = return_parcel->GetResult();
- if (result_list.size() == 0)
- return PMINFO_R_ENOENT;
-
- for (auto result : result_list) {
- if (result.size() != 1)
- return PMINFO_R_ERROR;
- if (result.front().empty() || result.front().size() == 0)
- return PMINFO_R_ERROR;
- char *privilege = strdup(result.front().c_str());
- if (privilege == nullptr) {
- LOG(ERROR) << "Out of memory";
- return PMINFO_R_ERROR;
- }
- *privileges = g_list_append(*privileges, privilege);
- }
-
- return PMINFO_R_OK;
+ const char* providerid, const char* type, uid_t uid, GList** privileges) {
+ char* query = nullptr;
+ query = sqlite3_mprintf(
+ "SELECT privilege FROM package_app_data_control_privilege "
+ "WHERE providerid=%Q AND type=%Q",
+ providerid, type);
+ if (query == nullptr) {
+ LOGE("Out of memory");
+ return PMINFO_R_ERROR;
+ }
+
+ std::shared_ptr<pcp::AbstractParcelable> parcelable(
+ new pcp::QueryParcelable(uid, std::string(query),
+ pcd::AbstractDBHandler::DBType::DB_TYPE_FILE_PKGDB,
+ pcd::AbstractDBHandler::OperationType::OPERATION_TYPE_READ));
+ sqlite3_free(query);
+
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
+ pkgmgr_common::ReqType::QUERY);
+ if (!client.SendRequest())
+ return PMINFO_R_ERROR;
+
+ auto ptr = client.GetResultParcel();
+ if (ptr == nullptr) {
+ LOG(ERROR) << "Fail to get return parcelable";
+ return PMINFO_R_ERROR;
+ }
+
+ if (ptr->GetRequestResult() != PMINFO_R_OK) {
+ LOG(ERROR) << "Request fail";
+ return ptr->GetRequestResult();
+ }
+
+ if (ptr->GetType() != pcp::ParcelableType::Result) {
+ LOG(ERROR) << "Invalid parcelable type";
+ return PMINFO_R_ERROR;
+ }
+
+ std::shared_ptr<pcp::ResultParcelable> return_parcel(
+ std::static_pointer_cast<pcp::ResultParcelable>(ptr));
+
+ // result_list is vector of string vector
+ auto result_list = return_parcel->GetResult();
+ if (result_list.size() == 0)
+ return PMINFO_R_ENOENT;
+
+ for (auto result : result_list) {
+ if (result.size() != 1)
+ return PMINFO_R_ERROR;
+ if (result.front().empty() || result.front().size() == 0)
+ return PMINFO_R_ERROR;
+ char* privilege = strdup(result.front().c_str());
+ if (privilege == nullptr) {
+ LOG(ERROR) << "Out of memory";
+ return PMINFO_R_ERROR;
+ }
+ *privileges = g_list_append(*privileges, privilege);
+ }
+
+ return PMINFO_R_OK;
}
extern "C" EXPORT_API int _appinfo_get_appcontrol_privileges(
- const char *appid, const char *operation, uid_t uid, GList **privileges) {
- char *query = nullptr;
- query = sqlite3_mprintf(
- "SELECT app_control, privilege FROM package_app_app_control_privilege "
- "WHERE app_id=%Q", appid);
- if (query == nullptr) {
- LOG(ERROR) << "Out of memory";
- return PMINFO_R_ERROR;
- }
-
- std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcelable(
- new pkgmgr_common::parcel::QueryParcelable(uid, std::string(query),
- pkgmgr_common::database::AbstractDBHandler::DBType::DB_TYPE_FILE_PKGDB,
- pkgmgr_common::database::AbstractDBHandler::OperationType::OPERATION_TYPE_READ));
- sqlite3_free(query);
-
- pkgmgr_client::PkgInfoClient client(parcelable, uid,
- pkgmgr_common::ReqType::QUERY);
- if (!client.SendRequest()) {
- return PMINFO_R_ERROR;
- }
-
- auto ptr = client.GetResultParcel();
- if (ptr == nullptr) {
- LOG(ERROR) << "Fail to get return parcelable";
- return PMINFO_R_ERROR;
- }
-
- if (ptr->GetRequestResult() != PMINFO_R_OK) {
- LOG(ERROR) << "Request fail";
- return ptr->GetRequestResult();
- }
-
- if (ptr->GetType() != pkgmgr_common::parcel::ParcelableType::Result) {
- LOG(ERROR) << "Invalid parcelable type";
- return PMINFO_R_ERROR;
- }
-
- std::shared_ptr<pkgmgr_common::parcel::ResultParcelable> return_parcel(
- std::static_pointer_cast<pkgmgr_common::parcel::ResultParcelable>(
- ptr));
-
- // result_list is vector of string vector
- auto result_list = return_parcel->GetResult();
- if (result_list.size() == 0)
- return PMINFO_R_ENOENT;
-
- for (auto result : result_list) {
- if (result.size() != 2)
- return PMINFO_R_ERROR;
- if (result.front().empty() || result.front().size() == 0 ||
- result.back().empty() || result.back().size() == 0)
- return PMINFO_R_ERROR;
- std::string app_control = result.front();
- std::stringstream ss(app_control);
- std::string token;
- while (std::getline(ss, token, '|')) {
- if (token.compare(std::string(operation))) {
- char *privilege = strdup(result.back().c_str());
- if (privilege == nullptr) {
- LOG(ERROR) << "Out of memory";
- return PMINFO_R_ERROR;
- }
- *privileges = g_list_append(*privileges, privilege);
- }
- }
- }
- return PMINFO_R_OK;
+ const char* appid, const char* operation, uid_t uid, GList** privileges) {
+ char* query = nullptr;
+ query = sqlite3_mprintf(
+ "SELECT app_control, privilege FROM package_app_app_control_privilege "
+ "WHERE app_id=%Q", appid);
+ if (query == nullptr) {
+ LOG(ERROR) << "Out of memory";
+ return PMINFO_R_ERROR;
+ }
+
+ std::shared_ptr<pcp::AbstractParcelable> parcelable(
+ new pcp::QueryParcelable(uid, std::string(query),
+ pcd::AbstractDBHandler::DBType::DB_TYPE_FILE_PKGDB,
+ pcd::AbstractDBHandler::OperationType::OPERATION_TYPE_READ));
+ sqlite3_free(query);
+
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
+ pkgmgr_common::ReqType::QUERY);
+ if (!client.SendRequest())
+ return PMINFO_R_ERROR;
+
+ auto ptr = client.GetResultParcel();
+ if (ptr == nullptr) {
+ LOG(ERROR) << "Fail to get return parcelable";
+ return PMINFO_R_ERROR;
+ }
+
+ if (ptr->GetRequestResult() != PMINFO_R_OK) {
+ LOG(ERROR) << "Request fail";
+ return ptr->GetRequestResult();
+ }
+
+ if (ptr->GetType() != pcp::ParcelableType::Result) {
+ LOG(ERROR) << "Invalid parcelable type";
+ return PMINFO_R_ERROR;
+ }
+
+ std::shared_ptr<pcp::ResultParcelable> return_parcel(
+ std::static_pointer_cast<pcp::ResultParcelable>(ptr));
+
+ // result_list is vector of string vector
+ auto result_list = return_parcel->GetResult();
+ if (result_list.size() == 0)
+ return PMINFO_R_ENOENT;
+
+ for (auto result : result_list) {
+ if (result.size() != 2)
+ return PMINFO_R_ERROR;
+ if (result.front().empty() || result.front().size() == 0 ||
+ result.back().empty() || result.back().size() == 0)
+ return PMINFO_R_ERROR;
+ std::string app_control = result.front();
+ std::stringstream ss(app_control);
+ std::string token;
+ while (std::getline(ss, token, '|')) {
+ if (token.compare(std::string(operation))) {
+ char* privilege = strdup(result.back().c_str());
+ if (privilege == nullptr) {
+ LOG(ERROR) << "Out of memory";
+ return PMINFO_R_ERROR;
+ }
+ *privileges = g_list_append(*privileges, privilege);
+ }
+ }
+ }
+ return PMINFO_R_OK;
}
extern "C" EXPORT_API int _plugininfo_get_appids(
- const char *pkgid, const char *plugin_type,
- const char *plugin_name, GList **list) {
- if (!pkgid || !plugin_type || !plugin_name || !list) {
- LOG(ERROR) << "Invalid parameter";
- return PMINFO_R_EINVAL;
- }
-
- char *query = nullptr;
- query = sqlite3_mprintf(
- "SELECT appid FROM "
- "package_plugin_info WHERE pkgid=%Q AND "
- "plugin_type=%Q AND plugin_name=%Q",
+ const char* pkgid, const char* plugin_type,
+ const char* plugin_name, GList** list) {
+ if (!pkgid || !plugin_type || !plugin_name || !list) {
+ LOG(ERROR) << "Invalid parameter";
+ return PMINFO_R_EINVAL;
+ }
+
+ char* query = nullptr;
+ query = sqlite3_mprintf(
+ "SELECT appid FROM "
+ "package_plugin_info WHERE pkgid=%Q AND "
+ "plugin_type=%Q AND plugin_name=%Q",
pkgid, plugin_type, plugin_name);
- if (query == nullptr) {
- LOG(ERROR) << "Out of memory";
- return PMINFO_R_ERROR;
- }
-
- std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcelable(
- new pkgmgr_common::parcel::QueryParcelable(_getuid(), std::string(query),
- pkgmgr_common::database::AbstractDBHandler::DBType::DB_TYPE_FILE_PKGDB,
- pkgmgr_common::database::AbstractDBHandler::OperationType::OPERATION_TYPE_READ));
- sqlite3_free(query);
-
- pkgmgr_client::PkgInfoClient client(parcelable, _getuid(),
- pkgmgr_common::ReqType::QUERY);
- if (!client.SendRequest()) {
- return PMINFO_R_ERROR;
- }
-
- auto ptr = client.GetResultParcel();
- if (ptr == nullptr) {
- LOG(ERROR) << "Fail to get return parcelable";
- return PMINFO_R_ERROR;
- }
-
- if (ptr->GetRequestResult() != PMINFO_R_OK) {
- LOG(ERROR) << "Request fail";
- return ptr->GetRequestResult();
- }
-
- if (ptr->GetType() != pkgmgr_common::parcel::ParcelableType::Result) {
- LOG(ERROR) << "Invalid parcelable type";
- return PMINFO_R_ERROR;
- }
-
- std::shared_ptr<pkgmgr_common::parcel::ResultParcelable> return_parcel(
- std::static_pointer_cast<pkgmgr_common::parcel::ResultParcelable>(
- ptr));
+ if (query == nullptr) {
+ LOG(ERROR) << "Out of memory";
+ return PMINFO_R_ERROR;
+ }
+
+ std::shared_ptr<pcp::AbstractParcelable> parcelable(
+ new pcp::QueryParcelable(_getuid(), std::string(query),
+ pcd::AbstractDBHandler::DBType::DB_TYPE_FILE_PKGDB,
+ pcd::AbstractDBHandler::OperationType::OPERATION_TYPE_READ));
+ sqlite3_free(query);
+
+ pkgmgr_client::PkgInfoClient client(parcelable, _getuid(),
+ pkgmgr_common::ReqType::QUERY);
+ if (!client.SendRequest())
+ return PMINFO_R_ERROR;
+
+ auto ptr = client.GetResultParcel();
+ if (ptr == nullptr) {
+ LOG(ERROR) << "Fail to get return parcelable";
+ return PMINFO_R_ERROR;
+ }
+
+ if (ptr->GetRequestResult() != PMINFO_R_OK) {
+ LOG(ERROR) << "Request fail";
+ return ptr->GetRequestResult();
+ }
+
+ if (ptr->GetType() != pcp::ParcelableType::Result) {
+ LOG(ERROR) << "Invalid parcelable type";
+ return PMINFO_R_ERROR;
+ }
+
+ std::shared_ptr<pcp::ResultParcelable> return_parcel(
+ std::static_pointer_cast<pcp::ResultParcelable>(ptr));
if (return_parcel->GetCol() != 1) {
LOG(ERROR) << "Invalid result";
return PMINFO_R_ERROR;
}
- // result_list is vector of string vector
- auto& result_list = return_parcel->GetResult();
- if (result_list.size() == 0)
- return PMINFO_R_ENOENT;
+ // result_list is vector of string vector
+ auto &result_list = return_parcel->GetResult();
+ if (result_list.size() == 0)
+ return PMINFO_R_ENOENT;
- for (auto result : result_list) {
+ for (auto result : result_list) {
if (result.size() != 1) {
LOG(ERROR) << "Invalid result";
g_list_free_full(*list, free);
return PMINFO_R_OK;
}
-static int __convert_update_type(const char *type, pkgmgrinfo_updateinfo_update_type *convert_type)
-{
- if (strncasecmp(type, PMINFO_UPDATEINFO_TYPE_NONE,
- strlen(PMINFO_UPDATEINFO_TYPE_NONE)) == 0)
- *convert_type = PMINFO_UPDATEINFO_NONE;
- else if (strncasecmp(type, PMINFO_UPDATEINFO_TYPE_FORCE,
- strlen(PMINFO_UPDATEINFO_TYPE_FORCE)) == 0)
- *convert_type = PMINFO_UPDATEINFO_FORCE;
- else if (strncasecmp(type, PMINFO_UPDATEINFO_TYPE_OPTIONAL,
- strlen(PMINFO_UPDATEINFO_TYPE_OPTIONAL)) == 0)
- *convert_type = PMINFO_UPDATEINFO_OPTIONAL;
- else
- return -1;
- return 0;
+static int __convert_update_type(const char* type,
+ pkgmgrinfo_updateinfo_update_type* convert_type) {
+ if (strncasecmp(type, PMINFO_UPDATEINFO_TYPE_NONE,
+ strlen(PMINFO_UPDATEINFO_TYPE_NONE)) == 0)
+ *convert_type = PMINFO_UPDATEINFO_NONE;
+ else if (strncasecmp(type, PMINFO_UPDATEINFO_TYPE_FORCE,
+ strlen(PMINFO_UPDATEINFO_TYPE_FORCE)) == 0)
+ *convert_type = PMINFO_UPDATEINFO_FORCE;
+ else if (strncasecmp(type, PMINFO_UPDATEINFO_TYPE_OPTIONAL,
+ strlen(PMINFO_UPDATEINFO_TYPE_OPTIONAL)) == 0)
+ *convert_type = PMINFO_UPDATEINFO_OPTIONAL;
+ else
+ return -1;
+ return 0;
}
-static void __free_update_info(gpointer data)
-{
- updateinfo_x *update_info = (updateinfo_x *)data;
- if (update_info == nullptr)
- return;
-
- if (update_info->pkgid)
- free((void *)update_info->pkgid);
- if (update_info->version)
- free((void *)update_info->version);
- free((void *)update_info);
+static void __free_update_info(gpointer data) {
+ updateinfo_x* update_info = reinterpret_cast<updateinfo_x*>(data);
+ if (update_info == nullptr)
+ return;
+ if (update_info->pkgid)
+ free(reinterpret_cast<void*>(update_info->pkgid));
+ if (update_info->version)
+ free(reinterpret_cast<void*>(update_info->version));
+ free(reinterpret_cast<void*>(update_info));
}
-extern "C" EXPORT_API int _get_pkg_updateinfo(const char *pkgid,
- GSList **update_info_list, uid_t uid)
-{
- char *query = nullptr;
- int ret;
-
- if (pkgid == nullptr)
- query = sqlite3_mprintf(
- "SELECT package, update_version, update_type "
- "FROM package_update_info");
- else
- query = sqlite3_mprintf(
- "SELECT package, update_version, update_type "
- "FROM package_update_info WHERE package=%Q",
- pkgid);
- if (query == nullptr) {
- LOG(ERROR) << "Out of memory";
- return PMINFO_R_ERROR;
- }
-
- std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcelable(
- new pkgmgr_common::parcel::QueryParcelable(uid, std::string(query),
- pkgmgr_common::database::AbstractDBHandler::DBType::DB_TYPE_FILE_PKGDB,
- pkgmgr_common::database::AbstractDBHandler::OperationType::OPERATION_TYPE_READ));
- sqlite3_free(query);
-
- pkgmgr_client::PkgInfoClient client(parcelable, uid,
- pkgmgr_common::ReqType::QUERY);
- if (!client.SendRequest()) {
- return PMINFO_R_ERROR;
- }
-
- auto ptr = client.GetResultParcel();
- if (ptr == nullptr) {
- LOG(ERROR) << "Fail to get return parcelable";
- return PMINFO_R_ERROR;
- }
-
- if (ptr->GetRequestResult() != PMINFO_R_OK) {
- LOG(ERROR) << "Request fail";
- return ptr->GetRequestResult();
- }
-
- if (ptr->GetType() != pkgmgr_common::parcel::ParcelableType::Result) {
- LOG(ERROR) << "Invalid parcelable type";
- return PMINFO_R_ERROR;
- }
-
- std::shared_ptr<pkgmgr_common::parcel::ResultParcelable> return_parcel(
- std::static_pointer_cast<pkgmgr_common::parcel::ResultParcelable>(
- ptr));
+extern "C" EXPORT_API int _get_pkg_updateinfo(const char* pkgid,
+ GSList** update_info_list, uid_t uid) {
+ char* query = nullptr;
+ int ret;
+
+ if (pkgid == nullptr)
+ query = sqlite3_mprintf(
+ "SELECT package, update_version, update_type "
+ "FROM package_update_info");
+ else
+ query = sqlite3_mprintf(
+ "SELECT package, update_version, update_type "
+ "FROM package_update_info WHERE package=%Q",
+ pkgid);
+ if (query == nullptr) {
+ LOG(ERROR) << "Out of memory";
+ return PMINFO_R_ERROR;
+ }
+
+ std::shared_ptr<pcp::AbstractParcelable> parcelable(
+ new pcp::QueryParcelable(uid, std::string(query),
+ pcd::AbstractDBHandler::DBType::DB_TYPE_FILE_PKGDB,
+ pcd::AbstractDBHandler::OperationType::OPERATION_TYPE_READ));
+ sqlite3_free(query);
+
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
+ pkgmgr_common::ReqType::QUERY);
+ if (!client.SendRequest())
+ return PMINFO_R_ERROR;
+
+ auto ptr = client.GetResultParcel();
+ if (ptr == nullptr) {
+ LOG(ERROR) << "Fail to get return parcelable";
+ return PMINFO_R_ERROR;
+ }
+
+ if (ptr->GetRequestResult() != PMINFO_R_OK) {
+ LOG(ERROR) << "Request fail";
+ return ptr->GetRequestResult();
+ }
+
+ if (ptr->GetType() != pcp::ParcelableType::Result) {
+ LOG(ERROR) << "Invalid parcelable type";
+ return PMINFO_R_ERROR;
+ }
+
+ std::shared_ptr<pcp::ResultParcelable> return_parcel(
+ std::static_pointer_cast<pcp::ResultParcelable>(ptr));
if (return_parcel->GetCol() != 3) {
LOG(ERROR) << "Invalid result";
return PMINFO_R_ERROR;
}
- auto result_list = return_parcel->GetResult();
- if (result_list.size() == 0)
- return PMINFO_R_ENOENT;
+ auto result_list = return_parcel->GetResult();
+ if (result_list.size() == 0)
+ return PMINFO_R_ENOENT;
- for (auto result : result_list) {
+ for (auto result : result_list) {
if (result.size() != 3) {
LOG(ERROR) << "Invalid result";
g_slist_free_full(*update_info_list, __free_update_info);
return PMINFO_R_ERROR;
}
- updateinfo_x *update_info = reinterpret_cast<updateinfo_x *>(calloc(1, sizeof(updateinfo_x)));
- if (update_info == nullptr) {
- LOG(ERROR) << "Out of memory";
- return PMINFO_R_ERROR;
- }
+ updateinfo_x* update_info = reinterpret_cast<updateinfo_x*>(
+ calloc(1, sizeof(updateinfo_x)));
+ if (update_info == nullptr) {
+ LOG(ERROR) << "Out of memory";
+ return PMINFO_R_ERROR;
+ }
update_info->pkgid = strdup(result[0].c_str());
update_info->version = strdup(result[1].c_str());
- pkgmgrinfo_updateinfo_update_type convert_type;
- ret = __convert_update_type(result[2].c_str(), &convert_type);
- if (ret != 0) {
- __free_update_info(update_info);
+ pkgmgrinfo_updateinfo_update_type convert_type;
+ ret = __convert_update_type(result[2].c_str(), &convert_type);
+ if (ret != 0) {
+ __free_update_info(update_info);
g_slist_free_full(*update_info_list, __free_update_info);
- return PMINFO_R_ERROR;
- }
- update_info->type = static_cast<int>(convert_type);
- *update_info_list = g_slist_prepend(*update_info_list,
- update_info);
+ return PMINFO_R_ERROR;
+ }
+ update_info->type = static_cast<int>(convert_type);
+ *update_info_list = g_slist_prepend(*update_info_list,
+ update_info);
}
- return PMINFO_R_OK;
+ return PMINFO_R_OK;
}
-extern "C" EXPORT_API int _pkginfo_set_usr_installed_storage(const char *pkgid,
- INSTALL_LOCATION location, const char *external_pkg_path,
- uid_t uid)
-{
- char *query = nullptr;
- const char *location_str;
- std::vector<std::string> queries;
-
- if (location == INSTALL_INTERNAL)
- location_str = "installed_internal";
- else if (location == INSTALL_EXTERNAL)
- location_str = "installed_external";
- else
- location_str = "installed_extended";
- /* pkgcakge_info table */
- query = sqlite3_mprintf(
- "update package_info set installed_storage=%Q, external_path=%Q where package=%Q",
- location_str, external_pkg_path, pkgid);
- queries.emplace_back(query);
- sqlite3_free(query);
-
- /* package_app_info table */
- query = sqlite3_mprintf(
- "update package_app_info set app_installed_storage=%Q, app_external_path=%Q where package=%Q",
- location_str, external_pkg_path, pkgid);
- queries.emplace_back(query);
- sqlite3_free(query);
-
- std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcelable(
- new pkgmgr_common::parcel::QueryParcelable(uid, queries,
- pkgmgr_common::database::AbstractDBHandler::DBType::DB_TYPE_FILE_PKGDB,
- pkgmgr_common::database::AbstractDBHandler::OperationType::OPERATION_TYPE_WRITE));
-
- pkgmgr_client::PkgInfoClient client(parcelable, uid,
- pkgmgr_common::ReqType::QUERY);
- if (!client.SendRequest()) {
- return PMINFO_R_ERROR;
- }
-
- auto ptr = client.GetResultParcel();
- if (ptr == nullptr) {
- LOG(ERROR) << "Fail to get return parcelable";
- return PMINFO_R_ERROR;
- }
-
- if (ptr->GetRequestResult() != PMINFO_R_OK) {
- LOG(ERROR) << "Request fail";
- return ptr->GetRequestResult();
- }
-
- if (ptr->GetType() != pkgmgr_common::parcel::ParcelableType::Result) {
- LOG(ERROR) << "Invalid parcelable type";
- return PMINFO_R_ERROR;
- }
-
- return PMINFO_R_OK;
+extern "C" EXPORT_API int _pkginfo_set_usr_installed_storage(const char* pkgid,
+ INSTALL_LOCATION location, const char* external_pkg_path, uid_t uid) {
+ char* query = nullptr;
+ const char* location_str;
+ std::vector<std::string> queries;
+
+ if (location == INSTALL_INTERNAL)
+ location_str = "installed_internal";
+ else if (location == INSTALL_EXTERNAL)
+ location_str = "installed_external";
+ else
+ location_str = "installed_extended";
+ /* pkgcakge_info table */
+ query = sqlite3_mprintf(
+ "UPDATE package_info SET installed_storage=%Q, external_path=%Q "
+ "WHERE package=%Q",
+ location_str, external_pkg_path, pkgid);
+ queries.emplace_back(query);
+ sqlite3_free(query);
+
+ /* package_app_info table */
+ query = sqlite3_mprintf(
+ "UPDATE package_app_info SET app_installed_storage=%Q, "
+ "app_external_path=%Q WGERE package=%Q",
+ location_str, external_pkg_path, pkgid);
+ queries.emplace_back(query);
+ sqlite3_free(query);
+
+ std::shared_ptr<pcp::AbstractParcelable> parcelable(
+ new pcp::QueryParcelable(uid, queries,
+ pcd::AbstractDBHandler::DBType::DB_TYPE_FILE_PKGDB,
+ pcd::AbstractDBHandler::OperationType::OPERATION_TYPE_WRITE));
+
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
+ pkgmgr_common::ReqType::QUERY);
+ if (!client.SendRequest())
+ return PMINFO_R_ERROR;
+
+ auto ptr = client.GetResultParcel();
+ if (ptr == nullptr) {
+ LOG(ERROR) << "Fail to get return parcelable";
+ return PMINFO_R_ERROR;
+ }
+
+ if (ptr->GetRequestResult() != PMINFO_R_OK) {
+ LOG(ERROR) << "Request fail";
+ return ptr->GetRequestResult();
+ }
+
+ if (ptr->GetType() != pcp::ParcelableType::Result) {
+ LOG(ERROR) << "Invalid parcelable type";
+ return PMINFO_R_ERROR;
+ }
+
+ return PMINFO_R_OK;
}
-extern "C" EXPORT_API int _certinfo_compare_pkg_certinfo(const char *l_pkgid,
- const char *r_pkgid, pkgmgrinfo_cert_compare_result_type_e *result) {
- char *query = sqlite3_mprintf("SELECT package, "
- "COALESCE(author_signer_cert, -1) FROM package_cert_info WHERE "
- "package IN (%Q, %Q)", l_pkgid, r_pkgid);
- if (query == nullptr) {
- LOG(ERROR) << "Out of memory";
- return PMINFO_R_ERROR;
- }
- std::vector<std::string> queries;
- queries.emplace_back(query);
- sqlite3_free(query);
-
- std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcelable(
- new pkgmgr_common::parcel::QueryParcelable(0, queries,
- pkgmgr_common::database::AbstractDBHandler::DBType::DB_TYPE_FILE_CERTDB,
- pkgmgr_common::database::AbstractDBHandler::OperationType::OPERATION_TYPE_READ));
- pkgmgr_client::PkgInfoClient client(parcelable, 0,
- pkgmgr_common::ReqType::QUERY);
- if (!client.SendRequest()) {
- return PMINFO_R_ERROR;
- }
-
- auto ptr = client.GetResultParcel();
- if (ptr == nullptr) {
- LOG(ERROR) << "Fail to get return parcelable";
- return PMINFO_R_ERROR;
- }
-
- if (ptr->GetRequestResult() != PMINFO_R_OK) {
- LOG(ERROR) << "Request fail";
- return ptr->GetRequestResult();
- }
-
- if (ptr->GetType() != pkgmgr_common::parcel::ParcelableType::Result) {
- LOG(ERROR) << "Invalid parcelable type";
- return PMINFO_R_ERROR;
- }
-
- std::shared_ptr<pkgmgr_common::parcel::ResultParcelable> return_parcel(
- std::static_pointer_cast<pkgmgr_common::parcel::ResultParcelable>(
- ptr));
-
- auto certinfo_list = return_parcel->GetResult();
- if (certinfo_list.size() != 2)
- return PMINFO_R_ERROR;
-
- std::map<std::string, std::string> result_map;
- for (auto& certinfo : certinfo_list)
- result_map.insert(make_pair(certinfo.front(), certinfo.back()));
-
- if (result_map.find(std::string(l_pkgid))->second == "-1" &&
- result_map.find(std::string(r_pkgid))->second == "-1")
- *result = PMINFO_CERT_COMPARE_BOTH_NO_CERT;
- else if (result_map.find(std::string(l_pkgid))->second == "-1")
- *result = PMINFO_CERT_COMPARE_LHS_NO_CERT;
- else if (result_map.find(std::string(r_pkgid))->second == "-1")
- *result = PMINFO_CERT_COMPARE_RHS_NO_CERT;
- else if (result_map.find(std::string(l_pkgid))->second ==
- result_map.find(std::string(r_pkgid))->second)
- *result = PMINFO_CERT_COMPARE_MATCH;
- else
- *result = PMINFO_CERT_COMPARE_MISMATCH;
-
- return PMINFO_R_OK;
+extern "C" EXPORT_API int _certinfo_compare_pkg_certinfo(const char* l_pkgid,
+ const char* r_pkgid, pkgmgrinfo_cert_compare_result_type_e* result) {
+ char* query = sqlite3_mprintf("SELECT package, "
+ "COALESCE(author_signer_cert, -1) FROM package_cert_info WHERE "
+ "package IN (%Q, %Q)",
+ l_pkgid, r_pkgid);
+ if (query == nullptr) {
+ LOG(ERROR) << "Out of memory";
+ return PMINFO_R_ERROR;
+ }
+ std::vector<std::string> queries;
+ queries.emplace_back(query);
+ sqlite3_free(query);
+
+ std::shared_ptr<pcp::AbstractParcelable> parcelable(
+ new pcp::QueryParcelable(0, queries,
+ pcd::AbstractDBHandler::DBType::DB_TYPE_FILE_CERTDB,
+ pcd::AbstractDBHandler::OperationType::OPERATION_TYPE_READ));
+ pkgmgr_client::PkgInfoClient client(parcelable, 0,
+ pkgmgr_common::ReqType::QUERY);
+ if (!client.SendRequest())
+ return PMINFO_R_ERROR;
+
+ auto ptr = client.GetResultParcel();
+ if (ptr == nullptr) {
+ LOG(ERROR) << "Fail to get return parcelable";
+ return PMINFO_R_ERROR;
+ }
+
+ if (ptr->GetRequestResult() != PMINFO_R_OK) {
+ LOG(ERROR) << "Request fail";
+ return ptr->GetRequestResult();
+ }
+
+ if (ptr->GetType() != pcp::ParcelableType::Result) {
+ LOG(ERROR) << "Invalid parcelable type";
+ return PMINFO_R_ERROR;
+ }
+
+ std::shared_ptr<pcp::ResultParcelable> return_parcel(
+ std::static_pointer_cast<pcp::ResultParcelable>(
+ ptr));
+
+ auto certinfo_list = return_parcel->GetResult();
+ if (certinfo_list.size() != 2)
+ return PMINFO_R_ERROR;
+
+ std::map<std::string, std::string> result_map;
+ for (auto &certinfo : certinfo_list)
+ result_map.insert(make_pair(certinfo.front(), certinfo.back()));
+
+ if (result_map.find(std::string(l_pkgid))->second == "-1" &&
+ result_map.find(std::string(r_pkgid))->second == "-1")
+ *result = PMINFO_CERT_COMPARE_BOTH_NO_CERT;
+ else if (result_map.find(std::string(l_pkgid))->second == "-1")
+ *result = PMINFO_CERT_COMPARE_LHS_NO_CERT;
+ else if (result_map.find(std::string(r_pkgid))->second == "-1")
+ *result = PMINFO_CERT_COMPARE_RHS_NO_CERT;
+ else if (result_map.find(std::string(l_pkgid))->second ==
+ result_map.find(std::string(r_pkgid))->second)
+ *result = PMINFO_CERT_COMPARE_MATCH;
+ else
+ *result = PMINFO_CERT_COMPARE_MISMATCH;
+
+ return PMINFO_R_OK;
}
extern "C" EXPORT_API int _certinfo_compare_app_certinfo(uid_t uid,
- const char *l_appid, const char *r_appid,
- pkgmgrinfo_cert_compare_result_type_e *result) {
- char* query = sqlite3_mprintf("SELECT app_id, package FROM "
- "package_app_info WHERE app_id IN (%Q, %Q)", l_appid, r_appid);
- if (query == nullptr) {
- LOG(ERROR) << "Out of memory";
- return PMINFO_R_ERROR;
- }
- std::vector<std::string> queries;
- queries.emplace_back(query);
- sqlite3_free(query);
-
- std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcelable(
- new pkgmgr_common::parcel::QueryParcelable(uid, queries,
- pkgmgr_common::database::AbstractDBHandler::DBType::DB_TYPE_FILE_PKGDB,
- pkgmgr_common::database::AbstractDBHandler::OperationType::OPERATION_TYPE_READ));
- pkgmgr_client::PkgInfoClient client(parcelable, uid,
- pkgmgr_common::ReqType::QUERY);
- if (!client.SendRequest()) {
- return PMINFO_R_ERROR;
- }
-
- auto ptr = client.GetResultParcel();
- if (ptr == nullptr) {
- LOG(ERROR) << "Fail to get return parcelable";
- return PMINFO_R_ERROR;
- }
-
- if (ptr->GetRequestResult() != PMINFO_R_OK) {
- LOG(ERROR) << "Request fail";
- return ptr->GetRequestResult();
- }
-
- if (ptr->GetType() != pkgmgr_common::parcel::ParcelableType::Result) {
- LOG(ERROR) << "Invalid parcelable type";
- return PMINFO_R_ERROR;
- }
-
- std::shared_ptr<pkgmgr_common::parcel::ResultParcelable> return_parcel(
- std::static_pointer_cast<pkgmgr_common::parcel::ResultParcelable>(
- ptr));
-
- auto pkgid_list = return_parcel->GetResult();
- std::map<std::string, std::string> result_map;
- for (auto& pkgid : pkgid_list)
- result_map.insert(make_pair(pkgid.front(), pkgid.back()));
-
- if (result_map.find(std::string(l_appid)) == result_map.end()) {
- LOG(ERROR) << "Cannot find pkgid of app " << l_appid
- << " for uid " << uid;
- return PMINFO_R_ENOENT;
- } else if (result_map.find(std::string(r_appid)) == result_map.end()) {
- LOG(ERROR) << "Cannot find pkgid of app " << r_appid
- << " for uid " << uid;
- return PMINFO_R_ENOENT;
- }
-
- const char* l_pkgid = result_map.find(
- std::string(l_appid))->second.c_str();
- const char* r_pkgid = result_map.find(
- std::string(r_appid))->second.c_str();
-
- return _certinfo_compare_pkg_certinfo(l_pkgid, r_pkgid, result);
+ const char* l_appid, const char* r_appid,
+ pkgmgrinfo_cert_compare_result_type_e* result) {
+ char* query = sqlite3_mprintf("SELECT app_id, package FROM "
+ "package_app_info WHERE app_id IN (%Q, %Q)",
+ l_appid, r_appid);
+ if (query == nullptr) {
+ LOG(ERROR) << "Out of memory";
+ return PMINFO_R_ERROR;
+ }
+ std::vector<std::string> queries;
+ queries.emplace_back(query);
+ sqlite3_free(query);
+
+ std::shared_ptr<pcp::AbstractParcelable> parcelable(
+ new pcp::QueryParcelable(uid, queries,
+ pcd::AbstractDBHandler::DBType::DB_TYPE_FILE_PKGDB,
+ pcd::AbstractDBHandler::OperationType::OPERATION_TYPE_READ));
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
+ pkgmgr_common::ReqType::QUERY);
+ if (!client.SendRequest())
+ return PMINFO_R_ERROR;
+
+ auto ptr = client.GetResultParcel();
+ if (ptr == nullptr) {
+ LOG(ERROR) << "Fail to get return parcelable";
+ return PMINFO_R_ERROR;
+ }
+
+ if (ptr->GetRequestResult() != PMINFO_R_OK) {
+ LOG(ERROR) << "Request fail";
+ return ptr->GetRequestResult();
+ }
+
+ if (ptr->GetType() != pcp::ParcelableType::Result) {
+ LOG(ERROR) << "Invalid parcelable type";
+ return PMINFO_R_ERROR;
+ }
+
+ std::shared_ptr<pcp::ResultParcelable> return_parcel(
+ std::static_pointer_cast<pcp::ResultParcelable>(ptr));
+
+ auto pkgid_list = return_parcel->GetResult();
+ std::map<std::string, std::string> result_map;
+ for (auto &pkgid : pkgid_list)
+ result_map.insert(make_pair(pkgid.front(), pkgid.back()));
+
+ if (result_map.find(std::string(l_appid)) == result_map.end()) {
+ LOG(ERROR) << "Cannot find pkgid of app " << l_appid
+ << " for uid " << uid;
+ return PMINFO_R_ENOENT;
+ } else if (result_map.find(std::string(r_appid)) == result_map.end()) {
+ LOG(ERROR) << "Cannot find pkgid of app " << r_appid
+ << " for uid " << uid;
+ return PMINFO_R_ENOENT;
+ }
+
+ const char* l_pkgid = result_map.find(std::string(l_appid))->second.c_str();
+ const char* r_pkgid = result_map.find(std::string(r_appid))->second.c_str();
+
+ return _certinfo_compare_pkg_certinfo(l_pkgid, r_pkgid, result);
}
-extern "C" EXPORT_API int _parser_execute_write_query(const char *query, uid_t uid)
-{
- std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcelable(
- new pkgmgr_common::parcel::QueryParcelable(uid, query,
- pkgmgr_common::database::AbstractDBHandler::DBType::DB_TYPE_FILE_PKGDB,
- pkgmgr_common::database::AbstractDBHandler::OperationType::OPERATION_TYPE_WRITE));
-
- pkgmgr_client::PkgInfoClient client(parcelable, uid,
- pkgmgr_common::ReqType::QUERY);
- if (!client.SendRequest()) {
- return -1;
- }
-
- auto ptr = client.GetResultParcel();
- if (ptr == nullptr) {
- LOG(ERROR) << "Fail to get return parcelable";
- return -1;
- }
-
- if (ptr->GetRequestResult() != PMINFO_R_OK) {
- LOG(ERROR) << "Request fail";
- return -1;
- }
-
- if (ptr->GetType() != pkgmgr_common::parcel::ParcelableType::Result) {
- LOG(ERROR) << "Invalid parcelable type";
- return -1;
- }
-
- return 0;
+extern "C" EXPORT_API int _parser_execute_write_query(
+ const char* query, uid_t uid) {
+ std::shared_ptr<pcp::AbstractParcelable> parcelable(
+ new pcp::QueryParcelable(uid, query,
+ pcd::AbstractDBHandler::DBType::DB_TYPE_FILE_PKGDB,
+ pcd::AbstractDBHandler::OperationType::OPERATION_TYPE_WRITE));
+
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
+ pkgmgr_common::ReqType::QUERY);
+ if (!client.SendRequest())
+ return -1;
+
+ auto ptr = client.GetResultParcel();
+ if (ptr == nullptr) {
+ LOG(ERROR) << "Fail to get return parcelable";
+ return -1;
+ }
+
+ if (ptr->GetRequestResult() != PMINFO_R_OK) {
+ LOG(ERROR) << "Request fail";
+ return -1;
+ }
+
+ if (ptr->GetType() != pcp::ParcelableType::Result) {
+ LOG(ERROR) << "Invalid parcelable type";
+ return -1;
+ }
+
+ return 0;
}
-extern "C" EXPORT_API int _parser_execute_write_queries(const char **queries, int len, uid_t uid)
-{
- std::vector<std::string> query_vt;
- for (int i = 0; i < len; ++i)
- query_vt.emplace_back(queries[i]);
-
- std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcelable(
- new pkgmgr_common::parcel::QueryParcelable(uid, query_vt,
- pkgmgr_common::database::AbstractDBHandler::DBType::DB_TYPE_FILE_PKGDB,
- pkgmgr_common::database::AbstractDBHandler::OperationType::OPERATION_TYPE_WRITE));
-
- pkgmgr_client::PkgInfoClient client(parcelable, uid,
- pkgmgr_common::ReqType::QUERY);
- if (!client.SendRequest()) {
- return -1;
- }
-
- auto ptr = client.GetResultParcel();
- if (ptr == nullptr) {
- LOG(ERROR) << "Fail to get return parcelable";
- return -1;
- }
-
- if (ptr->GetRequestResult() != PMINFO_R_OK) {
- LOG(ERROR) << "Request fail";
- return -1;
- }
-
- if (ptr->GetType() != pkgmgr_common::parcel::ParcelableType::Result) {
- LOG(ERROR) << "Invalid parcelable type";
- return -1;
- }
-
- return 0;
+extern "C" EXPORT_API int _parser_execute_write_queries(
+ const char** queries, int len, uid_t uid) {
+ std::vector<std::string> query_vt;
+ for (int i = 0; i < len; ++i)
+ query_vt.emplace_back(queries[i]);
+
+ std::shared_ptr<pcp::AbstractParcelable> parcelable(
+ new pcp::QueryParcelable(uid, query_vt,
+ pcd::AbstractDBHandler::DBType::DB_TYPE_FILE_PKGDB,
+ pcd::AbstractDBHandler::OperationType::OPERATION_TYPE_WRITE));
+
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
+ pkgmgr_common::ReqType::QUERY);
+ if (!client.SendRequest())
+ return -1;
+
+ auto ptr = client.GetResultParcel();
+ if (ptr == nullptr) {
+ LOG(ERROR) << "Fail to get return parcelable";
+ return -1;
+ }
+
+ if (ptr->GetRequestResult() != PMINFO_R_OK) {
+ LOG(ERROR) << "Request fail";
+ return -1;
+ }
+
+ if (ptr->GetType() != pcp::ParcelableType::Result) {
+ LOG(ERROR) << "Invalid parcelable type";
+ return -1;
+ }
+
+ return 0;
}
-extern "C" EXPORT_API int _parser_insert_manifest_info(manifest_x *mfx, uid_t uid)
-{
- auto parcelable =
- std::make_shared<pkgmgr_common::parcel::PkgInfoParcelable>(uid,
- std::vector<package_x *>{ mfx }, WriteType::Insert, false);
-
- pkgmgr_client::PkgInfoClient client(parcelable, uid,
- pkgmgr_common::ReqType::SET_PKG_INFO);
- if (!client.SendRequest()) {
- return -1;
- }
-
- auto ptr = client.GetResultParcel();
- if (ptr == nullptr) {
- LOG(ERROR) << "Fail to get return parcelable";
- return -1;
- }
-
- if (ptr->GetRequestResult() != PMINFO_R_OK) {
- LOG(ERROR) << "Request fail";
- return -1;
- }
-
- if (ptr->GetType() != pkgmgr_common::parcel::ParcelableType::Result) {
- LOG(ERROR) << "Invalid parcelable type";
- return -1;
- }
-
- return 0;
+extern "C" EXPORT_API int _parser_insert_manifest_info(
+ manifest_x* mfx, uid_t uid) {
+ auto parcelable =
+ std::make_shared<pcp::PkgInfoParcelable>(uid,
+ std::vector<package_x*>{mfx}, WriteType::Insert, false);
+
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
+ pkgmgr_common::ReqType::SET_PKG_INFO);
+ if (!client.SendRequest())
+ return -1;
+
+ auto ptr = client.GetResultParcel();
+ if (ptr == nullptr) {
+ LOG(ERROR) << "Fail to get return parcelable";
+ return -1;
+ }
+
+ if (ptr->GetRequestResult() != PMINFO_R_OK) {
+ LOG(ERROR) << "Request fail";
+ return -1;
+ }
+
+ if (ptr->GetType() != pcp::ParcelableType::Result) {
+ LOG(ERROR) << "Invalid parcelable type";
+ return -1;
+ }
+
+ return 0;
}
-extern "C" EXPORT_API int _parser_update_manifest_info(manifest_x *mfx, uid_t uid)
-{
- auto parcelable =
- std::make_shared<pkgmgr_common::parcel::PkgInfoParcelable>(uid,
- std::vector<package_x *>{ mfx }, WriteType::Update, false);
-
- pkgmgr_client::PkgInfoClient client(parcelable, uid,
- pkgmgr_common::ReqType::SET_PKG_INFO);
- if (!client.SendRequest()) {
- return -1;
- }
-
- auto ptr = client.GetResultParcel();
- if (ptr == nullptr) {
- LOG(ERROR) << "Fail to get return parcelable";
- return -1;
- }
-
- if (ptr->GetRequestResult() != PMINFO_R_OK) {
- LOG(ERROR) << "Request fail";
- return -1;
- }
-
- if (ptr->GetType() != pkgmgr_common::parcel::ParcelableType::Result) {
- LOG(ERROR) << "Invalid parcelable type";
- return -1;
- }
-
- return 0;
+extern "C" EXPORT_API int _parser_update_manifest_info(
+ manifest_x* mfx, uid_t uid) {
+ auto parcelable =
+ std::make_shared<pcp::PkgInfoParcelable>(uid,
+ std::vector<package_x*>{mfx}, WriteType::Update, false);
+
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
+ pkgmgr_common::ReqType::SET_PKG_INFO);
+ if (!client.SendRequest())
+ return -1;
+
+ auto ptr = client.GetResultParcel();
+ if (ptr == nullptr) {
+ LOG(ERROR) << "Fail to get return parcelable";
+ return -1;
+ }
+
+ if (ptr->GetRequestResult() != PMINFO_R_OK) {
+ LOG(ERROR) << "Request fail";
+ return -1;
+ }
+
+ if (ptr->GetType() != pcp::ParcelableType::Result) {
+ LOG(ERROR) << "Invalid parcelable type";
+ return -1;
+ }
+
+ return 0;
}
-extern "C" EXPORT_API int _parser_delete_manifest_info(manifest_x *mfx, uid_t uid)
-{
- auto parcelable =
- std::make_shared<pkgmgr_common::parcel::PkgInfoParcelable>(uid,
- std::vector<package_x *>{ mfx }, WriteType::Delete, false);
-
- pkgmgr_client::PkgInfoClient client(parcelable, uid,
- pkgmgr_common::ReqType::SET_PKG_INFO);
- if (!client.SendRequest()) {
- return -1;
- }
-
- auto ptr = client.GetResultParcel();
- if (ptr == nullptr) {
- LOG(ERROR) << "Fail to get return parcelable";
- return -1;
- }
-
- if (ptr->GetRequestResult() != PMINFO_R_OK) {
- LOG(ERROR) << "Request fail";
- return -1;
- }
-
- if (ptr->GetType() != pkgmgr_common::parcel::ParcelableType::Result) {
- LOG(ERROR) << "Invalid parcelable type";
- return -1;
- }
-
- return 0;
+extern "C" EXPORT_API int _parser_delete_manifest_info(
+ manifest_x* mfx, uid_t uid) {
+ auto parcelable =
+ std::make_shared<pcp::PkgInfoParcelable>(uid,
+ std::vector<package_x*>{mfx}, WriteType::Delete, false);
+
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
+ pkgmgr_common::ReqType::SET_PKG_INFO);
+ if (!client.SendRequest())
+ return -1;
+
+ auto ptr = client.GetResultParcel();
+ if (ptr == nullptr) {
+ LOG(ERROR) << "Fail to get return parcelable";
+ return -1;
+ }
+
+ if (ptr->GetRequestResult() != PMINFO_R_OK) {
+ LOG(ERROR) << "Request fail";
+ return -1;
+ }
+
+ if (ptr->GetType() != pcp::ParcelableType::Result) {
+ LOG(ERROR) << "Invalid parcelable type";
+ return -1;
+ }
+
+ return 0;
}
extern "C" EXPORT_API int _pkginfo_insert_certinfo(const char* pkgid,
- pkgmgr_certinfo_x* cert, uid_t uid)
-{
- std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcelable(
- new pkgmgr_common::parcel::CertInfoParcelable(uid, cert, false));
-
- pkgmgr_client::PkgInfoClient client(parcelable, uid,
- pkgmgr_common::ReqType::SET_CERT_INFO);
- if (!client.SendRequest())
- return PMINFO_R_ERROR;
-
- auto ptr = client.GetResultParcel();
- if (ptr == nullptr) {
- LOG(ERROR) << "Fail to get return parcelable";
- return PMINFO_R_ERROR;
- }
-
- if (ptr->GetRequestResult() != PMINFO_R_OK) {
- LOG(ERROR) << "Request fail";
- return ptr->GetRequestResult();
- }
-
- if (ptr->GetType() != pkgmgr_common::parcel::ParcelableType::Result) {
- LOG(ERROR) << "Invalid parcelable type";
- return PMINFO_R_ERROR;
- }
-
- return PMINFO_R_OK;
+ pkgmgr_certinfo_x* cert, uid_t uid) {
+ std::shared_ptr<pcp::AbstractParcelable> parcelable(
+ new pcp::CertInfoParcelable(uid, cert, false));
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
+ pkgmgr_common::ReqType::SET_CERT_INFO);
+
+ if (!client.SendRequest())
+ return PMINFO_R_ERROR;
+
+ auto ptr = client.GetResultParcel();
+ if (ptr == nullptr) {
+ LOG(ERROR) << "Fail to get return parcelable";
+ return PMINFO_R_ERROR;
+ }
+
+ if (ptr->GetRequestResult() != PMINFO_R_OK) {
+ LOG(ERROR) << "Request fail";
+ return ptr->GetRequestResult();
+ }
+
+ if (ptr->GetType() != pcp::ParcelableType::Result) {
+ LOG(ERROR) << "Invalid parcelable type";
+ return PMINFO_R_ERROR;
+ }
+
+ return PMINFO_R_OK;
}
-extern "C" EXPORT_API int _pkginfo_get_certinfo(const char *pkgid,
- pkgmgr_certinfo_x* cert, uid_t uid)
-{
- std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcelable(
- new pkgmgr_common::parcel::CertInfoParcelable(uid,
- std::string(pkgid)));
-
- pkgmgr_client::PkgInfoClient client(parcelable, uid,
- pkgmgr_common::ReqType::GET_CERT_INFO);
- if (!client.SendRequest())
- return PMINFO_R_ERROR;
-
- auto ptr = client.GetResultParcel();
- if (ptr == nullptr) {
- LOG(ERROR) << "Fail to get return parcelable";
- return PMINFO_R_ERROR;
- }
-
- if (ptr->GetRequestResult() != PMINFO_R_OK) {
- LOG(ERROR) << "Request fail";
- return ptr->GetRequestResult();
- }
-
- if (ptr->GetType() != pkgmgr_common::parcel::ParcelableType::CertInfo) {
- LOG(ERROR) << "Invalid parcelable type";
- return PMINFO_R_ERROR;
- }
-
- std::shared_ptr<pkgmgr_common::parcel::CertInfoParcelable> return_parcel(
- std::static_pointer_cast<pkgmgr_common::parcel::CertInfoParcelable>(
- ptr));
-
- pkgmgr_certinfo_x *certinfo = return_parcel->ExtractCertInfo();
- if (certinfo == nullptr)
- return PMINFO_R_ERROR;
-
- cert->for_all_users = certinfo->for_all_users;
- cert->pkgid = certinfo->pkgid;
- certinfo->pkgid = nullptr;
- cert->cert_value = certinfo->cert_value;
- certinfo->cert_value = nullptr;
- for (int i = 0; i < MAX_CERT_TYPE; i++) {
- cert->cert_info[i] = certinfo->cert_info[i];
- certinfo->cert_info[i] = nullptr;
- }
- for (int i = 0; i < MAX_CERT_TYPE; i++)
- cert->cert_id[i] = certinfo->cert_id[i];
-
- free(certinfo);
-
- return PMINFO_R_OK;
+extern "C" EXPORT_API int _pkginfo_get_certinfo(const char* pkgid,
+ pkgmgr_certinfo_x* cert, uid_t uid) {
+ std::shared_ptr<pcp::AbstractParcelable> parcelable(
+ new pcp::CertInfoParcelable(uid,
+ std::string(pkgid)));
+
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
+ pkgmgr_common::ReqType::GET_CERT_INFO);
+ if (!client.SendRequest())
+ return PMINFO_R_ERROR;
+
+ auto ptr = client.GetResultParcel();
+ if (ptr == nullptr) {
+ LOG(ERROR) << "Fail to get return parcelable";
+ return PMINFO_R_ERROR;
+ }
+
+ if (ptr->GetRequestResult() != PMINFO_R_OK) {
+ LOG(ERROR) << "Request fail";
+ return ptr->GetRequestResult();
+ }
+
+ if (ptr->GetType() != pcp::ParcelableType::CertInfo) {
+ LOG(ERROR) << "Invalid parcelable type";
+ return PMINFO_R_ERROR;
+ }
+
+ std::shared_ptr<pcp::CertInfoParcelable> return_parcel(
+ std::static_pointer_cast<pcp::CertInfoParcelable>(ptr));
+
+ pkgmgr_certinfo_x* certinfo = return_parcel->ExtractCertInfo();
+ if (certinfo == nullptr)
+ return PMINFO_R_ERROR;
+
+ cert->for_all_users = certinfo->for_all_users;
+ cert->pkgid = certinfo->pkgid;
+ certinfo->pkgid = nullptr;
+ cert->cert_value = certinfo->cert_value;
+ certinfo->cert_value = nullptr;
+ for (int i = 0; i < MAX_CERT_TYPE; i++) {
+ cert->cert_info[i] = certinfo->cert_info[i];
+ certinfo->cert_info[i] = nullptr;
+ }
+ for (int i = 0; i < MAX_CERT_TYPE; i++)
+ cert->cert_id[i] = certinfo->cert_id[i];
+
+ free(certinfo);
+
+ return PMINFO_R_OK;
}
-extern "C" EXPORT_API int _pkginfo_delete_certinfo(const char *pkgid)
-{
- char* query = sqlite3_mprintf("UPDATE package_cert_info SET "
- "package_count = package_count - 1 WHERE package=%Q", pkgid);
- if (query == nullptr) {
- LOG(ERROR) << "Out of memory";
- return PMINFO_R_ERROR;
- }
-
- std::vector<std::string> queries;
- queries.emplace_back(query);
- sqlite3_free(query);
-
- std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcelable(
- new pkgmgr_common::parcel::QueryParcelable(0, queries,
- pkgmgr_common::database::AbstractDBHandler::DBType::DB_TYPE_FILE_CERTDB,
- pkgmgr_common::database::AbstractDBHandler::OperationType::OPERATION_TYPE_WRITE));
-
- pkgmgr_client::PkgInfoClient client(parcelable, 0,
- pkgmgr_common::ReqType::QUERY);
- if (!client.SendRequest()) {
- return PMINFO_R_ERROR;
- }
-
- auto ptr = client.GetResultParcel();
- if (ptr == nullptr) {
- LOG(ERROR) << "Fail to get return parcelable";
- return PMINFO_R_ERROR;
- }
-
- if (ptr->GetRequestResult() != PMINFO_R_OK) {
- LOG(ERROR) << "Request fail";
- return PMINFO_R_ERROR;
- }
-
- if (ptr->GetType() != pkgmgr_common::parcel::ParcelableType::Result) {
- LOG(ERROR) << "Invalid parcelable type";
- return PMINFO_R_ERROR;
- }
-
- return PMINFO_R_OK;
+extern "C" EXPORT_API int _pkginfo_delete_certinfo(const char* pkgid) {
+ char* query = sqlite3_mprintf("UPDATE package_cert_info SET "
+ "package_count = package_count - 1 WHERE package=%Q", pkgid);
+ if (query == nullptr) {
+ LOG(ERROR) << "Out of memory";
+ return PMINFO_R_ERROR;
+ }
+
+ std::vector<std::string> queries;
+ queries.emplace_back(query);
+ sqlite3_free(query);
+
+ std::shared_ptr<pcp::AbstractParcelable> parcelable(
+ new pcp::QueryParcelable(0, queries,
+ pcd::AbstractDBHandler::DBType::DB_TYPE_FILE_CERTDB,
+ pcd::AbstractDBHandler::OperationType::OPERATION_TYPE_WRITE));
+
+ pkgmgr_client::PkgInfoClient client(parcelable, 0,
+ pkgmgr_common::ReqType::QUERY);
+ if (!client.SendRequest())
+ return PMINFO_R_ERROR;
+
+ auto ptr = client.GetResultParcel();
+ if (ptr == nullptr) {
+ LOG(ERROR) << "Fail to get return parcelable";
+ return PMINFO_R_ERROR;
+ }
+
+ if (ptr->GetRequestResult() != PMINFO_R_OK) {
+ LOG(ERROR) << "Request fail";
+ return PMINFO_R_ERROR;
+ }
+
+ if (ptr->GetType() != pcp::ParcelableType::Result) {
+ LOG(ERROR) << "Invalid parcelable type";
+ return PMINFO_R_ERROR;
+ }
+
+ return PMINFO_R_OK;
}
-extern "C" EXPORT_API int _parser_clear_cache_memory_db(uid_t uid)
-{
- std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcelable(
- new pkgmgr_common::parcel::CommandParcelable(uid, CommandType::RemoveCache));
+extern "C" EXPORT_API int _parser_clear_cache_memory_db(uid_t uid) {
+ std::shared_ptr<pcp::AbstractParcelable> parcelable(
+ new pcp::CommandParcelable(uid, CommandType::RemoveCache));
- pkgmgr_client::PkgInfoClient client(parcelable, uid,
- pkgmgr_common::ReqType::COMMAND);
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
+ pkgmgr_common::ReqType::COMMAND);
- if (!client.SendRequest()) {
- return PMINFO_R_ERROR;
- }
+ if (!client.SendRequest())
+ return PMINFO_R_ERROR;
- auto ptr = client.GetResultParcel();
- if (ptr == nullptr) {
- LOG(ERROR) << "Fail to get return parcelable";
- return PMINFO_R_ERROR;
- }
+ auto ptr = client.GetResultParcel();
+ if (ptr == nullptr) {
+ LOG(ERROR) << "Fail to get return parcelable";
+ return PMINFO_R_ERROR;
+ }
- if (ptr->GetRequestResult() != PMINFO_R_OK) {
- LOG(ERROR) << "Request fail";
- return PMINFO_R_ERROR;
- }
+ if (ptr->GetRequestResult() != PMINFO_R_OK) {
+ LOG(ERROR) << "Request fail";
+ return PMINFO_R_ERROR;
+ }
- if (ptr->GetType() != pkgmgr_common::parcel::ParcelableType::Result) {
- LOG(ERROR) << "Invalid parcelable type";
- return PMINFO_R_ERROR;
- }
+ if (ptr->GetType() != pcp::ParcelableType::Result) {
+ LOG(ERROR) << "Invalid parcelable type";
+ return PMINFO_R_ERROR;
+ }
- return PMINFO_R_OK;
+ return PMINFO_R_OK;
}