4 * Copyright (c) 2010 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
27 #include <sys/types.h>
28 #include "dd-system-managed.h"
31 #define DEPRECATED __attribute__((deprecated))
36 * @ingroup libdeviced System Manager library
37 * @brief This library provides APIs related with memory, performance, processes, and so on.
44 * @defgroup libdeviced System Manager library
45 * @ingroup SYSTEM_FRAMEWORK
46 * @brief System manager library
48 * This library provides APIs related with memory, performance, processes, and so on.
49 * <br> Please use libslp-system-dev debian package and dd-deviced.pc file for development.
50 * <br> And include dd-system.h file at your source codes as following.
51 * @addtogroup libdeviced System Manager library
60 * @breif Policy for low memory
63 OOM_LIKELY, /**< For miscellaneous applications */
64 OOM_IGNORE /**< For daemons */
70 * @fn int system_get_cmdline_name(pid_t pid, char *cmdline, size_t cmdline_size)
71 * @brief This API is used to get the file name of command line of the process from the proc fs.
72 * Caller process MUST allocate enough memory for the cmdline parameter. \n
73 * Its size should be assigned to cmdline_size. \n
74 * Internally it reads the 1st argument of /proc/{pid}/cmdline and copies it to cmdline.
75 * @param[in] pid pid of the process that you want to get the file name of command line
76 * @param[out] cmdline command line of the process that you want to get the file name <br>
77 * Callers should allocate memory to this parameter before calling this function.
78 * The allocated memory size must be large enough to store the file name.
79 * The result will include the terminating null byte('\0') at the end of the string.
80 * @return 0 on success, -1 if failed. If the size of cmdline is smaller than the result,
81 * it will return -1 and errno will be set as EOVERFLOW.
83 int system_get_cmdline_name(pid_t pid, char *cmdline,
87 * @fn char *system_get_apppath(pid_t pid, char *app_path, size_t app_path_size)
88 * @brief This API is used to get the execution path of the process specified by the pid parameter.\n
89 * Caller process MUST allocate enough memory for the app_path parameter. \n
90 * Its size should be assigned to app_path_size. \n
91 * Internally it reads a link of /proc/{pid}/exe and copies the path to app_path.
92 * @param[in] pid pid of the process that you want to get the executed path
93 * @param[out] app_path the executed file path of the process <br>
94 * Callers should allocate memory to this parameter before calling this function.
95 * The allocated memory size must be large enough to store the executed file path.
96 * The result will include the terminating null byte('\0') at the end of the string.
97 * @param[in] app_path_size allocated memory size of char *app_path
98 * @return 0 on success, -1 if failed. If the size of app_path is smaller than the result,
99 * it will return -1 and errno will be set as EOVERFLOW.
101 int system_get_apppath(pid_t pid, char *app_path, size_t app_path_size);
106 * @fn int system_conf_set_mempolicy(enum mem_policy mempol)
107 * @brief This API is used to set the policy of the caller process when the phone has low available memory.
108 * @param[in] mempol oom adjust value which you want to set
109 * @return 0 on success, -1 if failed.
110 * @see system_conf_set_mempolicy_bypid()
112 int system_conf_set_mempolicy(enum mem_policy mempol);
115 * @fn int system_conf_set_mempolicy_bypid(pid_t pid, enum mem_policy mempol)
116 * @brief This API is used to set the policy of the process when the phone has low available memory.
117 * @param[in] pid process id which you want to set
118 * @param[in] mempol oom adjust value which you want to set
119 * @return 0 on success, -1 if failed.
121 int system_conf_set_mempolicy_bypid(pid_t pid, enum mem_policy mempol);
124 * @fn int system_conf_set_permanent(void)
125 * @brief This API is used to set itself as a permanent process.\n
126 * If the permanent process is dead, system server will relaunch the process automatically.
127 * @return 0 on success, -1 if failed.
128 * @see system_conf_set_permanent_bypid()
132 * ret = system_conf_set_permanent();
134 * printf("Fail to set a process as permanent\n");
138 int system_conf_set_permanent(void);
141 * @fn int system_conf_set_permanent_bypid(pid_t pid)
142 * @brief This API is used to set a process which has pid as a permanent process.\n
143 * If the permanent process is dead, system server will relaunch the process automatically.
144 * @return 0 on success, -1 if failed.
145 * @see sysconf_set_permanent()
149 * ret = system_conf_set_permanent_bypid(pid);
151 * printf("Fail to set a process(%d) as permanent\n",pid);
155 int system_conf_set_permanent_bypid(pid_t pid);
158 * @fn int system_conf_set_vip(pid_t pid)
159 * @brief This API is used to set a process which has pid as Very Important Process(VIP) .\n
160 * If the VIP process is dead, restarter program will be run. \n
161 * Restarter program may kill almost processes and run rc.local scripts again.
162 * @param[in] pid process id to be vip
163 * @return 0 on success, -1 if failed.
164 * @see sysconf_is_vip
168 * ret = system_conf_set_vip(pid);
170 * printf("Fail to set a process(%d) as VIP\n",pid);
174 int system_conf_set_vip(pid_t pid);
177 * @fn int system_conf_is_vip(pid_t pid)
178 * @brief This API is used to verify that process which has pid is Very Important Process(VIP) or not.
179 * @param[in] pid process id to be vip
180 * @return 1 on success, 0 if failed.
181 * @see system_conf_set_vip
185 * ret = system_conf_is_vip(pid);
187 * printf("process(%d) is Very Important Process\n",pid);
191 int system_conf_is_vip(pid_t pid);
193 int system_set_timezone(char *tzpath_str);
195 int system_call_predef_action(const char *type, int num, ...);
197 int system_inform_foregrd(void);
198 int system_inform_backgrd(void);
199 int system_inform_active(pid_t pid);
200 int system_inform_inactive(pid_t pid);
202 int system_request_poweroff(void);
203 int system_request_entersleep(void);
204 int system_request_leavesleep(void);
205 int system_request_reboot(void);
207 int system_request_set_cpu_max_frequency(int val);
208 int system_request_set_cpu_min_frequency(int val);
210 int system_release_cpu_max_frequency(void);
211 int system_release_cpu_min_frequency(void);
220 #endif /* __DD_SYSTEM__ */