4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
7 * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
29 #include <sys/types.h>
31 #include <pkgmgr_parser.h>
32 #include <pkgmgr-info.h>
33 #include "package-manager.h"
34 #include "package-manager-types.h"
35 #include "pkgmgr-dbinfo.h"
36 #include "pkgmgr_installer.h"
40 static void __print_usage();
41 static int __get_pkg_info(char *pkgid, uid_t uid);
42 static int __get_app_info(char *appid);
43 static int __get_app_list(char *pkgid, uid_t uid);
44 static int __get_app_category_list(char *appid);
45 static int __get_app_metadata_list(char *appid);
46 static int __get_app_control_list(char *appid);
47 static int __get_pkg_list(uid_t uid);
48 static int __get_installed_app_list(uid_t uid);
49 static int __add_app_filter(uid_t uid);
50 static int __add_pkg_filter(uid_t uid);
51 static int __insert_manifest_in_db(char *manifest, uid_t uid);
52 static int __remove_manifest_from_db(char *manifest, uid_t uid);
53 static int __set_pkginfo_in_db(char *pkgid, uid_t uid);
54 static int __set_certinfo_in_db(char *pkgid);
55 static int __get_certinfo_from_db(char *pkgid);
56 static int __del_certinfo_from_db(char *pkgid);
57 static int __get_integer_input_data(void);
58 char *__get_string_input_data(void);
59 static int __pkg_list_cb (const pkgmgr_pkginfo_h handle, void *user_data, uid_t uid);
60 static int __app_category_list_cb(const char *category_name, void *user_data);
61 static int __app_control_list_cb(pkgmgrinfo_appcontrol_h handle, void *user_data);
62 static int __app_metadata_list_cb(const char *metadata_name, const char *metadata_value, void *user_data);
63 int app_func(const pkgmgr_appinfo_h handle, void *user_data);
65 static void __get_pkgmgrinfo_pkginfo(const pkgmgrinfo_pkginfo_h handle, void *user_data)
70 char *author_name = NULL;
71 char *author_email = NULL;
72 char *author_href = NULL;
73 char *root_path = NULL;
74 char *mainappid = NULL;
75 pkgmgr_install_location location = 0;
85 int installed_time = -1;
87 ret = pkgmgrinfo_pkginfo_get_type(handle, &type);
89 printf("Failed to get pkg type\n");
92 printf("Type: %s\n", type);
94 ret = pkgmgrinfo_pkginfo_get_version(handle, &version);
96 printf("Failed to get version\n");
99 printf("Version: %s\n", version);
101 ret = pkgmgrinfo_pkginfo_get_install_location(handle, &location);
103 printf("Failed to get install location\n");
105 printf("Install Location: %d\n", location);
107 ret = pkgmgrinfo_pkginfo_get_package_size(handle, &size);
109 printf("Failed to get package size \n");
111 printf("Package Size: %d\n", size);
113 ret = pkgmgrinfo_pkginfo_get_icon(handle, &icon);
115 printf("Failed to get icon\n");
118 printf("Icon: %s\n", icon);
120 ret = pkgmgrinfo_pkginfo_get_label(handle, &label);
122 printf("Failed to get label\n");
125 printf("Label: %s\n", label);
127 ret = pkgmgrinfo_pkginfo_get_description(handle, &desc);
129 printf("Failed to get description\n");
132 printf("Description: %s\n", desc);
134 ret = pkgmgrinfo_pkginfo_get_author_name(handle, &author_name);
136 printf("Failed to get author name\n");
139 printf("Author Name: %s\n", author_name);
141 ret = pkgmgrinfo_pkginfo_get_author_email(handle, &author_email);
143 printf("Failed to get author email\n");
146 printf("Author Email: %s\n", author_email);
148 ret = pkgmgrinfo_pkginfo_get_author_href(handle, &author_href);
150 printf("Failed to get author href\n");
153 printf("Author Href: %s\n", author_href);
155 ret = pkgmgrinfo_pkginfo_get_root_path(handle, &root_path);
157 printf("Failed to get root_path\n");
160 printf("root_path : %s\n", root_path);
162 ret = pkgmgrinfo_pkginfo_get_mainappid(handle, &mainappid);
164 printf("Failed to get mainappid\n");
167 printf("mainappid : %s\n", mainappid);
169 ret = pkgmgrinfo_pkginfo_get_installed_time(handle, &installed_time);
171 printf("Failed to get install time\n");
173 printf("Install time: %d\n", installed_time);
175 ret = pkgmgrinfo_pkginfo_is_removable(handle, &removable);
177 printf("Failed to get removable\n");
180 printf("Removable: %d\n", removable);
182 ret = pkgmgrinfo_pkginfo_is_preload(handle, &preload);
184 printf("Failed to get preload\n");
187 printf("Preload: %d\n", preload);
189 ret = pkgmgrinfo_pkginfo_is_readonly(handle, &readonly);
191 printf("Failed to get readonly\n");
194 printf("Readonly: %d\n", readonly);
196 ret = pkgmgrinfo_pkginfo_is_update(handle, &update);
198 printf("Failed to get update\n");
201 printf("update: %d\n", update);
203 ret = pkgmgrinfo_pkginfo_is_system(handle, &system);
205 printf("Failed to get system\n");
208 printf("system: %d\n", system);
212 int __get_app_id(const pkgmgrinfo_appinfo_h handle, void *user_data)
215 char *apptype = NULL;
218 ret = pkgmgrinfo_appinfo_get_appid(handle, &appid);
220 printf("Failed to get appid\n");
223 ret = pkgmgrinfo_appinfo_get_apptype(handle, &apptype);
225 printf("Failed to get package\n");
227 printf("apptype [%s]\t appid [%s]\n", apptype, appid);
232 static int __get_integer_input_data(void)
234 char input_str[32] = { 0, };
237 if (fgets(input_str, sizeof(input_str), stdin) == NULL) {
238 printf("fgets() failed....\n");
242 if (sscanf(input_str, "%4d", &data) != 1) {
243 printf("Input only integer option....\n");
251 char *__get_string_input_data(void)
253 char *data = (char *)malloc(1024);
255 printf("Malloc Failed\n");
258 if (fgets(data,1024,stdin) == NULL){
259 printf("Buffer overflow!!! try again\n");
262 data[strlen(data) - 1] = '\0';
266 static void __print_usage()
268 printf("For Getting package|App Info\n");
269 printf("\tpkginfo --[pkg|app] <pkgid|appid>\n\n");
270 printf("For Getting list of installed packages\n");
271 printf("\tpkginfo --listpkg \n\n");
272 printf("For Getting list of installed applications\n");
273 printf("\tpkginfo --listapp \n\n");
274 printf("For Getting app list for a particular package\n");
275 printf("\tpkginfo --list <pkgid>\n\n");
276 printf("For Getting app category list for a particular application\n");
277 printf("\tpkginfo --category <appid>\n\n");
278 printf("For Getting app metadata list for a particular application\n");
279 printf("\tpkginfo --metadata <appid>\n\n");
280 printf("For Getting app control list for a particular application\n");
281 printf("\tpkginfo --appcontrol <appid>\n\n");
282 printf("To insert|remove manifest info in DB\n");
283 printf("\tpkginfo --[imd|rmd] <manifest file name>\n\n");
284 printf("To set pkginfo in DB\n");
285 printf("\tpkginfo --setdb <pkgid>\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 choice = __get_integer_input_data();
421 ret = pkgmgrinfo_appinfo_filter_count(handle, &count);
423 printf("pkgmgrinfo_appinfo_filter_count() failed\n");
427 printf("App count = %d\n", count);
430 if (uid != GLOBAL_USER)
431 ret = pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, app_func, NULL, uid);
433 ret = pkgmgrinfo_appinfo_filter_foreach_appinfo(handle, app_func, NULL);
435 printf("pkgmgrinfo_appinfo_filter_foreach_appinfo() failed\n");
441 value = __get_string_input_data();
442 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
443 PMINFO_APPINFO_PROP_APP_ID, value);
445 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
453 value = __get_string_input_data();
454 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
455 PMINFO_APPINFO_PROP_APP_COMPONENT, value);
457 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
465 value = __get_string_input_data();
466 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
467 PMINFO_APPINFO_PROP_APP_EXEC, value);
469 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
477 value = __get_string_input_data();
478 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
479 PMINFO_APPINFO_PROP_APP_ICON, value);
481 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
489 value = __get_string_input_data();
490 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
491 PMINFO_APPINFO_PROP_APP_TYPE, value);
493 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
501 value = __get_string_input_data();
502 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
503 PMINFO_APPINFO_PROP_APP_OPERATION, value);
505 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
513 value = __get_string_input_data();
514 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
515 PMINFO_APPINFO_PROP_APP_URI, value);
517 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
525 value = __get_string_input_data();
526 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
527 PMINFO_APPINFO_PROP_APP_MIME, value);
529 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
537 value = __get_string_input_data();
538 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
539 PMINFO_APPINFO_PROP_APP_CATEGORY, value);
541 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
549 val = __get_integer_input_data();
550 ret = pkgmgrinfo_appinfo_filter_add_bool(handle,
551 PMINFO_APPINFO_PROP_APP_NODISPLAY, val);
553 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
559 val = __get_integer_input_data();
560 ret = pkgmgrinfo_appinfo_filter_add_bool(handle,
561 PMINFO_APPINFO_PROP_APP_MULTIPLE, val);
563 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
569 val = __get_integer_input_data();
570 ret = pkgmgrinfo_appinfo_filter_add_bool(handle,
571 PMINFO_APPINFO_PROP_APP_ONBOOT, val);
573 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
579 val = __get_integer_input_data();
580 ret = pkgmgrinfo_appinfo_filter_add_bool(handle,
581 PMINFO_APPINFO_PROP_APP_AUTORESTART, val);
583 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
589 val = __get_integer_input_data();
590 ret = pkgmgrinfo_appinfo_filter_add_bool(handle,
591 PMINFO_APPINFO_PROP_APP_TASKMANAGE, val);
593 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
599 value = __get_string_input_data();
600 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
601 PMINFO_APPINFO_PROP_APP_HWACCELERATION, value);
603 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
611 value = __get_string_input_data();
612 ret = pkgmgrinfo_appinfo_filter_add_string(handle,
613 PMINFO_APPINFO_PROP_APP_SCREENREADER, value);
615 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
623 printf("Invalid filter property\n");
624 pkgmgrinfo_appinfo_filter_destroy(handle);
631 pkgmgrinfo_appinfo_filter_destroy(handle);
639 static int __add_pkg_filter(uid_t uid)
646 pkgmgrinfo_pkginfo_filter_h handle;
647 ret = pkgmgrinfo_pkginfo_filter_create(&handle);
649 printf("pkginfo filter handle create failed\n");
652 while (choice != 0 && choice !=1)
654 printf("Enter Choice\n");
655 printf("0 --> Finalize filter and get count of packages\n");
656 printf("1 --> Finalize filter and get list of packages\n");
657 printf("2 --> filter by package ID\n");
658 printf("3 --> filter by package version\n");
659 printf("4 --> filter by package type\n");
660 printf("5 --> filter by package install location\n");
661 printf("6 --> filter by author name\n");
662 printf("7 --> filter by author email\n");
663 printf("8 --> filter by author href\n");
664 printf("9 --> filter by package removable [0|1]\n");
665 printf("10 --> filter by package readonly [0|1]\n");
666 printf("11 --> filter by package preload [0|1]\n");
667 printf("12 --> filter by package update [0|1]\n");
668 printf("13 --> filter by package appsetting [0|1]\n");
669 printf("14 --> filter by package size\n");
670 printf("15 --> filter by package installed storage[installed_internal | installed_external]\n");
671 choice = __get_integer_input_data();
674 if (uid != GLOBAL_USER)
675 ret = pkgmgrinfo_pkginfo_usr_filter_count(handle, &count, uid);
677 ret = pkgmgrinfo_pkginfo_filter_count(handle, &count);
679 printf("pkgmgrinfo_pkginfo_filter_count() failed\n");
683 printf("Package count = %d\n", count);
686 if (uid != GLOBAL_USER)
687 ret = pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo(handle, __pkg_list_cb, NULL, uid);
689 ret = pkgmgrinfo_pkginfo_filter_foreach_pkginfo(handle, __pkg_list_cb, NULL);
691 printf("pkgmgrinfo_pkginfo_(usr)_filter_foreach_pkginfo() failed\n");
697 value = __get_string_input_data();
698 ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
699 PMINFO_PKGINFO_PROP_PACKAGE_ID, value);
701 printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
709 value = __get_string_input_data();
710 ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
711 PMINFO_PKGINFO_PROP_PACKAGE_VERSION, value);
713 printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
721 value = __get_string_input_data();
722 ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
723 PMINFO_PKGINFO_PROP_PACKAGE_TYPE, value);
725 printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
733 value = __get_string_input_data();
734 ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
735 PMINFO_PKGINFO_PROP_PACKAGE_INSTALL_LOCATION, value);
737 printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
745 value = __get_string_input_data();
746 ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
747 PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_NAME, value);
749 printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
757 value = __get_string_input_data();
758 ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
759 PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_EMAIL, value);
761 printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
769 value = __get_string_input_data();
770 ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
771 PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_HREF, value);
773 printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
781 val = __get_integer_input_data();
782 ret = pkgmgrinfo_pkginfo_filter_add_bool(handle,
783 PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE, val);
785 printf("pkgmgrinfo_pkginfo_filter_add_bool() failed\n");
791 val = __get_integer_input_data();
792 ret = pkgmgrinfo_pkginfo_filter_add_bool(handle,
793 PMINFO_PKGINFO_PROP_PACKAGE_READONLY, val);
795 printf("pkgmgrinfo_pkginfo_filter_add_bool() failed\n");
801 val = __get_integer_input_data();
802 ret = pkgmgrinfo_pkginfo_filter_add_bool(handle,
803 PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD, val);
805 printf("pkgmgrinfo_pkginfo_filter_add_bool() failed\n");
811 val = __get_integer_input_data();
812 ret = pkgmgrinfo_pkginfo_filter_add_bool(handle,
813 PMINFO_PKGINFO_PROP_PACKAGE_UPDATE, val);
815 printf("pkgmgrinfo_pkginfo_filter_add_bool() failed\n");
821 val = __get_integer_input_data();
822 ret = pkgmgrinfo_pkginfo_filter_add_bool(handle,
823 PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING, val);
825 printf("pkgmgrinfo_pkginfo_filter_add_bool() failed\n");
831 val = __get_integer_input_data();
832 ret = pkgmgrinfo_pkginfo_filter_add_int(handle,
833 PMINFO_PKGINFO_PROP_PACKAGE_SIZE, val);
835 printf("pkgmgrinfo_pkginfo_filter_add_int() failed\n");
841 value = __get_string_input_data();
842 ret = pkgmgrinfo_pkginfo_filter_add_string(handle,
843 PMINFO_PKGINFO_PROP_PACKAGE_INSTALLED_STORAGE, value);
845 printf("pkgmgrinfo_pkginfo_filter_add_string() failed\n");
853 printf("Invalid filter property\n");
854 pkgmgrinfo_pkginfo_filter_destroy(handle);
861 pkgmgrinfo_pkginfo_filter_destroy(handle);
869 static int __add_arg_filter(char *key, char *value, uid_t uid)
874 pkgmgrinfo_appinfo_filter_h handle;
875 ret = pkgmgrinfo_appinfo_filter_create(&handle);
877 printf("appinfo filter handle create failed\n");
884 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_ID, value);
886 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
892 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_COMPONENT, value);
894 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
900 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_EXEC, value);
902 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
908 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_ICON, value);
910 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
916 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_TYPE, value);
918 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
924 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_OPERATION, value);
926 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
932 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_URI, value);
934 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
940 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_MIME, value);
942 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
950 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_CATEGORY, value);
952 printf("pkgmgrinfo_appinfo_filter_add_string() failed\n");
959 ret = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_NODISPLAY, val);
961 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
968 ret = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_MULTIPLE, val);
970 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
977 ret = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_ONBOOT, val);
979 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
986 ret = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_AUTORESTART, val);
988 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
995 ret = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_TASKMANAGE, val);
997 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
1003 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_HWACCELERATION, value);
1005 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
1011 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_SCREENREADER, value);
1013 printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
1020 __print_arg_filter_usage();
1023 if (uid != GLOBAL_USER)
1024 ret = pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, __get_app_id, NULL, uid);
1026 ret = pkgmgrinfo_appinfo_filter_foreach_appinfo(handle, __get_app_id, NULL);
1028 printf("pkgmgrinfo_appinfo_filter_foreach_appinfo() failed\n");
1034 pkgmgrinfo_appinfo_filter_destroy(handle);
1037 static int __del_certinfo_from_db(char *pkgid)
1040 if (pkgid == NULL) {
1041 printf("pkgid is NULL\n");
1044 ret = pkgmgr_installer_delete_certinfo(pkgid);
1046 printf("pkgmgr_installer_delete_certinfo failed\n");
1052 static int __get_certinfo_from_db(char *pkgid)
1054 if (pkgid == NULL) {
1055 printf("pkgid is NULL\n");
1061 const char *value = NULL;
1062 pkgmgr_certinfo_h handle = NULL;
1063 ret = pkgmgr_pkginfo_create_certinfo(&handle);
1065 printf("pkgmgr_pkginfo_create_certinfo failed\n");
1068 ret = pkgmgr_pkginfo_load_certinfo(pkgid, handle);
1070 printf("pkgmgr_pkginfo_load_certinfo failed\n");
1073 while (choice != 10)
1075 printf("Enter the choice to get\n");
1076 printf("0 --> to get all cert values\n");
1077 printf("1 --> author root certificate\n");
1078 printf("2 --> author intermediate certificate\n");
1079 printf("3 --> author signer certificate\n");
1080 printf("4 --> distributor root certificate\n");
1081 printf("5 --> distributor intermediate certificate\n");
1082 printf("6 --> distributor signer certificate\n");
1083 printf("7 --> distributor2 root certificate\n");
1084 printf("8 --> distributor2 intermediate certificate\n");
1085 printf("9 --> distributor2 signer certificate\n");
1086 printf("10 --> exit\n");
1087 choice = __get_integer_input_data();
1090 for (i = 0; i < 9; i++)
1092 pkgmgr_pkginfo_get_cert_value(handle, i, &value);
1094 printf("cert type[%d] value = %s\n", i, value);
1096 ret = pkgmgr_pkginfo_destroy_certinfo(handle);
1098 printf("pkgmgr_pkginfo_destroy_certinfo failed\n");
1111 ret = pkgmgr_pkginfo_get_cert_value(handle, choice - 1, &value);
1113 printf("cert type[%d] value = %s\n", choice - 1, value);
1116 ret = pkgmgr_pkginfo_destroy_certinfo(handle);
1118 printf("pkgmgr_pkginfo_destroy_certinfo failed\n");
1123 printf("Invalid choice entered\n");
1131 static int __compare_pkg_certinfo_from_db(char *lhs_pkgid, char *rhs_pkgid, uid_t uid)
1133 if (lhs_pkgid == NULL || rhs_pkgid == NULL) {
1134 printf("pkgid is NULL\n");
1139 pkgmgrinfo_cert_compare_result_type_e result;
1140 if (uid != GLOBAL_USER)
1141 ret = pkgmgrinfo_pkginfo_compare_usr_pkg_cert_info(lhs_pkgid, rhs_pkgid, uid, &result);
1143 ret = pkgmgrinfo_pkginfo_compare_pkg_cert_info(lhs_pkgid, rhs_pkgid, &result);
1144 if (ret != PMINFO_R_OK) {
1148 printf("Compare [match=0, mismatch=1, lhs_no=2, rhs_no=3, both_no=4]\n");
1149 printf("pkgid =[%s] and [%s] compare result = [%d] \n", lhs_pkgid, rhs_pkgid, result);
1153 static int __compare_app_certinfo_from_db(char *lhs_appid, char *rhs_appid, uid_t uid)
1155 if (lhs_appid == NULL || rhs_appid == NULL) {
1156 printf("appid is NULL\n");
1161 pkgmgrinfo_cert_compare_result_type_e result;
1162 if (uid != GLOBAL_USER)
1163 ret = pkgmgrinfo_pkginfo_compare_usr_app_cert_info(lhs_appid, rhs_appid, uid, &result);
1165 ret = pkgmgrinfo_pkginfo_compare_app_cert_info(lhs_appid, rhs_appid, &result);
1166 if (ret != PMINFO_R_OK) {
1170 printf("Compare [match=0, mismatch=1, lhs_no=2, rhs_no=3, both_no=4]\n");
1171 printf("appid =[%s] and [%s] compare result = [%d] \n", lhs_appid, rhs_appid, result);
1175 static int __set_certinfo_in_db(char *pkgid)
1177 if (pkgid == NULL) {
1178 printf("pkgid is NULL\n");
1184 pkgmgr_instcertinfo_h handle = NULL;
1185 ret = pkgmgr_installer_create_certinfo_set_handle(&handle);
1187 printf("pkgmgr_installer_create_certinfo_set_handle failed\n");
1192 printf("Enter the choice you want to set\n");
1193 printf("0 --> to set data in DB\n");
1194 printf("1 --> author root certificate\n");
1195 printf("2 --> author intermediate certificate\n");
1196 printf("3 --> author signer certificate\n");
1197 printf("4 --> distributor root certificate\n");
1198 printf("5 --> distributor intermediate certificate\n");
1199 printf("6 --> distributor signer certificate\n");
1200 printf("7 --> distributor2 root certificate\n");
1201 printf("8 --> distributor2 intermediate certificate\n");
1202 printf("9 --> distributor2 signer certificate\n");
1203 choice = __get_integer_input_data();
1206 ret = pkgmgr_installer_save_certinfo(pkgid, handle);
1208 printf("pkgmgr_installer_save_certinfo failed\n");
1209 pkgmgr_installer_destroy_certinfo_set_handle(handle);
1212 ret = pkgmgr_installer_destroy_certinfo_set_handle(handle);
1214 printf("pkgmgr_installer_destroy_certinfo_set_handle failed\n");
1219 printf("Enter Author Root Certificate Value: \n");
1220 value = __get_string_input_data();
1221 ret = pkgmgr_installer_set_cert_value(handle, 0, value);
1223 printf("pkgmgr_installer_set_cert_value failed\n");
1231 printf("Enter Author Intermediate Certificate Value: \n");
1232 value = __get_string_input_data();
1233 ret = pkgmgr_installer_set_cert_value(handle, 1, value);
1235 printf("pkgmgr_installer_set_cert_value failed\n");
1243 printf("Enter Author Signer Certificate Value: \n");
1244 value = __get_string_input_data();
1245 ret = pkgmgr_installer_set_cert_value(handle, 2, value);
1247 printf("pkgmgr_installer_set_cert_value failed\n");
1255 printf("Enter Distributor Root Certificate Value: \n");
1256 value = __get_string_input_data();
1257 ret = pkgmgr_installer_set_cert_value(handle, 3, value);
1259 printf("pkgmgr_installer_set_cert_value failed\n");
1267 printf("Enter Distributor Intermediate Certificate Value: \n");
1268 value = __get_string_input_data();
1269 ret = pkgmgr_installer_set_cert_value(handle, 4, value);
1271 printf("pkgmgr_installer_set_cert_value failed\n");
1279 printf("Enter Distributor Signer Certificate Value: \n");
1280 value = __get_string_input_data();
1281 ret = pkgmgr_installer_set_cert_value(handle, 5, value);
1283 printf("pkgmgr_installer_set_cert_value failed\n");
1291 printf("Enter Distributor2 Root Certificate Value: \n");
1292 value = __get_string_input_data();
1293 ret = pkgmgr_installer_set_cert_value(handle, 6, value);
1295 printf("pkgmgr_installer_set_cert_value failed\n");
1303 printf("Enter Distributor2 Intermediate Certificate Value: \n");
1304 value = __get_string_input_data();
1305 ret = pkgmgr_installer_set_cert_value(handle, 7, value);
1307 printf("pkgmgr_installer_set_cert_value failed\n");
1315 printf("Enter Distributor2 Signer Certificate Value: \n");
1316 value = __get_string_input_data();
1317 ret = pkgmgr_installer_set_cert_value(handle, 8, value);
1319 printf("pkgmgr_installer_set_cert_value failed\n");
1327 printf("Invalid Number Entered\n");
1329 ret = pkgmgr_installer_destroy_certinfo_set_handle(handle);
1331 printf("pkgmgr_installer_destroy_certinfo_set_handle failed\n");
1342 pkgmgr_installer_destroy_certinfo_set_handle(handle);
1346 static int __set_pkginfo_in_db(char *pkgid, uid_t uid)
1348 if (pkgid == NULL) {
1349 printf("pkgid is NULL\n");
1357 char *locale = NULL;
1358 pkgmgr_pkgdbinfo_h handle = NULL;
1359 INSTALL_LOCATION storage = 0;
1361 if(uid != GLOBAL_USER)
1362 ret = pkgmgrinfo_create_pkgusrdbinfo(pkgid, uid, &handle);
1364 ret = pkgmgrinfo_create_pkgdbinfo(pkgid, &handle);
1366 printf("pkgmgrinfo_create_pkgdbinfo failed\n");
1371 printf("Enter the choice you want to set\n");
1372 printf("0 --> to set data in DB\n");
1373 printf("1 --> pkg type\n");
1374 printf("2 --> pkg version\n");
1375 printf("3 --> pkg instal location\n");
1376 printf("4 --> pkg label\n");
1377 printf("5 --> pkg icon\n");
1378 printf("6 --> pkg description\n");
1379 printf("7 --> pkg author\n");
1380 printf("8 --> pkg removable\n");
1381 printf("9 --> pkg preload\n");
1382 printf("10 --> pkg size\n");
1383 printf("11 --> pkg installed storage\n");
1384 choice = __get_integer_input_data();
1387 ret = pkgmgrinfo_save_pkgdbinfo(handle);
1389 printf("pkgmgrinfo_save_pkgdbinfo failed\n");
1390 pkgmgrinfo_destroy_pkgdbinfo(handle);
1393 ret = pkgmgrinfo_destroy_pkgdbinfo(handle);
1395 printf("pkgmgrinfo_destroy_pkgdbinfo failed\n");
1400 printf("Enter type: \n");
1401 char *type = __get_string_input_data();
1402 ret = pkgmgrinfo_set_type_to_pkgdbinfo(handle, type);
1404 printf("pkgmgrinfo_set_type_to_pkgdbinfo failed\n");
1405 pkgmgrinfo_destroy_pkgdbinfo(handle);
1412 printf("Enter version: \n");
1413 char *version = __get_string_input_data();
1414 ret = pkgmgrinfo_set_version_to_pkgdbinfo(handle, version);
1416 printf("pkgmgrinfo_set_version_to_pkgdbinfo failed\n");
1417 pkgmgrinfo_destroy_pkgdbinfo(handle);
1424 printf("Enter install location [0:internal | 1:external]: \n");
1425 location = __get_integer_input_data();
1426 ret = pkgmgrinfo_set_install_location_to_pkgdbinfo(handle, location);
1428 printf("pkgmgrinfo_set_install_location_to_pkgdbinfo failed\n");
1429 pkgmgrinfo_destroy_pkgdbinfo(handle);
1434 printf("Enter label :\n");
1435 char *label = __get_string_input_data();
1436 printf("Enter locale ['def' for default]: \n");
1437 locale = __get_string_input_data();
1438 if (strcmp(locale, "def") == 0)
1439 ret = pkgmgrinfo_set_label_to_pkgdbinfo(handle, label, NULL);
1441 ret = pkgmgrinfo_set_label_to_pkgdbinfo(handle, label, locale);
1443 printf("pkgmgrinfo_set_label_to_pkgdbinfo failed\n");
1444 pkgmgrinfo_destroy_pkgdbinfo(handle);
1453 printf("Enter icon: \n");
1454 char *icon = __get_string_input_data();
1455 printf("Enter locale ['def' for default]: \n");
1456 locale = __get_string_input_data();
1457 if (strcmp(locale, "def") == 0)
1458 ret = pkgmgrinfo_set_icon_to_pkgdbinfo(handle, icon, NULL);
1460 ret = pkgmgrinfo_set_icon_to_pkgdbinfo(handle, icon, locale);
1462 printf("pkgmgrinfo_set_icon_to_pkgdbinfo failed\n");
1463 pkgmgrinfo_destroy_pkgdbinfo(handle);
1472 printf("Enter description: \n");
1473 char *description = __get_string_input_data();
1474 printf("Enter locale ['def' for default]: \n");
1475 locale = __get_string_input_data();
1476 if (strcmp(locale, "def") == 0)
1477 ret = pkgmgrinfo_set_description_to_pkgdbinfo(handle, description, NULL);
1479 ret = pkgmgrinfo_set_description_to_pkgdbinfo(handle, description, locale);
1481 printf("pkgmgrinfo_set_description_to_pkgdbinfo failed\n");
1482 pkgmgrinfo_destroy_pkgdbinfo(handle);
1491 printf("Enter author name: \n");
1492 char *author_name = __get_string_input_data();
1493 printf("Enter locale ['def' for default]: \n");
1494 locale = __get_string_input_data();
1495 printf("Enter author email: \n");
1496 char *author_email = __get_string_input_data();
1497 printf("Enter author href: \n");
1498 char *author_href = __get_string_input_data();
1499 if (strcmp(locale, "def") == 0)
1500 ret = pkgmgrinfo_set_author_to_pkgdbinfo(handle, author_name, author_email, author_href, NULL);
1502 ret = pkgmgrinfo_set_author_to_pkgdbinfo(handle, author_name, author_email, author_href, locale);
1504 printf("pkgmgrinfo_set_author_to_pkgdbinfo failed\n");
1505 pkgmgrinfo_destroy_pkgdbinfo(handle);
1518 printf("Enter removable [0:false | 1:true]: \n");
1519 removable = __get_integer_input_data();
1520 ret = pkgmgrinfo_set_removable_to_pkgdbinfo(handle, removable);
1522 printf("pkgmgrinfo_set_removable_to_pkgdbinfo failed\n");
1523 pkgmgrinfo_destroy_pkgdbinfo(handle);
1528 printf("Enter preload [0:false | 1:true]: \n");
1529 preload = __get_integer_input_data();
1530 ret = pkgmgrinfo_set_preload_to_pkgdbinfo(handle, preload);
1532 printf("pkgmgrinfo_set_preload_to_pkgdbinfo failed\n");
1533 pkgmgrinfo_destroy_pkgdbinfo(handle);
1538 printf("Enter size in MB \n");
1539 char *size = __get_string_input_data();
1540 ret = pkgmgrinfo_set_size_to_pkgdbinfo(handle, size);
1542 printf("pkgmgrinfo_set_size_to_pkgdbinfo failed\n");
1543 pkgmgrinfo_destroy_pkgdbinfo(handle);
1550 printf("Enter insatlled storage [ 0:INTERNAL | 1:EXTERNAL ] \n");
1551 storage = __get_integer_input_data();
1552 ret = pkgmgrinfo_set_installed_storage_to_pkgdbinfo(handle, storage);
1554 printf("pkgmgrinfo_set_installed_storage_to_pkgdbinfo failed\n");
1555 pkgmgrinfo_destroy_pkgdbinfo(handle);
1560 printf("Invalid number entered\n");
1567 static int __insert_manifest_in_db(char *manifest, uid_t uid)
1570 if (manifest == NULL) {
1571 printf("Manifest file is NULL\n");
1574 if (uid != GLOBAL_USER)
1575 ret = pkgmgr_parser_parse_usr_manifest_for_installation(manifest, uid, NULL);
1577 ret = pkgmgr_parser_parse_manifest_for_installation(manifest, NULL);
1579 printf("insert in db failed\n");
1585 static int __fota_insert_manifest_in_db(char *manifest, uid_t uid)
1588 char *temp[] = {"fota=true", NULL};
1590 if (manifest == NULL) {
1591 printf("Manifest file is NULL\n");
1594 if (uid != GLOBAL_USER)
1595 ret = pkgmgr_parser_parse_usr_manifest_for_installation(manifest, uid, NULL);
1597 ret = pkgmgr_parser_parse_manifest_for_installation(manifest, NULL);
1599 printf("insert in db failed\n");
1605 static int __remove_manifest_from_db(char *manifest, uid_t uid)
1608 if (manifest == NULL) {
1609 printf("Manifest file is NULL\n");
1612 if (uid != GLOBAL_USER)
1613 ret = pkgmgr_parser_parse_usr_manifest_for_uninstallation(manifest, uid, NULL);
1615 ret = pkgmgr_parser_parse_manifest_for_uninstallation(manifest, NULL);
1617 printf("remove from db failed\n");
1623 int app_func(const pkgmgr_appinfo_h handle, void *user_data)
1628 data = (char *)user_data;
1634 pkgmgr_app_component component = 0;
1635 char *apptype = NULL;
1638 bool taskmanage = 0;
1639 pkgmgr_hwacceleration_type hwacceleration;
1640 pkgmgrinfo_app_screenreader screenreader;
1642 bool autorestart = 0;
1643 char *package = NULL;
1645 ret = pkgmgr_appinfo_get_appid(handle, &appid);
1647 printf("Failed to get appid\n");
1650 printf("Appid: %s\n", appid);
1652 ret = pkgmgr_appinfo_get_pkgid(handle, &package);
1654 printf("Failed to get package\n");
1657 printf("Package: %s\n", package);
1659 ret = pkgmgr_appinfo_get_exec(handle, &exec);
1661 printf("Failed to get exec\n");
1664 printf("Exec: %s\n", exec);
1666 ret = pkgmgr_appinfo_get_icon(handle, &icon);
1668 printf("Failed to get icon\n");
1671 printf("Icon: %s\n", icon);
1673 ret = pkgmgr_appinfo_get_label(handle, &label);
1675 printf("Failed to get label\n");
1678 printf("Label: %s\n", label);
1680 ret = pkgmgr_appinfo_get_component(handle, &component);
1682 printf("Failed to get component\n");
1685 ret = pkgmgr_appinfo_get_apptype(handle, &apptype);
1687 printf("Failed to get apptype\n");
1690 printf("Apptype: %s\n", apptype);
1692 if (component == PM_UI_APP) {
1693 printf("component: uiapp\n");
1694 ret = pkgmgr_appinfo_is_multiple(handle, &multiple);
1696 printf("Failed to get multiple\n");
1698 printf("Multiple: %d\n", multiple);
1701 ret = pkgmgr_appinfo_is_nodisplay(handle, &nodisplay);
1703 printf("Failed to get nodisplay\n");
1705 printf("Nodisplay: %d \n", nodisplay);
1708 ret = pkgmgr_appinfo_is_taskmanage(handle, &taskmanage);
1710 printf("Failed to get taskmanage\n");
1712 printf("Taskmanage: %d\n", taskmanage);
1715 ret = pkgmgr_appinfo_get_hwacceleration(handle, &hwacceleration);
1717 printf("Failed to get hwacceleration\n");
1719 printf("hw-acceleration: %d\n", hwacceleration);
1722 ret = pkgmgrinfo_appinfo_get_screenreader(handle, &screenreader);
1724 printf("Failed to get screenreader\n");
1726 printf("screenreader: %d\n", screenreader);
1730 if (component == PM_SVC_APP) {
1731 printf("component: svcapp\n");
1732 ret = pkgmgr_appinfo_is_onboot(handle, &onboot);
1734 printf("Failed to get onboot\n");
1736 printf("Onboot: %d\n", onboot);
1739 ret = pkgmgr_appinfo_is_autorestart(handle, &autorestart);
1741 printf("Failed to get autorestart\n");
1743 printf("Autorestart: %d \n", autorestart);
1747 printf("user_data : %s\n\n", data);
1753 static int __pkg_list_cb (const pkgmgr_pkginfo_h handle, void *user_data, uid_t uid)
1755 char *test_data = "test data";
1761 int installed_time = -1;
1763 ret = pkgmgr_pkginfo_get_pkgid(handle, &pkgid);
1765 printf("pkgmgr_pkginfo_get_pkgid() failed\n");
1767 ret = pkgmgr_pkginfo_get_type(handle, &pkg_type);
1769 printf("pkgmgr_pkginfo_get_type() failed\n");
1771 ret = pkgmgr_pkginfo_get_version(handle, &pkg_version);
1773 printf("pkgmgr_pkginfo_get_version() failed\n");
1775 ret = pkgmgr_pkginfo_is_preload(handle, &preload);
1777 printf("pkgmgr_pkginfo_is_preload() failed\n");
1779 ret = pkgmgr_pkginfo_get_installed_time(handle, &installed_time);
1781 printf("pkgmgr_pkginfo_get_installed_time() failed\n");
1785 printf("---------------------------------------\n");
1786 printf("pkg_type [%s]\tpkgid [%s]\tversion [%s]\tpreload [%d]\tinstalled_time [%d]\n", pkg_type,
1787 pkgid, pkg_version, preload, installed_time);
1789 if (uid != GLOBAL_USER) {
1790 printf("**List of Ui-Apps**\n");
1791 ret = pkgmgr_appinfo_get_usr_list(handle, PM_UI_APP, app_func, (void *)test_data, uid);
1793 printf("pkgmgr_get_info_app() failed\n");
1795 printf("**List of Svc-Apps**\n");
1796 ret = pkgmgr_appinfo_get_usr_list(handle, PM_SVC_APP, app_func, (void *)test_data, uid);
1798 printf("pkgmgr_get_info_app() failed\n");
1801 printf("**List of Ui-Apps**\n");
1802 ret = pkgmgr_appinfo_get_list(handle, PM_UI_APP, app_func, (void *)test_data);
1804 printf("pkgmgr_get_info_app() failed\n");
1806 printf("**List of Svc-Apps**\n");
1807 ret = pkgmgr_appinfo_get_list(handle, PM_SVC_APP, app_func, (void *)test_data);
1809 printf("pkgmgr_get_info_app() failed\n");
1812 printf("---------------------------------------\n");
1817 static int __get_pkg_list(uid_t uid)
1820 if (uid != GLOBAL_USER)
1821 ret = pkgmgr_pkginfo_get_usr_list(__pkg_list_cb, NULL, uid);
1823 ret = pkgmgr_pkginfo_get_list(__pkg_list_cb, NULL);
1825 printf("pkgmgr_pkginfo_get_list() failed\n");
1831 static int __get_installed_app_list(uid_t uid)
1834 if(uid != GLOBAL_USER)
1835 ret = pkgmgrinfo_appinfo_get_usr_installed_list(app_func, uid, NULL);
1837 ret = pkgmgrinfo_appinfo_get_installed_list(app_func, NULL);
1839 printf("pkgmgrinfo_appinfo_get_installed_list() failed\n");
1846 static int __app_category_list_cb(const char *category_name, void *user_data)
1849 printf("Category: %s\n", category_name);
1853 static int __app_metadata_list_cb(const char *metadata_name, const char *metadata_value, void *user_data)
1855 if (metadata_name && metadata_value) {
1856 printf("Name: %s\n", metadata_name);
1857 printf("Value: %s\n", metadata_value);
1863 static int __app_control_list_cb(pkgmgrinfo_appcontrol_h handle, void *user_data)
1865 printf("-------------------------------------------------------\n");
1872 char **operation = NULL;
1875 char **subapp = NULL;
1877 ret = pkgmgrinfo_appinfo_get_operation(handle, &oc, &operation);
1879 printf("Get Operation Failed\n");
1882 ret = pkgmgrinfo_appinfo_get_uri(handle, &uc, &uri);
1884 printf("Get Uri Failed\n");
1887 ret = pkgmgrinfo_appinfo_get_mime(handle, &mc, &mime);
1889 printf("Get Mime Failed\n");
1892 ret = pkgmgrinfo_appinfo_get_subapp(handle, &sc, &subapp);
1894 printf("Get subapp Failed\n");
1898 for (i = 0; i < oc; i++) {
1899 if (operation && operation[i])
1900 printf("Operation: %s\n", operation[i]);
1902 for (i = 0; i < uc; i++) {
1904 printf("Uri: %s\n", uri[i]);
1906 for (i = 0; i < mc; i++) {
1907 if (mime && mime[i])
1908 printf("Mime: %s\n", mime[i]);
1910 for (i = 0; i < sc; i++) {
1911 if (subapp && subapp[i])
1912 printf("subapp: %s\n", subapp[i]);
1915 printf("-------------------------------------------------------\n\n");
1920 static int __get_app_category_list(char *appid)
1923 pkgmgr_appinfo_h handle;
1924 ret = pkgmgr_appinfo_get_appinfo(appid, &handle);
1926 printf("Failed to get handle\n");
1929 ret = pkgmgr_appinfo_foreach_category(handle, __app_category_list_cb, NULL);
1931 printf("pkgmgr_appinfo_foreach_category() failed\n");
1932 pkgmgr_appinfo_destroy_appinfo(handle);
1935 pkgmgr_appinfo_destroy_appinfo(handle);
1939 static int __get_app_metadata_list(char *appid)
1942 pkgmgr_appinfo_h handle;
1943 ret = pkgmgr_appinfo_get_appinfo(appid, &handle);
1945 printf("Failed to get handle\n");
1948 ret = pkgmgrinfo_appinfo_foreach_metadata(handle, __app_metadata_list_cb, NULL);
1950 printf("pkgmgrinfo_appinfo_foreach_metadata() failed\n");
1951 pkgmgr_appinfo_destroy_appinfo(handle);
1954 pkgmgr_appinfo_destroy_appinfo(handle);
1958 static int __get_app_control_list(char *appid)
1961 pkgmgr_appinfo_h handle;
1962 ret = pkgmgr_appinfo_get_appinfo(appid, &handle);
1964 printf("Failed to get handle\n");
1967 ret = pkgmgrinfo_appinfo_foreach_appcontrol(handle, __app_control_list_cb, NULL);
1969 printf("pkgmgrinfo_appinfo_foreach_appcontrol() failed\n");
1970 pkgmgr_appinfo_destroy_appinfo(handle);
1973 pkgmgr_appinfo_destroy_appinfo(handle);
1977 static int __set_app_enabled(char *appid, bool enabled)
1980 ret = pkgmgrinfo_appinfo_set_state_enabled(appid, enabled);
1982 printf("Failed to get handle\n");
1988 static int __get_app_list(char *pkgid, uid_t uid)
1990 pkgmgr_pkginfo_h handle;
1992 char *test_data = "test data";
1993 if(uid != GLOBAL_USER)
1994 ret = pkgmgr_pkginfo_get_usr_pkginfo(pkgid, uid, &handle);
1996 ret = pkgmgr_pkginfo_get_pkginfo(pkgid, &handle);
1998 printf("Failed to get handle\n");
2001 if (uid != GLOBAL_USER) {
2002 printf("List of Ui-Apps\n\n");
2003 ret = pkgmgr_appinfo_get_usr_list(handle, PM_UI_APP, app_func, (void *)test_data, uid);
2005 printf("pkgmgr_appinfo_get_list() failed\n");
2007 printf("List of Svc-Apps\n\n");
2008 ret = pkgmgr_appinfo_get_usr_list(handle, PM_SVC_APP, app_func, (void *)test_data, uid);
2010 printf("pkgmgr_appinfo_get_list() failed\n");
2013 printf("List of Ui-Apps\n\n");
2014 ret = pkgmgr_appinfo_get_list(handle, PM_UI_APP, app_func, (void *)test_data);
2016 printf("pkgmgr_appinfo_get_list() failed\n");
2018 printf("List of Svc-Apps\n\n");
2019 ret = pkgmgr_appinfo_get_list(handle, PM_SVC_APP, app_func, (void *)test_data);
2021 printf("pkgmgr_appinfo_get_list() failed\n");
2024 pkgmgr_pkginfo_destroy_pkginfo(handle);
2028 static int __get_pkg_info(char *pkgid, uid_t uid)
2030 pkgmgrinfo_pkginfo_h handle;
2033 printf("Get Pkg Info Called [%s]\n", pkgid);
2034 if(uid != GLOBAL_USER)
2035 ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, uid, &handle);
2037 ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
2039 printf("Failed to get handle\n");
2043 __get_pkgmgrinfo_pkginfo(handle, NULL);
2045 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
2049 static int __get_app_info(char *appid)
2051 printf("Get App Info Called [%s]\n", appid);
2053 char *app_id = NULL;
2054 char *apptype = NULL;
2057 char *package = NULL;
2058 pkgmgr_app_component component = 0;
2061 bool taskmanage = 0;
2062 pkgmgr_hwacceleration_type hwacceleration;
2063 pkgmgrinfo_app_screenreader screenreader;
2065 bool autorestart = 0;
2068 pkgmgr_appinfo_h handle;
2071 ret = pkgmgr_appinfo_get_appinfo(appid, &handle);
2073 printf("Failed to get handle\n");
2077 ret = pkgmgr_appinfo_get_pkgid(handle, &package);
2079 printf("Failed to get package\n");
2082 ret = pkgmgr_appinfo_get_appid(handle, &app_id);
2084 printf("Failed to get exec\n");
2087 ret = pkgmgr_appinfo_get_label(handle, &label);
2089 printf("Failed to get label\n");
2091 ret = pkgmgr_appinfo_get_icon(handle, &icon);
2093 printf("Failed to get icon\n");
2096 ret = pkgmgr_appinfo_get_exec(handle, &exec);
2098 printf("Failed to get exec\n");
2100 ret = pkgmgr_appinfo_get_component(handle, &component);
2102 printf("Failed to get component\n");
2104 ret = pkgmgr_appinfo_get_apptype(handle, &apptype);
2106 printf("Failed to get apptype\n");
2108 ret = pkgmgr_appinfo_is_nodisplay(handle, &nodisplay);
2110 printf("Failed to get nodisplay\n");
2112 ret = pkgmgr_appinfo_is_multiple(handle, &multiple);
2114 printf("Failed to get multiple\n");
2116 ret = pkgmgr_appinfo_is_taskmanage(handle, &taskmanage);
2118 printf("Failed to get taskmanage\n");
2120 ret = pkgmgr_appinfo_get_hwacceleration(handle, &hwacceleration);
2122 printf("Failed to get hwacceleration\n");
2124 ret = pkgmgrinfo_appinfo_get_screenreader(handle, &screenreader);
2126 printf("Failed to get screenreader\n");
2128 ret = pkgmgr_appinfo_is_onboot(handle, &onboot);
2130 printf("Failed to get onboot\n");
2132 ret = pkgmgr_appinfo_is_autorestart(handle, &autorestart);
2134 printf("Failed to get autorestart\n");
2136 ret = pkgmgrinfo_appinfo_is_enabled(handle, &enabled);
2138 printf("Failed to get enabled\n");
2140 ret = pkgmgrinfo_appinfo_is_preload(handle, &preload);
2142 printf("Failed to get preload\n");
2146 printf("Appid: %s\n", app_id);
2149 printf("Package: %s\n", package);
2152 printf("Exec: %s\n", exec);
2154 printf("Apptype: %s\n", apptype);
2156 if (component == PM_UI_APP) {
2157 printf("component: uiapp\n");
2160 printf("Icon: %s\n", icon);
2162 printf("Label: %s\n", label);
2164 printf("Nodisplay: %d\n", nodisplay);
2165 printf("Multiple: %d\n", multiple);
2166 printf("Taskmanage: %d\n", taskmanage);
2167 printf("Hw-Acceleration: %d\n", hwacceleration);
2168 printf("Screenreader: %d\n", screenreader);
2169 } else if (component == PM_SVC_APP) {
2170 printf("component: svcapp\n");
2173 printf("Icon: %s\n", icon);
2175 printf("Label: %s\n", label);
2177 printf("Autorestart: %d\n", autorestart);
2178 printf("Onboot: %d\n", onboot);
2180 printf("Invalid Component Type\n");
2183 printf("Enabled: %d\n", enabled);
2184 printf("Preload: %d\n", preload);
2186 pkgmgr_appinfo_destroy_appinfo(handle);
2191 static int __check_manifest_validation(char *manifest)
2194 if (manifest == NULL) {
2195 printf("Manifest file is NULL\n");
2198 ret = pkgmgr_parser_check_manifest_validation(manifest);
2200 printf("check manifest validation failed\n");
2206 int main(int argc, char *argv[])
2209 char *locale = NULL;
2214 gettimeofday(&tv, NULL);
2215 starttime = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
2217 locale = vconf_get_str(VCONFKEY_LANGSET);
2218 if (locale == NULL) {
2219 printf("locale is NULL\n");
2224 printf("Locale is %s\n", locale);
2227 if(getuid() == OWNER_ROOT) {
2228 printf("User is Root! : Only tizenglobalapp or regular user are allowed\n");
2235 if (strcmp(argv[1], "--listpkg") == 0) {
2236 ret = __get_pkg_list(getuid());
2238 printf("get pkg list failed\n");
2243 } else if (strcmp(argv[1], "--app-flt") == 0) {
2244 ret = __add_app_filter(getuid());
2246 printf("Adding app filter failed\n");
2251 } else if (strcmp(argv[1], "--pkg-flt") == 0) {
2252 ret = __add_pkg_filter(getuid());
2254 printf("Adding pkg filter failed\n");
2259 } else if (strcmp(argv[1], "--metadata-flt") == 0) {
2260 ret = __add_metadata_filter();
2262 printf("Adding pkg filter failed\n");
2267 } else if (strcmp(argv[1], "--listapp") == 0) {
2268 ret = __get_installed_app_list(getuid());
2270 printf("get installed app list failed\n");
2280 }else if (argc == 4) {
2281 if (strcmp(argv[1], "--setappenabled") == 0) {
2282 ret = __set_app_enabled(argv[2], (strcmp(argv[3], "0")==0)?false:true);
2284 printf("set app enabled failed\n");
2288 } else if(strcmp(argv[1], "--setpkgenabled") == 0) {
2289 ret = __set_app_enabled(argv[2], (strcmp(argv[3], "0")==0)?false:true);
2291 printf("set pkg enabled failed\n");
2295 } else if (strcmp(argv[1], "--cmp-pkgcert") == 0) {
2296 ret = __compare_pkg_certinfo_from_db(argv[2], argv[3], getuid());
2298 printf("compare certinfo from db failed\n");
2302 } else if (strcmp(argv[1], "--cmp-appcert") == 0) {
2303 ret = __compare_app_certinfo_from_db(argv[2], argv[3], getuid());
2305 printf("compare certinfo from db failed\n");
2309 } else if (strcmp(argv[1], "--arg-flt") == 0) {
2310 ret = __add_arg_filter(argv[2], argv[3], getuid());
2312 printf("compare certinfo from db failed\n");
2328 if (!argv[1] || !argv[2]) {
2334 if (strcmp(argv[1], "--pkg") == 0) {
2335 ret = __get_pkg_info(argv[2], getuid());
2337 printf("get pkg info failed\n");
2340 } else if (strcmp(argv[1], "--app") == 0) {
2341 ret = __get_app_info(argv[2]);
2343 printf("get app info failed\n");
2346 } else if (strcmp(argv[1], "--list") == 0) {
2347 ret = __get_app_list(argv[2], getuid());
2349 printf("get app list failed\n");
2352 } else if (strcmp(argv[1], "--imd") == 0) {
2353 ret = __insert_manifest_in_db(argv[2], getuid());
2355 printf("insert in db failed\n");
2358 } else if (strcmp(argv[1], "--fota") == 0) {
2359 ret = __fota_insert_manifest_in_db(argv[2], getuid());
2361 printf("insert in db failed\n");
2364 } else if (strcmp(argv[1], "--rmd") == 0) {
2365 ret = __remove_manifest_from_db(argv[2], getuid());
2367 printf("remove from db failed\n");
2370 } else if (strcmp(argv[1], "--setdb") == 0) {
2371 ret = __set_pkginfo_in_db(argv[2], getuid());
2373 printf("set pkginfo in db failed\n");
2376 } else if (strcmp(argv[1], "--setcert") == 0) {
2377 ret = __set_certinfo_in_db(argv[2]);
2379 printf("set certinfo in db failed\n");
2382 } else if (strcmp(argv[1], "--getcert") == 0) {
2383 ret = __get_certinfo_from_db(argv[2]);
2385 printf("get certinfo from db failed\n");
2388 } else if (strcmp(argv[1], "--delcert") == 0) {
2389 ret = __del_certinfo_from_db(argv[2]);
2391 printf("del certinfo from db failed\n");
2394 } else if (strcmp(argv[1], "--check") == 0) {
2395 ret = __check_manifest_validation(argv[2]);
2397 printf("check manifest failed\n");
2400 } else if (strcmp(argv[1], "--category") == 0) {
2401 ret = __get_app_category_list(argv[2]);
2403 printf("get app category list failed\n");
2406 } else if (strcmp(argv[1], "--metadata") == 0) {
2407 ret = __get_app_metadata_list(argv[2]);
2409 printf("get app metadata list failed\n");
2412 } else if (strcmp(argv[1], "--appcontrol") == 0) {
2413 ret = __get_app_control_list(argv[2]);
2415 printf("get app control list failed\n");
2423 gettimeofday(&tv, NULL);
2424 endtime = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
2426 printf("spend time for pkginfo is [%d]ms\n", (int)(endtime - starttime));