4a3b07accf5f20fd94cd5e1ad3e837550d6fdd5e
[platform/core/api/runtime-info.git] / include / runtime_info.h
1 /**
2  * Copyright (c) 2011 - 2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #ifndef __TIZEN_SYSTEM_RUNTIME_INFO_H__
18 #define __TIZEN_SYSTEM_RUNTIME_INFO_H__
19
20 #include <tizen.h>
21
22 #ifdef __cplusplus
23 extern "C"
24 {
25 #endif
26
27
28 /**
29  * @addtogroup  CAPI_SYSTEM_RUNTIME_INFO_MODULE
30  * @{
31  */
32
33
34 /**
35  * @brief        Enumeration for error codes for runtime information.
36  * @since_tizen  @if WEARABLE 2.3.1 @else 2.3 @endif
37  */
38 typedef enum {
39         RUNTIME_INFO_ERROR_NONE = TIZEN_ERROR_NONE,                           /**< Successful */
40         RUNTIME_INFO_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
41         RUNTIME_INFO_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY,         /**< Out of memory */
42         RUNTIME_INFO_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR,                   /**< An input/output error occurred when read value from system */
43         RUNTIME_INFO_ERROR_REMOTE_IO = TIZEN_ERROR_REMOTE_IO,                 /**< Remote I/O error occurred */
44         RUNTIME_INFO_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< No permission to use the api */
45         RUNTIME_INFO_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED,         /**< Not supported parameter */
46         RUNTIME_INFO_ERROR_NO_DATA = TIZEN_ERROR_NO_DATA                      /**< No data available (Since 3.0) */
47 } runtime_info_error_e;
48
49
50 /**
51  * @brief        Enumeration for keys for runtime information.
52  * @since_tizen  @if WEARABLE 2.3.1 @else 2.3 @endif
53  */
54 typedef enum {
55         RUNTIME_INFO_KEY_BLUETOOTH_ENABLED = 2,                 /**<Indicates whether Bluetooth is enabled. */
56         RUNTIME_INFO_KEY_WIFI_HOTSPOT_ENABLED = 3,              /**<Indicates whether Wi-Fi hotspot is enabled. */
57         RUNTIME_INFO_KEY_BLUETOOTH_TETHERING_ENABLED = 4,       /**<Indicates whether Bluetooth tethering is enabled. */
58         RUNTIME_INFO_KEY_USB_TETHERING_ENABLED = 5,             /**<Indicates whether USB tethering is enabled. */
59         RUNTIME_INFO_KEY_LOCATION_SERVICE_ENABLED = 6,          /**<Indicates whether the location service is allowed to use location data from GPS satellites. (Deprecated since 4.0) */
60         RUNTIME_INFO_KEY_LOCATION_NETWORK_POSITION_ENABLED = 8, /**<Indicates whether the location service is allowed to use location data from cellular and Wi-Fi. (Deprecated since 4.0) */
61         RUNTIME_INFO_KEY_PACKET_DATA_ENABLED = 9,               /**<Indicates Whether the packet data through 3G network is enabled. */
62         RUNTIME_INFO_KEY_DATA_ROAMING_ENABLED = 10,             /**<Indicates whether data roaming is enabled. */
63         RUNTIME_INFO_KEY_VIBRATION_ENABLED = 12,                /**<Indicates whether vibration is enabled. */
64         RUNTIME_INFO_KEY_AUDIO_JACK_CONNECTED = 17,             /**<Indicates whether audio jack is connected. */
65         RUNTIME_INFO_KEY_GPS_STATUS = 18,                       /**<Indicates the current status of GPS. */
66         RUNTIME_INFO_KEY_BATTERY_IS_CHARGING = 19,              /**<Indicates the battery is currently charging. */
67         RUNTIME_INFO_KEY_TV_OUT_CONNECTED = 20,                 /**<Indicates whether TV out is connected. */
68         RUNTIME_INFO_KEY_AUDIO_JACK_STATUS = 21,                /**<Indicates the current status of audio jack. */
69         RUNTIME_INFO_KEY_USB_CONNECTED = 23,                    /**<Indicates whether USB is connected. */
70         RUNTIME_INFO_KEY_CHARGER_CONNECTED = 24,                /**<Indicates whether charger is connected. */
71         RUNTIME_INFO_KEY_AUTO_ROTATION_ENABLED = 26,            /**<Indicates whether auto rotation is enabled. */
72 } runtime_info_key_e;
73
74
75 /**
76  * @brief        Enumeration for Wi-Fi status.
77  * @since_tizen  @if WEARABLE 2.3.1 @else 2.3 @endif
78  */
79 typedef enum {
80         RUNTIME_INFO_WIFI_STATUS_DISABLED,    /**< Wi-Fi is disabled. */
81         RUNTIME_INFO_WIFI_STATUS_UNCONNECTED, /**< Wi-Fi is enabled and network connection is not established. */
82         RUNTIME_INFO_WIFI_STATUS_CONNECTED,   /**< Network connection is established in Wi-Fi network. */
83 } runtime_info_wifi_status_e;
84
85
86 /**
87  * @brief        Enumeration for GPS status.
88  * @since_tizen  @if WEARABLE 2.3.1 @else 2.3 @endif
89  */
90 typedef enum {
91         RUNTIME_INFO_GPS_STATUS_DISABLED,  /**< GPS is disabled. */
92         RUNTIME_INFO_GPS_STATUS_SEARCHING, /**< GPS is searching for satellites. */
93         RUNTIME_INFO_GPS_STATUS_CONNECTED, /**< GPS connection is established. */
94 } runtime_info_gps_status_e;
95
96 /**
97  * @brief        Enumeration for audio jack status.
98  * @since_tizen  @if WEARABLE 2.3.1 @else 2.3 @endif
99  */
100 typedef enum {
101         RUNTIME_INFO_AUDIO_JACK_STATUS_UNCONNECTED,     /**< Audio jack is not connected */
102         RUNTIME_INFO_AUDIO_JACK_STATUS_CONNECTED_3WIRE, /**< 3-conductor wire is connected. */
103         RUNTIME_INFO_AUDIO_JACK_STATUS_CONNECTED_4WIRE, /**< 4-conductor wire is connected. */
104 } runtime_info_audio_jack_status_e;
105
106
107 /**
108  * @brief        Called when the runtime information changes.
109  * @since_tizen  @if WEARABLE 2.3.1 @else 2.3 @endif
110  *
111  * @param[in] key        The type of notification
112  * @param[in] user_data  The user data passed from the callback registration function
113  *
114  * @pre  runtime_info_set_changed_cb() will invoke this callback function.
115  * @see  runtime_info_set_changed_cb()
116  * @see  runtime_info_unset_changed_cb()
117  */
118 typedef void (*runtime_info_changed_cb)(runtime_info_key_e key, void *user_data);
119
120
121 /**
122  * @brief        Gets the integer value of the runtime information.
123  * @details      This function gets current state of the given key which represents specific runtime information.
124  * @since_tizen  @if WEARABLE 2.3.1 @else 2.3 @endif
125  *
126  * @param[in]  key    The runtime information status key from which data should be read
127  * @param[out] value  The current value of the given key
128  *
129  * @return  @c 0 on success,
130  *          otherwise a negative error value
131  * @retval #RUNTIME_INFO_ERROR_NONE               Successful
132  * @retval #RUNTIME_INFO_ERROR_INVALID_PARAMETER  Invalid parameter
133  * @retval #RUNTIME_INFO_ERROR_IO_ERROR           An input/output error occurred when read value from system
134  * @retval #RUNTIME_INFO_ERROR_PERMISSION_DENIED  No permission to use the api
135  * @retval #RUNTIME_INFO_ERROR_NOT_SUPPORTED      Not supported parameter
136  */
137 int runtime_info_get_value_int(runtime_info_key_e key, int *value);
138
139
140 /**
141  * @brief        Gets the boolean value from the runtime information.
142  * @details      This function gets current state of the given key which represents specific runtime information.
143  * @since_tizen  @if WEARABLE 2.3.1 @else 2.3 @endif
144  *
145  * @param[in]  key    The runtime information key from which data should be read
146  * @param[out] value  The current value of the given key
147  *
148  * @return  @c 0 on success,
149  *          otherwise a negative error value
150  * @retval #RUNTIME_INFO_ERROR_NONE               Successful
151  * @retval #RUNTIME_INFO_ERROR_INVALID_PARAMETER  Invalid parameter
152  * @retval #RUNTIME_INFO_ERROR_IO_ERROR           An input/output error occurred when read value from system
153  * @retval #RUNTIME_INFO_ERROR_PERMISSION_DENIED  No permission to use the api
154  * @retval #RUNTIME_INFO_ERROR_NOT_SUPPORTED      Not supported parameter
155  */
156 int runtime_info_get_value_bool(runtime_info_key_e key, bool *value);
157
158
159 /**
160  * @brief        Gets the double value from the runtime information.
161  * @details      This function gets current state of the given key which represents specific runtime information.
162  * @since_tizen  @if WEARABLE 2.3.1 @else 2.3 @endif
163  *
164  * @param[in]  key    The runtime information key from which data should be read
165  * @param[out] value  The current value of the given key
166  *
167  * @return  @c 0 on success,
168  *          otherwise a negative error value
169  * @retval #RUNTIME_INFO_ERROR_NONE               Successful
170  * @retval #RUNTIME_INFO_ERROR_INVALID_PARAMETER  Invalid parameter
171  * @retval #RUNTIME_INFO_ERROR_IO_ERROR           An input/output error occurred when read value from system
172  * @retval #RUNTIME_INFO_ERROR_PERMISSION_DENIED  No permission to use the api
173  * @retval #RUNTIME_INFO_ERROR_NOT_SUPPORTED      Not supported parameter
174  */
175 int runtime_info_get_value_double(runtime_info_key_e key, double *value);
176
177
178 /**
179  * @brief        Gets the string value for specified runtime information.
180  * @details      This function gets current state of the given key which represents specific runtime information.
181  * @since_tizen  @if WEARABLE 2.3.1 @else 2.3 @endif
182  *
183  * @remarks  You must release @a value using free().
184  *
185  * @param[in]  key    The runtime information key from which data should be read
186  * @param[out] value  The current value of the given key
187  *
188  * @return  @c 0 on success,
189  *          otherwise a negative error value
190  * @retval #RUNTIME_INFO_ERROR_NONE               Successful
191  * @retval #RUNTIME_INFO_ERROR_INVALID_PARAMETER  Invalid parameter
192  * @retval #RUNTIME_INFO_ERROR_IO_ERROR           An input/output error occurred when read value from system
193  * @retval #RUNTIME_INFO_ERROR_OUT_OF_MEMORY      Out of memory
194  * @retval #RUNTIME_INFO_ERROR_PERMISSION_DENIED  No permission to use the api
195  * @retval #RUNTIME_INFO_ERROR_NOT_SUPPORTED      Not supported parameter
196  */
197 int runtime_info_get_value_string(runtime_info_key_e key, char **value);
198
199
200 /**
201  * @brief        Registers a change event callback for given runtime information key.
202  * @since_tizen  @if WEARABLE 2.3.1 @else 2.3 @endif
203  *
204  * @param[in] key        The runtime information type
205  * @param[in] callback   The callback function to invoke
206  * @param[in] user_data  The user data to be passed to the callback function
207  *
208  * @return  @c 0 on success,
209  *          otherwise a negative error value
210  * @retval #RUNTIME_INFO_ERROR_NONE               Successful
211  * @retval #RUNTIME_INFO_ERROR_INVALID_PARAMETER  Invalid parameter
212  * @retval #RUNTIME_INFO_ERROR_PERMISSION_DENIED  No permission to use the api
213  * @retval #RUNTIME_INFO_ERROR_NOT_SUPPORTED      Not supported parameter
214  *
215  * @post  runtime_info_changed_cb() will be invoked.
216  * @see   runtime_info_unset_changed_cb()
217  * @see   runtime_info_changed_cb()
218 */
219 int runtime_info_set_changed_cb(runtime_info_key_e key, runtime_info_changed_cb callback, void *user_data);
220
221
222 /**
223  * @brief        Unregisters the callback function.
224  * @since_tizen  @if WEARABLE 2.3.1 @else 2.3 @endif
225  *
226  * @param[in] key  The runtime information type
227  *
228  * @return  @c 0 on success,
229  *          otherwise a negative error value
230  * @retval #RUNTIME_INFO_ERROR_NONE               Successful
231  * @retval #RUNTIME_INFO_ERROR_INVALID_PARAMETER  Invalid parameter
232  *
233  * @see  runtime_info_set_changed_cb()
234  */
235 int runtime_info_unset_changed_cb(runtime_info_key_e key);
236
237
238 /**
239  * @brief        Structure for memory information.
240  * @since_tizen  @if WEARABLE 3.0 @else 2.4 @endif
241  */
242 typedef struct {
243         int total; /**< Total memory (KiB) */
244         int used;  /**< Used memory (KiB) */
245         int free;  /**< Free memory (KiB) */
246         int cache; /**< Cache memory (KiB) */
247         int swap;  /**< Swap memory (KiB) */
248 } runtime_memory_info_s;
249
250
251 /**
252  * @brief        Gets system memory information.
253  * @since_tizen  @if WEARABLE 3.0 @else 2.4 @endif
254  *
255  * @param[out] info  The system memory information structure
256  *
257  * @return  @c 0 on success,
258  *          otherwise a negative error value
259  * @retval #RUNTIME_INFO_ERROR_NONE               Successful
260  * @retval #RUNTIME_INFO_ERROR_INVALID_PARAMETER  Invalid parameter
261  * @retval #RUNTIME_INFO_ERROR_IO_ERROR           An Input/Output error occurred while reading from system
262  *
263  * @see  runtime_info_get_process_memory_info()
264  */
265 int runtime_info_get_system_memory_info(runtime_memory_info_s *info);
266
267
268 /**
269  * @brief        Structure for memory information per process.
270  * @since_tizen  @if WEARABLE 3.0 @else 2.4 @endif
271  */
272 typedef struct {
273         int vsz;           /**< Virtual memory size (KiB) */
274         int rss;           /**< Resident set size (KiB) */
275         int pss;           /**< Proportional set size (KiB) */
276         int shared_clean;  /**< Not modified and mapped by other processes (KiB) */
277         int shared_dirty;  /**< Modified and mapped by other processes (KiB) */
278         int private_clean; /**< Not modified and available only to that process (KiB) */
279         int private_dirty; /**< Modified and available only to that process (KiB) */
280 } process_memory_info_s;
281
282
283 /**
284  * @brief        Gets memory information per process.
285  * @since_tizen  @if WEARABLE 3.0 @else 2.4 @endif
286  *
287  * @privlevel  public
288  * @privilege  %http://tizen.org/privilege/systemmonitor
289  * @remarks    You must release @a s value using free(). \n
290  *             The size of @a s is the same with @a size.
291  *
292  * @param[in]  pid   The process unique id array
293  * @param[in]  size  The size of pid array
294  * @param[out] info  The memory information structure array of the processes
295  *
296  * @return  @c 0 on success,
297  *          otherwise a negative error value
298  * @retval #RUNTIME_INFO_ERROR_NONE               Successful
299  * @retval #RUNTIME_INFO_ERROR_INVALID_PARAMETER  Invalid parameter
300  * @retval #RUNTIME_INFO_ERROR_OUT_OF_MEMORY      Not able to allocate memory (for output param/other operations)
301  * @retval #RUNTIME_INFO_ERROR_REMOTE_IO          Call to resource daemon failed (dbus errors/resource daemon errors)
302  * @retval #RUNTIME_INFO_ERROR_IO_ERROR           An I/O error during dbus message operations
303  * @retval #RUNTIME_INFO_ERROR_PERMISSION_DENIED  Process not authorized to request process usage info
304  *
305  * @see  runtime_info_get_system_memory_info()
306  */
307 int runtime_info_get_process_memory_info(int *pid, int size, process_memory_info_s **info);
308
309
310 /**
311  * @brief        Structure for CPU usage.
312  * @since_tizen  @if WEARABLE 3.0 @else 2.4 @endif
313  */
314 typedef struct {
315         double user;   /**< Time running un-niced user processes (Percent) */
316         double system; /**< Time running kernel processes (Percent) */
317         double nice;   /**< Time running niced user processes (Percent) */
318         double iowait; /**< Time waiting for I/O completion (Percent) */
319 } runtime_cpu_usage_s;
320
321
322 /**
323  * @brief        Gets CPU information.
324  * @since_tizen  @if WEARABLE 3.0 @else 2.4 @endif
325  *
326  * @param[out] usage  The CPU usage structure
327  *
328  * @return  @c 0 on success,
329  *          otherwise a negative error value
330  * @retval #RUNTIME_INFO_ERROR_NONE               Successful
331  * @retval #RUNTIME_INFO_ERROR_INVALID_PARAMETER  Invalid parameter
332  * @retval #RUNTIME_INFO_ERROR_IO_ERROR           An input/output error occurred while reading from system
333  *
334  * @see  runtime_info_get_process_cpu_usage()
335  */
336 int runtime_info_get_cpu_usage(runtime_cpu_usage_s *usage);
337
338
339 /**
340  * @brief        Structure for CPU usage per process.
341  * @since_tizen  @if WEARABLE 3.0 @else 2.4 @endif
342  */
343 typedef struct {
344         int utime; /**< Amount of time that this process has been scheduled in user mode (clock ticks) */
345         int stime; /**< Amount of time that this process has been scheduled in kernel mode (clock ticks) */
346 } process_cpu_usage_s;
347
348
349 /**
350  * @brief        Gets CPU usage per process.
351  * @since_tizen  @if WEARABLE 3.0 @else 2.4 @endif
352  *
353  * @privlevel  public
354  * @privilege  %http://tizen.org/privilege/systemmonitor
355  * @remarks    You must release @a s value using free(). \n
356  *             The size of @a s is the same with @a size.
357  *
358  * @param[in]  pid   The process unique id array
359  * @param[in]  size  The size of pid array
360  * @param[out] usage The CPU usage structure array of the processes
361  *
362  * @return  @c 0 on success,
363  *          otherwise a negative error value
364  * @retval #RUNTIME_INFO_ERROR_NONE               Successful
365  * @retval #RUNTIME_INFO_ERROR_INVALID_PARAMETER  Invalid parameter
366  * @retval #RUNTIME_INFO_ERROR_OUT_OF_MEMORY      Not able to allocate memory (for output param/other operations)
367  * @retval #RUNTIME_INFO_ERROR_REMOTE_IO          Call to resource daemon failed (dbus errors/resource daemon errors)
368  * @retval #RUNTIME_INFO_ERROR_IO_ERROR           An I/O error occurred (during dbus message operations/other IO operations)
369  * @retval #RUNTIME_INFO_ERROR_PERMISSION_DENIED  Process not authorized to request process usage info
370  *
371  * @see  runtime_info_get_cpu_usage()
372  */
373 int runtime_info_get_process_cpu_usage(int *pid, int size, process_cpu_usage_s **usage);
374
375
376 /**
377  * @brief        Gets the number of processors.
378  * @since_tizen  3.0
379  *
380  * @param[out] num_core  The number of whole processors
381  *
382  * @return  @c 0 on success,
383  *          otherwise a negative error value
384  * @retval #RUNTIME_INFO_ERROR_NONE               Successful
385  * @retval #RUNTIME_INFO_ERROR_INVALID_PARAMETER  Invalid parameter
386  * @retval #RUNTIME_INFO_ERROR_IO_ERROR           An I/O error occurred (during file open operation)
387  */
388 int runtime_info_get_processor_count(int *num_core);
389
390
391 /**
392  * @brief        Gets the current frequency of processor.
393  * @since_tizen  3.0
394  *
395  * @param[in]  core_idx  The index (from 0) of CPU core that you want to know the frequency
396  * @param[out] cpu_freq  The current frequency(MHz) of processor
397  *
398  * @return  @c 0 on success,
399  *          otherwise a negative error value
400  * @retval #RUNTIME_INFO_ERROR_NONE               Successful
401  * @retval #RUNTIME_INFO_ERROR_INVALID_PARAMETER  Invalid parameter
402  * @retval #RUNTIME_INFO_ERROR_IO_ERROR           An I/O error occurred (during file open operation)
403  * @retval #RUNTIME_INFO_ERROR_NO_DATA            No data available (Since 3.0)
404  */
405 int runtime_info_get_processor_current_frequency(int core_idx, int *cpu_freq);
406
407
408 /**
409  * @brief        Gets the max frequency of processor.
410  * @since_tizen  3.0
411  *
412  * @param[in]  core_idx  The index (from 0) of CPU core that you want to know the frequency
413  * @param[out] cpu_freq  The max frequency(MHz) of processor
414  *
415  * @return  @c 0 on success,
416  *          otherwise a negative error value
417  * @retval #RUNTIME_INFO_ERROR_NONE               Successful
418  * @retval #RUNTIME_INFO_ERROR_INVALID_PARAMETER  Invalid parameter
419  * @retval #RUNTIME_INFO_ERROR_IO_ERROR           An I/O error occurred (during file open operation)
420  * @retval #RUNTIME_INFO_ERROR_NO_DATA            No data available (Since 3.0)
421  */
422 int runtime_info_get_processor_max_frequency(int core_idx, int *cpu_freq);
423
424
425 /**
426  * @brief        Gets the physical memory size.
427  * @since_tizen  4.0
428  *
429  * @param[out] size  Physical memory size (KiB)
430  *
431  * @return  @c 0 on success,
432  *          otherwise a negative error value
433  * @retval #RUNTIME_INFO_ERROR_NONE               Successful
434  * @retval #RUNTIME_INFO_ERROR_INVALID_PARAMETER  Invalid parameter
435  * @retval #RUNTIME_INFO_ERROR_IO_ERROR           An I/O error occurred (during file open operation)
436  */
437 int runtime_info_get_physical_memory_size(int *size);
438
439
440 /**
441  * @brief        Handle for app usage information.
442  * @since_tizen  4.0
443  */
444 typedef struct app_usages_s *app_usage_h;
445
446
447 /**
448  * @brief        Frees an app usage handle.
449  * @since_tizen  4.0
450  *
451  * @param[in] handle  App usage handle to free
452  *
453  * @return  @c 0 on success,
454  *          otherwise a negative error value
455  * @retval #RUNTIME_INFO_ERROR_NONE               Successful
456  * @retval #RUNTIME_INFO_ERROR_INVALID_PARAMETER  Invalid parameter
457  */
458 int runtime_info_app_usage_destroy(app_usage_h handle);
459
460
461 /**
462  * @brief        Gets the app count from an app usage handle.
463  * @since_tizen  4.0
464  *
465  * @param[in]  handle  The app usage handle
466  * @param[out] count   The number of apps on the app list
467  *
468  * @return  @c 0 on success,
469  *          otherwise a negative error value
470  * @retval #RUNTIME_INFO_ERROR_NONE               Successful
471  * @retval #RUNTIME_INFO_ERROR_INVALID_PARAMETER  Invalid parameter
472  *
473  * @see  runtime_info_get_all_apps_memory_usage()
474  * @see  runtime_info_get_all_apps_cpu_rate()
475  */
476 int runtime_info_app_usage_get_count(app_usage_h handle, int *count);
477
478
479 /**
480  * @brief        Gets the app ID from an app usage handle.
481  * @since_tizen  4.0
482  *
483  * @remarks  You must release @a appid using free().
484  *
485  * @param[in]  handle  The app usage handle
486  * @param[in]  index   The index in the app list; should be between 0 and @a count - 1 (inclusive), \n
487  *                     where @a count is provided by runtime_info_app_usage_get_count()
488  * @param[out] appid   The app ID
489  *
490  * @return  @c 0 on success,
491  *          otherwise a negative error value
492  * @retval #RUNTIME_INFO_ERROR_NONE               Successful
493  * @retval #RUNTIME_INFO_ERROR_INVALID_PARAMETER  Invalid parameter
494  *
495  * @see  runtime_info_get_all_apps_memory_usage()
496  * @see  runtime_info_get_all_apps_cpu_rate()
497  */
498 int runtime_info_app_usage_get_appid(app_usage_h handle, int index, char **appid);
499
500
501 /**
502  * @brief        Gets resource usage from an app usage handle.
503  * @since_tizen  4.0
504  *
505  * @remarks  The meaning of @a usage depends on which function was used to create @a handle.
506  *
507  * @param[in]  handle  The app usage handle
508  * @param[in]  index   The index in the app list; should be between 0 and @a count - 1 (inclusive), \n
509  *                     where @a count is provided by runtime_info_app_usage_get_count()
510  * @param[out] usage   Resource usage
511  *
512  * @return  @c 0 on success,
513  *          otherwise a negative error value
514  * @retval #RUNTIME_INFO_ERROR_NONE               Successful
515  * @retval #RUNTIME_INFO_ERROR_INVALID_PARAMETER  Invalid parameter
516  *
517  * @see  runtime_info_get_all_apps_memory_usage()
518  * @see  runtime_info_get_all_apps_cpu_rate()
519  */
520 int runtime_info_app_usage_get_usage(app_usage_h handle, int index, unsigned int *usage);
521
522
523 /**
524  * @brief        Gets memory usage of all apps.
525  * @since_tizen  4.0
526  *
527  * @privlevel  public
528  * @privilege  %http://tizen.org/privilege/systemmonitor
529  * @remarks    You must release @a usage using runtime_info_app_usage_destroy().
530  *
531  * @param[out] usage  An array of each app's memory usage (KB)
532  *
533  * @return  @c 0 on success,
534  *          otherwise a negative error value
535  * @retval #RUNTIME_INFO_ERROR_NONE               Successful
536  * @retval #RUNTIME_INFO_ERROR_INVALID_PARAMETER  Invalid parameter
537  * @retval #RUNTIME_INFO_ERROR_OUT_OF_MEMORY      Not able to allocate memory (for output param/other operations)
538  * @retval #RUNTIME_INFO_ERROR_REMOTE_IO          Call to resource daemon failed (dbus errors/resource daemon errors)
539  * @retval #RUNTIME_INFO_ERROR_IO_ERROR           An I/O error during dbus message operations
540  * @retval #RUNTIME_INFO_ERROR_PERMISSION_DENIED  Process not authorized to request app usage info
541  * @retval #RUNTIME_INFO_ERROR_NO_DATA            No app running
542  *
543  * @code
544  * #include <runtime_info.h>
545  *
546  * void print_memory_usage(void)
547  * {
548  *     int i;
549  *     int count;
550  *     app_usage_h mem_usage_handle;
551  *     char *appid;
552  *     unsigned int usage;
553  *
554  *     runtime_info_get_all_apps_memory_usage(&mem_usage_handle);
555  *     runtime_info_app_usage_get_count(mem_usage_handle, &count);
556  *
557  *     for (i = 0; i < count; i++) {
558  *         runtime_info_app_usage_get_appid(mem_usage_handle, i, &appid);
559  *         runtime_info_app_usage_get_usage(mem_usage_handle, i, &usage);
560  *         printf("appid = %s, usage = %u KB\n", appid, usage);
561  *         free(appid);
562  *     }
563  *
564  *     runtime_info_app_usage_destroy(mem_usage_handle);
565  *
566  * }
567  * @endcode
568  */
569 int runtime_info_get_all_apps_memory_usage(app_usage_h *usage);
570
571
572 /**
573  * @brief        Gets CPU rate of all apps.
574  * @since_tizen  4.0
575  *
576  * @privlevel  public
577  * @privilege  %http://tizen.org/privilege/systemmonitor
578  * @remarks    You must release @a rate using runtime_info_app_usage_destroy().
579  *
580  * @param[out] rate  An array of each app's CPU usage rate (%), the values are rounded down.
581  *
582  * @return  @c 0 on success,
583  *          otherwise a negative error value
584  * @retval #RUNTIME_INFO_ERROR_NONE               Successful
585  * @retval #RUNTIME_INFO_ERROR_INVALID_PARAMETER  Invalid parameter
586  * @retval #RUNTIME_INFO_ERROR_OUT_OF_MEMORY      Not able to allocate memory (for output param/other operations)
587  * @retval #RUNTIME_INFO_ERROR_REMOTE_IO          Call to resource daemon failed (dbus errors/resource daemon errors)
588  * @retval #RUNTIME_INFO_ERROR_IO_ERROR           An I/O error during dbus message operations
589  * @retval #RUNTIME_INFO_ERROR_PERMISSION_DENIED  Process not authorized to request app usage info
590  * @retval #RUNTIME_INFO_ERROR_NO_DATA            No app running
591  *
592  * @code
593  * #include <runtime_info.h>
594  *
595  * void print_cpu_usage(void)
596  * {
597  *     int i;
598  *     int count;
599  *     app_usage_h cpu_rate_handle;
600  *     char *appid;
601  *     unsigned int rate;
602  *
603  *     runtime_info_get_all_apps_cpu_rate(&cpu_rate_handle);
604  *     runtime_info_app_usage_get_count(cpu_rate_handle, &count);
605  *
606  *     for (i = 0; i < count; i++) {
607  *         runtime_info_app_usage_get_appid(cpu_rate_handle, i, &appid);
608  *         runtime_info_app_usage_get_usage(cpu_rate_handle, i, &rate);
609  *         printf("appid = %s, rate = %u %%\n", appid, rate);
610  *         free(appid);
611  *     }
612  *
613  *     runtime_info_app_usage_destroy(cpu_rate_handle);
614  *
615  * }
616  * @endcode
617  */
618 int runtime_info_get_all_apps_cpu_rate(app_usage_h *rate);
619
620
621 /**
622  * @}
623  */
624
625 #ifdef __cplusplus
626 }
627 #endif
628
629 #endif /** __TIZEN_SYSTEM_RUNTIME_INFO_H__ */