2 * Copyright (c) 2011 - 2016 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_APPFW_APP_MANAGER_H
18 #define __TIZEN_APPFW_APP_MANAGER_H
22 #include <app_context.h>
34 * @addtogroup CAPI_APPLICATION_MANAGER_MODULE
39 * @brief Enumerations for Application Manager Error .
40 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
43 APP_MANAGER_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
44 APP_MANAGER_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
45 APP_MANAGER_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
46 APP_MANAGER_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< Internal I/O error */
47 APP_MANAGER_ERROR_NO_SUCH_APP = TIZEN_ERROR_APPLICATION_MANAGER | 0x01, /**< No such application */
48 APP_MANAGER_ERROR_DB_FAILED = TIZEN_ERROR_APPLICATION_MANAGER | 0x03, /**< Database error */
49 APP_MANAGER_ERROR_INVALID_PACKAGE = TIZEN_ERROR_APPLICATION_MANAGER | 0x04, /**< Invalid package name */
50 APP_MANAGER_ERROR_APP_NO_RUNNING = TIZEN_ERROR_APPLICATION_MANAGER | 0x05, /**< App is not running */
51 APP_MANAGER_ERROR_REQUEST_FAILED = TIZEN_ERROR_APPLICATION_MANAGER | 0x06, /**< Internal aul request error */
52 APP_MANAGER_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
53 APP_MANAGER_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED /**< Not supported (Since 3.0) */
54 } app_manager_error_e;
57 * @brief Enumeration for app manager status type.
61 APP_MANAGER_EVENT_STATUS_TYPE_ALL = 0x00, /**< All Status */
62 APP_MANAGER_EVENT_STATUS_TYPE_ENABLE = 0x01, /**< Application enable status */
63 APP_MANAGER_EVENT_STATUS_TYPE_DISABLE = 0x02, /**< Application disable status */
64 } app_manager_event_status_type_e;
67 * @brief Enumeration for app manager event type.
71 APP_MANAGER_EVENT_ENABLE_APP = 0, /**< Application enable event */
72 APP_MANAGER_EVENT_DISABLE_APP, /**< Application disable event. */
73 } app_manager_event_type_e;
76 * @brief Enumeration for app manager event state.
80 APP_MANAGER_EVENT_STATE_STARTED = 0, /**< Started event state */
81 APP_MANAGER_EVENT_STATE_COMPLETED, /**< Completed event state */
82 APP_MANAGER_EVENT_STATE_FAILED, /**< Failed event state */
83 } app_manager_event_state_e;
86 * @brief App manager event handle.
89 typedef struct app_manager_event_s *app_manager_event_h;
92 * @brief Called when the application is enabled or disabled.
95 * @param[in] type The type of the app to be enabled or disabled
96 * @param[in] app_id The app id to be enabled or disabled
97 * @param[in] event_type The event type of the app
98 * @param[in] event_state The current event state of the app
99 * @param[in] handle The app manager event handle
100 * @param[in] user_data The user data passed from app_manager_set_event_cb()
101 * @pre This function is called when an application being disabled or enabled, after you register this callback using app_manager_set_event_cb().
103 * @see app_manager_set_event_cb()
104 * @see app_manager_unset_event_cb()
106 typedef void (*app_manager_event_cb) (
109 app_manager_event_type_e event_type,
110 app_manager_event_state_e event_state,
111 app_manager_event_h handle,
115 * @brief Called when an application is launched or terminated.
116 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
117 * @param[in] app_context The application context of the application launched or terminated
118 * @param[in] event The application context event
119 * @param[in] user_data The user data passed from the foreach function
120 * @pre This function is called when an application gets launched or terminated, after you register this callback using app_manager_set_app_context_event_cb().
121 * @see app_manager_set_app_context_event_cb()
122 * @see app_manager_unset_app_context_event_cb()
124 typedef void (*app_manager_app_context_event_cb) (app_context_h app_context, app_context_event_e event, void *user_data);
127 * @brief Called to get the application context once for each running application.
128 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
129 * @param[in] app_context The application context of each running application
130 * @param[in] user_data The user data passed from the foreach function
131 * @return @c true to continue with the next iteration of the loop, \n
132 * otherwise @c false to break out of the loop
133 * @pre app_manager_foreach_app_context() will invoke this callback.
134 * @see app_manager_foreach_app_context()
136 typedef bool (*app_manager_app_context_cb) (app_context_h app_context, void *user_data);
139 * @brief Called to get the application information once for each installed application.
140 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
141 * @param[in] app_info The application information of each installed application
142 * @param[in] user_data The user data passed from the foreach function
143 * @return @c true to continue with the next iteration of the loop, \n
144 * otherwise @c false to break out of the loop
145 * @pre app_manager_foreach_app_info() will invoke this callback.
146 * @see app_manager_foreach_app_info()
148 typedef bool (*app_manager_app_info_cb) (app_info_h app_info, void *user_data);
151 * @brief Registers a callback function to be invoked when the applications get launched or terminated.
152 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
153 * @param[in] callback The callback function to register
154 * @param[in] user_data The user data to be passed to the callback function
155 * @return @c 0 on success,
156 * otherwise a negative error value
157 * @retval #APP_MANAGER_ERROR_NONE Successful
158 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
159 * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
160 * @retval #APP_MANAGER_ERROR_IO_ERROR Internal I/O error
161 * @post It will invoke app_manager_app_context_event_cb() when the application is launched or terminated.
162 * @see app_manager_unset_app_context_event_cb()
163 * @see app_manager_app_context_event_cb()
165 int app_manager_set_app_context_event_cb(app_manager_app_context_event_cb callback, void *user_data);
168 * @brief Unregisters the callback function.
169 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
170 * @see app_manager_app_context_event_cb()
172 void app_manager_unset_app_context_event_cb(void);
175 * @brief Retrieves all application contexts of running applications.
176 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
177 * @param[in] callback The callback function to invoke
178 * @param[in] user_data The user data to be passed to the callback function
179 * @return @c 0 on success,
180 * otherwise a negative error value
181 * @retval #APP_MANAGER_ERROR_NONE Successful
182 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
183 * @retval #APP_MANAGER_ERROR_IO_ERROR Internal I/O error
184 * @post This function invokes app_manager_app_context_cb() for each application context.
185 * @see app_manager_app_context_cb()
186 * @remarks In case of ui applications, sub apps in application groups will not be shown.
188 int app_manager_foreach_app_context(app_manager_app_context_cb callback, void *user_data);
192 * @brief Retrieves all application contexts of running applications including sub apps.
193 * @details You can iterate all the running application contexts using this API.
194 * This API is similar to app_manager_foreach_app_context() except that this API iterates application contexts including sub apps in application groups.
196 * @param[in] callback The callback function to invoke
197 * @param[in] user_data The user data to be passed to the callback function
198 * @return @c 0 on success,
199 * otherwise a negative error value
200 * @retval #APP_MANAGER_ERROR_NONE Successful
201 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
202 * @retval #APP_MANAGER_ERROR_IO_ERROR Internal I/O error
203 * @post This function invokes app_manager_app_context_cb() for each application context.
204 * @see app_manager_app_context_cb()
206 int app_manager_foreach_running_app_context(app_manager_app_context_cb callback, void *user_data);
210 * @brief Gets the application context for the given ID of the application.
211 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
212 * @remarks This function returns #APP_MANAGER_ERROR_NO_SUCH_APP if the application with the given application ID is not running. \n
213 * You must release @a app_context using app_context_destroy().
214 * @param[in] app_id The ID of the application
215 * @param[out] app_context The application context of the given application ID
216 * @return @c 0 on success,
217 * otherwise a negative error value
218 * @retval #APP_MANAGER_ERROR_NONE Successful
219 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
220 * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
221 * @retval #APP_MANAGER_ERROR_NO_SUCH_APP No such application
223 int app_manager_get_app_context(const char *app_id, app_context_h *app_context);
226 * @brief Gets the ID of the application for the given process ID.
227 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
228 * @remarks This function returns #APP_MANAGER_ERROR_NO_SUCH_APP if the application with the given process ID is not valid. \n
229 * You must release @a app_id using free().
230 * @param[in] pid The process ID of the application
231 * @param[out] app_id The ID of the application
232 * @return @c 0 on success,
233 * otherwise a negative error value
234 * @retval #APP_MANAGER_ERROR_NONE Successful
235 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
236 * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
238 int app_manager_get_app_id(pid_t pid, char **app_id);
241 * @brief Checks whether the application with the given ID of the application is running.
242 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
243 * @param[in] app_id The ID of the application
244 * @param[out] running @c true if the application is running, \n
245 * otherwise @c false if not running
246 * @return @c 0 on success,
247 * otherwise a negative error value
248 * @retval #APP_MANAGER_ERROR_NONE Successful
249 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
251 int app_manager_is_running(const char *app_id, bool *running);
254 * @brief Resumes the application.
255 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
257 * @privilege %http://tizen.org/privilege/appmanager.launch
258 * @param[in] app_context The application context
259 * @return @c 0 on success,
260 * otherwise a negative error value
261 * @retval #APP_MANAGER_ERROR_NONE Successful
262 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
263 * @retval #APP_MANAGER_ERROR_APP_NO_RUNNING App is not running
264 * @retval #APP_MANAGER_ERROR_REQUEST_FAILED Internal resume error
265 * @retval #APP_MANAGER_ERROR_PERMISSION_DENIED Permission denied
267 int app_manager_resume_app(app_context_h app_context);
270 * @brief Terminates the back ground application.\n
271 * UI applications that are in paused state or some service applications could be required to terminate by this API.
272 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
274 * @privilege %http://tizen.org/privilege/appmanager.kill.bgapp
275 * @remarks This function returns after it just sends a request for terminating a background application.\n
276 * Platform will decide if the target application could be terminated or not according to the state of the target application.
277 * @param[in] app_context The application context
278 * @return @c 0 on success,
279 * otherwise a negative error value
280 * @retval #APP_MANAGER_ERROR_NONE Successful
281 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
282 * @retval #APP_MANAGER_ERROR_REQUEST_FAILED Failed to send terminate request
283 * @retval #APP_MANAGER_ERROR_PERMISSION_DENIED Permission denied
285 int app_manager_request_terminate_bg_app(app_context_h app_context);
288 * @brief Retrieves all installed applications information.
289 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
290 * @param[in] callback The callback function to invoke
291 * @param[in] user_data The user data to be passed to the callback function
292 * @return @c 0 on success,
293 * otherwise a negative error value
294 * @retval #APP_MANAGER_ERROR_NONE Successful
295 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
296 * @post This function invokes app_manager_app_info_cb() for each application information.
297 * @see app_manager_app_info_cb()
299 int app_manager_foreach_app_info(app_manager_app_info_cb callback, void *user_data);
302 * @brief Gets the application information for the given application ID.
303 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
304 * @remarks You must release @a app_info using app_info_destroy().
305 * @param[in] app_id The ID of the application
306 * @param[out] app_info The application information for the given application ID
307 * @return @c 0 on success,
308 * otherwise a negative error value
309 * @retval #APP_MANAGER_ERROR_NONE Successful
310 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
311 * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
312 * @retval #APP_MANAGER_ERROR_NO_SUCH_APP No such application
314 int app_manager_get_app_info(const char *app_id, app_info_h *app_info);
317 * @brief Gets the absolute path to the shared data directory of the application specified
318 * with an application ID.
319 * @details An application can only read the files of other application's shared data directory.
320 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
321 * @remarks The specified @a path should be released with free(). @n
322 * Since Tizen 3.0, the shared/data directory is supported only for the applications that declare the http://tizen.org/privilege/appdir.shareddata privilege.
323 * The function will fail with #APP_MANAGER_ERROR_NOT_SUPPORTED if the privilege is not declared.
325 * @param[in] app_id The ID of the application
326 * @param[in,out] path The absolute path to the shared data directory of the application
327 * specified with the @a app_id
328 * @return @c 0 on success,
329 * otherwise a negative error value
330 * @retval #APP_MANAGER_ERROR_NONE Successful
331 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
332 * @retval #APP_MANAGER_ERROR_NO_SUCH_APP No such application
333 * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
334 * @retval #APP_MANAGER_ERROR_NOT_SUPPORTED Not supported
336 int app_manager_get_shared_data_path(const char *app_id, char **path);
339 * @brief Gets the absolute path to the shared resource directory of the application specified
340 * with an application ID.
341 * @details An application can only read the files of other application's shared resource directory.
342 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
343 * @remarks The specified @a path should be released with free().
345 * @param[in] app_id The ID of the application
346 * @param[in,out] path The absolute path to the shared resource directory of the application
347 * specified with the @a app_id
348 * @return @c 0 on success,
349 * otherwise a negative error value
350 * @retval #APP_MANAGER_ERROR_NONE Successful
351 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
352 * @retval #APP_MANAGER_ERROR_NO_SUCH_APP No such application
353 * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
355 int app_manager_get_shared_resource_path(const char *app_id, char **path);
358 * @brief Gets the absolute path to the shared trusted directory of the application specified
359 * with an application ID.
360 * @details An application signed with the same certificate can read and write the files of
361 * other application's shared trusted directory.
362 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
363 * @remarks The specified @a path should be released with free().
365 * @param[in] app_id The ID of the application
366 * @param[in,out] path The absolute path to the shared trusted directory of the application
367 * specified with the @a app_id
368 * @return @c 0 on success,
369 * otherwise a negative error value
370 * @retval #APP_MANAGER_ERROR_NONE Successful
371 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
372 * @retval #APP_MANAGER_ERROR_NO_SUCH_APP No such application
373 * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
375 int app_manager_get_shared_trusted_path(const char *app_id, char **path);
378 * @deprecated Deprecated since @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif.
379 * @brief Gets the absolute path to the shared data directory of the application specified
380 * with an application ID.
381 * @details An application can only read the files of other application's shared data directory.
382 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
383 * @remarks The specified @a path should be released with free().
384 * @remarks To access the path returned by this function may not work as intended in certain devices due to some implementation issues.
386 * @param[in] app_id The ID of the application
387 * @param[in,out] path The absolute path to the shared data directory of the application
388 * specified with the @a app_id
389 * @return @c 0 on success,
390 * otherwise a negative error value
391 * @retval #APP_MANAGER_ERROR_NONE Successful
392 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
393 * @retval #APP_MANAGER_ERROR_NO_SUCH_APP No such application
394 * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
396 int app_manager_get_external_shared_data_path(const char *app_id, char **path) TIZEN_DEPRECATED_API;
399 * @brief Creates a app manager event handle.
401 * @remarks You must release @a handle using app_manager_event_destroy().
403 * @param[out] handle The app manager event handle that is newly created on success
405 * @return @c 0 on success,
406 * otherwise a negative error value
408 * @retval #APP_MANAGER_ERROR_NONE Successful
409 * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
410 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
411 * @see app_manager_event_destroy()
413 int app_manager_event_create(app_manager_event_h *handle);
416 * @brief Sets the event to handle to listen.
417 * You can combine multiple status using OR operation which you want to listen.
420 * @param [in] handle The app manager event handle
421 * @param [in] status_type The status of the application
423 * @return @c 0 on success,
424 * otherwise a negative error value
426 * @retval #APP_MANAGER_ERROR_NONE Successful
427 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
428 * @retval #APP_MANAGER_ERROR_REQUEST_FAILED Internal error
430 * @see app_manager_event_status_type_e
431 * @see app_manager_set_event_cb()
433 int app_manager_event_set_status(app_manager_event_h handle, int status_type);
436 * @brief Registers a callback function to be invoked when the app is event has occurred
438 * @param[in] handle The app manager event handle
439 * @param[in] callback The callback function to be registered
440 * @param[in] user_data The user data to be passed to the callback function
442 * @return @c 0 on success,
443 * otherwise a negative error value
445 * @retval #APP_MANAGER_ERROR_NONE Successful
446 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
447 * @retval #APP_MANAGER_ERROR_REQUEST_FAILED Internal error
448 * @post app_manager_event_cb() will be invoked.
450 * @see app_manager_event_set_status()
451 * @see app_manager_event_cb()
452 * @see app_manager_unset_event_cb()
454 int app_manager_set_event_cb(app_manager_event_h handle,
455 app_manager_event_cb callback,
459 * @brief Unregisters the callback function.
462 * @param[in] handle The app manager event handle
464 * @return @c 0 on success,
465 * otherwise a negative error value
467 * @retval #APP_MANAGER_ERROR_NONE Successful
468 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
469 * @retval #APP_MANAGER_ERROR_REQUEST_FAILED Internal error
471 * @see app_manager_event_cb()
472 * @see app_manager_set_event_cb()
474 int app_manager_unset_event_cb(app_manager_event_h handle);
477 * @brief Destroys the app manager event handle.
480 * @param[in] handle The app manager event handle
482 * @return @c 0 on success,
483 * otherwise a negative error value
485 * @retval #APP_MANAGER_ERROR_NONE Successful
486 * @retval #APP_MANAGER_ERROR_REQUEST_FAILED Internal error
487 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
489 * @see app_manager_event_create()
491 int app_manager_event_destroy(app_manager_event_h handle);
502 #endif /* __TIZEN_APPFW_APP_MANAGER_H */