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)