Fix install check logic in app_launcher tool 31/325131/2 tizen
authorJihoi Kim <jihoi.kim@samsung.com>
Wed, 4 Jun 2025 03:33:51 +0000 (12:33 +0900)
committerJihoi Kim <jihoi.kim@samsung.com>
Wed, 4 Jun 2025 07:07:07 +0000 (16:07 +0900)
- Use appinfo_get_appinfo instead of filter_count API
- This patch is for performance and simple design

Change-Id: I4c5b042374cec546ff644ac2d5a0d9f1c72f25bf
Signed-off-by: Jihoi Kim <jihoi.kim@samsung.com>
src/tool/app_launcher/app_launcher.c

index 780c85d2c9ee752e62662d4a355bc8001a2b88b8..1878ff33273410840fab6d71050606cb70319e08 100644 (file)
@@ -229,46 +229,41 @@ static GOptionGroup *__get_opt_group(void)
 
 static int __is_app_installed(const char *appid, uid_t uid)
 {
-       pkgmgrinfo_appinfo_filter_h filter;
-       int is_installed = 0;
+       pkgmgrinfo_appinfo_h handle;
        int ret;
 
-       ret = pkgmgrinfo_appinfo_filter_create(&filter);
-       if (ret != PMINFO_R_OK) {
-               printf("Failed to create filter\n");
-               return -1;
+       ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle);
+       if (ret == PMINFO_R_ENOENT) {
+               return 0;
        }
-
-       ret = pkgmgrinfo_appinfo_filter_add_string(filter,
-                       PMINFO_APPINFO_PROP_APP_ID, appid);
        if (ret != PMINFO_R_OK) {
-               printf("Failed to add filter string\n");
-               pkgmgrinfo_appinfo_filter_destroy(filter);
+               printf("Failed to get appinfo(%s)", appid);
                return -1;
        }
 
-       ret = pkgmgrinfo_appinfo_usr_filter_count(filter,
-                       &is_installed, uid);
+       ret = pkgmgrinfo_appinfo_destroy_appinfo(handle);
        if (ret != PMINFO_R_OK) {
-               printf("Failed to get filter count\n");
-               pkgmgrinfo_appinfo_filter_destroy(filter);
+               printf("Failed to destroy appinfo(%s)", appid);
                return -1;
        }
 
-       pkgmgrinfo_appinfo_filter_destroy(filter);
-
-       return is_installed;
+       return 1;
 }
 
 static int __cmd_common_init(struct launch_arg *arg)
 {
-       if (!__is_app_installed(arg->appid, arg->uid)) {
+       int ret;
+
+       ret = __is_app_installed(arg->appid, arg->uid);
+       if (ret == 1)
+               return 0;
+
+       if (ret == 0) {
                printf("The app with ID: %s is not available for the user %d\n",
                                arg->appid, arg->uid);
-               return -1;
        }
 
-       return 0;
+       return -1;
 }
 
 static void __cmd_common_finish(struct launch_arg *arg)