2 * Copyright (c) 2011 - 2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef __TIZEN_SYSTEM_RUNTIME_INFO_H__
18 #define __TIZEN_SYSTEM_RUNTIME_INFO_H__
28 * @addtogroup CAPI_SYSTEM_RUNTIME_INFO_MODULE
33 * @brief Enumeration for error codes for runtime information.
36 RUNTIME_INFO_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
37 RUNTIME_INFO_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
38 RUNTIME_INFO_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
39 RUNTIME_INFO_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< An input/output error occurred when read value from system */
40 RUNTIME_INFO_ERROR_REMOTE_IO = TIZEN_ERROR_REMOTE_IO, /**< Remote I/O error occured */
41 RUNTIME_INFO_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< No permission to use the api */
42 RUNTIME_INFO_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported parameter @if MOBILE (Since 2.3.1) @endif */
43 } runtime_info_error_e;
46 * @brief Enumeration for keys for runtime information..
49 RUNTIME_INFO_KEY_FLIGHT_MODE_ENABLED, /**<@internal Indicates whether the device is in flight mode. */
50 RUNTIME_INFO_KEY_WIFI_STATUS, /**<@internal Indicates the current status of Wi-Fi. */
51 RUNTIME_INFO_KEY_BLUETOOTH_ENABLED, /**<Indicates whether Bluetooth is enabled. */
52 RUNTIME_INFO_KEY_WIFI_HOTSPOT_ENABLED, /**<Indicates whether Wi-Fi hotspot is enabled. */
53 RUNTIME_INFO_KEY_BLUETOOTH_TETHERING_ENABLED, /**<Indicates whether Bluetooth tethering is enabled. */
54 RUNTIME_INFO_KEY_USB_TETHERING_ENABLED, /**<Indicates whether USB tethering is enabled. */
55 RUNTIME_INFO_KEY_LOCATION_SERVICE_ENABLED, /**<Indicates whether the location service is allowed to use location data from GPS satellites. */
56 RUNTIME_INFO_KEY_LOCATION_ADVANCED_GPS_ENABLED, /**<@internal Indicates whether the location service is allowed to download location data for GPS operation. */
57 RUNTIME_INFO_KEY_LOCATION_NETWORK_POSITION_ENABLED, /**<Indicates whether the location service is allowed to use location data from cellular and Wi-Fi. */
58 RUNTIME_INFO_KEY_PACKET_DATA_ENABLED, /**<Indicates Whether the packet data through 3G network is enabled. */
59 RUNTIME_INFO_KEY_DATA_ROAMING_ENABLED, /**<Indicates whether data roaming is enabled. */
60 RUNTIME_INFO_KEY_SILENT_MODE_ENABLED, /**<@internal Indicates whether the device is in silent mode. */
61 RUNTIME_INFO_KEY_VIBRATION_ENABLED, /**<Indicates whether vibration is enabled. */
62 RUNTIME_INFO_KEY_24HOUR_CLOCK_FORMAT_ENABLED, /**<@internal Indicates whether 24-hour clock is enabled. */
63 RUNTIME_INFO_KEY_FIRST_DAY_OF_WEEK, /**<@internal Indicates the first day of week. */
64 RUNTIME_INFO_KEY_LANGUAGE, /**<@internal Indicates the current language setting. */
65 RUNTIME_INFO_KEY_REGION, /**<@internal Indicates the current region setting. */
66 RUNTIME_INFO_KEY_AUDIO_JACK_CONNECTED, /**<Indicates whether audio jack is connected. */
67 RUNTIME_INFO_KEY_GPS_STATUS, /**<Indicates the current status of GPS. */
68 RUNTIME_INFO_KEY_BATTERY_IS_CHARGING, /**<Indicates the battery is currently charging. */
69 RUNTIME_INFO_KEY_TV_OUT_CONNECTED, /**<Indicates whether TV out is connected. */
70 RUNTIME_INFO_KEY_AUDIO_JACK_STATUS, /**<Indicates the current status of audio jack. */
71 RUNTIME_INFO_KEY_SLIDING_KEYBOARD_OPENED, /**<@internal Indicates whether sliding keyboard is opened. */
72 RUNTIME_INFO_KEY_USB_CONNECTED, /**<Indicates whether USB is connected. */
73 RUNTIME_INFO_KEY_CHARGER_CONNECTED, /**<Indicates whether charger is connected. */
74 RUNTIME_INFO_KEY_VIBRATION_LEVEL_HAPTIC_FEEDBACK, /**<@internal Indicates the current vibration level of haptic feedback. */
75 RUNTIME_INFO_KEY_AUTO_ROTATION_ENABLED, /**<Indicates whether auto rotation is enabled. */
80 * @brief Enumeration for Wi-Fi status.
83 RUNTIME_INFO_WIFI_STATUS_DISABLED, /**< GPS is disabled. */
84 RUNTIME_INFO_WIFI_STATUS_UNCONNECTED, /**< Wi-Fi is enabled and network connection is not established. */
85 RUNTIME_INFO_WIFI_STATUS_CONNECTED, /**< Network connection is established in Wi-Fi network. */
86 } runtime_info_wifi_status_e;
89 * @brief Enumeration for GPS status.
92 RUNTIME_INFO_GPS_STATUS_DISABLED, /**< GPS is disabled. */
93 RUNTIME_INFO_GPS_STATUS_SEARCHING, /**< GPS is searching for satellites. */
94 RUNTIME_INFO_GPS_STATUS_CONNECTED, /**< GPS connection is established. */
95 } runtime_info_gps_status_e;
99 * @brief Enumeration for first day of week.
102 RUNTIME_INFO_FIRST_DAY_OF_WEEK_SUNDAY, /**< Sunday */
103 RUNTIME_INFO_FIRST_DAY_OF_WEEK_MONDAY, /**< Monday */
104 RUNTIME_INFO_FIRST_DAY_OF_WEEK_TUESDAY, /**< Tuesday */
105 RUNTIME_INFO_FIRST_DAY_OF_WEEK_WEDNESDAY, /**< Wednesday */
106 RUNTIME_INFO_FIRST_DAY_OF_WEEK_THURSDAY, /**< Thursday */
107 RUNTIME_INFO_FIRST_DAY_OF_WEEK_FRIDAY, /**< Friday */
108 RUNTIME_INFO_FIRST_DAY_OF_WEEK_SATURDAY, /**< Saturday */
109 } runtime_info_first_day_of_week_e;
112 * @brief Enumeration for audio jack status.
115 RUNTIME_INFO_AUDIO_JACK_STATUS_UNCONNECTED, /**< Audio jack is not connected */
116 RUNTIME_INFO_AUDIO_JACK_STATUS_CONNECTED_3WIRE, /**< 3-conductor wire is connected. */
117 RUNTIME_INFO_AUDIO_JACK_STATUS_CONNECTED_4WIRE, /**< 4-conductor wire is connected. */
118 } runtime_info_audio_jack_status_e;
122 * @brief Called when the runtime information changes
125 * @param[in] key The type of notification
126 * @param[in] user_data The user data passed from the callback registration function
128 * @pre runtime_info_set_changed_cb() will invoke this callback function.
130 * @see runtime_info_set_changed_cb()
131 * @see runtime_info_unset_changed_cb()
133 typedef void (*runtime_info_changed_cb)(runtime_info_key_e key, void *user_data);
136 * @brief Gets the integer value of the runtime information.
137 * @details This function gets current state of the given key which represents specific runtime information.
141 * @param[in] key The runtime information status key from which data should be read
142 * @param[out] value The current value of the given key
144 * @return @c 0 on success,
145 * otherwise a negative error value
147 * @retval #RUNTIME_INFO_ERROR_NONE Successful
148 * @retval #RUNTIME_INFO_ERROR_INVALID_PARAMETER Invalid parameter
149 * @retval #RUNTIME_INFO_ERROR_IO_ERROR An input/output error occurred when read value from system
150 * @retval #RUNTIME_INFO_ERROR_PERMISSION_DENIED No permission to use the api
151 * @retval #RUNTIME_INFO_ERROR_NOT_SUPPORTED Not supported parameter @if MOBILE (Since 2.3.1) @endif
153 int runtime_info_get_value_int(runtime_info_key_e key, int *value);
156 * @brief Gets the boolean value from the runtime information.
157 * @details This function gets current state of the given key which represents specific runtime information.
161 * @param[in] key The runtime information key from which data should be read
162 * @param[out] value The current value of the given key
164 * @return @c 0 on success,
165 * otherwise a negative error value
167 * @retval #RUNTIME_INFO_ERROR_NONE Successful
168 * @retval #RUNTIME_INFO_ERROR_INVALID_PARAMETER Invalid parameter
169 * @retval #RUNTIME_INFO_ERROR_IO_ERROR An input/output error occurred when read value from system
170 * @retval #RUNTIME_INFO_ERROR_PERMISSION_DENIED No permission to use the api
171 * @retval #RUNTIME_INFO_ERROR_NOT_SUPPORTED Not supported parameter @if MOBILE (Since 2.3.1) @endif
173 int runtime_info_get_value_bool(runtime_info_key_e key, bool *value);
176 * @brief Gets the double value from the runtime information.
177 * @details This function gets current state of the given key which represents specific runtime information.
181 * @param[in] key The runtime information key from which data should be read
182 * @param[out] value The current value of the given key
184 * @return @c 0 on success,
185 * otherwise a negative error value
187 * @retval #RUNTIME_INFO_ERROR_NONE Successful
188 * @retval #RUNTIME_INFO_ERROR_INVALID_PARAMETER Invalid parameter
189 * @retval #RUNTIME_INFO_ERROR_IO_ERROR An input/output error occurred when read value from system
190 * @retval #RUNTIME_INFO_ERROR_PERMISSION_DENIED No permission to use the api
191 * @retval #RUNTIME_INFO_ERROR_NOT_SUPPORTED Not supported parameter @if MOBILE (Since 2.3.1) @endif
193 int runtime_info_get_value_double(runtime_info_key_e key, double *value);
196 * @brief Gets the string value for specified runtime information.
197 * @details This function gets current state of the given key which represents specific runtime information.
201 * @remarks You must release @a value using free().
203 * @param[in] key The runtime information key from which data should be read
204 * @param[out] value The current value of the given key
206 * @return @c 0 on success,
207 * otherwise a negative error value
209 * @retval #RUNTIME_INFO_ERROR_NONE Successful
210 * @retval #RUNTIME_INFO_ERROR_INVALID_PARAMETER Invalid parameter
211 * @retval #RUNTIME_INFO_ERROR_IO_ERROR An input/output error occurred when read value from system
212 * @retval #RUNTIME_INFO_ERROR_OUT_OF_MEMORY Out of memory
213 * @retval #RUNTIME_INFO_ERROR_PERMISSION_DENIED No permission to use the api
214 * @retval #RUNTIME_INFO_ERROR_NOT_SUPPORTED Not supported parameter @if MOBILE (Since 2.3.1) @endif
216 int runtime_info_get_value_string(runtime_info_key_e key, char **value);
220 * @brief Registers a change event callback for given runtime information key.
223 * @param[in] key The runtime information type
224 * @param[in] callback The callback function to invoke
225 * @param[in] user_data The user data to be passed to the callback function
227 * @return @c 0 on success,
228 * otherwise a negative error value
230 * @retval #RUNTIME_INFO_ERROR_NONE Successful
231 * @retval #RUNTIME_INFO_ERROR_INVALID_PARAMETER Invalid parameter
232 * @retval #RUNTIME_INFO_ERROR_PERMISSION_DENIED No permission to use the api
233 * @retval #RUNTIME_INFO_ERROR_NOT_SUPPORTED Not supported parameter @if MOBILE (Since 2.3.1) @endif
234 * @post runtime_info_changed_cb() will be invoked.
236 * @see runtime_info_unset_changed_cb()
237 * @see runtime_info_changed_cb()
239 int runtime_info_set_changed_cb(runtime_info_key_e key, runtime_info_changed_cb callback, void *user_data);
243 * @brief Unregisters the callback function.
246 * @param[in] key The runtime information type
248 * @return @c 0 on success,
249 * otherwise a negative error value
251 * @retval #RUNTIME_INFO_ERROR_NONE Successful
252 * @retval #RUNTIME_INFO_ERROR_INVALID_PARAMETER Invalid parameter
254 * @see runtime_info_set_changed_cb()
256 int runtime_info_unset_changed_cb(runtime_info_key_e key);
259 * @brief Structure for memory information.
263 int total; /**< Total memory (KiB) */
264 int used; /**< Used memory (KiB) */
265 int free; /**< Free memory (KiB) */
266 int cache; /**< Cache memory (KiB) */
267 int swap; /**< Swap memory (KiB) */
268 } runtime_memory_info_s;
271 * @brief Gets system memory information
274 * @param[out] info The system memory information structure
276 * @return @c 0 on success,
277 * otherwise a negative error value
279 * @retval #RUNTIME_INFO_ERROR_NONE Successful
280 * @retval #RUNTIME_INFO_ERROR_INVALID_PARAMETER Invalid parameter
281 * @retval #RUNTIME_INFO_ERROR_IO_ERROR An Input/Output error occured while reading from system
283 * @see runtime_info_get_process_memory_info()
285 int runtime_info_get_system_memory_info(runtime_memory_info_s *info);
288 * @brief Structure for memory information per processes.
292 int vsz; /**< Virtual memory size (KiB) */
293 int rss; /**< Resident set size (KiB) */
294 int pss; /**< Proportional set size (KiB) */
295 int shared_clean; /**< Not modified and mapped by other processes (KiB) */
296 int shared_dirty; /**< Modified and mapped by other processes (KiB) */
297 int private_clean; /**< Not modified and available only to that process (KiB) */
298 int private_dirty; /**< Modified and available only to that process (KiB) */
299 } process_memory_info_s;
302 * @brief Gets memory information per processes
305 * @privilege %http://tizen.org/privilege/systemmonitor
307 * @remarks You must release @a s value using free(). \n
308 * The size of @a s is the same with @a size.
310 * @param[in] pid The process unique id array
311 * @param[in] size The size of pid array
312 * @param[out] info The memory information structure array of the processes
314 * @return @c 0 on success,
315 * otherwise a negative error value
317 * @retval #RUNTIME_INFO_ERROR_NONE Successful
318 * @retval #RUNTIME_INFO_ERROR_INVALID_PARAMETER Invalid parameter
319 * @retval #RUNTIME_INFO_ERROR_PERMISSION_DENIED Permission denied
321 * @see runtime_info_get_system_memory_info()
323 int runtime_info_get_process_memory_info(int *pid, int size, process_memory_info_s **info);
326 * @brief Structure for cpu usage.
330 double user; /**< Time running un-niced user processes (Percent) */
331 double system; /**< Time running kernel processes (Percent) */
332 double nice; /**< Time running niced user processes (Percent) */
333 double iowait; /**< Time waiting for I/O completion (Percent) */
334 } runtime_cpu_usage_s;
337 * @brief Gets cpu information
340 * @param[out] usage The cpu usage structure
342 * @return @c 0 on success,
343 * otherwise a negative error value
345 * @retval #RUNTIME_INFO_ERROR_NONE Successful
346 * @retval #RUNTIME_INFO_ERROR_INVALID_PARAMETER Invalid parameter
347 * @retval #RUNTIME_INFO_ERROR_IO_ERROR An input/output error occured while reading from system
349 * @see runtime_info_get_process_cpu_usage()
351 int runtime_info_get_cpu_usage(runtime_cpu_usage_s *usage);
354 * @brief Structure for cpu usage per processes.
358 int utime; /**< Amount of time that this process has been scheduled in user mode (clock ticks) */
359 int stime; /**< Amount of time that this process has been scheduled in kernel mode (clock ticks) */
360 } process_cpu_usage_s;
363 * @brief Gets cpu usage per processes
366 * @privilege %http://tizen.org/privilege/systemmonitor
368 * @remarks You must release @a s value using free(). \n
369 * The size of @a s is the same with @a size.
371 * @param[in] pid The process unique id array
372 * @param[in] size The size of pid array
373 * @param[out] usage The cpu usage structure array of the processes
375 * @return @c 0 on success,
376 * otherwise a negative error value
378 * @retval #RUNTIME_INFO_ERROR_NONE Successful
379 * @retval #RUNTIME_INFO_ERROR_INVALID_PARAMETER Invalid parameter
380 * @retval #RUNTIME_INFO_ERROR_PERMISSION_DENIED Permission denied
382 * @see runtime_info_get_cpu_usage()
384 int runtime_info_get_process_cpu_usage(int *pid, int size, process_cpu_usage_s **usage);
394 #endif /* __TIZEN_SYSTEM_RUNTIME_INFO_H__ */