Modify the function to kill running apps
[platform/core/appfw/app2sd.git] / plugin / app2sd / server / app2sd_interface.c
index f08abe7..c1b2477 100644 (file)
@@ -523,26 +523,48 @@ static int _app2sd_kill_running_app(const char *pkgid, uid_t uid)
 {
        int ret = 0;
        pkgmgrinfo_pkginfo_h handle;
+       pkgmgrinfo_appinfo_filter_h filter;
 
-       ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, uid, &handle);
+       ret = pkgmgrinfo_pkginfo_get_usr_all_pkginfo(pkgid, uid, &handle);
        if (ret < 0) {
                _E("failed to get pkginfo");
                return APP2EXT_ERROR_PKGMGR_ERROR;
        }
 
-       ret = pkgmgrinfo_appinfo_get_usr_list(handle,
-               PMINFO_ALL_APP, _app2sd_application_handler, &uid, uid);
+       pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+
+       ret = pkgmgrinfo_appinfo_filter_create(&filter);
+       if (ret < 0) {
+               _E("failed to create appinfo filter");
+               return APP2EXT_ERROR_PKGMGR_ERROR;
+       }
+
+       ret = pkgmgrinfo_appinfo_filter_add_string(filter,
+                       PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid);
        if (ret < 0) {
-               _E("failed to get appinfo");
+               _E("failed to add pkgid to filter");
+               pkgmgrinfo_appinfo_filter_destroy(filter);
                return APP2EXT_ERROR_PKGMGR_ERROR;
        }
 
-       ret = pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+       ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
+                       PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false);
        if (ret < 0) {
-               _E("failed to destroy pkginfo");
+               _E("failed to add check_storage to filter");
+               pkgmgrinfo_appinfo_filter_destroy(filter);
                return APP2EXT_ERROR_PKGMGR_ERROR;
        }
 
+       ret = pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(filter,
+                       _app2sd_application_handler, &uid, uid);
+       if (ret < 0) {
+               _E("failed to get filtered foreach appinfo");
+               pkgmgrinfo_appinfo_filter_destroy(filter);
+               return APP2EXT_ERROR_PKGMGR_ERROR;
+       }
+
+       pkgmgrinfo_appinfo_filter_destroy(filter);
+
        return APP2EXT_SUCCESS;
 }