-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;
- }
-
- std::shared_ptr<pkgmgr_common::parcel::ResultParcelable> return_parcel(
- std::static_pointer_cast<pkgmgr_common::parcel::ResultParcelable>(
- client.GetResultParcel()));
-
- auto result_list = return_parcel->GetResult();
- if (result_list.size() != 1) {
- LOG(ERROR) << "Invalid result";
- return PMINFO_R_ERROR;
- }
-
- if (result_list[0].size() != 1) {
- LOG(ERROR) << "Invalid result";
- return PMINFO_R_ERROR;
- }
-
- LOG(ERROR) << "result : " << result_list[0][0];
- if (result_list[0][0] != "SUCCESS")
- 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) {
+ const char* location_str;
+
+ if (location == INSTALL_INTERNAL)
+ location_str = "installed_internal";
+ else if (location == INSTALL_EXTERNAL)
+ location_str = "installed_external";
+ else
+ location_str = "installed_extended";
+
+ std::shared_ptr<pcp::AbstractParcelable> parcelable(
+ new pcp::QueryParcelable(uid, { {
+ QUERY_INDEX_PKGINFO_SET_USR_INSTALLED_STORAGE_1, {
+ location_str,
+ external_pkg_path,
+ pkgid
+ }
+ }, {
+ QUERY_INDEX_PKGINFO_SET_USR_INSTALLED_STORAGE_2, {
+ location_str,
+ external_pkg_path,
+ pkgid
+ }
+ },
+ },
+ pkgmgr_common::DBType::DB_TYPE_FILE_PKGDB,
+ pkgmgr_common::DBOperationType::OPERATION_TYPE_WRITE));
+
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
+ pkgmgr_common::ReqType::WRITE_QUERY);
+ if (!client.SendRequest())
+ return PMINFO_R_ERROR;
+
+ return ValidateParcelable(
+ client.GetResultParcel(), pcp::ParcelableType::Result);