2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "manager/pkginfo_manager.h"
19 #include <sys/types.h>
26 #include "pkgmgrinfo_private.h"
29 #include "common/database/abstract_db_handler.hh"
30 #include "common/parcel/appinfo_parcelable.hh"
31 #include "common/parcel/filter_parcelable.hh"
32 #include "common/parcel/pkginfo_parcelable.hh"
33 #include "common/parcel/query_parcelable.hh"
34 #include "common/parcel/result_parcelable.hh"
36 #include "client/pkginfo_client.hh"
43 #define LOG_TAG "PKGMGR_INFO"
48 #define EXPORT_API __attribute__((visibility("default")))
50 extern "C" EXPORT_API int _pkginfo_get_packages(uid_t uid,
51 pkgmgrinfo_filter_x *filter, int flag, GHashTable *packages) {
52 std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcelable(
53 new pkgmgr_common::parcel::FilterParcelable(uid,
54 static_cast<pkgmgrinfo_filter_x*>(filter), flag));
56 pkgmgr_client::PkgInfoClient client(parcelable, uid,
57 pkgmgr_common::ReqType::GET_PKG_INFO);
58 if (!client.SendRequest())
59 return PMINFO_R_ERROR;
61 std::shared_ptr<pkgmgr_common::parcel::PkgInfoParcelable> return_parcel(
62 std::static_pointer_cast<pkgmgr_common::parcel::PkgInfoParcelable>(
63 client.GetResultParcel()));
65 tizen_base::Parcel parcel;
66 parcel.ReadParcelable(return_parcel.get());
68 auto result_list = return_parcel->GetPkgInfo();
69 // TODO: check noentry error has returned if size of result_list is 0
70 for (auto& pkginfo : result_list)
71 g_hash_table_insert(packages, (gpointer)pkginfo->package,
77 // TODO: Need to add target db uid to identify which database to be searched
78 extern "C" EXPORT_API int _appinfo_get_applications(uid_t db_uid, uid_t uid,
79 pkgmgrinfo_filter_x *filter, int flag, GHashTable *packages) {
80 std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcelable(
81 new pkgmgr_common::parcel::FilterParcelable(uid,
82 static_cast<pkgmgrinfo_filter_x*>(filter), flag));
84 pkgmgr_client::PkgInfoClient client(parcelable, uid, pkgmgr_common::ReqType::GET_APP_INFO);
85 if (!client.SendRequest())
86 return PMINFO_R_ERROR;
88 std::shared_ptr<pkgmgr_common::parcel::AppInfoParcelable> return_parcel(
89 std::static_pointer_cast<pkgmgr_common::parcel::AppInfoParcelable>(
90 client.GetResultParcel()));
92 tizen_base::Parcel parcel;
93 parcel.ReadParcelable(return_parcel.get());
94 auto result_list = return_parcel->GetAppInfo();
95 for (auto& appinfo : result_list)
96 g_hash_table_insert(packages, (gpointer)appinfo->appid,
102 extern "C" EXPORT_API char *_appinfo_get_localed_label(
103 const char *appid, const char *locale, uid_t uid) {
104 char *query = nullptr;
105 query = sqlite3_mprintf(
106 "SELECT COALESCE((SELECT app_label FROM package_app_localized_info "
107 "WHERE app_id=%Q AND app_locale=%Q),"
108 "(SELECT app_label FROM package_app_localized_info WHERE "
109 "app_id=%Q AND app_locale='No Locale'))", appid, locale, appid);
110 if (query == nullptr) {
111 LOG(ERROR) << "Out of memory";
115 std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcelable(
116 new pkgmgr_common::parcel::QueryParcelable(uid, std::string(query),
117 pkgmgr_common::database::AbstractDBHandler::DBType::DB_TYPE_FILE_PKGDB,
118 pkgmgr_common::database::AbstractDBHandler::OperationType::OPERATION_TYPE_READ));
120 pkgmgr_client::PkgInfoClient client(parcelable, uid,
121 pkgmgr_common::ReqType::QUERY);
122 if (!client.SendRequest()) {
127 std::shared_ptr<pkgmgr_common::parcel::ResultParcelable> return_parcel(
128 std::static_pointer_cast<pkgmgr_common::parcel::ResultParcelable>(
129 client.GetResultParcel()));
130 tizen_base::Parcel parcel;
131 parcel.ReadParcelable(return_parcel.get());
133 // result_list is vector of string vector
134 char *label = nullptr;
135 auto result_list = return_parcel->GetResult();
136 for (auto result : result_list) {
137 // result is string vector
138 // it only has one string or not.
139 if (result.front().empty() || result.front().length() == 0)
141 label = strdup(result.front().c_str());
142 if (label == nullptr) {
143 LOG(ERROR) << "Out of memory";
152 extern "C" EXPORT_API int _appinfo_get_datacontrol_info(
153 const char *providerid, const char *type, uid_t uid,
154 char **appid, char **access) {
155 char *query = nullptr;
156 query = sqlite3_mprintf("SELECT app_id, access FROM "
157 "package_app_data_control WHERE "
158 "providerid=%Q AND type=%Q", providerid, type);
159 if (query == nullptr) {
160 LOG(ERROR) << "Out of memory";
161 return PMINFO_R_ERROR;
164 std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcelable(
165 new pkgmgr_common::parcel::QueryParcelable(uid, std::string(query),
166 pkgmgr_common::database::AbstractDBHandler::DBType::DB_TYPE_FILE_PKGDB,
167 pkgmgr_common::database::AbstractDBHandler::OperationType::OPERATION_TYPE_READ));
169 pkgmgr_client::PkgInfoClient client(parcelable, uid,
170 pkgmgr_common::ReqType::QUERY);
171 if (!client.SendRequest()) {
173 return PMINFO_R_ERROR;
176 std::shared_ptr<pkgmgr_common::parcel::ResultParcelable> return_parcel(
177 std::static_pointer_cast<pkgmgr_common::parcel::ResultParcelable>(
178 client.GetResultParcel()));
179 tizen_base::Parcel parcel;
180 parcel.ReadParcelable(return_parcel.get());
182 // result_list is vector of string vector
183 auto result_list = return_parcel->GetResult();
184 if (result_list.size() == 0)
185 return PMINFO_R_ENOENT;
186 for (auto result : result_list) {
187 if (result.size() != 2)
188 return PMINFO_R_ERROR;
189 if (result.front().empty() || result.front().size() == 0 ||
190 result.back().empty() || result.back().size() == 0)
191 return PMINFO_R_ERROR;
192 *appid = strdup(result.front().c_str());
193 *access = strdup(result.back().c_str());
194 if (*appid == nullptr || *access == nullptr) {
195 LOG(ERROR) << "Out of memory";
196 return PMINFO_R_ERROR;
203 extern "C" EXPORT_API int _appinfo_get_datacontrol_appid(
204 const char *providerid, uid_t uid, char **appid) {
205 char *query = nullptr;
207 query = sqlite3_mprintf("SELECT app_id FROM package_app_data_control "
208 "WHERE providerid=%Q", providerid);
210 LOGE("Out of memory");
211 return PMINFO_R_ERROR;
213 std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcelable(
214 new pkgmgr_common::parcel::QueryParcelable(uid, std::string(query),
215 pkgmgr_common::database::AbstractDBHandler::DBType::DB_TYPE_FILE_PKGDB,
216 pkgmgr_common::database::AbstractDBHandler::OperationType::OPERATION_TYPE_READ));
218 pkgmgr_client::PkgInfoClient client(parcelable, uid,
219 pkgmgr_common::ReqType::QUERY);
220 if (!client.SendRequest()) {
222 return PMINFO_R_ERROR;
224 // TODO: deliver rawdata to reqhandler directly if server is not working
226 std::shared_ptr<pkgmgr_common::parcel::ResultParcelable> return_parcel(
227 std::static_pointer_cast<pkgmgr_common::parcel::ResultParcelable>(
228 client.GetResultParcel()));
229 tizen_base::Parcel parcel;
230 parcel.ReadParcelable(return_parcel.get());
233 // result_list is vector of string vector
234 auto result_list = return_parcel->GetResult();
235 if (result_list.size() == 0)
236 return PMINFO_R_ENOENT;
237 for (auto result : result_list) {
238 if (result.size() != 1)
239 return PMINFO_R_ERROR;
240 if (result.front().empty() || result.front().size() == 0)
241 return PMINFO_R_ERROR;
242 *appid = strdup(result.front().c_str());
243 if (*appid == nullptr) {
244 LOG(ERROR) << "Out of memory";
245 return PMINFO_R_ERROR;
252 extern "C" EXPORT_API int _appinfo_get_datacontrol_trusted_info(
253 const char *providerid, const char *type, uid_t uid,
254 char **appid, char **trusted) {
255 char *query = nullptr;
256 query = sqlite3_mprintf(
257 "SELECT app_id, trusted FROM package_app_data_control "
258 "WHERE providerid=%Q AND type=%Q", providerid, type);
260 LOGE("Out of memory");
261 return PMINFO_R_ERROR;
264 std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcelable(
265 new pkgmgr_common::parcel::QueryParcelable(uid, std::string(query),
266 pkgmgr_common::database::AbstractDBHandler::DBType::DB_TYPE_FILE_PKGDB,
267 pkgmgr_common::database::AbstractDBHandler::OperationType::OPERATION_TYPE_READ));
269 pkgmgr_client::PkgInfoClient client(parcelable, uid,
270 pkgmgr_common::ReqType::QUERY);
271 if (!client.SendRequest()) {
273 return PMINFO_R_ERROR;
275 // TODO: deliver rawdata to reqhandler directly if server is not working
277 std::shared_ptr<pkgmgr_common::parcel::ResultParcelable> return_parcel(
278 std::static_pointer_cast<pkgmgr_common::parcel::ResultParcelable>(
279 client.GetResultParcel()));
280 tizen_base::Parcel parcel;
281 parcel.ReadParcelable(return_parcel.get());
283 // result_list is vector of string vector
284 auto result_list = return_parcel->GetResult();
285 if (result_list.size() == 0)
286 return PMINFO_R_ENOENT;
287 for (auto result : result_list) {
288 if (result.size() != 2)
289 return PMINFO_R_ERROR;
290 if (result.front().empty() || result.front().size() == 0 ||
291 result.back().empty() || result.back().size() == 0)
292 return PMINFO_R_ERROR;
293 *appid = strdup(result.front().c_str());
294 *trusted = strdup(result.back().c_str());
295 if (*appid == nullptr || *trusted == nullptr) {
296 LOG(ERROR) << "Out of memory";
297 return PMINFO_R_ERROR;
304 extern "C" EXPORT_API int _appinfo_get_datacontrol_privileges(
305 const char *providerid, const char *type, uid_t uid,
306 GList **privileges) {
307 char *query = nullptr;
308 query = sqlite3_mprintf(
309 "SELECT privilege FROM package_app_data_control_privilege "
310 "WHERE providerid=%Q AND type=%Q", providerid, type);
312 LOGE("Out of memory");
313 return PMINFO_R_ERROR;
316 std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcelable(
317 new pkgmgr_common::parcel::QueryParcelable(uid, std::string(query),
318 pkgmgr_common::database::AbstractDBHandler::DBType::DB_TYPE_FILE_PKGDB,
319 pkgmgr_common::database::AbstractDBHandler::OperationType::OPERATION_TYPE_READ));
321 pkgmgr_client::PkgInfoClient client(parcelable, uid,
322 pkgmgr_common::ReqType::QUERY);
323 if (!client.SendRequest()) {
325 return PMINFO_R_ERROR;
327 // TODO: deliver rawdata to reqhandler directly if server is not working
329 std::shared_ptr<pkgmgr_common::parcel::ResultParcelable> return_parcel(
330 std::static_pointer_cast<pkgmgr_common::parcel::ResultParcelable>(
331 client.GetResultParcel()));
332 tizen_base::Parcel parcel;
333 parcel.ReadParcelable(return_parcel.get());
335 // result_list is vector of string vector
336 auto result_list = return_parcel->GetResult();
337 if (result_list.size() == 0)
338 return PMINFO_R_ENOENT;
340 for (auto result : result_list) {
341 if (result.size() != 1)
342 return PMINFO_R_ERROR;
343 if (result.front().empty() || result.front().size() == 0)
344 return PMINFO_R_ERROR;
345 char *privilege = strdup(result.front().c_str());
346 if (privilege == nullptr) {
347 LOG(ERROR) << "Out of memory";
348 return PMINFO_R_ERROR;
350 *privileges = g_list_append(*privileges, privilege);
356 extern "C" EXPORT_API int _appinfo_get_appcontrol_privileges(
357 const char *appid, const char *operation, uid_t uid, GList **privileges) {
358 char *query = nullptr;
359 query = sqlite3_mprintf(
360 "SELECT app_control, privilege FROM package_app_app_control_privilege "
361 "WHERE app_id=%Q", appid);
363 LOG(ERROR) << "Out of memory";
364 return PMINFO_R_ERROR;
367 std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcelable(
368 new pkgmgr_common::parcel::QueryParcelable(uid, std::string(query),
369 pkgmgr_common::database::AbstractDBHandler::DBType::DB_TYPE_FILE_PKGDB,
370 pkgmgr_common::database::AbstractDBHandler::OperationType::OPERATION_TYPE_READ));
372 pkgmgr_client::PkgInfoClient client(parcelable, uid,
373 pkgmgr_common::ReqType::QUERY);
374 if (!client.SendRequest()) {
376 return PMINFO_R_ERROR;
378 // TODO: deliver rawdata to reqhandler directly if server is not working
380 std::shared_ptr<pkgmgr_common::parcel::ResultParcelable> return_parcel(
381 std::static_pointer_cast<pkgmgr_common::parcel::ResultParcelable>(
382 client.GetResultParcel()));
383 tizen_base::Parcel parcel;
384 parcel.ReadParcelable(return_parcel.get());
386 // result_list is vector of string vector
387 auto result_list = return_parcel->GetResult();
388 if (result_list.size() == 0)
389 return PMINFO_R_ENOENT;
391 for (auto result : result_list) {
392 if (result.size() != 2)
393 return PMINFO_R_ERROR;
394 if (result.front().empty() || result.front().size() == 0 ||
395 result.back().empty() || result.back().size() == 0)
396 return PMINFO_R_ERROR;
397 std::string app_control = result.front();
398 std::stringstream ss(app_control);
400 while (std::getline(ss, token, '|')) {
401 if (token.compare(std::string(operation))) {
402 char *privilege = strdup(result.back().c_str());
403 if (privilege == nullptr) {
404 LOG(ERROR) << "Out of memory";
405 return PMINFO_R_ERROR;
407 *privileges = g_list_append(*privileges, privilege);
414 extern "C" EXPORT_API int _plugininfo_get_appids(
415 const char *pkgid, const char *plugin_type,
416 const char *plugin_name, GList **list) {
417 if (!pkgid || !plugin_type || !plugin_name || !list) {
418 LOG(ERROR) << "Invalid parameter";
419 return PMINFO_R_EINVAL;
422 char *query = nullptr;
423 query = sqlite3_mprintf(
425 "package_plugin_info WHERE pkgid=%Q AND "
426 "plugin_type=%Q AND plugin_name=%Q",
427 pkgid, plugin_type, plugin_name);
429 LOG(ERROR) << "Out of memory";
430 return PMINFO_R_ERROR;
433 std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcelable(
434 new pkgmgr_common::parcel::QueryParcelable(_getuid(), std::string(query),
435 pkgmgr_common::database::AbstractDBHandler::DBType::DB_TYPE_FILE_PKGDB,
436 pkgmgr_common::database::AbstractDBHandler::OperationType::OPERATION_TYPE_READ));
439 pkgmgr_client::PkgInfoClient client(parcelable, _getuid(),
440 pkgmgr_common::ReqType::QUERY);
441 if (!client.SendRequest()) {
442 return PMINFO_R_ERROR;
445 std::shared_ptr<pkgmgr_common::parcel::ResultParcelable> return_parcel(
446 std::static_pointer_cast<pkgmgr_common::parcel::ResultParcelable>(
447 client.GetResultParcel()));
448 if (return_parcel->GetCol() != 1) {
449 LOG(ERROR) << "Invalid result";
450 return PMINFO_R_ERROR;
452 // result_list is vector of string vector
453 auto result_list = return_parcel->GetResult();
454 if (result_list.size() == 0)
455 return PMINFO_R_ENOENT;
457 for (auto result : result_list) {
458 if (result.size() != 1) {
459 LOG(ERROR) << "Invalid result";
460 g_list_free_full(*list, free);
461 return PMINFO_R_ERROR;
463 *list = g_list_append(*list, strdup(result[0].c_str()));
469 static int __convert_update_type(const char *type, pkgmgrinfo_updateinfo_update_type *convert_type)
471 if (strncasecmp(type, PMINFO_UPDATEINFO_TYPE_NONE,
472 strlen(PMINFO_UPDATEINFO_TYPE_NONE)) == 0)
473 *convert_type = PMINFO_UPDATEINFO_NONE;
474 else if (strncasecmp(type, PMINFO_UPDATEINFO_TYPE_FORCE,
475 strlen(PMINFO_UPDATEINFO_TYPE_FORCE)) == 0)
476 *convert_type = PMINFO_UPDATEINFO_FORCE;
477 else if (strncasecmp(type, PMINFO_UPDATEINFO_TYPE_OPTIONAL,
478 strlen(PMINFO_UPDATEINFO_TYPE_OPTIONAL)) == 0)
479 *convert_type = PMINFO_UPDATEINFO_OPTIONAL;
485 static void __free_update_info(gpointer data)
487 updateinfo_x *update_info = (updateinfo_x *)data;
488 if (update_info == NULL)
491 if (update_info->pkgid)
492 free((void *)update_info->pkgid);
493 if (update_info->version)
494 free((void *)update_info->version);
495 free((void *)update_info);
499 extern "C" EXPORT_API int _get_pkg_updateinfo(const char *pkgid,
500 GSList **update_info_list, uid_t uid)
502 char *query = nullptr;
506 query = sqlite3_mprintf(
507 "SELECT package, update_version, update_type "
508 "FROM package_update_info");
510 query = sqlite3_mprintf(
511 "SELECT package, update_version, update_type "
512 "FROM package_update_info WHERE package=%Q",
515 LOG(ERROR) << "Out of memory";
516 return PMINFO_R_ERROR;
519 std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcelable(
520 new pkgmgr_common::parcel::QueryParcelable(uid, std::string(query),
521 pkgmgr_common::database::AbstractDBHandler::DBType::DB_TYPE_FILE_PKGDB,
522 pkgmgr_common::database::AbstractDBHandler::OperationType::OPERATION_TYPE_READ));
525 pkgmgr_client::PkgInfoClient client(parcelable, uid,
526 pkgmgr_common::ReqType::QUERY);
527 if (!client.SendRequest()) {
528 return PMINFO_R_ERROR;
531 std::shared_ptr<pkgmgr_common::parcel::ResultParcelable> return_parcel(
532 std::static_pointer_cast<pkgmgr_common::parcel::ResultParcelable>(
533 client.GetResultParcel()));
534 if (return_parcel->GetCol() != 3) {
535 LOG(ERROR) << "Invalid result";
536 return PMINFO_R_ERROR;
539 auto result_list = return_parcel->GetResult();
540 if (result_list.size() == 0)
541 return PMINFO_R_ENOENT;
543 for (auto result : result_list) {
544 if (result.size() != 3) {
545 LOG(ERROR) << "Invalid result";
546 g_slist_free_full(*update_info_list, __free_update_info);
547 return PMINFO_R_ERROR;
549 updateinfo_x *update_info = reinterpret_cast<updateinfo_x *>(calloc(1, sizeof(updateinfo_x)));
550 if (update_info == NULL) {
551 LOG(ERROR) << "Out of memory";
552 return PMINFO_R_ERROR;
554 update_info->pkgid = strdup(result[0].c_str());
555 update_info->version = strdup(result[1].c_str());
556 pkgmgrinfo_updateinfo_update_type convert_type;
557 ret = __convert_update_type(result[2].c_str(), &convert_type);
559 __free_update_info(update_info);
560 g_slist_free_full(*update_info_list, __free_update_info);
561 return PMINFO_R_ERROR;
563 update_info->type = static_cast<int>(convert_type);
564 *update_info_list = g_slist_prepend(*update_info_list,
571 extern "C" EXPORT_API int _pkginfo_set_usr_installed_storage(const char *pkgid,
572 INSTALL_LOCATION location, const char *external_pkg_path,
576 const char *location_str;
577 std::vector<std::string> queries;
579 if (location == INSTALL_INTERNAL)
580 location_str = "installed_internal";
581 else if (location == INSTALL_EXTERNAL)
582 location_str = "installed_external";
584 location_str = "installed_extended";
585 /* pkgcakge_info table */
586 query = sqlite3_mprintf(
587 "update package_info set installed_storage=%Q, external_path=%Q where package=%Q",
588 location_str, external_pkg_path, pkgid);
589 queries.emplace_back(query);
592 /* package_app_info table */
593 query = sqlite3_mprintf(
594 "update package_app_info set app_installed_storage=%Q, app_external_path=%Q where package=%Q",
595 location_str, external_pkg_path, pkgid);
596 queries.emplace_back(query);
599 std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcelable(
600 new pkgmgr_common::parcel::QueryParcelable(uid, queries,
601 pkgmgr_common::database::AbstractDBHandler::DBType::DB_TYPE_FILE_PKGDB,
602 pkgmgr_common::database::AbstractDBHandler::OperationType::OPERATION_TYPE_WRITE));
604 pkgmgr_client::PkgInfoClient client(parcelable, uid,
605 pkgmgr_common::ReqType::QUERY);
606 if (!client.SendRequest()) {
607 return PMINFO_R_ERROR;
610 std::shared_ptr<pkgmgr_common::parcel::ResultParcelable> return_parcel(
611 std::static_pointer_cast<pkgmgr_common::parcel::ResultParcelable>(
612 client.GetResultParcel()));
614 auto result_list = return_parcel->GetResult();
615 if (result_list.size() != 1) {
616 LOG(ERROR) << "Invalid result";
617 return PMINFO_R_ERROR;
620 if (result_list[0].size() != 1) {
621 LOG(ERROR) << "Invalid result";
622 return PMINFO_R_ERROR;
625 LOG(ERROR) << "result : " << result_list[0][0];
626 if (result_list[0][0] != "SUCCESS")
627 return PMINFO_R_ERROR;
632 extern "C" EXPORT_API int _parser_execute_write_query(const char *query, uid_t uid)
634 std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcelable(
635 new pkgmgr_common::parcel::QueryParcelable(uid, query,
636 pkgmgr_common::database::AbstractDBHandler::DBType::DB_TYPE_FILE_PKGDB,
637 pkgmgr_common::database::AbstractDBHandler::OperationType::OPERATION_TYPE_WRITE));
639 pkgmgr_client::PkgInfoClient client(parcelable, uid,
640 pkgmgr_common::ReqType::QUERY);
641 if (!client.SendRequest()) {
645 std::shared_ptr<pkgmgr_common::parcel::ResultParcelable> return_parcel(
646 std::static_pointer_cast<pkgmgr_common::parcel::ResultParcelable>(
647 client.GetResultParcel()));
649 auto result_list = return_parcel->GetResult();
650 if (result_list.size() != 1) {
651 LOG(ERROR) << "Invalid result";
655 if (result_list[0].size() != 1) {
656 LOG(ERROR) << "Invalid result";
660 LOG(ERROR) << "result : " << result_list[0][0];
661 if (result_list[0][0] != "SUCCESS")
667 extern "C" EXPORT_API int _parser_execute_write_queries(const char **queries, int len, uid_t uid)
669 std::vector<std::string> query_vt;
670 for (int i = 0; i < len; ++i)
671 query_vt.emplace_back(queries[i]);
673 std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcelable(
674 new pkgmgr_common::parcel::QueryParcelable(uid, query_vt,
675 pkgmgr_common::database::AbstractDBHandler::DBType::DB_TYPE_FILE_PKGDB,
676 pkgmgr_common::database::AbstractDBHandler::OperationType::OPERATION_TYPE_WRITE));
678 pkgmgr_client::PkgInfoClient client(parcelable, uid,
679 pkgmgr_common::ReqType::QUERY);
680 if (!client.SendRequest()) {
684 std::shared_ptr<pkgmgr_common::parcel::ResultParcelable> return_parcel(
685 std::static_pointer_cast<pkgmgr_common::parcel::ResultParcelable>(
686 client.GetResultParcel()));
688 auto result_list = return_parcel->GetResult();
689 if (result_list.size() != 1) {
690 LOG(ERROR) << "Invalid result";
694 if (result_list[0].size() != 1) {
695 LOG(ERROR) << "Invalid result";
699 LOG(ERROR) << "result : " << result_list[0][0];
700 if (result_list[0][0] != "SUCCESS")