From: SangYoun Kwak Date: Tue, 6 Aug 2024 06:56:31 +0000 (+0900) Subject: process: Add dbus method to get app info X-Git-Tag: accepted/tizen/unified/20241205.173755~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=61b84c62097c1ea83aaa15e6790c951fa49b84f3;p=platform%2Fcore%2Fsystem%2Fresourced.git process: Add dbus method to get app info To get app information using dbue method, a method "GetAppInfo" is added. This method gets an app id as a parameter and returns the informations of app if exists. Change-Id: Ie22bd26a7a8e58d01067639b7c2e16a36cdf5cef Signed-off-by: SangYoun Kwak --- diff --git a/src/process/proc-monitor.c b/src/process/proc-monitor.c index 62c23190..83b8a90d 100644 --- a/src/process/proc-monitor.c +++ b/src/process/proc-monitor.c @@ -362,6 +362,48 @@ static void dbus_get_meminfo(GDBusMethodInvocation *invocation, GVariant *params mem_total, mem_free, cached, used, swap)); } +EXPORT_TEST void dbus_get_app_info(GDBusMethodInvocation *invocation, GVariant *params) +{ + char *appid = NULL; + struct proc_app_info *pai = NULL; + const char *error_message = "Success"; + + do_expr_unless_g_variant_get_typechecked(return, params, "(s)", &appid); + if (appid == NULL) { + _E("Invalid parameters"); + error_message = "Parameter should be a string"; + goto failure; + } + + pai = find_app_info_by_appid(appid); + if (pai == NULL) { + _E("No such app: %s", appid); + error_message = "No such application exists"; + goto failure; + } + + g_dbus_method_invocation_return_value(invocation, g_variant_new("(ibbiiiiii)", + pai->main_pid, + pai->app_watchdog_exclude, + pai->app_cpu_nice_update_exclude, + pai->runtime_exclude, + pai->flags, + pai->lru_state, + pai->categories, + pai->state, + pai->type)); + + g_free(appid); + + return; + +failure: + g_free(appid); + + g_dbus_method_invocation_return_error(invocation, G_DBUS_ERROR, + G_DBUS_ERROR_INVALID_ARGS, "%s", error_message); +} + static void dbus_reclaim_memory(GDBusMethodInvocation *invocation, GVariant *params) { _D("reclaiming memory!"); @@ -1372,6 +1414,18 @@ static const char dbus_methods_xml[] = " " " " " " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " " " " " " " @@ -1416,6 +1470,7 @@ static struct d_bus_method dbus_methods[] = { { "GetMemoryList", dbus_get_memory_list }, { "GetMemoryLists", dbus_get_memory_lists }, { "GetMemInfo", dbus_get_meminfo }, + { "GetAppInfo", dbus_get_app_info }, { "ReclaimMemory", dbus_reclaim_memory }, { "PrePoweroff", dbus_pre_poweroff }, { "ProcExclude", proc_dbus_exclude_method_handler},