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>
32 //Work around for https://bugs.tizen.org/jira/browse/TC-2399
33 #include <ail_vconf.h>
34 #include <pkgmgr_parser.h>
35 #include <pkgmgr-info.h>
37 #include "package-manager.h"
38 #include "package-manager-types.h"
39 #include "pkgmgr_installer.h"
43 static void __print_usage();
44 static int __get_pkg_info(char *pkgid, uid_t uid);
45 static int __get_app_info(char *appid);
46 static int __get_app_list(char *pkgid, uid_t uid);
47 static int __get_app_category_list(char *appid);
48 static int __get_app_metadata_list(char *appid);
49 static int __get_app_control_list(char *appid);
50 static int __get_pkg_list(uid_t uid);
51 static int __get_installed_app_list(uid_t uid);
52 static int __add_app_filter(uid_t uid);
53 static int __add_pkg_filter(uid_t uid);
54 static int __insert_manifest_in_db(char *manifest, uid_t uid);
55 static int __remove_manifest_from_db(char *manifest, 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 pkgmgrinfo_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 pkgmgrinfo_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 pkgmgrinfo_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 manifest validation\n");
287 printf("\tpkginfo --check <manifest file name>\n\n");
288 printf("To set cert info in DB\n");
289 printf("\tpkginfo --setcert <pkgid>\n\n");
290 printf("To get cert info from DB\n");
291 printf("\tpkginfo --getcert <pkgid>\n\n");
292 printf("To compare pkg cert info from DB\n");
293 printf("\tpkginfo --cmp-pkgcert <lhs_pkgid> <rhs_pkgid>\n\n");
294 printf("To compare app cert info from DB\n");
295 printf("\tpkginfo --cmp-appcert <lhs_appid> <rhs_appid>\n\n");
296 printf("To delete all cert info from DB\n");
297 printf("\tpkginfo --delcert <pkgid>\n\n");
298 printf("To add application filter values [Multiple values can be added]\n");
299 printf("\tpkginfo --app-flt\n\n");
300 printf("To add package filter values [Multiple values can be added]\n");
301 printf("\tpkginfo --pkg-flt\n\n");
302 printf("To add metadata filter values\n");
303 printf("\tpkginfo --metadata-flt\n\n");
306 static void __print_arg_filter_usage()
308 printf("=========================================\n");
309 printf("pkginfo --arg-flt key value\n");
310 printf("ex : pkginfo --arg-flt 6 webapp\n");
311 printf("key list is bellowed\n");
312 printf("2 --> filter by app ID\n");
313 printf("3 --> filter by app component\n");
314 printf("4 --> filter by app exec\n");
315 printf("5 --> filter by app icon\n");
316 printf("6 --> filter by app type\n");
317 printf("7 --> filter by app operation\n");
318 printf("8 --> filter by app uri\n");
319 printf("9 --> filter by app mime\n");
320 printf("10 --> filter by app category\n");
321 printf("11 --> filter by app nodisplay [0|1]\n");
322 printf("12 --> filter by app multiple [0|1]\n");
323 printf("13 --> filter by app onboot [0|1]\n");
324 printf("14 --> filter by app autorestart [0|1]\n");
325 printf("15 --> filter by app taskmanage [0|1]\n");
326 printf("16 --> filter by app hwacceleration\n");
327 printf("17 --> filter by app screenreader\n");
328 printf("=========================================\n");
331 static int __app_list_cb(pkgmgrinfo_appinfo_h handle, void *user_data)
334 pkgmgrinfo_appinfo_get_appid(handle, &appid);
335 printf("appid : %s\n", appid);
339 static int __add_metadata_filter()
342 pkgmgrinfo_appinfo_metadata_filter_h handle;
346 ret = pkgmgrinfo_appinfo_metadata_filter_create(&handle);
347 if (ret != PMINFO_R_OK){
348 printf("pkgmgrinfo_appinfo_metadata_filter_create() failed\n");
352 printf("enter metadata - key\n");
353 key = __get_string_input_data();
354 printf("enter metadata - value\n");
355 value = __get_string_input_data();
357 printf("filter condition : key=[%s], value=[%s]\n", key, value);
359 ret = pkgmgrinfo_appinfo_metadata_filter_add(handle, key, value);
360 if (ret != PMINFO_R_OK){
361 printf("pkgmgrinfo_appinfo_metadata_filter_add() failed\n");
365 ret = pkgmgrinfo_appinfo_metadata_filter_foreach(handle, __app_list_cb, NULL);
366 if (ret != PMINFO_R_OK){
367 printf("pkgmgrinfo_appinfo_metadata_filter_add() failed\n");
372 pkgmgrinfo_appinfo_metadata_filter_destroy(handle);
384 static int __add_app_filter(uid_t uid)
391 pkgmgrinfo_appinfo_filter_h handle;
392 ret = pkgmgrinfo_appinfo_filter_create(&handle);
394 printf("appinfo filter handle create failed\n");
397 while (choice != 0 && choice != 1)
399 printf("Enter Choice\n");
400 printf("0 --> Finalize filter and get count of apps\n");
401 printf("1 --> Finalize filter and get list of apps\n");
402 printf("2 --> filter by app ID\n");
403 printf("3 --> filter by app component\n");
404 printf("4 --> filter by app exec\n");
405 printf("5 --> filter by app icon\n");
406 printf("6 --> filter by app type\n");
407 printf("7 --> filter by app operation\n");
408 printf("8 --> filter by app uri\n");
409 printf("9 --> filter by app mime\n");
410 printf("10 --> filter by app category\n");
411 printf("11 --> filter by app nodisplay [0|1]\n");
412 printf("12 --> filter by app multiple [0|1]\n");
413 printf("13 --> filter by app onboot [0|1]\n");
414 printf("14 --> filter by app autorestart [0|1]\n");
415 printf("15 --> filter by app taskmanage [0|1]\n");
416 printf("16 --> filter by app hwacceleration\n");
417 printf("17 --> filter by app screenreader\n");
418 printf("18 --> filter by app ui-gadget [0|1]\n");
419 printf("19 --> filter by app support disable [0|1]\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 val = __get_integer_input_data();
626 ret = pkgmgrinfo_appinfo_filter_add_bool(handle,
627 PMINFO_APPINFO_PROP_APP_UI_GADGET, val);
629 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
635 val = __get_integer_input_data();
636 ret = pkgmgrinfo_appinfo_filter_add_bool(handle,
637 PMINFO_APPINFO_PROP_APP_SUPPORT_DISABLE, val);
639 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
645 printf("Invalid filter property\n");
646 pkgmgrinfo_appinfo_filter_destroy(handle);
653 pkgmgrinfo_appinfo_filter_destroy(handle);
661 static int __add_pkg_filter(uid_t uid)
668 pkgmgrinfo_pkginfo_filter_h handle;
670 ret = pkgmgrinfo_pkginfo_filter_create(&handle);
672 printf("pkginfo filter handle create failed\n");
675 while (choice != 0 && choice !=1)
677 printf("Enter Choice\n");
678 printf("0 --> Finalize filter and get count of packages\n");
679 printf("1 --> Finalize filter and get list of packages\n");
680 printf("2 --> filter by package ID\n");
681 printf("3 --> filter by package version\n");
682 printf("4 --> filter by package type\n");
683 printf("5 --> filter by package install location\n");
684 printf("6 --> filter by author name\n");
685 printf("7 --> filter by author email\n");
686 printf("8 --> filter by author href\n");
687 printf("9 --> filter by package removable [0|1]\n");
688 printf("10 --> filter by package readonly [0|1]\n");
689 printf("11 --> filter by package preload [0|1]\n");
690 printf("12 --> filter by package update [0|1]\n");
691 printf("13 --> filter by package appsetting [0|1]\n");
692 printf("14 --> filter by package size\n");
693 printf("15 --> filter by package installed storage[installed_internal | installed_external]\n");
694 printf("16 --> filter by package privilege\n");
695 printf("17 --> filter by package support disable [0|1]\n");
696 choice = __get_integer_input_data();
699 if (uid != GLOBAL_USER)
700 ret = pkgmgrinfo_pkginfo_usr_filter_count(handle, &count, uid);
702 ret = pkgmgrinfo_pkginfo_filter_count(handle, &count);
704 printf("pkgmgrinfo_pkginfo_filter_count() failed\n");
708 printf("Package count = %d\n", count);
711 if (uid != GLOBAL_USER)
712 ret = pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo(handle, __pkg_list_cb, NULL, uid);
714 ret = pkgmgrinfo_pkginfo_filter_foreach_pkginfo(handle, __pkg_list_cb, NULL);
716 printf("pkgmgrinfo_pkginfo_(usr)_filter_foreach_pkginfo() failed\n");
722 value = __get_string_input_data();
723 ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
724 PMINFO_PKGINFO_PROP_PACKAGE_ID, value);
726 printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
734 value = __get_string_input_data();
735 ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
736 PMINFO_PKGINFO_PROP_PACKAGE_VERSION, value);
738 printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
746 value = __get_string_input_data();
747 ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
748 PMINFO_PKGINFO_PROP_PACKAGE_TYPE, value);
750 printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
758 value = __get_string_input_data();
759 ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
760 PMINFO_PKGINFO_PROP_PACKAGE_INSTALL_LOCATION, value);
762 printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
770 value = __get_string_input_data();
771 ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
772 PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_NAME, value);
774 printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
782 value = __get_string_input_data();
783 ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
784 PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_EMAIL, value);
786 printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
794 value = __get_string_input_data();
795 ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
796 PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_HREF, value);
798 printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
806 val = __get_integer_input_data();
807 ret = pkgmgrinfo_pkginfo_filter_add_bool(handle,
808 PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE, val);
810 printf("pkgmgrinfo_pkginfo_filter_add_bool() failed\n");
816 val = __get_integer_input_data();
817 ret = pkgmgrinfo_pkginfo_filter_add_bool(handle,
818 PMINFO_PKGINFO_PROP_PACKAGE_READONLY, val);
820 printf("pkgmgrinfo_pkginfo_filter_add_bool() failed\n");
826 val = __get_integer_input_data();
827 ret = pkgmgrinfo_pkginfo_filter_add_bool(handle,
828 PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD, val);
830 printf("pkgmgrinfo_pkginfo_filter_add_bool() failed\n");
836 val = __get_integer_input_data();
837 ret = pkgmgrinfo_pkginfo_filter_add_bool(handle,
838 PMINFO_PKGINFO_PROP_PACKAGE_UPDATE, val);
840 printf("pkgmgrinfo_pkginfo_filter_add_bool() failed\n");
846 val = __get_integer_input_data();
847 ret = pkgmgrinfo_pkginfo_filter_add_bool(handle,
848 PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING, val);
850 printf("pkgmgrinfo_pkginfo_filter_add_bool() failed\n");
856 val = __get_integer_input_data();
857 ret = pkgmgrinfo_pkginfo_filter_add_int(handle,
858 PMINFO_PKGINFO_PROP_PACKAGE_SIZE, val);
860 printf("pkgmgrinfo_pkginfo_filter_add_int() failed\n");
866 value = __get_string_input_data();
867 ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
868 PMINFO_PKGINFO_PROP_PACKAGE_INSTALLED_STORAGE, value);
870 printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
878 value = __get_string_input_data();
879 ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
880 PMINFO_PKGINFO_PROP_PACKAGE_PRIVILEGE,
883 printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
891 val = __get_integer_input_data();
892 ret = pkgmgrinfo_pkginfo_filter_add_bool(handle,
893 PMINFO_PKGINFO_PROP_PACKAGE_SUPPORT_DISABLE, val);
895 printf("pkgmgrinfo_pkginfo_filter_add_bool() failed\n");
901 printf("Invalid filter property\n");
908 pkgmgrinfo_pkginfo_filter_destroy(handle);
916 static int __add_arg_filter(char *key, char *value, uid_t uid)
921 pkgmgrinfo_appinfo_filter_h handle;
922 ret = pkgmgrinfo_appinfo_filter_create(&handle);
924 printf("appinfo filter handle create failed\n");
931 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_ID, value);
933 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
939 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_COMPONENT, value);
941 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
947 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_EXEC, value);
949 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
955 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_ICON, value);
957 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
963 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_TYPE, value);
965 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
971 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_OPERATION, value);
973 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
979 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_URI, value);
981 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
987 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_MIME, value);
989 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
997 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_CATEGORY, value);
999 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
1006 ret = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_NODISPLAY, val);
1008 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
1015 ret = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_MULTIPLE, val);
1017 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
1024 ret = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_ONBOOT, val);
1026 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
1033 ret = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_AUTORESTART, val);
1035 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
1042 ret = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_TASKMANAGE, val);
1044 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
1050 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_HWACCELERATION, value);
1052 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
1058 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_SCREENREADER, value);
1060 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
1067 __print_arg_filter_usage();
1070 if (uid != GLOBAL_USER)
1071 ret = pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, __get_app_id, NULL, uid);
1073 ret = pkgmgrinfo_appinfo_filter_foreach_appinfo(handle, __get_app_id, NULL);
1075 printf("pkgmgrinfo_appinfo_filter_foreach_appinfo() failed\n");
1081 pkgmgrinfo_appinfo_filter_destroy(handle);
1084 static int __del_certinfo_from_db(char *pkgid)
1087 if (pkgid == NULL) {
1088 printf("pkgid is NULL\n");
1091 ret = pkgmgr_installer_delete_certinfo(pkgid);
1093 printf("pkgmgr_installer_delete_certinfo failed\n");
1099 static int __get_certinfo_from_db(char *pkgid, uid_t uid)
1101 if (pkgid == NULL) {
1102 printf("pkgid is NULL\n");
1108 const char *value = NULL;
1109 pkgmgrinfo_certinfo_h handle = NULL;
1110 ret = pkgmgrinfo_pkginfo_create_certinfo(&handle);
1112 printf("pkgmgrinfo_pkginfo_create_certinfo failed\n");
1115 ret = pkgmgrinfo_pkginfo_load_certinfo(pkgid, handle, uid);
1117 printf("pkgmgrinfo_pkginfo_load_certinfo failed\n");
1120 while (choice != 10)
1122 printf("Enter the choice to get\n");
1123 printf("0 --> to get all cert values\n");
1124 printf("1 --> author root certificate\n");
1125 printf("2 --> author intermediate certificate\n");
1126 printf("3 --> author signer certificate\n");
1127 printf("4 --> distributor root certificate\n");
1128 printf("5 --> distributor intermediate certificate\n");
1129 printf("6 --> distributor signer certificate\n");
1130 printf("7 --> distributor2 root certificate\n");
1131 printf("8 --> distributor2 intermediate certificate\n");
1132 printf("9 --> distributor2 signer certificate\n");
1133 printf("10 --> exit\n");
1134 choice = __get_integer_input_data();
1137 for (i = 0; i < 9; i++)
1139 pkgmgrinfo_pkginfo_get_cert_value(handle, i, &value);
1141 printf("cert type[%d] value = %s\n", i, value);
1143 ret = pkgmgrinfo_pkginfo_destroy_certinfo(handle);
1145 printf("pkgmgrinfo_pkginfo_destroy_certinfo failed\n");
1158 ret = pkgmgrinfo_pkginfo_get_cert_value(handle, choice - 1, &value);
1160 printf("cert type[%d] value = %s\n", choice - 1, value);
1163 ret = pkgmgrinfo_pkginfo_destroy_certinfo(handle);
1165 printf("pkgmgrinfo_pkginfo_destroy_certinfo failed\n");
1170 printf("Invalid choice entered\n");
1178 static int __compare_pkg_certinfo_from_db(char *lhs_pkgid, char *rhs_pkgid, uid_t uid)
1180 if (lhs_pkgid == NULL || rhs_pkgid == NULL) {
1181 printf("pkgid is NULL\n");
1186 pkgmgrinfo_cert_compare_result_type_e result;
1187 if (uid != GLOBAL_USER)
1188 ret = pkgmgrinfo_pkginfo_compare_usr_pkg_cert_info(lhs_pkgid, rhs_pkgid, uid, &result);
1190 ret = pkgmgrinfo_pkginfo_compare_pkg_cert_info(lhs_pkgid, rhs_pkgid, &result);
1191 if (ret != PMINFO_R_OK) {
1195 printf("Compare [match=0, mismatch=1, lhs_no=2, rhs_no=3, both_no=4]\n");
1196 printf("pkgid =[%s] and [%s] compare result = [%d] \n", lhs_pkgid, rhs_pkgid, result);
1200 static int __compare_app_certinfo_from_db(char *lhs_appid, char *rhs_appid, uid_t uid)
1202 if (lhs_appid == NULL || rhs_appid == NULL) {
1203 printf("appid is NULL\n");
1208 pkgmgrinfo_cert_compare_result_type_e result;
1209 if (uid != GLOBAL_USER)
1210 ret = pkgmgrinfo_pkginfo_compare_usr_app_cert_info(lhs_appid, rhs_appid, uid, &result);
1212 ret = pkgmgrinfo_pkginfo_compare_app_cert_info(lhs_appid, rhs_appid, &result);
1213 if (ret != PMINFO_R_OK) {
1217 printf("Compare [match=0, mismatch=1, lhs_no=2, rhs_no=3, both_no=4]\n");
1218 printf("appid =[%s] and [%s] compare result = [%d] \n", lhs_appid, rhs_appid, result);
1222 static int __set_certinfo_in_db(char *pkgid, uid_t uid)
1224 if (pkgid == NULL) {
1225 printf("pkgid is NULL\n");
1231 pkgmgr_instcertinfo_h handle = NULL;
1232 ret = pkgmgr_installer_create_certinfo_set_handle(&handle);
1234 printf("pkgmgr_installer_create_certinfo_set_handle failed\n");
1239 printf("Enter the choice you want to set\n");
1240 printf("0 --> to set data in DB\n");
1241 printf("1 --> author root certificate\n");
1242 printf("2 --> author intermediate certificate\n");
1243 printf("3 --> author signer certificate\n");
1244 printf("4 --> distributor root certificate\n");
1245 printf("5 --> distributor intermediate certificate\n");
1246 printf("6 --> distributor signer certificate\n");
1247 printf("7 --> distributor2 root certificate\n");
1248 printf("8 --> distributor2 intermediate certificate\n");
1249 printf("9 --> distributor2 signer certificate\n");
1250 choice = __get_integer_input_data();
1253 ret = pkgmgr_installer_save_certinfo(pkgid, handle, uid);
1255 printf("pkgmgr_installer_save_certinfo failed\n");
1256 pkgmgr_installer_destroy_certinfo_set_handle(handle);
1259 ret = pkgmgr_installer_destroy_certinfo_set_handle(handle);
1261 printf("pkgmgr_installer_destroy_certinfo_set_handle failed\n");
1266 printf("Enter Author Root Certificate Value: \n");
1267 value = __get_string_input_data();
1268 ret = pkgmgr_installer_set_cert_value(handle, 0, value);
1270 printf("pkgmgr_installer_set_cert_value failed\n");
1278 printf("Enter Author Intermediate Certificate Value: \n");
1279 value = __get_string_input_data();
1280 ret = pkgmgr_installer_set_cert_value(handle, 1, value);
1282 printf("pkgmgr_installer_set_cert_value failed\n");
1290 printf("Enter Author Signer Certificate Value: \n");
1291 value = __get_string_input_data();
1292 ret = pkgmgr_installer_set_cert_value(handle, 2, value);
1294 printf("pkgmgr_installer_set_cert_value failed\n");
1302 printf("Enter Distributor Root Certificate Value: \n");
1303 value = __get_string_input_data();
1304 ret = pkgmgr_installer_set_cert_value(handle, 3, value);
1306 printf("pkgmgr_installer_set_cert_value failed\n");
1314 printf("Enter Distributor Intermediate Certificate Value: \n");
1315 value = __get_string_input_data();
1316 ret = pkgmgr_installer_set_cert_value(handle, 4, value);
1318 printf("pkgmgr_installer_set_cert_value failed\n");
1326 printf("Enter Distributor Signer Certificate Value: \n");
1327 value = __get_string_input_data();
1328 ret = pkgmgr_installer_set_cert_value(handle, 5, value);
1330 printf("pkgmgr_installer_set_cert_value failed\n");
1338 printf("Enter Distributor2 Root Certificate Value: \n");
1339 value = __get_string_input_data();
1340 ret = pkgmgr_installer_set_cert_value(handle, 6, value);
1342 printf("pkgmgr_installer_set_cert_value failed\n");
1350 printf("Enter Distributor2 Intermediate Certificate Value: \n");
1351 value = __get_string_input_data();
1352 ret = pkgmgr_installer_set_cert_value(handle, 7, value);
1354 printf("pkgmgr_installer_set_cert_value failed\n");
1362 printf("Enter Distributor2 Signer Certificate Value: \n");
1363 value = __get_string_input_data();
1364 ret = pkgmgr_installer_set_cert_value(handle, 8, value);
1366 printf("pkgmgr_installer_set_cert_value failed\n");
1374 printf("Invalid Number Entered\n");
1376 ret = pkgmgr_installer_destroy_certinfo_set_handle(handle);
1378 printf("pkgmgr_installer_destroy_certinfo_set_handle failed\n");
1389 pkgmgr_installer_destroy_certinfo_set_handle(handle);
1393 static int __insert_manifest_in_db(char *manifest, uid_t uid)
1396 if (manifest == NULL) {
1397 printf("Manifest file is NULL\n");
1400 if (uid == GLOBAL_USER || uid == OWNER_ROOT)
1401 ret = pkgmgr_parser_parse_manifest_for_installation(manifest, NULL);
1403 ret = pkgmgr_parser_parse_usr_manifest_for_installation(manifest, uid, NULL);
1405 printf("insert in db failed\n");
1411 static int __fota_insert_manifest_in_db(char *manifest, uid_t uid)
1414 char *temp[] = {"fota=true", NULL};
1416 if (manifest == NULL) {
1417 printf("Manifest file is NULL\n");
1420 if (uid != GLOBAL_USER)
1421 ret = pkgmgr_parser_parse_usr_manifest_for_installation(manifest, uid, NULL);
1423 ret = pkgmgr_parser_parse_manifest_for_installation(manifest, NULL);
1425 printf("insert in db failed\n");
1431 static int __remove_manifest_from_db(char *manifest, uid_t uid)
1434 if (manifest == NULL) {
1435 printf("Manifest file is NULL\n");
1438 if (uid != GLOBAL_USER)
1439 ret = pkgmgr_parser_parse_usr_manifest_for_uninstallation(manifest, uid, NULL);
1441 ret = pkgmgr_parser_parse_manifest_for_uninstallation(manifest, NULL);
1443 printf("remove from db failed\n");
1449 int app_func(const pkgmgrinfo_appinfo_h handle, void *user_data)
1454 data = (char *)user_data;
1460 pkgmgrinfo_app_component component = 0;
1461 char *apptype = NULL;
1464 bool taskmanage = 0;
1465 pkgmgrinfo_app_hwacceleration hwacceleration;
1466 pkgmgrinfo_app_screenreader screenreader;
1468 bool autorestart = 0;
1469 char *package = NULL;
1471 ret = pkgmgrinfo_appinfo_get_appid(handle, &appid);
1473 printf("Failed to get appid\n");
1476 printf("Appid: %s\n", appid);
1478 ret = pkgmgrinfo_appinfo_get_pkgid(handle, &package);
1480 printf("Failed to get package\n");
1483 printf("Package: %s\n", package);
1485 ret = pkgmgrinfo_appinfo_get_exec(handle, &exec);
1487 printf("Failed to get exec\n");
1490 printf("Exec: %s\n", exec);
1492 ret = pkgmgrinfo_appinfo_get_icon(handle, &icon);
1494 printf("Failed to get icon\n");
1497 printf("Icon: %s\n", icon);
1499 ret = pkgmgrinfo_appinfo_get_label(handle, &label);
1501 printf("Failed to get label\n");
1504 printf("Label: %s\n", label);
1506 ret = pkgmgrinfo_appinfo_get_component(handle, &component);
1508 printf("Failed to get component\n");
1511 ret = pkgmgrinfo_appinfo_get_apptype(handle, &apptype);
1513 printf("Failed to get apptype\n");
1516 printf("Apptype: %s\n", apptype);
1518 if (component == PMINFO_UI_APP) {
1519 printf("component: uiapp\n");
1520 ret = pkgmgrinfo_appinfo_is_multiple(handle, &multiple);
1522 printf("Failed to get multiple\n");
1524 printf("Multiple: %d\n", multiple);
1527 ret = pkgmgrinfo_appinfo_is_nodisplay(handle, &nodisplay);
1529 printf("Failed to get nodisplay\n");
1531 printf("Nodisplay: %d \n", nodisplay);
1534 ret = pkgmgrinfo_appinfo_is_taskmanage(handle, &taskmanage);
1536 printf("Failed to get taskmanage\n");
1538 printf("Taskmanage: %d\n", taskmanage);
1541 ret = pkgmgrinfo_appinfo_get_hwacceleration(handle, &hwacceleration);
1543 printf("Failed to get hwacceleration\n");
1545 printf("hw-acceleration: %d\n", hwacceleration);
1548 ret = pkgmgrinfo_appinfo_get_screenreader(handle, &screenreader);
1550 printf("Failed to get screenreader\n");
1552 printf("screenreader: %d\n", screenreader);
1556 if (component == PMINFO_SVC_APP) {
1557 printf("component: svcapp\n");
1558 ret = pkgmgrinfo_appinfo_is_onboot(handle, &onboot);
1560 printf("Failed to get onboot\n");
1562 printf("Onboot: %d\n", onboot);
1565 ret = pkgmgrinfo_appinfo_is_autorestart(handle, &autorestart);
1567 printf("Failed to get autorestart\n");
1569 printf("Autorestart: %d \n", autorestart);
1573 printf("user_data : %s\n\n", data);
1579 static int __pkg_list_cb (const pkgmgrinfo_pkginfo_h handle, void *user_data)
1581 char *test_data = "test data";
1587 int installed_time = -1;
1589 pkgmgrinfo_uidinfo_t *uid_info = (pkgmgrinfo_uidinfo_t *) handle;
1590 ret = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
1592 printf("pkgmgrinfo_pkginfo_get_pkgid() failed\n");
1594 ret = pkgmgrinfo_pkginfo_get_type(handle, &pkg_type);
1596 printf("pkgmgrinfo_pkginfo_get_type() failed\n");
1598 ret = pkgmgrinfo_pkginfo_get_version(handle, &pkg_version);
1600 printf("pkgmgrinfo_pkginfo_get_version() failed\n");
1602 ret = pkgmgrinfo_pkginfo_is_preload(handle, &preload);
1604 printf("pkgmgrinfo_pkginfo_is_preload() failed\n");
1606 ret = pkgmgrinfo_pkginfo_get_installed_time(handle, &installed_time);
1608 printf("pkgmgrinfo_pkginfo_get_installed_time() failed\n");
1612 printf("---------------------------------------\n");
1613 printf("pkg_type [%s]\tpkgid [%s]\tversion [%s]\tpreload [%d]\tinstalled_time [%d]\n", pkg_type,
1614 pkgid, pkg_version, preload, installed_time);
1616 if (uid_info->uid != GLOBAL_USER) {
1617 printf("**List of Ui-Apps**\n");
1618 ret = pkgmgrinfo_appinfo_get_usr_list(handle, PMINFO_UI_APP, app_func, (void *)test_data, uid_info->uid);
1620 printf("pkgmgr_get_info_app() failed\n");
1622 printf("**List of Svc-Apps**\n");
1623 ret = pkgmgrinfo_appinfo_get_usr_list(handle, PMINFO_SVC_APP, app_func, (void *)test_data, uid_info->uid);
1625 printf("pkgmgr_get_info_app() failed\n");
1628 printf("**List of Ui-Apps**\n");
1629 ret = pkgmgrinfo_appinfo_get_list(handle, PMINFO_UI_APP, app_func, (void *)test_data);
1631 printf("pkgmgr_get_info_app() failed\n");
1633 printf("**List of Svc-Apps**\n");
1634 ret = pkgmgrinfo_appinfo_get_list(handle, PMINFO_SVC_APP, app_func, (void *)test_data);
1636 printf("pkgmgr_get_info_app() failed\n");
1639 printf("---------------------------------------\n");
1644 static int __get_pkg_list(uid_t uid)
1647 if (uid != GLOBAL_USER)
1648 ret = pkgmgrinfo_pkginfo_get_usr_list(__pkg_list_cb, NULL, uid);
1650 ret = pkgmgrinfo_pkginfo_get_list(__pkg_list_cb, NULL);
1652 printf("pkgmgrinfo_pkginfo_get_list() failed\n");
1658 static int __get_installed_app_list(uid_t uid)
1661 if(uid != GLOBAL_USER)
1662 ret = pkgmgrinfo_appinfo_get_usr_installed_list(app_func, uid, NULL);
1664 ret = pkgmgrinfo_appinfo_get_installed_list(app_func, NULL);
1666 printf("pkgmgrinfo_appinfo_get_installed_list() failed\n");
1673 static int __app_category_list_cb(const char *category_name, void *user_data)
1676 printf("Category: %s\n", category_name);
1680 static int __app_metadata_list_cb(const char *metadata_name, const char *metadata_value, void *user_data)
1682 if (metadata_name && metadata_value) {
1683 printf("Name: %s\n", metadata_name);
1684 printf("Value: %s\n", metadata_value);
1690 static int __app_control_list_cb(const char *operation, const char *uri, const char *mime, void *user_data)
1692 printf("-------------------------------------------------------\n");
1693 printf("Operation: %s\n", operation);
1694 printf("Uri: %s\n", uri);
1695 printf("Mime: %s\n", mime);
1696 printf("-------------------------------------------------------\n\n");
1701 static int __get_app_category_list(char *appid)
1704 pkgmgrinfo_appinfo_h handle;
1705 ret = pkgmgrinfo_appinfo_get_usr_appinfo(appid, getuid(), &handle);
1707 printf("Failed to get handle\n");
1710 ret = pkgmgrinfo_appinfo_foreach_category(handle, __app_category_list_cb, NULL);
1712 printf("pkgmgrinfo_appinfo_foreach_category() failed\n");
1713 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1716 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1720 static int __get_app_metadata_list(char *appid)
1723 pkgmgrinfo_appinfo_h handle;
1724 ret = pkgmgrinfo_appinfo_get_usr_appinfo(appid, getuid(), &handle);
1726 printf("Failed to get handle\n");
1729 ret = pkgmgrinfo_appinfo_foreach_metadata(handle, __app_metadata_list_cb, NULL);
1731 printf("pkgmgrinfo_appinfo_foreach_metadata() failed\n");
1732 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1735 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1739 static int __get_app_control_list(char *appid)
1742 pkgmgrinfo_appinfo_h handle;
1743 ret = pkgmgrinfo_appinfo_get_usr_appinfo(appid, getuid(), &handle);
1745 printf("Failed to get handle\n");
1748 ret = pkgmgrinfo_appinfo_foreach_appcontrol(handle, __app_control_list_cb, NULL);
1750 printf("pkgmgrinfo_appinfo_foreach_appcontrol() failed\n");
1751 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1754 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1758 static int __set_app_enabled(char *appid, bool enabled)
1761 ret = pkgmgrinfo_appinfo_set_state_enabled(appid, enabled);
1763 printf("Failed to get handle\n");
1769 static int __get_app_list(char *pkgid, uid_t uid)
1771 pkgmgrinfo_pkginfo_h handle;
1773 char *test_data = "test data";
1774 if(uid != GLOBAL_USER)
1775 ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, uid, &handle);
1777 ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
1779 printf("Failed to get handle\n");
1782 if (uid != GLOBAL_USER) {
1783 printf("List of Ui-Apps\n\n");
1784 ret = pkgmgrinfo_appinfo_get_usr_list(handle, PMINFO_UI_APP, app_func, (void *)test_data, uid);
1786 printf("pkgmgrinfo_appinfo_get_list() failed\n");
1788 printf("List of Svc-Apps\n\n");
1789 ret = pkgmgrinfo_appinfo_get_usr_list(handle, PMINFO_SVC_APP, app_func, (void *)test_data, uid);
1791 printf("pkgmgrinfo_appinfo_get_list() failed\n");
1794 printf("List of Ui-Apps\n\n");
1795 ret = pkgmgrinfo_appinfo_get_list(handle, PMINFO_UI_APP, app_func, (void *)test_data);
1797 printf("pkgmgrinfo_appinfo_get_list() failed\n");
1799 printf("List of Svc-Apps\n\n");
1800 ret = pkgmgrinfo_appinfo_get_list(handle, PMINFO_SVC_APP, app_func, (void *)test_data);
1802 printf("pkgmgrinfo_appinfo_get_list() failed\n");
1805 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
1809 static int __get_pkg_info(char *pkgid, uid_t uid)
1811 pkgmgrinfo_pkginfo_h handle;
1814 printf("Get Pkg Info Called [%s]\n", pkgid);
1815 if(uid != GLOBAL_USER)
1816 ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, uid, &handle);
1818 ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
1820 printf("Failed to get handle\n");
1824 __get_pkgmgrinfo_pkginfo(handle, NULL);
1826 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
1830 static int __get_app_info(char *appid)
1832 printf("Get App Info Called [%s]\n", appid);
1834 char *app_id = NULL;
1835 char *apptype = NULL;
1838 char *package = NULL;
1839 pkgmgrinfo_app_component component = 0;
1842 bool taskmanage = 0;
1843 pkgmgrinfo_app_hwacceleration hwacceleration;
1844 pkgmgrinfo_app_screenreader screenreader;
1846 bool autorestart = 0;
1849 pkgmgrinfo_appinfo_h handle;
1852 ret = pkgmgrinfo_appinfo_get_usr_appinfo(appid, getuid(), &handle);
1854 printf("Failed to get handle\n");
1858 ret = pkgmgrinfo_appinfo_get_pkgid(handle, &package);
1860 printf("Failed to get package\n");
1863 ret = pkgmgrinfo_appinfo_get_appid(handle, &app_id);
1865 printf("Failed to get exec\n");
1868 ret = pkgmgrinfo_appinfo_get_label(handle, &label);
1870 printf("Failed to get label\n");
1872 ret = pkgmgrinfo_appinfo_get_icon(handle, &icon);
1874 printf("Failed to get icon\n");
1877 ret = pkgmgrinfo_appinfo_get_exec(handle, &exec);
1879 printf("Failed to get exec\n");
1881 ret = pkgmgrinfo_appinfo_get_component(handle, &component);
1883 printf("Failed to get component\n");
1885 ret = pkgmgrinfo_appinfo_get_apptype(handle, &apptype);
1887 printf("Failed to get apptype\n");
1889 ret = pkgmgrinfo_appinfo_is_nodisplay(handle, &nodisplay);
1891 printf("Failed to get nodisplay\n");
1893 ret = pkgmgrinfo_appinfo_is_multiple(handle, &multiple);
1895 printf("Failed to get multiple\n");
1897 ret = pkgmgrinfo_appinfo_is_taskmanage(handle, &taskmanage);
1899 printf("Failed to get taskmanage\n");
1901 ret = pkgmgrinfo_appinfo_get_hwacceleration(handle, &hwacceleration);
1903 printf("Failed to get hwacceleration\n");
1905 ret = pkgmgrinfo_appinfo_get_screenreader(handle, &screenreader);
1907 printf("Failed to get screenreader\n");
1909 ret = pkgmgrinfo_appinfo_is_onboot(handle, &onboot);
1911 printf("Failed to get onboot\n");
1913 ret = pkgmgrinfo_appinfo_is_autorestart(handle, &autorestart);
1915 printf("Failed to get autorestart\n");
1917 ret = pkgmgrinfo_appinfo_is_enabled(handle, &enabled);
1919 printf("Failed to get enabled\n");
1921 ret = pkgmgrinfo_appinfo_is_preload(handle, &preload);
1923 printf("Failed to get preload\n");
1927 printf("Appid: %s\n", app_id);
1930 printf("Package: %s\n", package);
1933 printf("Exec: %s\n", exec);
1935 printf("Apptype: %s\n", apptype);
1937 if (component == PMINFO_UI_APP) {
1938 printf("component: uiapp\n");
1941 printf("Icon: %s\n", icon);
1943 printf("Label: %s\n", label);
1945 printf("Nodisplay: %d\n", nodisplay);
1946 printf("Multiple: %d\n", multiple);
1947 printf("Taskmanage: %d\n", taskmanage);
1948 printf("Hw-Acceleration: %d\n", hwacceleration);
1949 printf("Screenreader: %d\n", screenreader);
1950 } else if (component == PMINFO_SVC_APP) {
1951 printf("component: svcapp\n");
1954 printf("Icon: %s\n", icon);
1956 printf("Label: %s\n", label);
1958 printf("Autorestart: %d\n", autorestart);
1959 printf("Onboot: %d\n", onboot);
1961 printf("Invalid Component Type\n");
1964 printf("Enabled: %d\n", enabled);
1965 printf("Preload: %d\n", preload);
1967 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1972 static int __check_manifest_validation(char *manifest)
1975 if (manifest == NULL) {
1976 printf("Manifest file is NULL\n");
1979 ret = pkgmgr_parser_check_manifest_validation(manifest);
1981 printf("check manifest validation failed\n");
1987 int main(int argc, char *argv[])
1990 char *locale = NULL;
1995 gettimeofday(&tv, NULL);
1996 starttime = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
1998 locale = ail_vconf_get_str(VCONFKEY_LANGSET);
1999 //Work around for https://bugs.tizen.org/jira/browse/TC-2399
2000 if (locale == NULL) {
2001 printf("locale is NULL\n");
2006 printf("Locale is %s\n", locale);
2012 if (strcmp(argv[1], "--listpkg") == 0) {
2013 ret = __get_pkg_list(getuid());
2015 printf("get pkg list failed\n");
2020 } else if (strcmp(argv[1], "--app-flt") == 0) {
2021 ret = __add_app_filter(getuid());
2023 printf("Adding app filter failed\n");
2028 } else if (strcmp(argv[1], "--pkg-flt") == 0) {
2029 ret = __add_pkg_filter(getuid());
2031 printf("Adding pkg filter failed\n");
2036 } else if (strcmp(argv[1], "--metadata-flt") == 0) {
2037 ret = __add_metadata_filter();
2039 printf("Adding pkg filter failed\n");
2044 } else if (strcmp(argv[1], "--listapp") == 0) {
2045 ret = __get_installed_app_list(getuid());
2047 printf("get installed app list failed\n");
2057 }else if (argc == 4) {
2058 if (strcmp(argv[1], "--setappenabled") == 0) {
2059 ret = __set_app_enabled(argv[2], (strcmp(argv[3], "0")==0)?false:true);
2061 printf("set app enabled failed\n");
2065 } else if(strcmp(argv[1], "--setpkgenabled") == 0) {
2066 ret = __set_app_enabled(argv[2], (strcmp(argv[3], "0")==0)?false:true);
2068 printf("set pkg enabled failed\n");
2072 } else if (strcmp(argv[1], "--cmp-pkgcert") == 0) {
2073 ret = __compare_pkg_certinfo_from_db(argv[2], argv[3], getuid());
2075 printf("compare certinfo from db failed\n");
2079 } else if (strcmp(argv[1], "--cmp-appcert") == 0) {
2080 ret = __compare_app_certinfo_from_db(argv[2], argv[3], getuid());
2082 printf("compare certinfo from db failed\n");
2086 } else if (strcmp(argv[1], "--arg-flt") == 0) {
2087 ret = __add_arg_filter(argv[2], argv[3], getuid());
2089 printf("compare certinfo from db failed\n");
2105 if (!argv[1] || !argv[2]) {
2111 if (strcmp(argv[1], "--pkg") == 0) {
2112 ret = __get_pkg_info(argv[2], getuid());
2114 printf("get pkg info failed\n");
2117 } else if (strcmp(argv[1], "--app") == 0) {
2118 ret = __get_app_info(argv[2]);
2120 printf("get app info failed\n");
2123 } else if (strcmp(argv[1], "--list") == 0) {
2124 ret = __get_app_list(argv[2], getuid());
2126 printf("get app list failed\n");
2129 } else if (strcmp(argv[1], "--imd") == 0) {
2130 ret = __insert_manifest_in_db(argv[2], getuid());
2132 printf("insert in db failed\n");
2135 } else if (strcmp(argv[1], "--fota") == 0) {
2136 ret = __fota_insert_manifest_in_db(argv[2], getuid());
2138 printf("insert in db failed\n");
2141 } else if (strcmp(argv[1], "--rmd") == 0) {
2142 ret = __remove_manifest_from_db(argv[2], getuid());
2144 printf("remove from db failed\n");
2147 } else if (strcmp(argv[1], "--setcert") == 0) {
2148 ret = __set_certinfo_in_db(argv[2], getuid());
2150 printf("set certinfo in db failed\n");
2153 } else if (strcmp(argv[1], "--getcert") == 0) {
2154 ret = __get_certinfo_from_db(argv[2], getuid());
2156 printf("get certinfo from db failed\n");
2159 } else if (strcmp(argv[1], "--delcert") == 0) {
2160 ret = __del_certinfo_from_db(argv[2]);
2162 printf("del certinfo from db failed\n");
2165 } else if (strcmp(argv[1], "--check") == 0) {
2166 ret = __check_manifest_validation(argv[2]);
2168 printf("check manifest failed\n");
2171 } else if (strcmp(argv[1], "--category") == 0) {
2172 ret = __get_app_category_list(argv[2]);
2174 printf("get app category list failed\n");
2177 } else if (strcmp(argv[1], "--metadata") == 0) {
2178 ret = __get_app_metadata_list(argv[2]);
2180 printf("get app metadata list failed\n");
2183 } else if (strcmp(argv[1], "--appcontrol") == 0) {
2184 ret = __get_app_control_list(argv[2]);
2186 printf("get app control list failed\n");
2194 gettimeofday(&tv, NULL);
2195 endtime = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
2197 printf("spend time for pkginfo is [%d]ms\n", (int)(endtime - starttime));