1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
|
/*
* Copyright (c) 2011 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.
*/
#ifndef __TIZEN_APPFW_APP_MANAGER_H
#define __TIZEN_APPFW_APP_MANAGER_H
#include <tizen.h>
#include <app_context.h>
#include <app_info.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @file app_manager.h
*/
/**
* @addtogroup CAPI_APPLICATION_MANAGER_MODULE
* @{
*/
/**
* @brief Enumerations for Application Manager Error .
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
typedef enum
{
APP_MANAGER_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
APP_MANAGER_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
APP_MANAGER_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
APP_MANAGER_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< Internal I/O error */
APP_MANAGER_ERROR_NO_SUCH_APP = TIZEN_ERROR_APPLICATION_MANAGER | 0x01, /**< No such application */
APP_MANAGER_ERROR_DB_FAILED = TIZEN_ERROR_APPLICATION_MANAGER | 0x03, /**< Database error */
APP_MANAGER_ERROR_INVALID_PACKAGE = TIZEN_ERROR_APPLICATION_MANAGER | 0x04, /**< Invalid package name */
APP_MANAGER_ERROR_APP_NO_RUNNING = TIZEN_ERROR_APPLICATION_MANAGER | 0x05, /**< App is not running */
APP_MANAGER_ERROR_REQUEST_FAILED = TIZEN_ERROR_APPLICATION_MANAGER | 0x06, /**< Internal aul request error */
APP_MANAGER_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED /**< Permission denied */
} app_manager_error_e;
/**
* @internal
* @brief Called when an application is launched or terminated.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
* @param[in] app_context The application context of the application launched or terminated
* @param[in] event The application context event
* @param[in] user_data The user data passed from the foreach function
* @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().
* @see app_manager_set_app_context_event_cb()
* @see app_manager_unset_app_context_event_cb()
*/
typedef void (*app_manager_app_context_event_cb) (app_context_h app_context, app_context_event_e event, void *user_data);
/**
* @brief Called to get the application context once for each running application.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
* @param[in] app_context The application context of each running application
* @param[in] user_data The user data passed from the foreach function
* @return @c true to continue with the next iteration of the loop, \n
* otherwise @c false to break out of the loop
* @pre app_manager_foreach_app_context() will invoke this callback.
* @see app_manager_foreach_app_context()
*/
typedef bool (*app_manager_app_context_cb) (app_context_h app_context, void *user_data);
/**
* @brief Called to get the application information once for each installed application.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
* @param[in] app_info The application information of each installed application
* @param[in] user_data The user data passed from the foreach function
* @return @c true to continue with the next iteration of the loop, \n
* otherwise @c false to break out of the loop
* @pre app_manager_foreach_app_info() will invoke this callback.
* @see app_manager_foreach_app_info()
*/
typedef bool (*app_manager_app_info_cb) (app_info_h app_info, void *user_data);
/**
* @internal
* @brief Registers a callback function to be invoked when the applications get launched or terminated.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
* @param[in] callback The callback function to register
* @param[in] user_data The user data to be passed to the callback function
* @return @c 0 on success,
* otherwise a negative error value
* @retval #APP_MANAGER_ERROR_NONE Successful
* @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
* @post It will invoke app_manager_app_context_event_cb() when the application is launched or terminated.
* @see app_manager_unset_app_context_event_cb()
* @see app_manager_app_context_event_cb()
*/
int app_manager_set_app_context_event_cb(app_manager_app_context_event_cb callback, void *user_data);
/**
* @internal
* @brief Unregisters the callback function.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
* @see app_manager_set_app_event_cb()
* @see app_manager_app_context_event_cb()
*/
void app_manager_unset_app_context_event_cb(void);
/**
* @brief Retrieves all application contexts of running applications.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
* @param[in] callback The callback function to invoke
* @param[in] user_data The user data to be passed to the callback function
* @return @c 0 on success,
* otherwise a negative error value
* @retval #APP_MANAGER_ERROR_NONE Successful
* @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
* @post This function invokes app_manager_app_context_cb() for each application context.
* @see app_manager_app_context_cb()
*/
int app_manager_foreach_app_context(app_manager_app_context_cb callback, void *user_data);
/**
* @brief Gets the application context for the given ID of the application.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
* @remarks This function returns #APP_MANAGER_ERROR_NO_SUCH_APP if the application with the given application ID is not running. \n
* You must release @a app_context using app_context_destroy().
* @param[in] app_id The ID of the application
* @param[out] app_context The application context of the given application ID
* @return @c 0 on success,
* otherwise a negative error value
* @retval #APP_MANAGER_ERROR_NONE Successful
* @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
* @retval #APP_MANAGER_ERROR_NO_SUCH_APP No such application
*/
int app_manager_get_app_context(const char *app_id, app_context_h *app_context);
/**
* @brief Gets the ID of the application for the given process ID.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
* @remarks This function returns #APP_MANAGER_ERROR_NO_SUCH_APP if the application with the given process ID is not valid. \n
* You must release @a app_id using free().
* @param[in] pid The process ID of the application
* @param[out] app_id The ID of the application
* @return @c 0 on success,
* otherwise a negative error value
* @retval #APP_MANAGER_ERROR_NONE Successful
* @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
*/
int app_manager_get_app_id(pid_t pid, char **app_id);
/**
* @brief Checks whether the application with the given package name is running.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
* @param[in] app_id The ID of the application
* @param[out] running @c true if the application is running, \n
* otherwise @c false if not running
* @return @c 0 on success,
* otherwise a negative error value
* @retval #APP_MANAGER_ERROR_NONE Successful
* @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
*/
int app_manager_is_running(const char *app_id, bool *running);
/**
* @brief Resumes the application.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
* @privlevel public
* @privilege %http://tizen.org/privilege/appmanager.launch
* @param[in] app_context The application context
* @return @c 0 on success,
* otherwise a negative error value
* @retval #APP_MANAGER_ERROR_NONE Successful
* @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #APP_MANAGER_ERROR_APP_NO_RUNNING App is not running
* @retval #APP_MANAGER_ERROR_REQUEST_FAILED Internal resume error
* @retval #APP_MANAGER_ERROR_PERMISSION_DENIED Permission denied
*/
int app_manager_resume_app(app_context_h app_context);
/**
* @internal
* @brief Opens the application.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
* @privlevel public
* @privilege %http://tizen.org/privilege/appmanager.launch
* @param[in] app_id The ID of the application
* @return @c 0 on success,
* otherwise a negative error value
* @retval #APP_MANAGER_ERROR_NONE Successful
* @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #APP_MANAGER_ERROR_NO_SUCH_APP No such application
* @retval #APP_MANAGER_ERROR_REQUEST_FAILED Internal open error
* @retval #APP_MANAGER_ERROR_PERMISSION_DENIED Permission denied
*/
int app_manager_open_app(const char *app_id);
/**
* @internal
* @brief Terminates the application.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
* @privlevel platform
* @privilege %http://tizen.org/privilege/appmanager.kill
* @param[in] app_context The application context
* @return @c 0 on success,
* otherwise a negative error value
* @retval #APP_MANAGER_ERROR_NONE Successful
* @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #APP_MANAGER_ERROR_REQUEST_FAILED Internal terminate error
* @retval #APP_MANAGER_ERROR_PERMISSION_DENIED Permission denied
*/
int app_manager_terminate_app(app_context_h app_context);
/**
* @brief Retrieves all installed applications information.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
* @param[in] callback The callback function to invoke
* @param[in] user_data The user data to be passed to the callback function
* @return @c 0 on success,
* otherwise a negative error value
* @retval #APP_MANAGER_ERROR_NONE Successful
* @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
* @post This function invokes app_manager_app_info_cb() for each application information.
* @see app_manager_app_info_cb()
*/
int app_manager_foreach_app_info(app_manager_app_info_cb callback, void *user_data);
/**
* @brief Gets the application information for the given application ID.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
* @remarks You must release @a app_info using app_info_destroy().
* @param[in] app_id The ID of the application
* @param[out] app_info The application information for the given application ID
* @return @c 0 on success,
* otherwise a negative error value
* @retval #APP_MANAGER_ERROR_NONE Successful
* @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
* @retval #APP_MANAGER_ERROR_NO_SUCH_APP No such application
*/
int app_manager_get_app_info(const char *app_id, app_info_h *app_info);
/**
* @brief Gets the absolute path to the shared data directory of the application specified
* with an application ID.
* @details An application can only read the files of other application's shared data directory.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
* @remarks The specified @a path should be released.
*
* @param[in] app_id The ID of the application
* @param[in,out] path The absolute path to the shared data directory of the application
* specified with the @a app_id
* @return @c 0 on success,
* otherwise a negative error value
* @retval #APP_MANAGER_ERROR_NONE Successful
* @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #APP_MANAGER_ERROR_NO_SUCH_APP No such application
* @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
*/
int app_manager_get_shared_data_path(const char *app_id, char **path);
/**
* @brief Gets the absolute path to the shared resource directory of the application specified
* with an application ID.
* @details An application can only read the files of other application's shared resource directory.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
* @remarks The specified @a path should be released.
*
* @param[in] app_id The ID of the application
* @param[in,out] path The absolute path to the shared resource directory of the application
* specified with the @a app_id
* @return @c 0 on success,
* otherwise a negative error value
* @retval #APP_MANAGER_ERROR_NONE Successful
* @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #APP_MANAGER_ERROR_NO_SUCH_APP No such application
* @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
*/
int app_manager_get_shared_resource_path(const char *app_id, char **path);
/**
* @brief Gets the absolute path to the shared trusted directory of the application specified
* with an application ID.
* @details An application signed with the same certificate can read and write the files of
* other application's shared trusted directory.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
* @remarks The specified @a path should be released.
*
* @param[in] app_id The ID of the application
* @param[in,out] path The absolute path to the shared trusted directory of the application
* specified with the @a app_id
* @return @c 0 on success,
* otherwise a negative error value
* @retval #APP_MANAGER_ERROR_NONE Successful
* @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #APP_MANAGER_ERROR_NO_SUCH_APP No such application
* @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
*/
int app_manager_get_shared_trusted_path(const char *app_id, char **path);
/**
* @brief Gets the absolute path to the shared data directory of the application specified
* with an application ID.
* @details An application can only read the files of other application's shared data directory.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
* @remarks The specified @a path should be released.
*
* @param[in] app_id The ID of the application
* @param[in,out] path The absolute path to the shared data directory of the application
* specified with the @a app_id
* @return @c 0 on success,
* otherwise a negative error value
* @retval #APP_MANAGER_ERROR_NONE Successful
* @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #APP_MANAGER_ERROR_NO_SUCH_APP No such application
* @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
*/
int app_manager_get_external_shared_data_path(const char *app_id, char **path);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __TIZEN_APPFW_APP_MANAGER_H */
|