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 choice = __get_integer_input_data();
422 ret = pkgmgrinfo_appinfo_filter_count(handle, &count);
424 printf("pkgmgrinfo_appinfo_filter_count() failed\n");
428 printf("App count = %d\n", count);
431 if (uid != GLOBAL_USER)
432 ret = pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, app_func, NULL, uid);
434 ret = pkgmgrinfo_appinfo_filter_foreach_appinfo(handle, app_func, NULL);
436 printf("pkgmgrinfo_appinfo_filter_foreach_appinfo() failed\n");
442 value = __get_string_input_data();
443 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
444 PMINFO_APPINFO_PROP_APP_ID, value);
446 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
454 value = __get_string_input_data();
455 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
456 PMINFO_APPINFO_PROP_APP_COMPONENT, value);
458 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
466 value = __get_string_input_data();
467 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
468 PMINFO_APPINFO_PROP_APP_EXEC, value);
470 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
478 value = __get_string_input_data();
479 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
480 PMINFO_APPINFO_PROP_APP_ICON, value);
482 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
490 value = __get_string_input_data();
491 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
492 PMINFO_APPINFO_PROP_APP_TYPE, value);
494 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
502 value = __get_string_input_data();
503 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
504 PMINFO_APPINFO_PROP_APP_OPERATION, value);
506 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
514 value = __get_string_input_data();
515 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
516 PMINFO_APPINFO_PROP_APP_URI, value);
518 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
526 value = __get_string_input_data();
527 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
528 PMINFO_APPINFO_PROP_APP_MIME, value);
530 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
538 value = __get_string_input_data();
539 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
540 PMINFO_APPINFO_PROP_APP_CATEGORY, value);
542 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
550 val = __get_integer_input_data();
551 ret = pkgmgrinfo_appinfo_filter_add_bool(handle,
552 PMINFO_APPINFO_PROP_APP_NODISPLAY, val);
554 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
560 val = __get_integer_input_data();
561 ret = pkgmgrinfo_appinfo_filter_add_bool(handle,
562 PMINFO_APPINFO_PROP_APP_MULTIPLE, val);
564 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
570 val = __get_integer_input_data();
571 ret = pkgmgrinfo_appinfo_filter_add_bool(handle,
572 PMINFO_APPINFO_PROP_APP_ONBOOT, val);
574 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
580 val = __get_integer_input_data();
581 ret = pkgmgrinfo_appinfo_filter_add_bool(handle,
582 PMINFO_APPINFO_PROP_APP_AUTORESTART, val);
584 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
590 val = __get_integer_input_data();
591 ret = pkgmgrinfo_appinfo_filter_add_bool(handle,
592 PMINFO_APPINFO_PROP_APP_TASKMANAGE, val);
594 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
600 value = __get_string_input_data();
601 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
602 PMINFO_APPINFO_PROP_APP_HWACCELERATION, value);
604 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
612 value = __get_string_input_data();
613 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
614 PMINFO_APPINFO_PROP_APP_SCREENREADER, value);
616 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
624 val = __get_integer_input_data();
625 ret = pkgmgrinfo_appinfo_filter_add_bool(handle,
626 PMINFO_APPINFO_PROP_APP_UI_GADGET, val);
628 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
634 printf("Invalid filter property\n");
635 pkgmgrinfo_appinfo_filter_destroy(handle);
642 pkgmgrinfo_appinfo_filter_destroy(handle);
650 static int __add_pkg_filter(uid_t uid)
657 pkgmgrinfo_pkginfo_filter_h handle;
659 ret = pkgmgrinfo_pkginfo_filter_create(&handle);
661 printf("pkginfo filter handle create failed\n");
664 while (choice != 0 && choice !=1)
666 printf("Enter Choice\n");
667 printf("0 --> Finalize filter and get count of packages\n");
668 printf("1 --> Finalize filter and get list of packages\n");
669 printf("2 --> filter by package ID\n");
670 printf("3 --> filter by package version\n");
671 printf("4 --> filter by package type\n");
672 printf("5 --> filter by package install location\n");
673 printf("6 --> filter by author name\n");
674 printf("7 --> filter by author email\n");
675 printf("8 --> filter by author href\n");
676 printf("9 --> filter by package removable [0|1]\n");
677 printf("10 --> filter by package readonly [0|1]\n");
678 printf("11 --> filter by package preload [0|1]\n");
679 printf("12 --> filter by package update [0|1]\n");
680 printf("13 --> filter by package appsetting [0|1]\n");
681 printf("14 --> filter by package size\n");
682 printf("15 --> filter by package installed storage[installed_internal | installed_external]\n");
683 printf("16 --> filter by package privilege\n");
684 choice = __get_integer_input_data();
687 if (uid != GLOBAL_USER)
688 ret = pkgmgrinfo_pkginfo_usr_filter_count(handle, &count, uid);
690 ret = pkgmgrinfo_pkginfo_filter_count(handle, &count);
692 printf("pkgmgrinfo_pkginfo_filter_count() failed\n");
696 printf("Package count = %d\n", count);
699 if (uid != GLOBAL_USER)
700 ret = pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo(handle, __pkg_list_cb, NULL, uid);
702 ret = pkgmgrinfo_pkginfo_filter_foreach_pkginfo(handle, __pkg_list_cb, NULL);
704 printf("pkgmgrinfo_pkginfo_(usr)_filter_foreach_pkginfo() failed\n");
710 value = __get_string_input_data();
711 ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
712 PMINFO_PKGINFO_PROP_PACKAGE_ID, value);
714 printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
722 value = __get_string_input_data();
723 ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
724 PMINFO_PKGINFO_PROP_PACKAGE_VERSION, 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_TYPE, 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_INSTALL_LOCATION, 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_AUTHOR_NAME, 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_EMAIL, 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_HREF, value);
786 printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
794 val = __get_integer_input_data();
795 ret = pkgmgrinfo_pkginfo_filter_add_bool(handle,
796 PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE, 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_READONLY, 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_PRELOAD, 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_UPDATE, val);
828 printf("pkgmgrinfo_pkginfo_filter_add_bool() failed\n");
834 val = __get_integer_input_data();
835 ret = pkgmgrinfo_pkginfo_filter_add_bool(handle,
836 PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING, val);
838 printf("pkgmgrinfo_pkginfo_filter_add_bool() failed\n");
844 val = __get_integer_input_data();
845 ret = pkgmgrinfo_pkginfo_filter_add_int(handle,
846 PMINFO_PKGINFO_PROP_PACKAGE_SIZE, val);
848 printf("pkgmgrinfo_pkginfo_filter_add_int() failed\n");
854 value = __get_string_input_data();
855 ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
856 PMINFO_PKGINFO_PROP_PACKAGE_INSTALLED_STORAGE, value);
858 printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
866 value = __get_string_input_data();
867 ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
868 PMINFO_PKGINFO_PROP_PACKAGE_PRIVILEGE,
871 printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
879 printf("Invalid filter property\n");
886 pkgmgrinfo_pkginfo_filter_destroy(handle);
894 static int __add_arg_filter(char *key, char *value, uid_t uid)
899 pkgmgrinfo_appinfo_filter_h handle;
900 ret = pkgmgrinfo_appinfo_filter_create(&handle);
902 printf("appinfo filter handle create failed\n");
909 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_ID, value);
911 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
917 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_COMPONENT, value);
919 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
925 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_EXEC, value);
927 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
933 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_ICON, value);
935 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
941 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_TYPE, value);
943 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
949 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_OPERATION, value);
951 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
957 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_URI, value);
959 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
965 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_MIME, value);
967 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
975 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_CATEGORY, value);
977 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
984 ret = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_NODISPLAY, val);
986 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
993 ret = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_MULTIPLE, val);
995 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
1002 ret = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_ONBOOT, val);
1004 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
1011 ret = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_AUTORESTART, val);
1013 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
1020 ret = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_TASKMANAGE, val);
1022 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
1028 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_HWACCELERATION, value);
1030 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
1036 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_SCREENREADER, value);
1038 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
1045 __print_arg_filter_usage();
1048 if (uid != GLOBAL_USER)
1049 ret = pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, __get_app_id, NULL, uid);
1051 ret = pkgmgrinfo_appinfo_filter_foreach_appinfo(handle, __get_app_id, NULL);
1053 printf("pkgmgrinfo_appinfo_filter_foreach_appinfo() failed\n");
1059 pkgmgrinfo_appinfo_filter_destroy(handle);
1062 static int __del_certinfo_from_db(char *pkgid)
1065 if (pkgid == NULL) {
1066 printf("pkgid is NULL\n");
1069 ret = pkgmgr_installer_delete_certinfo(pkgid);
1071 printf("pkgmgr_installer_delete_certinfo failed\n");
1077 static int __get_certinfo_from_db(char *pkgid, uid_t uid)
1079 if (pkgid == NULL) {
1080 printf("pkgid is NULL\n");
1086 const char *value = NULL;
1087 pkgmgrinfo_certinfo_h handle = NULL;
1088 ret = pkgmgrinfo_pkginfo_create_certinfo(&handle);
1090 printf("pkgmgrinfo_pkginfo_create_certinfo failed\n");
1093 ret = pkgmgrinfo_pkginfo_load_certinfo(pkgid, handle, uid);
1095 printf("pkgmgrinfo_pkginfo_load_certinfo failed\n");
1098 while (choice != 10)
1100 printf("Enter the choice to get\n");
1101 printf("0 --> to get all cert values\n");
1102 printf("1 --> author root certificate\n");
1103 printf("2 --> author intermediate certificate\n");
1104 printf("3 --> author signer certificate\n");
1105 printf("4 --> distributor root certificate\n");
1106 printf("5 --> distributor intermediate certificate\n");
1107 printf("6 --> distributor signer certificate\n");
1108 printf("7 --> distributor2 root certificate\n");
1109 printf("8 --> distributor2 intermediate certificate\n");
1110 printf("9 --> distributor2 signer certificate\n");
1111 printf("10 --> exit\n");
1112 choice = __get_integer_input_data();
1115 for (i = 0; i < 9; i++)
1117 pkgmgrinfo_pkginfo_get_cert_value(handle, i, &value);
1119 printf("cert type[%d] value = %s\n", i, value);
1121 ret = pkgmgrinfo_pkginfo_destroy_certinfo(handle);
1123 printf("pkgmgrinfo_pkginfo_destroy_certinfo failed\n");
1136 ret = pkgmgrinfo_pkginfo_get_cert_value(handle, choice - 1, &value);
1138 printf("cert type[%d] value = %s\n", choice - 1, value);
1141 ret = pkgmgrinfo_pkginfo_destroy_certinfo(handle);
1143 printf("pkgmgrinfo_pkginfo_destroy_certinfo failed\n");
1148 printf("Invalid choice entered\n");
1156 static int __compare_pkg_certinfo_from_db(char *lhs_pkgid, char *rhs_pkgid, uid_t uid)
1158 if (lhs_pkgid == NULL || rhs_pkgid == NULL) {
1159 printf("pkgid is NULL\n");
1164 pkgmgrinfo_cert_compare_result_type_e result;
1165 if (uid != GLOBAL_USER)
1166 ret = pkgmgrinfo_pkginfo_compare_usr_pkg_cert_info(lhs_pkgid, rhs_pkgid, uid, &result);
1168 ret = pkgmgrinfo_pkginfo_compare_pkg_cert_info(lhs_pkgid, rhs_pkgid, &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("pkgid =[%s] and [%s] compare result = [%d] \n", lhs_pkgid, rhs_pkgid, result);
1178 static int __compare_app_certinfo_from_db(char *lhs_appid, char *rhs_appid, uid_t uid)
1180 if (lhs_appid == NULL || rhs_appid == NULL) {
1181 printf("appid is NULL\n");
1186 pkgmgrinfo_cert_compare_result_type_e result;
1187 if (uid != GLOBAL_USER)
1188 ret = pkgmgrinfo_pkginfo_compare_usr_app_cert_info(lhs_appid, rhs_appid, uid, &result);
1190 ret = pkgmgrinfo_pkginfo_compare_app_cert_info(lhs_appid, rhs_appid, &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("appid =[%s] and [%s] compare result = [%d] \n", lhs_appid, rhs_appid, result);
1200 static int __set_certinfo_in_db(char *pkgid, uid_t uid)
1202 if (pkgid == NULL) {
1203 printf("pkgid is NULL\n");
1209 pkgmgr_instcertinfo_h handle = NULL;
1210 ret = pkgmgr_installer_create_certinfo_set_handle(&handle);
1212 printf("pkgmgr_installer_create_certinfo_set_handle failed\n");
1217 printf("Enter the choice you want to set\n");
1218 printf("0 --> to set data in DB\n");
1219 printf("1 --> author root certificate\n");
1220 printf("2 --> author intermediate certificate\n");
1221 printf("3 --> author signer certificate\n");
1222 printf("4 --> distributor root certificate\n");
1223 printf("5 --> distributor intermediate certificate\n");
1224 printf("6 --> distributor signer certificate\n");
1225 printf("7 --> distributor2 root certificate\n");
1226 printf("8 --> distributor2 intermediate certificate\n");
1227 printf("9 --> distributor2 signer certificate\n");
1228 choice = __get_integer_input_data();
1231 ret = pkgmgr_installer_save_certinfo(pkgid, handle, uid);
1233 printf("pkgmgr_installer_save_certinfo failed\n");
1234 pkgmgr_installer_destroy_certinfo_set_handle(handle);
1237 ret = pkgmgr_installer_destroy_certinfo_set_handle(handle);
1239 printf("pkgmgr_installer_destroy_certinfo_set_handle failed\n");
1244 printf("Enter Author Root Certificate Value: \n");
1245 value = __get_string_input_data();
1246 ret = pkgmgr_installer_set_cert_value(handle, 0, value);
1248 printf("pkgmgr_installer_set_cert_value failed\n");
1256 printf("Enter Author Intermediate Certificate Value: \n");
1257 value = __get_string_input_data();
1258 ret = pkgmgr_installer_set_cert_value(handle, 1, value);
1260 printf("pkgmgr_installer_set_cert_value failed\n");
1268 printf("Enter Author Signer Certificate Value: \n");
1269 value = __get_string_input_data();
1270 ret = pkgmgr_installer_set_cert_value(handle, 2, value);
1272 printf("pkgmgr_installer_set_cert_value failed\n");
1280 printf("Enter Distributor Root Certificate Value: \n");
1281 value = __get_string_input_data();
1282 ret = pkgmgr_installer_set_cert_value(handle, 3, value);
1284 printf("pkgmgr_installer_set_cert_value failed\n");
1292 printf("Enter Distributor Intermediate Certificate Value: \n");
1293 value = __get_string_input_data();
1294 ret = pkgmgr_installer_set_cert_value(handle, 4, value);
1296 printf("pkgmgr_installer_set_cert_value failed\n");
1304 printf("Enter Distributor Signer Certificate Value: \n");
1305 value = __get_string_input_data();
1306 ret = pkgmgr_installer_set_cert_value(handle, 5, value);
1308 printf("pkgmgr_installer_set_cert_value failed\n");
1316 printf("Enter Distributor2 Root Certificate Value: \n");
1317 value = __get_string_input_data();
1318 ret = pkgmgr_installer_set_cert_value(handle, 6, value);
1320 printf("pkgmgr_installer_set_cert_value failed\n");
1328 printf("Enter Distributor2 Intermediate Certificate Value: \n");
1329 value = __get_string_input_data();
1330 ret = pkgmgr_installer_set_cert_value(handle, 7, value);
1332 printf("pkgmgr_installer_set_cert_value failed\n");
1340 printf("Enter Distributor2 Signer Certificate Value: \n");
1341 value = __get_string_input_data();
1342 ret = pkgmgr_installer_set_cert_value(handle, 8, value);
1344 printf("pkgmgr_installer_set_cert_value failed\n");
1352 printf("Invalid Number Entered\n");
1354 ret = pkgmgr_installer_destroy_certinfo_set_handle(handle);
1356 printf("pkgmgr_installer_destroy_certinfo_set_handle failed\n");
1367 pkgmgr_installer_destroy_certinfo_set_handle(handle);
1371 static int __insert_manifest_in_db(char *manifest, uid_t uid)
1374 if (manifest == NULL) {
1375 printf("Manifest file is NULL\n");
1378 if (uid == GLOBAL_USER || uid == OWNER_ROOT)
1379 ret = pkgmgr_parser_parse_manifest_for_installation(manifest, NULL);
1381 ret = pkgmgr_parser_parse_usr_manifest_for_installation(manifest, uid, NULL);
1383 printf("insert in db failed\n");
1389 static int __fota_insert_manifest_in_db(char *manifest, uid_t uid)
1392 char *temp[] = {"fota=true", NULL};
1394 if (manifest == NULL) {
1395 printf("Manifest file is NULL\n");
1398 if (uid != GLOBAL_USER)
1399 ret = pkgmgr_parser_parse_usr_manifest_for_installation(manifest, uid, NULL);
1401 ret = pkgmgr_parser_parse_manifest_for_installation(manifest, NULL);
1403 printf("insert in db failed\n");
1409 static int __remove_manifest_from_db(char *manifest, uid_t uid)
1412 if (manifest == NULL) {
1413 printf("Manifest file is NULL\n");
1416 if (uid != GLOBAL_USER)
1417 ret = pkgmgr_parser_parse_usr_manifest_for_uninstallation(manifest, uid, NULL);
1419 ret = pkgmgr_parser_parse_manifest_for_uninstallation(manifest, NULL);
1421 printf("remove from db failed\n");
1427 int app_func(const pkgmgrinfo_appinfo_h handle, void *user_data)
1432 data = (char *)user_data;
1438 pkgmgrinfo_app_component component = 0;
1439 char *apptype = NULL;
1442 bool taskmanage = 0;
1443 pkgmgrinfo_app_hwacceleration hwacceleration;
1444 pkgmgrinfo_app_screenreader screenreader;
1446 bool autorestart = 0;
1447 char *package = NULL;
1449 ret = pkgmgrinfo_appinfo_get_appid(handle, &appid);
1451 printf("Failed to get appid\n");
1454 printf("Appid: %s\n", appid);
1456 ret = pkgmgrinfo_appinfo_get_pkgid(handle, &package);
1458 printf("Failed to get package\n");
1461 printf("Package: %s\n", package);
1463 ret = pkgmgrinfo_appinfo_get_exec(handle, &exec);
1465 printf("Failed to get exec\n");
1468 printf("Exec: %s\n", exec);
1470 ret = pkgmgrinfo_appinfo_get_icon(handle, &icon);
1472 printf("Failed to get icon\n");
1475 printf("Icon: %s\n", icon);
1477 ret = pkgmgrinfo_appinfo_get_label(handle, &label);
1479 printf("Failed to get label\n");
1482 printf("Label: %s\n", label);
1484 ret = pkgmgrinfo_appinfo_get_component(handle, &component);
1486 printf("Failed to get component\n");
1489 ret = pkgmgrinfo_appinfo_get_apptype(handle, &apptype);
1491 printf("Failed to get apptype\n");
1494 printf("Apptype: %s\n", apptype);
1496 if (component == PMINFO_UI_APP) {
1497 printf("component: uiapp\n");
1498 ret = pkgmgrinfo_appinfo_is_multiple(handle, &multiple);
1500 printf("Failed to get multiple\n");
1502 printf("Multiple: %d\n", multiple);
1505 ret = pkgmgrinfo_appinfo_is_nodisplay(handle, &nodisplay);
1507 printf("Failed to get nodisplay\n");
1509 printf("Nodisplay: %d \n", nodisplay);
1512 ret = pkgmgrinfo_appinfo_is_taskmanage(handle, &taskmanage);
1514 printf("Failed to get taskmanage\n");
1516 printf("Taskmanage: %d\n", taskmanage);
1519 ret = pkgmgrinfo_appinfo_get_hwacceleration(handle, &hwacceleration);
1521 printf("Failed to get hwacceleration\n");
1523 printf("hw-acceleration: %d\n", hwacceleration);
1526 ret = pkgmgrinfo_appinfo_get_screenreader(handle, &screenreader);
1528 printf("Failed to get screenreader\n");
1530 printf("screenreader: %d\n", screenreader);
1534 if (component == PMINFO_SVC_APP) {
1535 printf("component: svcapp\n");
1536 ret = pkgmgrinfo_appinfo_is_onboot(handle, &onboot);
1538 printf("Failed to get onboot\n");
1540 printf("Onboot: %d\n", onboot);
1543 ret = pkgmgrinfo_appinfo_is_autorestart(handle, &autorestart);
1545 printf("Failed to get autorestart\n");
1547 printf("Autorestart: %d \n", autorestart);
1551 printf("user_data : %s\n\n", data);
1557 static int __pkg_list_cb (const pkgmgrinfo_pkginfo_h handle, void *user_data)
1559 char *test_data = "test data";
1565 int installed_time = -1;
1567 pkgmgrinfo_uidinfo_t *uid_info = (pkgmgrinfo_uidinfo_t *) handle;
1568 ret = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
1570 printf("pkgmgrinfo_pkginfo_get_pkgid() failed\n");
1572 ret = pkgmgrinfo_pkginfo_get_type(handle, &pkg_type);
1574 printf("pkgmgrinfo_pkginfo_get_type() failed\n");
1576 ret = pkgmgrinfo_pkginfo_get_version(handle, &pkg_version);
1578 printf("pkgmgrinfo_pkginfo_get_version() failed\n");
1580 ret = pkgmgrinfo_pkginfo_is_preload(handle, &preload);
1582 printf("pkgmgrinfo_pkginfo_is_preload() failed\n");
1584 ret = pkgmgrinfo_pkginfo_get_installed_time(handle, &installed_time);
1586 printf("pkgmgrinfo_pkginfo_get_installed_time() failed\n");
1590 printf("---------------------------------------\n");
1591 printf("pkg_type [%s]\tpkgid [%s]\tversion [%s]\tpreload [%d]\tinstalled_time [%d]\n", pkg_type,
1592 pkgid, pkg_version, preload, installed_time);
1594 if (uid_info->uid != GLOBAL_USER) {
1595 printf("**List of Ui-Apps**\n");
1596 ret = pkgmgrinfo_appinfo_get_usr_list(handle, PMINFO_UI_APP, app_func, (void *)test_data, uid_info->uid);
1598 printf("pkgmgr_get_info_app() failed\n");
1600 printf("**List of Svc-Apps**\n");
1601 ret = pkgmgrinfo_appinfo_get_usr_list(handle, PMINFO_SVC_APP, app_func, (void *)test_data, uid_info->uid);
1603 printf("pkgmgr_get_info_app() failed\n");
1606 printf("**List of Ui-Apps**\n");
1607 ret = pkgmgrinfo_appinfo_get_list(handle, PMINFO_UI_APP, app_func, (void *)test_data);
1609 printf("pkgmgr_get_info_app() failed\n");
1611 printf("**List of Svc-Apps**\n");
1612 ret = pkgmgrinfo_appinfo_get_list(handle, PMINFO_SVC_APP, app_func, (void *)test_data);
1614 printf("pkgmgr_get_info_app() failed\n");
1617 printf("---------------------------------------\n");
1622 static int __get_pkg_list(uid_t uid)
1625 if (uid != GLOBAL_USER)
1626 ret = pkgmgrinfo_pkginfo_get_usr_list(__pkg_list_cb, NULL, uid);
1628 ret = pkgmgrinfo_pkginfo_get_list(__pkg_list_cb, NULL);
1630 printf("pkgmgrinfo_pkginfo_get_list() failed\n");
1636 static int __get_installed_app_list(uid_t uid)
1639 if(uid != GLOBAL_USER)
1640 ret = pkgmgrinfo_appinfo_get_usr_installed_list(app_func, uid, NULL);
1642 ret = pkgmgrinfo_appinfo_get_installed_list(app_func, NULL);
1644 printf("pkgmgrinfo_appinfo_get_installed_list() failed\n");
1651 static int __app_category_list_cb(const char *category_name, void *user_data)
1654 printf("Category: %s\n", category_name);
1658 static int __app_metadata_list_cb(const char *metadata_name, const char *metadata_value, void *user_data)
1660 if (metadata_name && metadata_value) {
1661 printf("Name: %s\n", metadata_name);
1662 printf("Value: %s\n", metadata_value);
1668 static int __app_control_list_cb(const char *operation, const char *uri, const char *mime, void *user_data)
1670 printf("-------------------------------------------------------\n");
1671 printf("Operation: %s\n", operation);
1672 printf("Uri: %s\n", uri);
1673 printf("Mime: %s\n", mime);
1674 printf("-------------------------------------------------------\n\n");
1679 static int __get_app_category_list(char *appid)
1682 pkgmgrinfo_appinfo_h handle;
1683 ret = pkgmgrinfo_appinfo_get_usr_appinfo(appid, getuid(), &handle);
1685 printf("Failed to get handle\n");
1688 ret = pkgmgrinfo_appinfo_foreach_category(handle, __app_category_list_cb, NULL);
1690 printf("pkgmgrinfo_appinfo_foreach_category() failed\n");
1691 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1694 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1698 static int __get_app_metadata_list(char *appid)
1701 pkgmgrinfo_appinfo_h handle;
1702 ret = pkgmgrinfo_appinfo_get_usr_appinfo(appid, getuid(), &handle);
1704 printf("Failed to get handle\n");
1707 ret = pkgmgrinfo_appinfo_foreach_metadata(handle, __app_metadata_list_cb, NULL);
1709 printf("pkgmgrinfo_appinfo_foreach_metadata() failed\n");
1710 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1713 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1717 static int __get_app_control_list(char *appid)
1720 pkgmgrinfo_appinfo_h handle;
1721 ret = pkgmgrinfo_appinfo_get_usr_appinfo(appid, getuid(), &handle);
1723 printf("Failed to get handle\n");
1726 ret = pkgmgrinfo_appinfo_foreach_appcontrol(handle, __app_control_list_cb, NULL);
1728 printf("pkgmgrinfo_appinfo_foreach_appcontrol() failed\n");
1729 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1732 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1736 static int __set_app_enabled(char *appid, bool enabled)
1739 ret = pkgmgrinfo_appinfo_set_state_enabled(appid, enabled);
1741 printf("Failed to get handle\n");
1747 static int __get_app_list(char *pkgid, uid_t uid)
1749 pkgmgrinfo_pkginfo_h handle;
1751 char *test_data = "test data";
1752 if(uid != GLOBAL_USER)
1753 ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, uid, &handle);
1755 ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
1757 printf("Failed to get handle\n");
1760 if (uid != GLOBAL_USER) {
1761 printf("List of Ui-Apps\n\n");
1762 ret = pkgmgrinfo_appinfo_get_usr_list(handle, PMINFO_UI_APP, app_func, (void *)test_data, uid);
1764 printf("pkgmgrinfo_appinfo_get_list() failed\n");
1766 printf("List of Svc-Apps\n\n");
1767 ret = pkgmgrinfo_appinfo_get_usr_list(handle, PMINFO_SVC_APP, app_func, (void *)test_data, uid);
1769 printf("pkgmgrinfo_appinfo_get_list() failed\n");
1772 printf("List of Ui-Apps\n\n");
1773 ret = pkgmgrinfo_appinfo_get_list(handle, PMINFO_UI_APP, app_func, (void *)test_data);
1775 printf("pkgmgrinfo_appinfo_get_list() failed\n");
1777 printf("List of Svc-Apps\n\n");
1778 ret = pkgmgrinfo_appinfo_get_list(handle, PMINFO_SVC_APP, app_func, (void *)test_data);
1780 printf("pkgmgrinfo_appinfo_get_list() failed\n");
1783 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
1787 static int __get_pkg_info(char *pkgid, uid_t uid)
1789 pkgmgrinfo_pkginfo_h handle;
1792 printf("Get Pkg Info Called [%s]\n", pkgid);
1793 if(uid != GLOBAL_USER)
1794 ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, uid, &handle);
1796 ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
1798 printf("Failed to get handle\n");
1802 __get_pkgmgrinfo_pkginfo(handle, NULL);
1804 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
1808 static int __get_app_info(char *appid)
1810 printf("Get App Info Called [%s]\n", appid);
1812 char *app_id = NULL;
1813 char *apptype = NULL;
1816 char *package = NULL;
1817 pkgmgrinfo_app_component component = 0;
1820 bool taskmanage = 0;
1821 pkgmgrinfo_app_hwacceleration hwacceleration;
1822 pkgmgrinfo_app_screenreader screenreader;
1824 bool autorestart = 0;
1827 pkgmgrinfo_appinfo_h handle;
1830 ret = pkgmgrinfo_appinfo_get_usr_appinfo(appid, getuid(), &handle);
1832 printf("Failed to get handle\n");
1836 ret = pkgmgrinfo_appinfo_get_pkgid(handle, &package);
1838 printf("Failed to get package\n");
1841 ret = pkgmgrinfo_appinfo_get_appid(handle, &app_id);
1843 printf("Failed to get exec\n");
1846 ret = pkgmgrinfo_appinfo_get_label(handle, &label);
1848 printf("Failed to get label\n");
1850 ret = pkgmgrinfo_appinfo_get_icon(handle, &icon);
1852 printf("Failed to get icon\n");
1855 ret = pkgmgrinfo_appinfo_get_exec(handle, &exec);
1857 printf("Failed to get exec\n");
1859 ret = pkgmgrinfo_appinfo_get_component(handle, &component);
1861 printf("Failed to get component\n");
1863 ret = pkgmgrinfo_appinfo_get_apptype(handle, &apptype);
1865 printf("Failed to get apptype\n");
1867 ret = pkgmgrinfo_appinfo_is_nodisplay(handle, &nodisplay);
1869 printf("Failed to get nodisplay\n");
1871 ret = pkgmgrinfo_appinfo_is_multiple(handle, &multiple);
1873 printf("Failed to get multiple\n");
1875 ret = pkgmgrinfo_appinfo_is_taskmanage(handle, &taskmanage);
1877 printf("Failed to get taskmanage\n");
1879 ret = pkgmgrinfo_appinfo_get_hwacceleration(handle, &hwacceleration);
1881 printf("Failed to get hwacceleration\n");
1883 ret = pkgmgrinfo_appinfo_get_screenreader(handle, &screenreader);
1885 printf("Failed to get screenreader\n");
1887 ret = pkgmgrinfo_appinfo_is_onboot(handle, &onboot);
1889 printf("Failed to get onboot\n");
1891 ret = pkgmgrinfo_appinfo_is_autorestart(handle, &autorestart);
1893 printf("Failed to get autorestart\n");
1895 ret = pkgmgrinfo_appinfo_is_enabled(handle, &enabled);
1897 printf("Failed to get enabled\n");
1899 ret = pkgmgrinfo_appinfo_is_preload(handle, &preload);
1901 printf("Failed to get preload\n");
1905 printf("Appid: %s\n", app_id);
1908 printf("Package: %s\n", package);
1911 printf("Exec: %s\n", exec);
1913 printf("Apptype: %s\n", apptype);
1915 if (component == PMINFO_UI_APP) {
1916 printf("component: uiapp\n");
1919 printf("Icon: %s\n", icon);
1921 printf("Label: %s\n", label);
1923 printf("Nodisplay: %d\n", nodisplay);
1924 printf("Multiple: %d\n", multiple);
1925 printf("Taskmanage: %d\n", taskmanage);
1926 printf("Hw-Acceleration: %d\n", hwacceleration);
1927 printf("Screenreader: %d\n", screenreader);
1928 } else if (component == PMINFO_SVC_APP) {
1929 printf("component: svcapp\n");
1932 printf("Icon: %s\n", icon);
1934 printf("Label: %s\n", label);
1936 printf("Autorestart: %d\n", autorestart);
1937 printf("Onboot: %d\n", onboot);
1939 printf("Invalid Component Type\n");
1942 printf("Enabled: %d\n", enabled);
1943 printf("Preload: %d\n", preload);
1945 pkgmgrinfo_appinfo_destroy_appinfo(handle);
1950 static int __check_manifest_validation(char *manifest)
1953 if (manifest == NULL) {
1954 printf("Manifest file is NULL\n");
1957 ret = pkgmgr_parser_check_manifest_validation(manifest);
1959 printf("check manifest validation failed\n");
1965 int main(int argc, char *argv[])
1968 char *locale = NULL;
1973 gettimeofday(&tv, NULL);
1974 starttime = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
1976 locale = ail_vconf_get_str(VCONFKEY_LANGSET);
1977 //Work around for https://bugs.tizen.org/jira/browse/TC-2399
1978 if (locale == NULL) {
1979 printf("locale is NULL\n");
1984 printf("Locale is %s\n", locale);
1990 if (strcmp(argv[1], "--listpkg") == 0) {
1991 ret = __get_pkg_list(getuid());
1993 printf("get pkg list failed\n");
1998 } else if (strcmp(argv[1], "--app-flt") == 0) {
1999 ret = __add_app_filter(getuid());
2001 printf("Adding app filter failed\n");
2006 } else if (strcmp(argv[1], "--pkg-flt") == 0) {
2007 ret = __add_pkg_filter(getuid());
2009 printf("Adding pkg filter failed\n");
2014 } else if (strcmp(argv[1], "--metadata-flt") == 0) {
2015 ret = __add_metadata_filter();
2017 printf("Adding pkg filter failed\n");
2022 } else if (strcmp(argv[1], "--listapp") == 0) {
2023 ret = __get_installed_app_list(getuid());
2025 printf("get installed app list failed\n");
2035 }else if (argc == 4) {
2036 if (strcmp(argv[1], "--setappenabled") == 0) {
2037 ret = __set_app_enabled(argv[2], (strcmp(argv[3], "0")==0)?false:true);
2039 printf("set app enabled failed\n");
2043 } else if(strcmp(argv[1], "--setpkgenabled") == 0) {
2044 ret = __set_app_enabled(argv[2], (strcmp(argv[3], "0")==0)?false:true);
2046 printf("set pkg enabled failed\n");
2050 } else if (strcmp(argv[1], "--cmp-pkgcert") == 0) {
2051 ret = __compare_pkg_certinfo_from_db(argv[2], argv[3], getuid());
2053 printf("compare certinfo from db failed\n");
2057 } else if (strcmp(argv[1], "--cmp-appcert") == 0) {
2058 ret = __compare_app_certinfo_from_db(argv[2], argv[3], getuid());
2060 printf("compare certinfo from db failed\n");
2064 } else if (strcmp(argv[1], "--arg-flt") == 0) {
2065 ret = __add_arg_filter(argv[2], argv[3], getuid());
2067 printf("compare certinfo from db failed\n");
2083 if (!argv[1] || !argv[2]) {
2089 if (strcmp(argv[1], "--pkg") == 0) {
2090 ret = __get_pkg_info(argv[2], getuid());
2092 printf("get pkg info failed\n");
2095 } else if (strcmp(argv[1], "--app") == 0) {
2096 ret = __get_app_info(argv[2]);
2098 printf("get app info failed\n");
2101 } else if (strcmp(argv[1], "--list") == 0) {
2102 ret = __get_app_list(argv[2], getuid());
2104 printf("get app list failed\n");
2107 } else if (strcmp(argv[1], "--imd") == 0) {
2108 ret = __insert_manifest_in_db(argv[2], getuid());
2110 printf("insert in db failed\n");
2113 } else if (strcmp(argv[1], "--fota") == 0) {
2114 ret = __fota_insert_manifest_in_db(argv[2], getuid());
2116 printf("insert in db failed\n");
2119 } else if (strcmp(argv[1], "--rmd") == 0) {
2120 ret = __remove_manifest_from_db(argv[2], getuid());
2122 printf("remove from db failed\n");
2125 } else if (strcmp(argv[1], "--setcert") == 0) {
2126 ret = __set_certinfo_in_db(argv[2], getuid());
2128 printf("set certinfo in db failed\n");
2131 } else if (strcmp(argv[1], "--getcert") == 0) {
2132 ret = __get_certinfo_from_db(argv[2], getuid());
2134 printf("get certinfo from db failed\n");
2137 } else if (strcmp(argv[1], "--delcert") == 0) {
2138 ret = __del_certinfo_from_db(argv[2]);
2140 printf("del certinfo from db failed\n");
2143 } else if (strcmp(argv[1], "--check") == 0) {
2144 ret = __check_manifest_validation(argv[2]);
2146 printf("check manifest failed\n");
2149 } else if (strcmp(argv[1], "--category") == 0) {
2150 ret = __get_app_category_list(argv[2]);
2152 printf("get app category list failed\n");
2155 } else if (strcmp(argv[1], "--metadata") == 0) {
2156 ret = __get_app_metadata_list(argv[2]);
2158 printf("get app metadata list failed\n");
2161 } else if (strcmp(argv[1], "--appcontrol") == 0) {
2162 ret = __get_app_control_list(argv[2]);
2164 printf("get app control list failed\n");
2172 gettimeofday(&tv, NULL);
2173 endtime = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
2175 printf("spend time for pkginfo is [%d]ms\n", (int)(endtime - starttime));