4 * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Garima Shrivastava<garima.s@samsung.com>
7 * Jyotsna Dhumale <jyotsna.a@samsung.com>
8 * Venkatesha Sarpangala <sarpangala.v@samsung.com>
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
24 #ifndef __APPTOSD_INTERFACE_H__
25 #define __APPTOSD_INTERFACE_H__
28 * @file app2sd_interface.h
30 * @brief This file declares API of app2sd library
33 * @addtogroup APPLICATION_FRAMEWORK
39 * @section Header to use them:
41 * #include <app2sd_interface.h>
53 #include <app2ext_interface.h>
57 * @brief : This API prepares the setup for installation in SD card.
58 * It should be called before actual installation is done.
59 * @pre vfat type sd card must be present.
60 * @post Installation is done by package installer.
61 Encryption password is saved in db /opt/dbspace/.app2sd.db
62 * @param[in] appname application package name
63 * [Ex: com.samsung.calculator]
64 *This entry is parsed from application package control/manifest file.
65 * @param[in] dir_list directory structure of the application
66 * @param[in] size size of memory required by application(in MB).
67 *This entry is parsed from application package control/manifest file.
68 * @return 0 if success, error code(>0) if fail
73 #include <app2sd_interface.h>
75 GList* dir_list = NULL;
76 // Package manager populates dir_list with directory structure information
77 ret= app2sd_pre_app_install
78 ("com.samsung.calculotor", dir_list, 10);
82 // Package installer performs installation
83 // app2sd_post_app_install() API should be called
90 API int app2sd_pre_app_install(const char *appname,
91 GList* dir_list, int size);
94 * @brief : This API does post installation operations after
95 * the installation in SD card
96 * @param[in] appname application package name
97 * [Ex: com.samsung.calculator]
98 * @param[in] install_status Status of installation of package
99 *[ enum app2ext_status].If package installation failed then
100 * install_status= APP2EXT_STATUS_FAILURE else if installation
101 * was successful then install_status = APP2EXT_ISTATUS_SUCCESS.
102 * @pre Installation should be done by package installer.
103 * @return 0 if success, error code(>0) if fail
104 * @remark @see enum app2sd_install_status
108 #include <app2sd_interface.h>
110 ret= app2sd_pre_app_install
111 ("com.samsung.calculotor", APP2EXT_NATIVE_APP, 10);
114 printf("\n SUCCESS");
115 // Package installer performs installation
116 //Package was installed successfully.
117 if(package_installation _success)
119 ret = app2sd_post_app_install
120 ("com.samsung.calculator",APP2EXT_STATUS_SUCCESS);
122 printf("\n SUCCESS");
124 printf("\n FAILURE");
129 //Package installation failed
130 ret = app2sd_post_app_install
131 ("com.samsung.calculator",APP2EXT_STATUS_FAILURE);
133 printf("\n SUCCESS");
135 printf("\n FAILURE");
140 printf("\n FAILURE");
143 API int app2sd_post_app_install(const char *appname,
144 app2ext_status install_status);
147 * @brief : This API prepares the setup for upgradation of
148 * application package
149 * @pre vfat type sd card must be present.
150 * @post Upgradation is done by package installer.
151 * @param[in] appname application package name
152 * [Ex: com.samsung.calculator]
153 * @param[in] dir_list directory structure of the application
154 * @param[in] size size of memory required by application(in MB).
155 *This entry is parsed from application package control/manifest file.
156 * @return 0 if success, error code(>0) if fail
161 #include <app2sd_interface.h>
163 GList* dir_list = NULL;
164 // Package manager populates dir_list with directory structure information
165 ret= app2sd_pre_app_upgrade
166 ("com.samsung.calculator", dir_list, 10);
169 printf("\n SUCCESS");
170 // Package installer performs upgradation
171 // app2sd_post_app_upgrade() API should be called
175 printf("\n FAILURE");
178 API int app2sd_pre_app_upgrade(const char *appname,
179 GList* dir_list, int size);
182 * @brief : This API does post upgradation operations after
183 * the installation in SD card
184 * @param[in] appname application package name
185 * [Ex: com.samsung.calculator]
186 * @param[in] install_status Status of installation of package
187 *[ enum app2extl_status].If package upgradation failed then
188 * upgrade_status= APP2EXT_STATUS_FAILURE else if upgradation
189 * was successful then upgrade_status = APP2EXT_STATUS_SUCCESS.
190 * @pre Upgradation should be done by package installer.
191 * @return 0 if success, error code(>0) if fail
192 * @remark @see enum app2ext_status
196 #include <app2sd_interface.h>
198 ret= app2sd_pre_app_upgrade
199 ("com.samsung.calculator", APP2EXT_NATIVE_APP, 10);
202 printf("\n SUCCESS");
203 // Package installer performs upgradation
204 //Package was upgraded successfully.
205 if(package_upgradation _success)
207 ret = app2sd_post_app_upgrade
208 ("com.samsung.calculator",APP2EXT_STATUS_SUCCESS);
210 printf("\n SUCCESS");
212 printf("\n FAILURE");
217 //Package upgradation failed
218 ret = app2sd_post_app_upgrade
219 ("com.samsung.calculator",APP2EXT_STATUS_FAILURE);
221 printf("\n SUCCESS");
223 printf("\n FAILURE");
228 printf("\n FAILURE");
231 API int app2sd_post_app_upgrade(const char *appname,
232 app2ext_status upgrade_status);
235 * @brief: This API prepares the setup for uninstallation
236 * @pre Package must be installed in sdcard.
237 * @post Package is uninstalled by the package installer.
238 * @param[in] appname application package name
239 * [Ex: com.samsung.calculator]
240 * @return 0 if success, error code(>0) if fail
245 #include <app2sd_interface.h>
247 ret= app2sd_pre_app_uninstall
248 ("com.samsung.calculator");
251 printf("\n SUCCESS");
252 // Package installer performs uninstallation
253 // app2sd_post_app_uninstall() API should be called
257 printf("\n FAILURE");
260 API int app2sd_pre_app_uninstall(const char *appname);
263 * @brief This API removes the resources created during
264 app2sd setup.It is called after uninstallation.
265 * @pre Package must be uninstalled .
266 * @post Encryption password is removed from sqlite db.
267 * @param[in] appname application package name
268 * [Ex: com.samsung.calculator]
269 * @return 0 if success, error code(>0) if fail
274 #include <app2sd_interface.h>
276 ret= app2sd_pre_app_uninstall
277 ("com.samsung.calculator");
280 printf("\n SUCCESS");
281 // Package installer performs uninstallation
282 ret = app2sd_post_app_uninstall("com.samsung.calculator");
284 printf("\n SUCCESS");
286 printf("\n FAILURE");
290 printf("\n FAILURE");
293 API int app2sd_post_app_uninstall(const char *appname);
296 * @brief : This API moves the package from sd card
297 to internal memory and vice versa.
298 * @param[in] pkgid application package id
299 * [Ex: com.samsung.calculator]
300 * @param[in] move_type Move type[enum app2ext_move_type]
301 * [sd card to internal/internal to sd card]
302 * @param[in] dir_list directory structure of the application
303 * @pre Package must be installed and its installation
304 * location should be known.Use app2sd_get_app_install_location()
305 * to get installation location.
306 * @see app2sd_get_app_install_location().
307 * @post Package is moved to new location.
308 * @return 0 if success, error code(>0) if fail
313 #include <app2sd_interface.h>
315 GList* dir_list = NULL;
316 // Package manager populates dir_list with directory structure information
317 ret = app2sd_get_app_install_location("com.samsung.calculator");
318 if(ret == APP2SD_INTERNAL_MEM)
320 ret= app2sd_move_installed_app("com.samsung.calculator",
321 dir_list, APP2EXT_MOVE_TO_EXT);
323 printf("\n SUCCESS");
325 printf("\n FAILURE");
327 else if(ret == APP2SD_EXTERNAL_MEM)
329 ret= app2sd_move_installed_app("com.samsung.calculator",
330 dir_list, APP2SD_MOVE_TO PHONE);
332 printf("\n SUCCESS");
334 printf("\n FAILURE");
338 API int app2sd_move_installed_app(const char *pkgid,
339 GList* dir_list, app2ext_move_type move_type);
342 * @brief : This API Enables the application in sd card
343 for use. This API should be called by AUL.
344 * @param[in] pkgid application package id
345 * [Ex: com.samsung.calculator]
346 * @pre Package must be installed
347 * @post application is enabled in SD card.
348 * @return 0 if success, error code(>0) if fail
353 #include <app2sd_interface.h>
355 ret= app2sd_on_demand_setup_init("com.samsung.calculator");
357 printf("\n SUCCESS");
359 printf("\n FAILURE");
363 API int app2sd_on_demand_setup_init(const char *pkgid);
367 * @brief : This API Disables the application in sd card
368 . This API should be called by Launchpad callback which will be registered
369 during app launch for exit action of the application
370 * @param[in] pkgid application package id
371 * [Ex: com.samsung.calculator]
372 * @pre Package must be installed and enabled
373 * and application must be running in SD card
374 * @post application is disabked in SD card.
375 * @return 0 if success, error code(>0) if fail
380 #include <app2sd_interface.h>
382 ret= app2sd_on_demand_setup_exit("com.samsung.calculator");
384 printf("\n SUCCESS");
386 printf("\n FAILURE");
390 API int app2sd_on_demand_setup_exit(const char *pkgid);
393 * @brief : This is the plug-in load function.
394 The plugin has to bind its functions to function pointers of storage handle
395 * @param[in/out] st_interface Specifies the storage interface.
398 API void app2ext_on_load(app2ext_interface *st_interface);