Add resourced-monitor tool
authorSangYoun Kwak <sy.kwak@samsung.com>
Wed, 7 Aug 2024 02:55:43 +0000 (11:55 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Mon, 21 Oct 2024 09:56:51 +0000 (18:56 +0900)
resourced-monitor gets process information and prints them for <app id>s
which is provided as parameters.
resourced-monitor is included in the package 'resourced-monitor'.

CMakeLists.txt
packaging/resourced.spec
tools/CMakeLists.txt [new file with mode: 0644]
tools/resourced-monitor/CMakeLists.txt [new file with mode: 0644]
tools/resourced-monitor/dbus-helper.c [new file with mode: 0644]
tools/resourced-monitor/dbus-helper.h [new file with mode: 0644]
tools/resourced-monitor/main.c [new file with mode: 0644]
tools/resourced-monitor/proc-info.c [new file with mode: 0644]
tools/resourced-monitor/proc-info.h [new file with mode: 0644]
tools/resourced-monitor/resourced-info.c [new file with mode: 0644]
tools/resourced-monitor/resourced-info.h [new file with mode: 0644]

index 448a83fa73780bebe074633db8c32bd8a9628f06..c3b0198c8669291c4d17eb6ae1bce266e21db8c4 100644 (file)
@@ -101,3 +101,4 @@ IF(DEFINED RD_TESTS_PATH)
 ENDIF(DEFINED RD_TESTS_PATH)
 
 ADD_SUBDIRECTORY(isu)
+ADD_SUBDIRECTORY(tools)
index 1f186898880e01e59c059d8a1812b16b80dc8081..3f503357ae773d9ad595ceea56a2ff3279511fe1 100644 (file)
@@ -44,6 +44,7 @@ BuildRequires:  pkgconfig(cmocka)
 BuildRequires:  pkgconfig(libsyscommon)
 BuildRequires:  pkgconfig(libsyscommon-plugin-api-resourced)
 BuildRequires:  pkgconfig(aul)
+BuildRequires:  pkgconfig(gio-2.0)
 BuildRequires: gperf
 
 # for swap plugin
@@ -108,6 +109,11 @@ Group:   Application Framework/Service
 %description isu
 Configuration files to generate the ISU (Individual Service Upgrade) package
 
+%package       monitor
+Summary:       A monitor tool for resourced
+Requires:      %{name}-monitor = %{version}-%{release}
+%description   monitor
+
 %prep
 %setup -q
 
@@ -228,3 +234,6 @@ mv %{confdir}/optimizer-profile-tv.conf %{confdir}/optimizer.conf
 
 %files isu
 /etc/isu/resourced/*
+
+%files monitor
+%{_bindir}/resourced-monitor
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
new file mode 100644 (file)
index 0000000..931b704
--- /dev/null
@@ -0,0 +1,4 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(resourced-tools C)
+
+ADD_SUBDIRECTORY(resourced-monitor)
diff --git a/tools/resourced-monitor/CMakeLists.txt b/tools/resourced-monitor/CMakeLists.txt
new file mode 100644 (file)
index 0000000..17d76af
--- /dev/null
@@ -0,0 +1,25 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+SET(OUTPUT_BIN_NAME "resourced-monitor")
+PROJECT(resourced-tools-${OUTPUT_BIN_NAME} C)
+
+SET(PKG_MODULES
+       glib-2.0
+       gio-2.0
+)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(REQUIRED_PKGS REQUIRED ${PKG_MODULES})
+
+FOREACH(flag ${REQUIRED_PKGS_CFLAGS})
+        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+SET(CMAKE_C_FLAGS ${EXTRA_CFLAGS})
+
+INCLUDE_DIRECTORIES(. ${CMAKE_SOURCE_DIR}/include)
+
+FILE(GLOB_RECURSE SRCS main.c dbus-helper.c proc-info.c resourced-info.c)
+ADD_EXECUTABLE(${OUTPUT_BIN_NAME} ${SRCS})
+SET_TARGET_PROPERTIES(${OUTPUT_BIN_NAME} PROPERTIES COMPILE_FLAGS "-fPIE")
+SET_TARGET_PROPERTIES(${OUTPUT_BIN_NAME} PROPERTIES LINK_FLAGS "-pie")
+TARGET_LINK_LIBRARIES(${OUTPUT_BIN_NAME} ${REQUIRED_PKGS_LDFLAGS})
+INSTALL(TARGETS ${OUTPUT_BIN_NAME} DESTINATION /usr/bin)
diff --git a/tools/resourced-monitor/dbus-helper.c b/tools/resourced-monitor/dbus-helper.c
new file mode 100644 (file)
index 0000000..6371d1f
--- /dev/null
@@ -0,0 +1,80 @@
+/**
+ * resourced-monitor
+ *
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+*/
+
+#include <stdio.h>
+#include <assert.h>
+
+#include "dbus-helper.h"
+
+int dbus_helper_new_connection(GDBusConnection **connection)
+{
+       assert(connection != NULL);
+
+       GDBusConnection *new_connection = NULL;
+       GError *error = NULL;
+
+       new_connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+       if (new_connection == NULL) {
+               fprintf(stderr, "Failed to get dbus connection: %s(%d)\n",
+                               error->message, error->code);
+               g_error_free(error);
+               return -ECONNREFUSED;
+       }
+
+       g_dbus_connection_set_exit_on_close(new_connection, TRUE);
+
+       *connection = new_connection;
+
+       return 0;
+}
+
+int dbus_helper_call_sync(GVariant **out_reply,
+                       GDBusConnection *connection,
+                       const char *bus_name,
+                       const char *object_path,
+                       const char *interface_name,
+                       const char *method_name,
+                       GVariant *parameters)
+{
+       assert(out_reply != NULL);
+       assert(connection != NULL);
+       assert(bus_name != NULL);
+       assert(object_path != NULL);
+       assert(interface_name != NULL);
+       assert(method_name != NULL);
+       assert(parameters != NULL);
+
+       GVariant *reply = NULL;
+       GError *error = NULL;
+
+       reply = g_dbus_connection_call_sync(connection, bus_name, object_path,
+                       interface_name, method_name, parameters, NULL,
+                       G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+
+       if (reply == NULL) {
+               fprintf(stderr, "Failed to call g_dbus_connection_call_sync: "
+                       "%s(%d)\n", error->message, error->code);
+               g_error_free(error);
+               return -ECONNREFUSED;
+       }
+
+       *out_reply = reply;
+
+       return 0;
+}
diff --git a/tools/resourced-monitor/dbus-helper.h b/tools/resourced-monitor/dbus-helper.h
new file mode 100644 (file)
index 0000000..43752d4
--- /dev/null
@@ -0,0 +1,32 @@
+/**
+ * resourced-monitor
+ *
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+*/
+
+#pragma once
+
+#include <glib.h>
+#include <gio/gio.h>
+
+int dbus_helper_new_connection(GDBusConnection **connection);
+int dbus_helper_call_sync(GVariant **out_reply,
+                       GDBusConnection *connection,
+                       const char *bus_name,
+                       const char *object_path,
+                       const char *interface_name,
+                       const char *method_name,
+                       GVariant *parameters);
diff --git a/tools/resourced-monitor/main.c b/tools/resourced-monitor/main.c
new file mode 100644 (file)
index 0000000..0fb581f
--- /dev/null
@@ -0,0 +1,55 @@
+/**
+ * resourced-monitor
+ *
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+*/
+
+#include "dbus-helper.h"
+#include "proc-info.h"
+
+void print_usage(const char *exec_name)
+{
+       printf("usage: %s <app id>[ <app id>...]\n", exec_name);
+}
+
+int main(int argc, char **argv)
+{
+       if (argc < 2) {
+               print_usage(argv[0]);
+               return -1;
+       }
+
+       GDBusConnection *connection = NULL;
+       if (dbus_helper_new_connection(&connection) != 0) {
+               fprintf(stderr, "Failed to connect to dbus.\n");
+               return -1;
+       }
+
+       for (int i = 1; i < argc; ++i) {
+               const char *appid = argv[i];
+               struct proc_info info = { 0, };
+               int ret = 0;
+
+               ret = proc_info_get_proc_info(connection, appid, &info);
+
+               if (ret != 0)
+                       continue;
+
+               proc_info_print(&info);
+       }
+
+       return 0;
+}
diff --git a/tools/resourced-monitor/proc-info.c b/tools/resourced-monitor/proc-info.c
new file mode 100644 (file)
index 0000000..85cbc7f
--- /dev/null
@@ -0,0 +1,159 @@
+/**
+ * resourced-monitor
+ *
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+*/
+
+#include <assert.h>
+
+#include "proc-info.h"
+#include "resourced-info.h"
+
+static const char *bool_str(bool value)
+{
+       return value ? "true" : "false";
+}
+
+static int get_proc_info_from_reply(struct proc_info *proc_info, GVariant *reply)
+{
+       assert(proc_info != NULL);
+       assert(reply != NULL);
+
+       const gchar *reply_type_str_expected =
+               RESOURCED_DBUS_INFO_PROCESS_METHOD_GET_APP_INFO_REPLY_TYPE_STR;
+       const gchar *reply_type_str = g_variant_get_type_string(reply);
+
+       if (!g_str_equal(reply_type_str_expected, reply_type_str)) {
+               fprintf(stderr, "Reply type: %s is expected but %s is received\n",
+                               reply_type_str_expected, reply_type_str);
+               return -EINVAL;
+       }
+
+       g_variant_get(reply, reply_type_str_expected,
+                       &proc_info->main_pid,
+                       &proc_info->app_watchdog_exclude,
+                       &proc_info->app_cpu_nice_update_exclude,
+                       &proc_info->runtime_exclude,
+                       &proc_info->prelaunch_flags,
+                       &proc_info->lru_state,
+                       &proc_info->background_categories,
+                       &proc_info->state,
+                       &proc_info->type);
+
+       return 0;
+}
+
+static int print_prelaunch_flags(int prelaunch_flags)
+{
+       for (int i = 0; i < sizeof(prelaunch_flags) * 4; ++i) {
+               int prelaunch_flag = prelaunch_flags & (0x1 << i);
+               if (prelaunch_flag == RESOURCED_INFO_PROC_NONE)
+                       continue;
+
+               const char *prelaunch_flag_str =
+                       resourced_info_convert_proc_prelaunch_flags_to_str(prelaunch_flag);
+               if (prelaunch_flag_str == NULL)
+                       continue;
+
+               printf("%s, ", prelaunch_flag_str);
+       }
+
+       return 0;
+}
+
+static int print_background_categories(int background_categories)
+{
+       for (int i = 0; i < sizeof(background_categories) * 4; ++i) {
+               int background_category = background_categories & (0x1 << i);
+               if (background_category == RESOURCED_INFO_PROC_BG_NONE)
+                       continue;
+
+               const char *background_category_str =
+                       resourced_info_convert_proc_background_category_to_str(background_category);
+               if (background_category_str == NULL)
+                       continue;
+
+               printf("%s, ", background_category_str);
+       }
+
+       return 0;
+}
+
+/* TODO: Modify the printing formats to be more readable */
+int proc_info_print(const struct proc_info *info)
+{
+       assert(info != NULL);
+
+       printf("\"%s\":\n", info->appid);
+       printf("\tmain_pid: %d\n", info->main_pid);
+       printf("\tapp_watchdog_exclude: %s\n", bool_str(info->app_watchdog_exclude));
+       printf("\tapp_cpu_nice_update_exclude: %s\n", bool_str(info->app_cpu_nice_update_exclude));
+       printf("\truntime_exclude: %d\n", info->runtime_exclude);
+
+       printf("\tprelaunch_flags: [ ");
+       print_prelaunch_flags(info->prelaunch_flags);
+       printf("]\n");
+
+       printf("\tlru_state: %s\n", resourced_info_convert_proc_lru_state_to_str(info->lru_state));
+
+       printf("\tbackground_categories: [ ");
+       print_background_categories(info->background_categories);
+       printf("]\n");
+
+       printf("\tstate: %s\n", resourced_info_convert_proc_state_to_str(info->state));
+       printf("\ttype: %s\n", resourced_info_convert_application_type_to_str(info->type));
+
+       return 0;
+}
+
+
+int proc_info_get_proc_info(GDBusConnection *connection, const char *appid, struct proc_info *info)
+{
+       assert(connection != NULL);
+       assert(appid != NULL);
+       assert(info != NULL);
+
+       GVariant *reply = NULL;
+       int ret = 0;
+
+       ret = dbus_helper_call_sync(&reply, connection,
+                       RESOURCED_DBUS_INFO_BUS_NAME,
+                       RESOURCED_DBUS_INFO_PROCESS_OBJECT_PATH,
+                       RESOURCED_DBUS_INFO_PROCESS_INTERFACE_NAME,
+                       RESOURCED_DBUS_INFO_PROCESS_METHOD_GET_APP_INFO,
+                       g_variant_new(
+                               RESOURCED_DBUS_INFO_PROCESS_METHOD_GET_APP_INFO_PARAM_TYPE_STR,
+                               appid));
+
+       if (ret != 0) {
+               fprintf(stderr, "Failed to call %s for appid=%s: %d\n",
+                               RESOURCED_DBUS_INFO_PROCESS_METHOD_GET_APP_INFO,
+                               appid, ret);
+               return ret;
+       }
+
+       info->appid = appid;
+       ret = get_proc_info_from_reply(info, reply);
+       g_variant_unref(reply);
+       if (ret != 0) {
+               fprintf(stderr, "Failed to parse the reply of method %s for appid=%s: %d\n",
+                               RESOURCED_DBUS_INFO_PROCESS_METHOD_GET_APP_INFO,
+                               appid, ret);
+               return ret;
+       }
+
+       return 0;
+}
diff --git a/tools/resourced-monitor/proc-info.h b/tools/resourced-monitor/proc-info.h
new file mode 100644 (file)
index 0000000..88d419b
--- /dev/null
@@ -0,0 +1,41 @@
+/**
+ * resourced-monitor
+ *
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+*/
+
+#pragma once
+
+#include <stdio.h>
+#include <stdbool.h>
+
+#include "dbus-helper.h"
+
+struct proc_info {
+       char *appid;
+       int main_pid;
+       bool app_watchdog_exclude;
+       bool app_cpu_nice_update_exclude;
+       int runtime_exclude;
+       int prelaunch_flags;
+       int lru_state;
+       int background_categories;
+       int state;
+       int type;
+};
+
+int proc_info_print(const struct proc_info *info);
+int proc_info_get_proc_info(GDBusConnection *connection, const char *appid, struct proc_info *info);
diff --git a/tools/resourced-monitor/resourced-info.c b/tools/resourced-monitor/resourced-info.c
new file mode 100644 (file)
index 0000000..972ac49
--- /dev/null
@@ -0,0 +1,136 @@
+/**
+ * resourced-monitor
+ *
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+
+#include "resourced-info.h"
+
+const char *resourced_info_convert_proc_prelaunch_flags_to_str(int flag)
+{
+       switch (flag) {
+       case RESOURCED_INFO_PROC_NONE:
+               return "PROC_NONE";
+       case RESOURCED_INFO_PROC_LARGEMEMORY:
+               return "PROC_LARGEMEMORY";
+       case RESOURCED_INFO_PROC_SIGTERM:
+               return "PROC_SIGTERM";
+       case RESOURCED_INFO_PROC_WEBAPP:
+               return "PROC_WEBAPP";
+       case RESOURCED_INFO_PROC_DOWNLOADAPP:
+               return "PROC_DOWNLOADAPP";
+       case RESOURCED_INFO_PROC_SERVICEAPP:
+               return "PROC_SERVICEAPP";
+       case RESOURCED_INFO_PROC_CGROUP_HIGH_ATTRIBUTE:
+               return "PROC_CGROUP_HIGH_ATTRIBUTE";
+       case RESOURCED_INFO_PROC_BGALLOW:
+               return "PROC_BGALLOW";
+       case RESOURCED_INFO_PROC_BGCTRL_PLATFORM:
+               return "PROC_BGCTRL_PLATFORM";
+       case RESOURCED_INFO_PROC_BGCTRL_APP:
+               return "PROC_BGCTRL_APP";
+       default:
+               return NULL;
+       }
+}
+
+const char *resourced_info_convert_proc_lru_state_to_str(int lru_state)
+{
+       switch (lru_state) {
+       case RESOURCED_INFO_PROC_FOREGROUND:
+               return "PROC_FOREGROUND";
+       case RESOURCED_INFO_PROC_ACTIVE:
+               return "PROC_ACTIVE";
+       case RESOURCED_INFO_PROC_BACKGROUND:
+               return "PROC_BACKGROUND";
+       case RESOURCED_INFO_PROC_LRU_MAX:
+               return "PROC_LRU_MAX";
+       case RESOURCED_INFO_PROC_FAVORITE:
+               return "PROC_FAVORITE";
+       case RESOURCED_INFO_PROC_FAVORITE_LRU_MAX:
+               return "PROC_FAVORITE_LRU_MAX";
+       default:
+               return NULL;
+       }
+}
+
+const char *resourced_info_convert_proc_background_category_to_str(int background_category)
+{
+       switch (background_category) {
+       case RESOURCED_INFO_PROC_BG_NONE:
+               return "PROC_BG_NONE";
+       case RESOURCED_INFO_PROC_BG_MEDIA:
+               return "PROC_BG_MEDIA";
+       case RESOURCED_INFO_PROC_BG_DOWNLOAD:
+               return "PROC_BG_DOWNLOAD";
+       case RESOURCED_INFO_PROC_BG_NETWORK:
+               return "PROC_BG_NETWORK";
+       case RESOURCED_INFO_PROC_BG_LOCATION:
+               return "PROC_BG_LOCATION";
+       case RESOURCED_INFO_PROC_BG_SENSOR:
+               return "PROC_BG_SENSOR";
+       case RESOURCED_INFO_PROC_BG_IOT:
+               return "PROC_BG_IOT";
+       case RESOURCED_INFO_PROC_BG_SYSTEM:
+               return "PROC_BG_SYSTEM";
+       default:
+               return NULL;
+       }
+}
+
+const char *resourced_info_convert_proc_state_to_str(int state)
+{
+       switch (state) {
+       case RESOURCED_INFO_PROC_STATE_DEFAULT:
+               return "PROC_STATE_DEFAULT";
+       case RESOURCED_INFO_PROC_STATE_FOREGROUND:
+               return "PROC_STATE_FOREGROUND";
+       case RESOURCED_INFO_PROC_STATE_BACKGROUND:
+               return "PROC_STATE_BACKGROUND";
+       case RESOURCED_INFO_PROC_STATE_SUSPEND_READY:
+               return "PROC_STATE_SUSPEND_READY";
+       case RESOURCED_INFO_PROC_STATE_SUSPEND:
+               return "PROC_STATE_SUSPEND";
+       default:
+               return NULL;
+       }
+}
+
+const char *resourced_info_convert_application_type_to_str(int type)
+{
+       switch (type) {
+       case RESOURCED_INFO_PROC_TYPE_NONE:
+               return "PROC_TYPE_NONE";
+       case RESOURCED_INFO_PROC_TYPE_READY:
+               return "PROC_TYPE_READY";
+       case RESOURCED_INFO_PROC_TYPE_GUI:
+               return "PROC_TYPE_GUI";
+       case RESOURCED_INFO_PROC_TYPE_SERVICE:
+               return "PROC_TYPE_SERVICE";
+       case RESOURCED_INFO_PROC_TYPE_GROUP:
+               return "PROC_TYPE_GROUP";
+       case RESOURCED_INFO_PROC_TYPE_WATCH:
+               return "PROC_TYPE_WATCH";
+       case RESOURCED_INFO_PROC_TYPE_WIDGET:
+               return "PROC_TYPE_WIDGET";
+       case RESOURCED_INFO_PROC_TYPE_MAX:
+               return "PROC_TYPE_MAX";
+       default:
+               return NULL;
+       }
+}
diff --git a/tools/resourced-monitor/resourced-info.h b/tools/resourced-monitor/resourced-info.h
new file mode 100644 (file)
index 0000000..780e2dc
--- /dev/null
@@ -0,0 +1,92 @@
+/**
+ * resourced-monitor
+ *
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+*/
+
+#pragma once
+
+/**
+ * TODO: Integrate these resourced informations with the original resourced
+ *       source files.
+ */
+
+#define RESOURCED_DBUS_INFO_BUS_NAME           "org.tizen.resourced"
+
+#define RESOURCED_DBUS_INFO_PROCESS_OBJECT_PATH        "/Org/Tizen/ResourceD/Process"
+#define RESOURCED_DBUS_INFO_PROCESS_INTERFACE_NAME     "org.tizen.resourced.process"
+
+#define RESOURCED_DBUS_INFO_PROCESS_METHOD_GET_APP_INFO        "GetAppInfo"
+#define RESOURCED_DBUS_INFO_PROCESS_METHOD_GET_APP_INFO_PARAM_TYPE_STR "(s)"
+#define RESOURCED_DBUS_INFO_PROCESS_METHOD_GET_APP_INFO_REPLY_TYPE_STR "(ibbiiiiii)"
+
+enum resourced_info_proc_prelaunch_flags {
+       RESOURCED_INFO_PROC_NONE                        = 0x00u,
+       RESOURCED_INFO_PROC_LARGEMEMORY                 = 0x01u,        /* for mark large memory */
+       RESOURCED_INFO_PROC_SIGTERM                     = 0x02u,        /* for make killer kill victim by SIGTERM */
+       RESOURCED_INFO_PROC_WEBAPP                      = 0x04u,        /* for checking webapp */
+       RESOURCED_INFO_PROC_DOWNLOADAPP                 = 0x08u,        /* for monitoring disk usage about downloadable app */
+       RESOURCED_INFO_PROC_SERVICEAPP                  = 0x10u,        /* for distinguishing service app and ui app */
+       RESOURCED_INFO_PROC_CGROUP_HIGH_ATTRIBUTE       = 0x20u,        /* for providing High level about MDM app */
+       RESOURCED_INFO_PROC_BGALLOW                     = 0x100u,       /* for allowing background application */
+       RESOURCED_INFO_PROC_BGCTRL_PLATFORM             = 0x200u,       /* for controlling background application by appfw */
+       RESOURCED_INFO_PROC_BGCTRL_APP                  = 0x400u,       /* for checking old version application */
+};
+
+enum resourced_info_proc_lru_state {
+       RESOURCED_INFO_PROC_FOREGROUND          = -1,
+       RESOURCED_INFO_PROC_ACTIVE              = 0,
+       RESOURCED_INFO_PROC_BACKGROUND          = 1,
+       RESOURCED_INFO_PROC_LRU_MAX             = 15,
+       RESOURCED_INFO_PROC_FAVORITE            = 16,
+       RESOURCED_INFO_PROC_FAVORITE_LRU_MAX    = 35,
+};
+
+enum resourced_info_proc_background_category {
+       RESOURCED_INFO_PROC_BG_NONE     = 0x0,
+       RESOURCED_INFO_PROC_BG_MEDIA    = 0x1,
+       RESOURCED_INFO_PROC_BG_DOWNLOAD = 0x2,
+       RESOURCED_INFO_PROC_BG_NETWORK  = 0x4,
+       RESOURCED_INFO_PROC_BG_LOCATION = 0x8,
+       RESOURCED_INFO_PROC_BG_SENSOR   = 0x10,
+       RESOURCED_INFO_PROC_BG_IOT      = 0x20,
+       RESOURCED_INFO_PROC_BG_SYSTEM   = 0x40,
+};
+
+enum resourced_info_proc_state {
+       RESOURCED_INFO_PROC_STATE_DEFAULT,
+       RESOURCED_INFO_PROC_STATE_FOREGROUND,
+       RESOURCED_INFO_PROC_STATE_BACKGROUND,
+       RESOURCED_INFO_PROC_STATE_SUSPEND_READY,
+       RESOURCED_INFO_PROC_STATE_SUSPEND,
+};
+
+enum resourced_info_application_type {
+       RESOURCED_INFO_PROC_TYPE_NONE,
+       RESOURCED_INFO_PROC_TYPE_READY,
+       RESOURCED_INFO_PROC_TYPE_GUI,
+       RESOURCED_INFO_PROC_TYPE_SERVICE,
+       RESOURCED_INFO_PROC_TYPE_GROUP,
+       RESOURCED_INFO_PROC_TYPE_WATCH,
+       RESOURCED_INFO_PROC_TYPE_WIDGET,
+       RESOURCED_INFO_PROC_TYPE_MAX,
+};
+
+const char *resourced_info_convert_proc_prelaunch_flags_to_str(int flag);
+const char *resourced_info_convert_proc_lru_state_to_str(int state);
+const char *resourced_info_convert_proc_background_category_to_str(int category);
+const char *resourced_info_convert_proc_state_to_str(int state);
+const char *resourced_info_convert_application_type_to_str(int type);