4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
7 * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
29 #include <sys/types.h>
31 //Work around for https://bugs.tizen.org/jira/browse/TC-2399
32 #include <ail_vconf.h>
33 #include <pkgmgr_parser.h>
34 #include <pkgmgr-info.h>
35 #include "package-manager.h"
36 #include "package-manager-types.h"
37 #include "pkgmgr-dbinfo.h"
38 #include "pkgmgr_installer.h"
42 static void __print_usage();
43 static int __get_pkg_info(char *pkgid, uid_t uid);
44 static int __get_app_info(char *appid);
45 static int __get_app_list(char *pkgid, uid_t uid);
46 static int __get_app_category_list(char *appid);
47 static int __get_app_metadata_list(char *appid);
48 static int __get_app_control_list(char *appid);
49 static int __get_pkg_list(uid_t uid);
50 static int __get_installed_app_list(uid_t uid);
51 static int __add_app_filter(uid_t uid);
52 static int __add_pkg_filter(uid_t uid);
53 static int __insert_manifest_in_db(char *manifest, uid_t uid);
54 static int __remove_manifest_from_db(char *manifest, uid_t uid);
55 static int __set_pkginfo_in_db(char *pkgid, uid_t uid);
56 static int __set_certinfo_in_db(char *pkgid, uid_t uid);
57 static int __get_certinfo_from_db(char *pkgid, uid_t uid);
58 static int __del_certinfo_from_db(char *pkgid);
59 static int __get_integer_input_data(void);
60 char *__get_string_input_data(void);
61 static int __pkg_list_cb (const pkgmgr_pkginfo_h handle, void *user_data);
62 static int __app_category_list_cb(const char *category_name, void *user_data);
63 static int __app_control_list_cb(const char *operation, const char *uri, const char *mime, void *user_data);
64 static int __app_metadata_list_cb(const char *metadata_name, const char *metadata_value, void *user_data);
65 int app_func(const pkgmgr_appinfo_h handle, void *user_data);
67 static void __get_pkgmgrinfo_pkginfo(const pkgmgrinfo_pkginfo_h handle, void *user_data)
72 char *author_name = NULL;
73 char *author_email = NULL;
74 char *author_href = NULL;
75 char *root_path = NULL;
76 char *mainappid = NULL;
77 pkgmgr_install_location location = 0;
87 int installed_time = -1;
89 ret = pkgmgrinfo_pkginfo_get_type(handle, &type);
91 printf("Failed to get pkg type\n");
94 printf("Type: %s\n", type);
96 ret = pkgmgrinfo_pkginfo_get_version(handle, &version);
98 printf("Failed to get version\n");
101 printf("Version: %s\n", version);
103 ret = pkgmgrinfo_pkginfo_get_install_location(handle, &location);
105 printf("Failed to get install location\n");
107 printf("Install Location: %d\n", location);
109 ret = pkgmgrinfo_pkginfo_get_package_size(handle, &size);
111 printf("Failed to get package size \n");
113 printf("Package Size: %d\n", size);
115 ret = pkgmgrinfo_pkginfo_get_icon(handle, &icon);
117 printf("Failed to get icon\n");
120 printf("Icon: %s\n", icon);
122 ret = pkgmgrinfo_pkginfo_get_label(handle, &label);
124 printf("Failed to get label\n");
127 printf("Label: %s\n", label);
129 ret = pkgmgrinfo_pkginfo_get_description(handle, &desc);
131 printf("Failed to get description\n");
134 printf("Description: %s\n", desc);
136 ret = pkgmgrinfo_pkginfo_get_author_name(handle, &author_name);
138 printf("Failed to get author name\n");
141 printf("Author Name: %s\n", author_name);
143 ret = pkgmgrinfo_pkginfo_get_author_email(handle, &author_email);
145 printf("Failed to get author email\n");
148 printf("Author Email: %s\n", author_email);
150 ret = pkgmgrinfo_pkginfo_get_author_href(handle, &author_href);
152 printf("Failed to get author href\n");
155 printf("Author Href: %s\n", author_href);
157 ret = pkgmgrinfo_pkginfo_get_root_path(handle, &root_path);
159 printf("Failed to get root_path\n");
162 printf("root_path : %s\n", root_path);
164 ret = pkgmgrinfo_pkginfo_get_mainappid(handle, &mainappid);
166 printf("Failed to get mainappid\n");
169 printf("mainappid : %s\n", mainappid);
171 ret = pkgmgrinfo_pkginfo_get_installed_time(handle, &installed_time);
173 printf("Failed to get install time\n");
175 printf("Install time: %d\n", installed_time);
177 ret = pkgmgrinfo_pkginfo_is_removable(handle, &removable);
179 printf("Failed to get removable\n");
182 printf("Removable: %d\n", removable);
184 ret = pkgmgrinfo_pkginfo_is_preload(handle, &preload);
186 printf("Failed to get preload\n");
189 printf("Preload: %d\n", preload);
191 ret = pkgmgrinfo_pkginfo_is_readonly(handle, &readonly);
193 printf("Failed to get readonly\n");
196 printf("Readonly: %d\n", readonly);
198 ret = pkgmgrinfo_pkginfo_is_update(handle, &update);
200 printf("Failed to get update\n");
203 printf("update: %d\n", update);
205 ret = pkgmgrinfo_pkginfo_is_system(handle, &system);
207 printf("Failed to get system\n");
210 printf("system: %d\n", system);
214 int __get_app_id(const pkgmgrinfo_appinfo_h handle, void *user_data)
217 char *apptype = NULL;
220 ret = pkgmgrinfo_appinfo_get_appid(handle, &appid);
222 printf("Failed to get appid\n");
225 ret = pkgmgrinfo_appinfo_get_apptype(handle, &apptype);
227 printf("Failed to get package\n");
229 printf("apptype [%s]\t appid [%s]\n", apptype, appid);
234 static int __get_integer_input_data(void)
236 char input_str[32] = { 0, };
239 if (fgets(input_str, sizeof(input_str), stdin) == NULL) {
240 printf("fgets() failed....\n");
244 if (sscanf(input_str, "%4d", &data) != 1) {
245 printf("Input only integer option....\n");
253 char *__get_string_input_data(void)
255 char *data = (char *)malloc(1024);
257 printf("Malloc Failed\n");
260 if (fgets(data,1024,stdin) == NULL){
261 printf("Buffer overflow!!! try again\n");
264 data[strlen(data) - 1] = '\0';
268 static void __print_usage()
270 printf("For Getting package|App Info\n");
271 printf("\tpkginfo --[pkg|app] <pkgid|appid>\n\n");
272 printf("For Getting list of installed packages\n");
273 printf("\tpkginfo --listpkg \n\n");
274 printf("For Getting list of installed applications\n");
275 printf("\tpkginfo --listapp \n\n");
276 printf("For Getting app list for a particular package\n");
277 printf("\tpkginfo --list <pkgid>\n\n");
278 printf("For Getting app category list for a particular application\n");
279 printf("\tpkginfo --category <appid>\n\n");
280 printf("For Getting app metadata list for a particular application\n");
281 printf("\tpkginfo --metadata <appid>\n\n");
282 printf("For Getting app control list for a particular application\n");
283 printf("\tpkginfo --appcontrol <appid>\n\n");
284 printf("To insert|remove manifest info in DB\n");
285 printf("\tpkginfo --[imd|rmd] <manifest file name>\n\n");
286 printf("To set pkginfo in DB\n");
287 printf("\tpkginfo --setdb <pkgid>\n\n");
288 printf("To set manifest validation\n");
289 printf("\tpkginfo --check <manifest file name>\n\n");
290 printf("To set cert info in DB\n");
291 printf("\tpkginfo --setcert <pkgid>\n\n");
292 printf("To get cert info from DB\n");
293 printf("\tpkginfo --getcert <pkgid>\n\n");
294 printf("To compare pkg cert info from DB\n");
295 printf("\tpkginfo --cmp-pkgcert <lhs_pkgid> <rhs_pkgid>\n\n");
296 printf("To compare app cert info from DB\n");
297 printf("\tpkginfo --cmp-appcert <lhs_appid> <rhs_appid>\n\n");
298 printf("To delete all cert info from DB\n");
299 printf("\tpkginfo --delcert <pkgid>\n\n");
300 printf("To add application filter values [Multiple values can be added]\n");
301 printf("\tpkginfo --app-flt\n\n");
302 printf("To add package filter values [Multiple values can be added]\n");
303 printf("\tpkginfo --pkg-flt\n\n");
304 printf("To add metadata filter values\n");
305 printf("\tpkginfo --metadata-flt\n\n");
308 static void __print_arg_filter_usage()
310 printf("=========================================\n");
311 printf("pkginfo --arg-flt key value\n");
312 printf("ex : pkginfo --arg-flt 6 webapp\n");
313 printf("key list is bellowed\n");
314 printf("2 --> filter by app ID\n");
315 printf("3 --> filter by app component\n");
316 printf("4 --> filter by app exec\n");
317 printf("5 --> filter by app icon\n");
318 printf("6 --> filter by app type\n");
319 printf("7 --> filter by app operation\n");
320 printf("8 --> filter by app uri\n");
321 printf("9 --> filter by app mime\n");
322 printf("10 --> filter by app category\n");
323 printf("11 --> filter by app nodisplay [0|1]\n");
324 printf("12 --> filter by app multiple [0|1]\n");
325 printf("13 --> filter by app onboot [0|1]\n");
326 printf("14 --> filter by app autorestart [0|1]\n");
327 printf("15 --> filter by app taskmanage [0|1]\n");
328 printf("16 --> filter by app hwacceleration\n");
329 printf("17 --> filter by app screenreader\n");
330 printf("=========================================\n");
333 static int __app_list_cb(pkgmgrinfo_appinfo_h handle, void *user_data)
336 pkgmgrinfo_appinfo_get_appid(handle, &appid);
337 printf("appid : %s\n", appid);
341 static int __add_metadata_filter()
344 pkgmgrinfo_appinfo_metadata_filter_h handle;
348 ret = pkgmgrinfo_appinfo_metadata_filter_create(&handle);
349 if (ret != PMINFO_R_OK){
350 printf("pkgmgrinfo_appinfo_metadata_filter_create() failed\n");
354 printf("enter metadata - key\n");
355 key = __get_string_input_data();
356 printf("enter metadata - value\n");
357 value = __get_string_input_data();
359 printf("filter condition : key=[%s], value=[%s]\n", key, value);
361 ret = pkgmgrinfo_appinfo_metadata_filter_add(handle, key, value);
362 if (ret != PMINFO_R_OK){
363 printf("pkgmgrinfo_appinfo_metadata_filter_add() failed\n");
367 ret = pkgmgrinfo_appinfo_metadata_filter_foreach(handle, __app_list_cb, NULL);
368 if (ret != PMINFO_R_OK){
369 printf("pkgmgrinfo_appinfo_metadata_filter_add() failed\n");
374 pkgmgrinfo_appinfo_metadata_filter_destroy(handle);
386 static int __add_app_filter(uid_t uid)
393 pkgmgrinfo_appinfo_filter_h handle;
394 ret = pkgmgrinfo_appinfo_filter_create(&handle);
396 printf("appinfo filter handle create failed\n");
399 while (choice != 0 && choice != 1)
401 printf("Enter Choice\n");
402 printf("0 --> Finalize filter and get count of apps\n");
403 printf("1 --> Finalize filter and get list of apps\n");
404 printf("2 --> filter by app ID\n");
405 printf("3 --> filter by app component\n");
406 printf("4 --> filter by app exec\n");
407 printf("5 --> filter by app icon\n");
408 printf("6 --> filter by app type\n");
409 printf("7 --> filter by app operation\n");
410 printf("8 --> filter by app uri\n");
411 printf("9 --> filter by app mime\n");
412 printf("10 --> filter by app category\n");
413 printf("11 --> filter by app nodisplay [0|1]\n");
414 printf("12 --> filter by app multiple [0|1]\n");
415 printf("13 --> filter by app onboot [0|1]\n");
416 printf("14 --> filter by app autorestart [0|1]\n");
417 printf("15 --> filter by app taskmanage [0|1]\n");
418 printf("16 --> filter by app hwacceleration\n");
419 printf("17 --> filter by app screenreader\n");
420 choice = __get_integer_input_data();
423 ret = pkgmgrinfo_appinfo_filter_count(handle, &count);
425 printf("pkgmgrinfo_appinfo_filter_count() failed\n");
429 printf("App count = %d\n", count);
432 if (uid != GLOBAL_USER)
433 ret = pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, app_func, NULL, uid);
435 ret = pkgmgrinfo_appinfo_filter_foreach_appinfo(handle, app_func, NULL);
437 printf("pkgmgrinfo_appinfo_filter_foreach_appinfo() failed\n");
443 value = __get_string_input_data();
444 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
445 PMINFO_APPINFO_PROP_APP_ID, value);
447 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
455 value = __get_string_input_data();
456 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
457 PMINFO_APPINFO_PROP_APP_COMPONENT, value);
459 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
467 value = __get_string_input_data();
468 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
469 PMINFO_APPINFO_PROP_APP_EXEC, value);
471 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
479 value = __get_string_input_data();
480 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
481 PMINFO_APPINFO_PROP_APP_ICON, value);
483 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
491 value = __get_string_input_data();
492 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
493 PMINFO_APPINFO_PROP_APP_TYPE, value);
495 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
503 value = __get_string_input_data();
504 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
505 PMINFO_APPINFO_PROP_APP_OPERATION, value);
507 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
515 value = __get_string_input_data();
516 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
517 PMINFO_APPINFO_PROP_APP_URI, value);
519 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
527 value = __get_string_input_data();
528 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
529 PMINFO_APPINFO_PROP_APP_MIME, value);
531 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
539 value = __get_string_input_data();
540 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
541 PMINFO_APPINFO_PROP_APP_CATEGORY, value);
543 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
551 val = __get_integer_input_data();
552 ret = pkgmgrinfo_appinfo_filter_add_bool(handle,
553 PMINFO_APPINFO_PROP_APP_NODISPLAY, val);
555 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
561 val = __get_integer_input_data();
562 ret = pkgmgrinfo_appinfo_filter_add_bool(handle,
563 PMINFO_APPINFO_PROP_APP_MULTIPLE, val);
565 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
571 val = __get_integer_input_data();
572 ret = pkgmgrinfo_appinfo_filter_add_bool(handle,
573 PMINFO_APPINFO_PROP_APP_ONBOOT, val);
575 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
581 val = __get_integer_input_data();
582 ret = pkgmgrinfo_appinfo_filter_add_bool(handle,
583 PMINFO_APPINFO_PROP_APP_AUTORESTART, val);
585 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
591 val = __get_integer_input_data();
592 ret = pkgmgrinfo_appinfo_filter_add_bool(handle,
593 PMINFO_APPINFO_PROP_APP_TASKMANAGE, val);
595 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
601 value = __get_string_input_data();
602 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
603 PMINFO_APPINFO_PROP_APP_HWACCELERATION, value);
605 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
613 value = __get_string_input_data();
614 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
615 PMINFO_APPINFO_PROP_APP_SCREENREADER, value);
617 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
625 printf("Invalid filter property\n");
626 pkgmgrinfo_appinfo_filter_destroy(handle);
633 pkgmgrinfo_appinfo_filter_destroy(handle);
641 static int __add_pkg_filter(uid_t uid)
648 pkgmgrinfo_pkginfo_filter_h handle;
650 ret = pkgmgrinfo_pkginfo_filter_create(&handle);
652 printf("pkginfo filter handle create failed\n");
655 while (choice != 0 && choice !=1)
657 printf("Enter Choice\n");
658 printf("0 --> Finalize filter and get count of packages\n");
659 printf("1 --> Finalize filter and get list of packages\n");
660 printf("2 --> filter by package ID\n");
661 printf("3 --> filter by package version\n");
662 printf("4 --> filter by package type\n");
663 printf("5 --> filter by package install location\n");
664 printf("6 --> filter by author name\n");
665 printf("7 --> filter by author email\n");
666 printf("8 --> filter by author href\n");
667 printf("9 --> filter by package removable [0|1]\n");
668 printf("10 --> filter by package readonly [0|1]\n");
669 printf("11 --> filter by package preload [0|1]\n");
670 printf("12 --> filter by package update [0|1]\n");
671 printf("13 --> filter by package appsetting [0|1]\n");
672 printf("14 --> filter by package size\n");
673 printf("15 --> filter by package installed storage[installed_internal | installed_external]\n");
674 choice = __get_integer_input_data();
677 if (uid != GLOBAL_USER)
678 ret = pkgmgrinfo_pkginfo_usr_filter_count(handle, &count, uid);
680 ret = pkgmgrinfo_pkginfo_filter_count(handle, &count);
682 printf("pkgmgrinfo_pkginfo_filter_count() failed\n");
686 printf("Package count = %d\n", count);
689 if (uid != GLOBAL_USER)
690 ret = pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo(handle, __pkg_list_cb, NULL, uid);
692 ret = pkgmgrinfo_pkginfo_filter_foreach_pkginfo(handle, __pkg_list_cb, NULL);
694 printf("pkgmgrinfo_pkginfo_(usr)_filter_foreach_pkginfo() failed\n");
700 value = __get_string_input_data();
701 ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
702 PMINFO_PKGINFO_PROP_PACKAGE_ID, value);
704 printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
712 value = __get_string_input_data();
713 ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
714 PMINFO_PKGINFO_PROP_PACKAGE_VERSION, value);
716 printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
724 value = __get_string_input_data();
725 ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
726 PMINFO_PKGINFO_PROP_PACKAGE_TYPE, value);
728 printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
736 value = __get_string_input_data();
737 ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
738 PMINFO_PKGINFO_PROP_PACKAGE_INSTALL_LOCATION, value);
740 printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
748 value = __get_string_input_data();
749 ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
750 PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_NAME, value);
752 printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
760 value = __get_string_input_data();
761 ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
762 PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_EMAIL, value);
764 printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
772 value = __get_string_input_data();
773 ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
774 PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_HREF, value);
776 printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
784 val = __get_integer_input_data();
785 ret = pkgmgrinfo_pkginfo_filter_add_bool(handle,
786 PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE, val);
788 printf("pkgmgrinfo_pkginfo_filter_add_bool() failed\n");
794 val = __get_integer_input_data();
795 ret = pkgmgrinfo_pkginfo_filter_add_bool(handle,
796 PMINFO_PKGINFO_PROP_PACKAGE_READONLY, val);
798 printf("pkgmgrinfo_pkginfo_filter_add_bool() failed\n");
804 val = __get_integer_input_data();
805 ret = pkgmgrinfo_pkginfo_filter_add_bool(handle,
806 PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD, val);
808 printf("pkgmgrinfo_pkginfo_filter_add_bool() failed\n");
814 val = __get_integer_input_data();
815 ret = pkgmgrinfo_pkginfo_filter_add_bool(handle,
816 PMINFO_PKGINFO_PROP_PACKAGE_UPDATE, val);
818 printf("pkgmgrinfo_pkginfo_filter_add_bool() failed\n");
824 val = __get_integer_input_data();
825 ret = pkgmgrinfo_pkginfo_filter_add_bool(handle,
826 PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING, val);
828 printf("pkgmgrinfo_pkginfo_filter_add_bool() failed\n");
834 val = __get_integer_input_data();
835 ret = pkgmgrinfo_pkginfo_filter_add_int(handle,
836 PMINFO_PKGINFO_PROP_PACKAGE_SIZE, val);
838 printf("pkgmgrinfo_pkginfo_filter_add_int() failed\n");
844 value = __get_string_input_data();
845 ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
846 PMINFO_PKGINFO_PROP_PACKAGE_INSTALLED_STORAGE, value);
848 printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
856 printf("Invalid filter property\n");
857 pkgmgrinfo_pkginfo_filter_destroy(handle);
864 pkgmgrinfo_pkginfo_filter_destroy(handle);
872 static int __add_arg_filter(char *key, char *value, uid_t uid)
877 pkgmgrinfo_appinfo_filter_h handle;
878 ret = pkgmgrinfo_appinfo_filter_create(&handle);
880 printf("appinfo filter handle create failed\n");
887 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_ID, value);
889 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
895 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_COMPONENT, value);
897 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
903 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_EXEC, value);
905 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
911 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_ICON, value);
913 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
919 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_TYPE, value);
921 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
927 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_OPERATION, value);
929 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
935 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_URI, value);
937 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
943 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_MIME, value);
945 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
953 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_CATEGORY, value);
955 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
962 ret = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_NODISPLAY, val);
964 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
971 ret = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_MULTIPLE, val);
973 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
980 ret = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_ONBOOT, val);
982 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
989 ret = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_AUTORESTART, val);
991 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
998 ret = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_TASKMANAGE, val);
1000 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
1006 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_HWACCELERATION, value);
1008 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
1014 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_SCREENREADER, value);
1016 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
1023 __print_arg_filter_usage();
1026 if (uid != GLOBAL_USER)
1027 ret = pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, __get_app_id, NULL, uid);
1029 ret = pkgmgrinfo_appinfo_filter_foreach_appinfo(handle, __get_app_id, NULL);
1031 printf("pkgmgrinfo_appinfo_filter_foreach_appinfo() failed\n");
1037 pkgmgrinfo_appinfo_filter_destroy(handle);
1040 static int __del_certinfo_from_db(char *pkgid)
1043 if (pkgid == NULL) {
1044 printf("pkgid is NULL\n");
1047 ret = pkgmgr_installer_delete_certinfo(pkgid);
1049 printf("pkgmgr_installer_delete_certinfo failed\n");
1055 static int __get_certinfo_from_db(char *pkgid, uid_t uid)
1057 if (pkgid == NULL) {
1058 printf("pkgid is NULL\n");
1064 const char *value = NULL;
1065 pkgmgr_certinfo_h handle = NULL;
1066 ret = pkgmgr_pkginfo_create_certinfo(&handle);
1068 printf("pkgmgr_pkginfo_create_certinfo failed\n");
1071 ret = pkgmgr_pkginfo_load_certinfo(pkgid, handle, uid);
1073 printf("pkgmgr_pkginfo_load_certinfo failed\n");
1076 while (choice != 10)
1078 printf("Enter the choice to get\n");
1079 printf("0 --> to get all cert values\n");
1080 printf("1 --> author root certificate\n");
1081 printf("2 --> author intermediate certificate\n");
1082 printf("3 --> author signer certificate\n");
1083 printf("4 --> distributor root certificate\n");
1084 printf("5 --> distributor intermediate certificate\n");
1085 printf("6 --> distributor signer certificate\n");
1086 printf("7 --> distributor2 root certificate\n");
1087 printf("8 --> distributor2 intermediate certificate\n");
1088 printf("9 --> distributor2 signer certificate\n");
1089 printf("10 --> exit\n");
1090 choice = __get_integer_input_data();
1093 for (i = 0; i < 9; i++)
1095 pkgmgr_pkginfo_get_cert_value(handle, i, &value);
1097 printf("cert type[%d] value = %s\n", i, value);
1099 ret = pkgmgr_pkginfo_destroy_certinfo(handle);
1101 printf("pkgmgr_pkginfo_destroy_certinfo failed\n");
1114 ret = pkgmgr_pkginfo_get_cert_value(handle, choice - 1, &value);
1116 printf("cert type[%d] value = %s\n", choice - 1, value);
1119 ret = pkgmgr_pkginfo_destroy_certinfo(handle);
1121 printf("pkgmgr_pkginfo_destroy_certinfo failed\n");
1126 printf("Invalid choice entered\n");
1134 static int __compare_pkg_certinfo_from_db(char *lhs_pkgid, char *rhs_pkgid, uid_t uid)
1136 if (lhs_pkgid == NULL || rhs_pkgid == NULL) {
1137 printf("pkgid is NULL\n");
1142 pkgmgrinfo_cert_compare_result_type_e result;
1143 if (uid != GLOBAL_USER)
1144 ret = pkgmgrinfo_pkginfo_compare_usr_pkg_cert_info(lhs_pkgid, rhs_pkgid, uid, &result);
1146 ret = pkgmgrinfo_pkginfo_compare_pkg_cert_info(lhs_pkgid, rhs_pkgid, &result);
1147 if (ret != PMINFO_R_OK) {
1151 printf("Compare [match=0, mismatch=1, lhs_no=2, rhs_no=3, both_no=4]\n");
1152 printf("pkgid =[%s] and [%s] compare result = [%d] \n", lhs_pkgid, rhs_pkgid, result);
1156 static int __compare_app_certinfo_from_db(char *lhs_appid, char *rhs_appid, uid_t uid)
1158 if (lhs_appid == NULL || rhs_appid == NULL) {
1159 printf("appid is NULL\n");
1164 pkgmgrinfo_cert_compare_result_type_e result;
1165 if (uid != GLOBAL_USER)
1166 ret = pkgmgrinfo_pkginfo_compare_usr_app_cert_info(lhs_appid, rhs_appid, uid, &result);
1168 ret = pkgmgrinfo_pkginfo_compare_app_cert_info(lhs_appid, rhs_appid, &result);
1169 if (ret != PMINFO_R_OK) {
1173 printf("Compare [match=0, mismatch=1, lhs_no=2, rhs_no=3, both_no=4]\n");
1174 printf("appid =[%s] and [%s] compare result = [%d] \n", lhs_appid, rhs_appid, result);
1178 static int __set_certinfo_in_db(char *pkgid, uid_t uid)
1180 if (pkgid == NULL) {
1181 printf("pkgid is NULL\n");
1187 pkgmgr_instcertinfo_h handle = NULL;
1188 ret = pkgmgr_installer_create_certinfo_set_handle(&handle);
1190 printf("pkgmgr_installer_create_certinfo_set_handle failed\n");
1195 printf("Enter the choice you want to set\n");
1196 printf("0 --> to set data in DB\n");
1197 printf("1 --> author root certificate\n");
1198 printf("2 --> author intermediate certificate\n");
1199 printf("3 --> author signer certificate\n");
1200 printf("4 --> distributor root certificate\n");
1201 printf("5 --> distributor intermediate certificate\n");
1202 printf("6 --> distributor signer certificate\n");
1203 printf("7 --> distributor2 root certificate\n");
1204 printf("8 --> distributor2 intermediate certificate\n");
1205 printf("9 --> distributor2 signer certificate\n");
1206 choice = __get_integer_input_data();
1209 ret = pkgmgr_installer_save_certinfo(pkgid, handle, uid);
1211 printf("pkgmgr_installer_save_certinfo failed\n");
1212 pkgmgr_installer_destroy_certinfo_set_handle(handle);
1215 ret = pkgmgr_installer_destroy_certinfo_set_handle(handle);
1217 printf("pkgmgr_installer_destroy_certinfo_set_handle failed\n");
1222 printf("Enter Author Root Certificate Value: \n");
1223 value = __get_string_input_data();
1224 ret = pkgmgr_installer_set_cert_value(handle, 0, value);
1226 printf("pkgmgr_installer_set_cert_value failed\n");
1234 printf("Enter Author Intermediate Certificate Value: \n");
1235 value = __get_string_input_data();
1236 ret = pkgmgr_installer_set_cert_value(handle, 1, value);
1238 printf("pkgmgr_installer_set_cert_value failed\n");
1246 printf("Enter Author Signer Certificate Value: \n");
1247 value = __get_string_input_data();
1248 ret = pkgmgr_installer_set_cert_value(handle, 2, value);
1250 printf("pkgmgr_installer_set_cert_value failed\n");
1258 printf("Enter Distributor Root Certificate Value: \n");
1259 value = __get_string_input_data();
1260 ret = pkgmgr_installer_set_cert_value(handle, 3, value);
1262 printf("pkgmgr_installer_set_cert_value failed\n");
1270 printf("Enter Distributor Intermediate Certificate Value: \n");
1271 value = __get_string_input_data();
1272 ret = pkgmgr_installer_set_cert_value(handle, 4, value);
1274 printf("pkgmgr_installer_set_cert_value failed\n");
1282 printf("Enter Distributor Signer Certificate Value: \n");
1283 value = __get_string_input_data();
1284 ret = pkgmgr_installer_set_cert_value(handle, 5, value);
1286 printf("pkgmgr_installer_set_cert_value failed\n");
1294 printf("Enter Distributor2 Root Certificate Value: \n");
1295 value = __get_string_input_data();
1296 ret = pkgmgr_installer_set_cert_value(handle, 6, value);
1298 printf("pkgmgr_installer_set_cert_value failed\n");
1306 printf("Enter Distributor2 Intermediate Certificate Value: \n");
1307 value = __get_string_input_data();
1308 ret = pkgmgr_installer_set_cert_value(handle, 7, value);
1310 printf("pkgmgr_installer_set_cert_value failed\n");
1318 printf("Enter Distributor2 Signer Certificate Value: \n");
1319 value = __get_string_input_data();
1320 ret = pkgmgr_installer_set_cert_value(handle, 8, value);
1322 printf("pkgmgr_installer_set_cert_value failed\n");
1330 printf("Invalid Number Entered\n");
1332 ret = pkgmgr_installer_destroy_certinfo_set_handle(handle);
1334 printf("pkgmgr_installer_destroy_certinfo_set_handle failed\n");
1345 pkgmgr_installer_destroy_certinfo_set_handle(handle);
1349 static int __set_pkginfo_in_db(char *pkgid, uid_t uid)
1351 if (pkgid == NULL) {
1352 printf("pkgid is NULL\n");
1360 char *locale = NULL;
1361 pkgmgr_pkgdbinfo_h handle = NULL;
1362 INSTALL_LOCATION storage = 0;
1364 if(uid != GLOBAL_USER)
1365 ret = pkgmgrinfo_create_pkgusrdbinfo(pkgid, uid, &handle);
1367 ret = pkgmgrinfo_create_pkgdbinfo(pkgid, &handle);
1369 printf("pkgmgrinfo_create_pkgdbinfo failed\n");
1374 printf("Enter the choice you want to set\n");
1375 printf("0 --> to set data in DB\n");
1376 printf("1 --> pkg type\n");
1377 printf("2 --> pkg version\n");
1378 printf("3 --> pkg instal location\n");
1379 printf("4 --> pkg label\n");
1380 printf("5 --> pkg icon\n");
1381 printf("6 --> pkg description\n");
1382 printf("7 --> pkg author\n");
1383 printf("8 --> pkg removable\n");
1384 printf("9 --> pkg preload\n");
1385 printf("10 --> pkg size\n");
1386 printf("11 --> pkg installed storage\n");
1387 choice = __get_integer_input_data();
1390 ret = pkgmgrinfo_save_pkgdbinfo(handle);
1392 printf("pkgmgrinfo_save_pkgdbinfo failed\n");
1393 pkgmgrinfo_destroy_pkgdbinfo(handle);
1396 ret = pkgmgrinfo_destroy_pkgdbinfo(handle);
1398 printf("pkgmgrinfo_destroy_pkgdbinfo failed\n");
1403 printf("Enter type: \n");
1404 char *type = __get_string_input_data();
1405 ret = pkgmgrinfo_set_type_to_pkgdbinfo(handle, type);
1407 printf("pkgmgrinfo_set_type_to_pkgdbinfo failed\n");
1408 pkgmgrinfo_destroy_pkgdbinfo(handle);
1415 printf("Enter version: \n");
1416 char *version = __get_string_input_data();
1417 ret = pkgmgrinfo_set_version_to_pkgdbinfo(handle, version);
1419 printf("pkgmgrinfo_set_version_to_pkgdbinfo failed\n");
1420 pkgmgrinfo_destroy_pkgdbinfo(handle);
1427 printf("Enter install location [0:internal | 1:external]: \n");
1428 location = __get_integer_input_data();
1429 ret = pkgmgrinfo_set_install_location_to_pkgdbinfo(handle, location);
1431 printf("pkgmgrinfo_set_install_location_to_pkgdbinfo failed\n");
1432 pkgmgrinfo_destroy_pkgdbinfo(handle);
1437 printf("Enter label :\n");
1438 char *label = __get_string_input_data();
1439 printf("Enter locale ['def' for default]: \n");
1440 locale = __get_string_input_data();
1441 if (strcmp(locale, "def") == 0)
1442 ret = pkgmgrinfo_set_label_to_pkgdbinfo(handle, label, NULL);
1444 ret = pkgmgrinfo_set_label_to_pkgdbinfo(handle, label, locale);
1446 printf("pkgmgrinfo_set_label_to_pkgdbinfo failed\n");
1447 pkgmgrinfo_destroy_pkgdbinfo(handle);
1456 printf("Enter icon: \n");
1457 char *icon = __get_string_input_data();
1458 printf("Enter locale ['def' for default]: \n");
1459 locale = __get_string_input_data();
1460 if (strcmp(locale, "def") == 0)
1461 ret = pkgmgrinfo_set_icon_to_pkgdbinfo(handle, icon, NULL);
1463 ret = pkgmgrinfo_set_icon_to_pkgdbinfo(handle, icon, locale);
1465 printf("pkgmgrinfo_set_icon_to_pkgdbinfo failed\n");
1466 pkgmgrinfo_destroy_pkgdbinfo(handle);
1475 printf("Enter description: \n");
1476 char *description = __get_string_input_data();
1477 printf("Enter locale ['def' for default]: \n");
1478 locale = __get_string_input_data();
1479 if (strcmp(locale, "def") == 0)
1480 ret = pkgmgrinfo_set_description_to_pkgdbinfo(handle, description, NULL);
1482 ret = pkgmgrinfo_set_description_to_pkgdbinfo(handle, description, locale);
1484 printf("pkgmgrinfo_set_description_to_pkgdbinfo failed\n");
1485 pkgmgrinfo_destroy_pkgdbinfo(handle);
1494 printf("Enter author name: \n");
1495 char *author_name = __get_string_input_data();
1496 printf("Enter locale ['def' for default]: \n");
1497 locale = __get_string_input_data();
1498 printf("Enter author email: \n");
1499 char *author_email = __get_string_input_data();
1500 printf("Enter author href: \n");
1501 char *author_href = __get_string_input_data();
1502 if (strcmp(locale, "def") == 0)
1503 ret = pkgmgrinfo_set_author_to_pkgdbinfo(handle, author_name, author_email, author_href, NULL);
1505 ret = pkgmgrinfo_set_author_to_pkgdbinfo(handle, author_name, author_email, author_href, locale);
1507 printf("pkgmgrinfo_set_author_to_pkgdbinfo failed\n");
1508 pkgmgrinfo_destroy_pkgdbinfo(handle);
1521 printf("Enter removable [0:false | 1:true]: \n");
1522 removable = __get_integer_input_data();
1523 ret = pkgmgrinfo_set_removable_to_pkgdbinfo(handle, removable);
1525 printf("pkgmgrinfo_set_removable_to_pkgdbinfo failed\n");
1526 pkgmgrinfo_destroy_pkgdbinfo(handle);
1531 printf("Enter preload [0:false | 1:true]: \n");
1532 preload = __get_integer_input_data();
1533 ret = pkgmgrinfo_set_preload_to_pkgdbinfo(handle, preload);
1535 printf("pkgmgrinfo_set_preload_to_pkgdbinfo failed\n");
1536 pkgmgrinfo_destroy_pkgdbinfo(handle);
1541 printf("Enter size in MB \n");
1542 char *size = __get_string_input_data();
1543 ret = pkgmgrinfo_set_size_to_pkgdbinfo(handle, size);
1545 printf("pkgmgrinfo_set_size_to_pkgdbinfo failed\n");
1546 pkgmgrinfo_destroy_pkgdbinfo(handle);
1553 printf("Enter insatlled storage [ 0:INTERNAL | 1:EXTERNAL ] \n");
1554 storage = __get_integer_input_data();
1555 ret = pkgmgrinfo_set_installed_storage_to_pkgdbinfo(handle, storage);
1557 printf("pkgmgrinfo_set_installed_storage_to_pkgdbinfo failed\n");
1558 pkgmgrinfo_destroy_pkgdbinfo(handle);
1563 printf("Invalid number entered\n");
1570 static int __insert_manifest_in_db(char *manifest, uid_t uid)
1573 if (manifest == NULL) {
1574 printf("Manifest file is NULL\n");
1577 if (uid != GLOBAL_USER)
1578 ret = pkgmgr_parser_parse_usr_manifest_for_installation(manifest, uid, NULL);
1580 ret = pkgmgr_parser_parse_manifest_for_installation(manifest, NULL);
1582 printf("insert in db failed\n");
1588 static int __fota_insert_manifest_in_db(char *manifest, uid_t uid)
1591 char *temp[] = {"fota=true", NULL};
1593 if (manifest == NULL) {
1594 printf("Manifest file is NULL\n");
1597 if (uid != GLOBAL_USER)
1598 ret = pkgmgr_parser_parse_usr_manifest_for_installation(manifest, uid, NULL);
1600 ret = pkgmgr_parser_parse_manifest_for_installation(manifest, NULL);
1602 printf("insert in db failed\n");
1608 static int __remove_manifest_from_db(char *manifest, uid_t uid)
1611 if (manifest == NULL) {
1612 printf("Manifest file is NULL\n");
1615 if (uid != GLOBAL_USER)
1616 ret = pkgmgr_parser_parse_usr_manifest_for_uninstallation(manifest, uid, NULL);
1618 ret = pkgmgr_parser_parse_manifest_for_uninstallation(manifest, NULL);
1620 printf("remove from db failed\n");
1626 int app_func(const pkgmgr_appinfo_h handle, void *user_data)
1631 data = (char *)user_data;
1637 pkgmgr_app_component component = 0;
1638 char *apptype = NULL;
1641 bool taskmanage = 0;
1642 pkgmgr_hwacceleration_type hwacceleration;
1643 pkgmgrinfo_app_screenreader screenreader;
1645 bool autorestart = 0;
1646 char *package = NULL;
1648 ret = pkgmgr_appinfo_get_appid(handle, &appid);
1650 printf("Failed to get appid\n");
1653 printf("Appid: %s\n", appid);
1655 ret = pkgmgr_appinfo_get_pkgid(handle, &package);
1657 printf("Failed to get package\n");
1660 printf("Package: %s\n", package);
1662 ret = pkgmgr_appinfo_get_exec(handle, &exec);
1664 printf("Failed to get exec\n");
1667 printf("Exec: %s\n", exec);
1669 ret = pkgmgr_appinfo_get_icon(handle, &icon);
1671 printf("Failed to get icon\n");
1674 printf("Icon: %s\n", icon);
1676 ret = pkgmgr_appinfo_get_label(handle, &label);
1678 printf("Failed to get label\n");
1681 printf("Label: %s\n", label);
1683 ret = pkgmgr_appinfo_get_component(handle, &component);
1685 printf("Failed to get component\n");
1688 ret = pkgmgr_appinfo_get_apptype(handle, &apptype);
1690 printf("Failed to get apptype\n");
1693 printf("Apptype: %s\n", apptype);
1695 if (component == PM_UI_APP) {
1696 printf("component: uiapp\n");
1697 ret = pkgmgr_appinfo_is_multiple(handle, &multiple);
1699 printf("Failed to get multiple\n");
1701 printf("Multiple: %d\n", multiple);
1704 ret = pkgmgr_appinfo_is_nodisplay(handle, &nodisplay);
1706 printf("Failed to get nodisplay\n");
1708 printf("Nodisplay: %d \n", nodisplay);
1711 ret = pkgmgr_appinfo_is_taskmanage(handle, &taskmanage);
1713 printf("Failed to get taskmanage\n");
1715 printf("Taskmanage: %d\n", taskmanage);
1718 ret = pkgmgr_appinfo_get_hwacceleration(handle, &hwacceleration);
1720 printf("Failed to get hwacceleration\n");
1722 printf("hw-acceleration: %d\n", hwacceleration);
1725 ret = pkgmgrinfo_appinfo_get_screenreader(handle, &screenreader);
1727 printf("Failed to get screenreader\n");
1729 printf("screenreader: %d\n", screenreader);
1733 if (component == PM_SVC_APP) {
1734 printf("component: svcapp\n");
1735 ret = pkgmgr_appinfo_is_onboot(handle, &onboot);
1737 printf("Failed to get onboot\n");
1739 printf("Onboot: %d\n", onboot);
1742 ret = pkgmgr_appinfo_is_autorestart(handle, &autorestart);
1744 printf("Failed to get autorestart\n");
1746 printf("Autorestart: %d \n", autorestart);
1750 printf("user_data : %s\n\n", data);
1756 static int __pkg_list_cb (const pkgmgr_pkginfo_h handle, void *user_data)
1758 char *test_data = "test data";
1764 int installed_time = -1;
1766 pkgmgrinfo_uidinfo_t *uid_info = (pkgmgrinfo_uidinfo_t *) handle;
1767 ret = pkgmgr_pkginfo_get_pkgid(handle, &pkgid);
1769 printf("pkgmgr_pkginfo_get_pkgid() failed\n");
1771 ret = pkgmgr_pkginfo_get_type(handle, &pkg_type);
1773 printf("pkgmgr_pkginfo_get_type() failed\n");
1775 ret = pkgmgr_pkginfo_get_version(handle, &pkg_version);
1777 printf("pkgmgr_pkginfo_get_version() failed\n");
1779 ret = pkgmgr_pkginfo_is_preload(handle, &preload);
1781 printf("pkgmgr_pkginfo_is_preload() failed\n");
1783 ret = pkgmgr_pkginfo_get_installed_time(handle, &installed_time);
1785 printf("pkgmgr_pkginfo_get_installed_time() failed\n");
1789 printf("---------------------------------------\n");
1790 printf("pkg_type [%s]\tpkgid [%s]\tversion [%s]\tpreload [%d]\tinstalled_time [%d]\n", pkg_type,
1791 pkgid, pkg_version, preload, installed_time);
1793 if (uid_info->uid != GLOBAL_USER) {
1794 printf("**List of Ui-Apps**\n");
1795 ret = pkgmgr_appinfo_get_usr_list(handle, PM_UI_APP, app_func, (void *)test_data, uid_info->uid);
1797 printf("pkgmgr_get_info_app() failed\n");
1799 printf("**List of Svc-Apps**\n");
1800 ret = pkgmgr_appinfo_get_usr_list(handle, PM_SVC_APP, app_func, (void *)test_data, uid_info->uid);
1802 printf("pkgmgr_get_info_app() failed\n");
1805 printf("**List of Ui-Apps**\n");
1806 ret = pkgmgr_appinfo_get_list(handle, PM_UI_APP, app_func, (void *)test_data);
1808 printf("pkgmgr_get_info_app() failed\n");
1810 printf("**List of Svc-Apps**\n");
1811 ret = pkgmgr_appinfo_get_list(handle, PM_SVC_APP, app_func, (void *)test_data);
1813 printf("pkgmgr_get_info_app() failed\n");
1816 printf("---------------------------------------\n");
1821 static int __get_pkg_list(uid_t uid)
1824 if (uid != GLOBAL_USER)
1825 ret = pkgmgr_pkginfo_get_usr_list(__pkg_list_cb, NULL, uid);
1827 ret = pkgmgr_pkginfo_get_list(__pkg_list_cb, NULL);
1829 printf("pkgmgr_pkginfo_get_list() failed\n");
1835 static int __get_installed_app_list(uid_t uid)
1838 if(uid != GLOBAL_USER)
1839 ret = pkgmgrinfo_appinfo_get_usr_installed_list(app_func, uid, NULL);
1841 ret = pkgmgrinfo_appinfo_get_installed_list(app_func, NULL);
1843 printf("pkgmgrinfo_appinfo_get_installed_list() failed\n");
1850 static int __app_category_list_cb(const char *category_name, void *user_data)
1853 printf("Category: %s\n", category_name);
1857 static int __app_metadata_list_cb(const char *metadata_name, const char *metadata_value, void *user_data)
1859 if (metadata_name && metadata_value) {
1860 printf("Name: %s\n", metadata_name);
1861 printf("Value: %s\n", metadata_value);
1867 static int __app_control_list_cb(const char *operation, const char *uri, const char *mime, void *user_data)
1869 printf("-------------------------------------------------------\n");
1870 printf("Operation: %s\n", operation);
1871 printf("Uri: %s\n", uri);
1872 printf("Mime: %s\n", mime);
1873 printf("-------------------------------------------------------\n\n");
1878 static int __get_app_category_list(char *appid)
1881 pkgmgr_appinfo_h handle;
1882 ret = pkgmgrinfo_appinfo_get_usr_appinfo(appid, getuid(), &handle);
1884 printf("Failed to get handle\n");
1887 ret = pkgmgr_appinfo_foreach_category(handle, __app_category_list_cb, NULL);
1889 printf("pkgmgr_appinfo_foreach_category() failed\n");
1890 pkgmgr_appinfo_destroy_appinfo(handle);
1893 pkgmgr_appinfo_destroy_appinfo(handle);
1897 static int __get_app_metadata_list(char *appid)
1900 pkgmgr_appinfo_h handle;
1901 ret = pkgmgrinfo_appinfo_get_usr_appinfo(appid, getuid(), &handle);
1903 printf("Failed to get handle\n");
1906 ret = pkgmgrinfo_appinfo_foreach_metadata(handle, __app_metadata_list_cb, NULL);
1908 printf("pkgmgrinfo_appinfo_foreach_metadata() failed\n");
1909 pkgmgr_appinfo_destroy_appinfo(handle);
1912 pkgmgr_appinfo_destroy_appinfo(handle);
1916 static int __get_app_control_list(char *appid)
1919 pkgmgr_appinfo_h handle;
1920 ret = pkgmgrinfo_appinfo_get_usr_appinfo(appid, getuid(), &handle);
1922 printf("Failed to get handle\n");
1925 ret = pkgmgrinfo_appinfo_foreach_appcontrol(handle, __app_control_list_cb, NULL);
1927 printf("pkgmgrinfo_appinfo_foreach_appcontrol() failed\n");
1928 pkgmgr_appinfo_destroy_appinfo(handle);
1931 pkgmgr_appinfo_destroy_appinfo(handle);
1935 static int __set_app_enabled(char *appid, bool enabled)
1938 ret = pkgmgrinfo_appinfo_set_state_enabled(appid, enabled);
1940 printf("Failed to get handle\n");
1946 static int __get_app_list(char *pkgid, uid_t uid)
1948 pkgmgr_pkginfo_h handle;
1950 char *test_data = "test data";
1951 if(uid != GLOBAL_USER)
1952 ret = pkgmgr_pkginfo_get_usr_pkginfo(pkgid, uid, &handle);
1954 ret = pkgmgr_pkginfo_get_pkginfo(pkgid, &handle);
1956 printf("Failed to get handle\n");
1959 if (uid != GLOBAL_USER) {
1960 printf("List of Ui-Apps\n\n");
1961 ret = pkgmgr_appinfo_get_usr_list(handle, PM_UI_APP, app_func, (void *)test_data, uid);
1963 printf("pkgmgr_appinfo_get_list() failed\n");
1965 printf("List of Svc-Apps\n\n");
1966 ret = pkgmgr_appinfo_get_usr_list(handle, PM_SVC_APP, app_func, (void *)test_data, uid);
1968 printf("pkgmgr_appinfo_get_list() failed\n");
1971 printf("List of Ui-Apps\n\n");
1972 ret = pkgmgr_appinfo_get_list(handle, PM_UI_APP, app_func, (void *)test_data);
1974 printf("pkgmgr_appinfo_get_list() failed\n");
1976 printf("List of Svc-Apps\n\n");
1977 ret = pkgmgr_appinfo_get_list(handle, PM_SVC_APP, app_func, (void *)test_data);
1979 printf("pkgmgr_appinfo_get_list() failed\n");
1982 pkgmgr_pkginfo_destroy_pkginfo(handle);
1986 static int __get_pkg_info(char *pkgid, uid_t uid)
1988 pkgmgrinfo_pkginfo_h handle;
1991 printf("Get Pkg Info Called [%s]\n", pkgid);
1992 if(uid != GLOBAL_USER)
1993 ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, uid, &handle);
1995 ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
1997 printf("Failed to get handle\n");
2001 __get_pkgmgrinfo_pkginfo(handle, NULL);
2003 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
2007 static int __get_app_info(char *appid)
2009 printf("Get App Info Called [%s]\n", appid);
2011 char *app_id = NULL;
2012 char *apptype = NULL;
2015 char *package = NULL;
2016 pkgmgr_app_component component = 0;
2019 bool taskmanage = 0;
2020 pkgmgr_hwacceleration_type hwacceleration;
2021 pkgmgrinfo_app_screenreader screenreader;
2023 bool autorestart = 0;
2026 pkgmgr_appinfo_h handle;
2029 ret = pkgmgrinfo_appinfo_get_usr_appinfo(appid, getuid(), &handle);
2031 printf("Failed to get handle\n");
2035 ret = pkgmgr_appinfo_get_pkgid(handle, &package);
2037 printf("Failed to get package\n");
2040 ret = pkgmgr_appinfo_get_appid(handle, &app_id);
2042 printf("Failed to get exec\n");
2045 ret = pkgmgr_appinfo_get_label(handle, &label);
2047 printf("Failed to get label\n");
2049 ret = pkgmgr_appinfo_get_icon(handle, &icon);
2051 printf("Failed to get icon\n");
2054 ret = pkgmgr_appinfo_get_exec(handle, &exec);
2056 printf("Failed to get exec\n");
2058 ret = pkgmgr_appinfo_get_component(handle, &component);
2060 printf("Failed to get component\n");
2062 ret = pkgmgr_appinfo_get_apptype(handle, &apptype);
2064 printf("Failed to get apptype\n");
2066 ret = pkgmgr_appinfo_is_nodisplay(handle, &nodisplay);
2068 printf("Failed to get nodisplay\n");
2070 ret = pkgmgr_appinfo_is_multiple(handle, &multiple);
2072 printf("Failed to get multiple\n");
2074 ret = pkgmgr_appinfo_is_taskmanage(handle, &taskmanage);
2076 printf("Failed to get taskmanage\n");
2078 ret = pkgmgr_appinfo_get_hwacceleration(handle, &hwacceleration);
2080 printf("Failed to get hwacceleration\n");
2082 ret = pkgmgrinfo_appinfo_get_screenreader(handle, &screenreader);
2084 printf("Failed to get screenreader\n");
2086 ret = pkgmgr_appinfo_is_onboot(handle, &onboot);
2088 printf("Failed to get onboot\n");
2090 ret = pkgmgr_appinfo_is_autorestart(handle, &autorestart);
2092 printf("Failed to get autorestart\n");
2094 ret = pkgmgrinfo_appinfo_is_enabled(handle, &enabled);
2096 printf("Failed to get enabled\n");
2098 ret = pkgmgrinfo_appinfo_is_preload(handle, &preload);
2100 printf("Failed to get preload\n");
2104 printf("Appid: %s\n", app_id);
2107 printf("Package: %s\n", package);
2110 printf("Exec: %s\n", exec);
2112 printf("Apptype: %s\n", apptype);
2114 if (component == PM_UI_APP) {
2115 printf("component: uiapp\n");
2118 printf("Icon: %s\n", icon);
2120 printf("Label: %s\n", label);
2122 printf("Nodisplay: %d\n", nodisplay);
2123 printf("Multiple: %d\n", multiple);
2124 printf("Taskmanage: %d\n", taskmanage);
2125 printf("Hw-Acceleration: %d\n", hwacceleration);
2126 printf("Screenreader: %d\n", screenreader);
2127 } else if (component == PM_SVC_APP) {
2128 printf("component: svcapp\n");
2131 printf("Icon: %s\n", icon);
2133 printf("Label: %s\n", label);
2135 printf("Autorestart: %d\n", autorestart);
2136 printf("Onboot: %d\n", onboot);
2138 printf("Invalid Component Type\n");
2141 printf("Enabled: %d\n", enabled);
2142 printf("Preload: %d\n", preload);
2144 pkgmgr_appinfo_destroy_appinfo(handle);
2149 static int __check_manifest_validation(char *manifest)
2152 if (manifest == NULL) {
2153 printf("Manifest file is NULL\n");
2156 ret = pkgmgr_parser_check_manifest_validation(manifest);
2158 printf("check manifest validation failed\n");
2164 int main(int argc, char *argv[])
2167 char *locale = NULL;
2172 gettimeofday(&tv, NULL);
2173 starttime = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
2175 locale = ail_vconf_get_str(VCONFKEY_LANGSET);
2176 //Work around for https://bugs.tizen.org/jira/browse/TC-2399
2177 if (locale == NULL) {
2178 printf("locale is NULL\n");
2183 printf("Locale is %s\n", locale);
2186 if(getuid() == OWNER_ROOT) {
2187 printf("User is Root! : Only tizenglobalapp or regular user are allowed\n");
2194 if (strcmp(argv[1], "--listpkg") == 0) {
2195 ret = __get_pkg_list(getuid());
2197 printf("get pkg list failed\n");
2202 } else if (strcmp(argv[1], "--app-flt") == 0) {
2203 ret = __add_app_filter(getuid());
2205 printf("Adding app filter failed\n");
2210 } else if (strcmp(argv[1], "--pkg-flt") == 0) {
2211 ret = __add_pkg_filter(getuid());
2213 printf("Adding pkg filter failed\n");
2218 } else if (strcmp(argv[1], "--metadata-flt") == 0) {
2219 ret = __add_metadata_filter();
2221 printf("Adding pkg filter failed\n");
2226 } else if (strcmp(argv[1], "--listapp") == 0) {
2227 ret = __get_installed_app_list(getuid());
2229 printf("get installed app list failed\n");
2239 }else if (argc == 4) {
2240 if (strcmp(argv[1], "--setappenabled") == 0) {
2241 ret = __set_app_enabled(argv[2], (strcmp(argv[3], "0")==0)?false:true);
2243 printf("set app enabled failed\n");
2247 } else if(strcmp(argv[1], "--setpkgenabled") == 0) {
2248 ret = __set_app_enabled(argv[2], (strcmp(argv[3], "0")==0)?false:true);
2250 printf("set pkg enabled failed\n");
2254 } else if (strcmp(argv[1], "--cmp-pkgcert") == 0) {
2255 ret = __compare_pkg_certinfo_from_db(argv[2], argv[3], getuid());
2257 printf("compare certinfo from db failed\n");
2261 } else if (strcmp(argv[1], "--cmp-appcert") == 0) {
2262 ret = __compare_app_certinfo_from_db(argv[2], argv[3], getuid());
2264 printf("compare certinfo from db failed\n");
2268 } else if (strcmp(argv[1], "--arg-flt") == 0) {
2269 ret = __add_arg_filter(argv[2], argv[3], getuid());
2271 printf("compare certinfo from db failed\n");
2287 if (!argv[1] || !argv[2]) {
2293 if (strcmp(argv[1], "--pkg") == 0) {
2294 ret = __get_pkg_info(argv[2], getuid());
2296 printf("get pkg info failed\n");
2299 } else if (strcmp(argv[1], "--app") == 0) {
2300 ret = __get_app_info(argv[2]);
2302 printf("get app info failed\n");
2305 } else if (strcmp(argv[1], "--list") == 0) {
2306 ret = __get_app_list(argv[2], getuid());
2308 printf("get app list failed\n");
2311 } else if (strcmp(argv[1], "--imd") == 0) {
2312 ret = __insert_manifest_in_db(argv[2], getuid());
2314 printf("insert in db failed\n");
2317 } else if (strcmp(argv[1], "--fota") == 0) {
2318 ret = __fota_insert_manifest_in_db(argv[2], getuid());
2320 printf("insert in db failed\n");
2323 } else if (strcmp(argv[1], "--rmd") == 0) {
2324 ret = __remove_manifest_from_db(argv[2], getuid());
2326 printf("remove from db failed\n");
2329 } else if (strcmp(argv[1], "--setdb") == 0) {
2330 ret = __set_pkginfo_in_db(argv[2], getuid());
2332 printf("set pkginfo in db failed\n");
2335 } else if (strcmp(argv[1], "--setcert") == 0) {
2336 ret = __set_certinfo_in_db(argv[2], getuid());
2338 printf("set certinfo in db failed\n");
2341 } else if (strcmp(argv[1], "--getcert") == 0) {
2342 ret = __get_certinfo_from_db(argv[2], getuid());
2344 printf("get certinfo from db failed\n");
2347 } else if (strcmp(argv[1], "--delcert") == 0) {
2348 ret = __del_certinfo_from_db(argv[2]);
2350 printf("del certinfo from db failed\n");
2353 } else if (strcmp(argv[1], "--check") == 0) {
2354 ret = __check_manifest_validation(argv[2]);
2356 printf("check manifest failed\n");
2359 } else if (strcmp(argv[1], "--category") == 0) {
2360 ret = __get_app_category_list(argv[2]);
2362 printf("get app category list failed\n");
2365 } else if (strcmp(argv[1], "--metadata") == 0) {
2366 ret = __get_app_metadata_list(argv[2]);
2368 printf("get app metadata list failed\n");
2371 } else if (strcmp(argv[1], "--appcontrol") == 0) {
2372 ret = __get_app_control_list(argv[2]);
2374 printf("get app control list failed\n");
2382 gettimeofday(&tv, NULL);
2383 endtime = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
2385 printf("spend time for pkginfo is [%d]ms\n", (int)(endtime - starttime));