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 #include <app2sd_internals.h>
25 #include <app2sd_interface.h>
27 #include <sys/types.h>
29 #include <pkgmgr-info.h>
32 #define MAX_BUF_LEN 1024
33 #define APP2SD_TMP_PATH "/opt/usr/apps/tmp"
35 int app2sd_pre_app_install(const char *pkgid, GList* dir_list,
40 char *device_node = NULL;
43 int reqd_disk_size = size + ceil(size*0.2);
45 /*Validate the function parameter recieved */
46 if (pkgid == NULL || dir_list == NULL || size <= 0) {
47 app2ext_print("App2Sd Error : Invalid function arguments\n");
48 return APP2EXT_ERROR_INVALID_ARGUMENTS;
50 /*Check whether MMC is present or not */
51 ret = _app2sd_check_mmc_status();
53 app2ext_print("App2Sd Error : MMC not preset OR Not ready %d\n",
55 return APP2EXT_ERROR_MMC_STATUS;
57 /*Find available free memory in the MMC card */
58 ret = _app2sd_get_available_free_memory(MMC_PATH,
61 app2ext_print("App2Sd Error : Unable to get available free memory in MMC %d\n", ret);
62 return APP2EXT_ERROR_MMC_STATUS;
64 app2ext_print("Size details for application installation:size=%dMB, reqd_disk_size=%dMB, free_mmc_size=%dMB\n",
65 size, reqd_disk_size, free_mmc_mem);
66 /*If avaialalbe free memory in MMC is less than required size + 5MB , return error */
67 if ((reqd_disk_size + PKG_BUF_SIZE + MEM_BUF_SIZE) > free_mmc_mem) {
68 app2ext_print("Insufficient memory in MMC for application installation %d\n", ret);
69 return APP2EXT_ERROR_MMC_INSUFFICIENT_MEMORY;
71 /*Create a loopback device */
72 ret = _app2sd_create_loopback_device(pkgid, (reqd_disk_size+PKG_BUF_SIZE));
74 app2ext_print("App2Sd Error : Package already present\n");
75 char buf_dir[FILENAME_MAX] = { 0, };
76 memset((void *)&buf_dir, '\0', FILENAME_MAX);
77 snprintf(buf_dir, FILENAME_MAX, "%s%s", APP_INSTALLATION_PATH, pkgid);
78 ret = _app2sd_delete_directory(buf_dir);
81 ("App2Sd Error : Unable to delete the directory %s\n",
85 /*Perform Loopback encryption setup */
86 device_node = _app2sd_do_loopback_encryption_setup(pkgid);
88 app2ext_print("App2Sd Error : Loopback encryption setup failed\n");
89 _app2sd_delete_loopback_device(pkgid);
90 return APP2EXT_ERROR_DO_LOSETUP;
92 /*Check whether loopback device is associated with device node or not */
93 devi = _app2sd_find_associated_device_node(pkgid);
95 app2ext_print("App2Sd Error : finding associated device node failed\n");
96 ret = APP2EXT_ERROR_DO_LOSETUP;
100 /*Format the loopback file system */
101 ret = _app2sd_create_file_system(device_node);
103 app2ext_print("App2Sd Error : creating FS failed failed\n");
104 ret = APP2EXT_ERROR_CREATE_FS;
108 /*Mount the loopback encrypted pseudo device on application installation path as with Read Write permission */
109 ret =_app2sd_mount_app_content(pkgid, device_node, MOUNT_TYPE_RW,
110 dir_list, APP2SD_PRE_INSTALL);
112 app2ext_print("App2Sd Error : mounting dev path to app install path failed\n");
113 ret = APP2EXT_ERROR_MOUNT_PATH;
118 ret = APP2EXT_SUCCESS;
124 result = _app2sd_detach_loop_device(device_node);
129 _app2sd_delete_loopback_device(pkgid);
143 int app2sd_post_app_install(const char *pkgid,
144 app2ext_status install_status)
146 char *device_name = NULL;
147 char buf_dir[FILENAME_MAX] = { 0, };
148 int ret = APP2EXT_SUCCESS;
149 /*Validate the function parameter recieved */
150 if (pkgid == NULL || install_status < APP2EXT_STATUS_FAILED
151 || install_status > APP2EXT_STATUS_SUCCESS) {
152 app2ext_print("Invalid func parameters\n");
153 return APP2EXT_ERROR_INVALID_ARGUMENTS;
156 /*Check whether MMC is present or not */
157 ret = _app2sd_check_mmc_status();
159 app2ext_print("App2Sd Error : MMC not preset OR Not ready %d\n",
161 return APP2EXT_ERROR_MMC_STATUS;
164 /*Get the associated device node for SD card applicationer */
165 device_name = _app2sd_find_associated_device_node(pkgid);
166 if (NULL == device_name) {
167 return APP2EXT_ERROR_FIND_ASSOCIATED_DEVICE_NODE;
169 ret = _app2sd_unmount_app_content(pkgid);
175 app2ext_print("Unable to unmount the app content %d\n", ret);
176 return APP2EXT_ERROR_UNMOUNT;
178 ret = _app2sd_remove_loopback_encryption_setup(pkgid);
185 ("Unable to Detach the loopback encryption setup for the application");
186 return APP2EXT_ERROR_UNMOUNT;
193 /*Take appropriate action based on installation
194 status of application package */
195 if (install_status == APP2EXT_STATUS_FAILED) {
196 /*Delete the loopback device from the SD card */
197 ret = _app2sd_delete_loopback_device(pkgid);
200 ("App2Sd Error : Unable to delete the loopback device from the SD Card\n");
201 return APP2EXT_ERROR_DELETE_LOOPBACK_DEVICE;
203 ret = _app2sd_remove_password_from_db(pkgid);
207 ("App2Sd Error : Unable to delete the password\n");
210 snprintf(buf_dir, FILENAME_MAX, "%s%s", APP_INSTALLATION_PATH, pkgid);
212 ret = _app2sd_delete_directory(buf_dir);
216 ("App2Sd Error : Unable to delete the directory %s\n",
221 /*If the status is success, then update installed storage to pkgmgr_parser db*/
223 rt = pkgmgrinfo_pkginfo_set_installed_storage(pkgid, INSTALL_EXTERNAL);
225 app2ext_print("fail to update installed location to db[%s, %d]\n", pkgid, INSTALL_EXTERNAL);
231 int app2sd_on_demand_setup_init(const char *pkgid)
233 int ret = APP2EXT_SUCCESS;
234 char app_path[FILENAME_MAX] = { 0, };
235 char *device_node = NULL;
239 /*Validate the function parameter recieved */
242 ("App2Sd Error : Invalid function arguments to app launch setup\n");
243 return APP2EXT_ERROR_INVALID_ARGUMENTS;
246 /*Check whether MMC is present or not */
247 ret = _app2sd_check_mmc_status();
249 app2ext_print("App2Sd Error : MMC not preset OR Not ready %d\n",
251 return APP2EXT_ERROR_MMC_STATUS;
254 /*check app entry is there in sd card or not. */
255 snprintf(app_path, FILENAME_MAX, "%s%s", APP2SD_PATH,
257 fp = fopen(app_path, "r+");
260 ("App2SD Error: App Entry is not present in SD Card\n");
261 return APP2EXT_ERROR_INVALID_PACKAGE;
264 result = (char *)_app2sd_find_associated_device(app_path);
265 /*process the string */
266 if ((result!=NULL) && strstr(result, "/dev") != NULL) {
267 app2ext_print("App2SD Error! Already associated\n");
270 return APP2EXT_ERROR_ALREADY_MOUNTED;
273 /*Do loopback setup */
274 device_node = _app2sd_do_loopback_encryption_setup(pkgid);
275 if (device_node == NULL) {
277 ("App2Sd Error : loopback encryption setup failed\n");
278 return APP2EXT_ERROR_DO_LOSETUP;
283 _app2sd_mount_app_content(pkgid, device_node, MOUNT_TYPE_RD,
284 NULL, APP2SD_APP_LAUNCH);
286 app2ext_print("App2Sd Error : Re-mount failed\n");
291 return APP2EXT_ERROR_MOUNT_PATH;
300 int app2sd_on_demand_setup_exit(const char *pkgid)
302 int ret = APP2EXT_SUCCESS;
303 char app_path[FILENAME_MAX] = { 0, };
306 /*Validate the function parameter recieved */
309 ("App2Sd Error : Invalid function arguments to app launch setup\n");
310 return APP2EXT_ERROR_INVALID_ARGUMENTS;
313 /*Check whether MMC is present or not */
314 ret = _app2sd_check_mmc_status();
316 app2ext_print("App2Sd Error : MMC not preset OR Not ready %d\n",
318 return APP2EXT_ERROR_MMC_STATUS;
320 /*check app entry is there in sd card or not. */
321 snprintf(app_path, FILENAME_MAX, "%s%s", APP2SD_PATH,
323 fp = fopen(app_path, "r+");
326 ("App2SD Error: App Entry is not present in SD Card\n");
327 return APP2EXT_ERROR_INVALID_PACKAGE;
330 ret = _app2sd_unmount_app_content(pkgid);
333 ("App2SD Error: Unable to unmount the SD application\n");
334 return APP2EXT_ERROR_UNMOUNT;
336 ret = _app2sd_remove_loopback_encryption_setup(pkgid);
338 app2ext_print("App2SD Error: Unable to remove loopback setup\n");
339 return APP2EXT_ERROR_DELETE_LOOPBACK_DEVICE;
344 int app2sd_pre_app_uninstall(const char *pkgid)
346 int ret = APP2EXT_SUCCESS;
347 char app_path[FILENAME_MAX] = { 0, };
348 char *device_node = NULL;
351 /*Validate the function parameter recieved */
354 ("App2Sd Error : Invalid function arguments to app launch setup\n");
355 ret = APP2EXT_ERROR_INVALID_ARGUMENTS;
358 /*Check whether MMC is present or not */
359 ret = _app2sd_check_mmc_status();
361 app2ext_print("App2Sd Error : MMC not preset OR Not ready %d\n",
363 ret = APP2EXT_ERROR_MMC_STATUS;
366 /*check app entry is there in sd card or not. */
367 snprintf(app_path, FILENAME_MAX, "%s%s", APP2SD_PATH, pkgid);
368 fp = fopen(app_path, "r+");
371 ("App2SD Error: App Entry is not present in SD Card\n");
372 ret = APP2EXT_ERROR_INVALID_PACKAGE;
377 /*Get the associated device node for SD card applicationer */
378 device_node = _app2sd_find_associated_device_node(pkgid);
379 if (NULL == device_node) {
380 /*Do loopback setup */
381 device_node = _app2sd_do_loopback_encryption_setup(pkgid);
383 if (device_node == NULL) {
385 ("App2Sd Error : loopback encryption setup failed\n");
386 ret = APP2EXT_ERROR_DO_LOSETUP;
391 _app2sd_mount_app_content(pkgid, device_node,
393 APP2SD_PRE_UNINSTALL);
396 app2ext_print("App2Sd Error : RW-mount failed\n");
401 ret = APP2EXT_ERROR_MOUNT_PATH;
407 _app2sd_mount_app_content(pkgid, device_node,
408 MOUNT_TYPE_RW_REMOUNT, NULL,
409 APP2SD_PRE_UNINSTALL);
412 app2ext_print("App2Sd Error : Re-mount failed\n");
417 ret = APP2EXT_ERROR_MOUNT_PATH;
427 if (ret != APP2EXT_SUCCESS)
428 app2ext_print("App2Sd Error : app2sd has [%d]error, but return success for uninstallation\n", ret);
433 * app2sd_post_app_uninstall_setup
434 * Uninstall Application and free all the allocated resources
435 * Called after dpkg remove, It deallocates dev node and loopback
437 int app2sd_post_app_uninstall(const char *pkgid)
439 char buf_dir[FILENAME_MAX] = { 0, };
440 int ret = APP2EXT_SUCCESS;
441 int ret1 = APP2EXT_SUCCESS;
442 /*Validate the function parameter recieved */
445 ("App2Sd Error : Invalid function arguments to Post Uninstall\n");
446 ret = APP2EXT_ERROR_INVALID_ARGUMENTS;
449 /*Check whether MMC is present or not */
450 ret = _app2sd_check_mmc_status();
452 app2ext_print("App2Sd Error : MMC not preset OR Not ready %d\n",
454 ret = APP2EXT_ERROR_MMC_STATUS;
457 /*Unmount the loopback encrypted pseudo device from the application installation path */
458 ret = _app2sd_unmount_app_content(pkgid);
460 app2ext_print("Unable to unmount the app content %d\n", ret);
461 ret = APP2EXT_ERROR_UNMOUNT;
464 /*Detach the loopback encryption setup for the application */
465 ret = _app2sd_remove_loopback_encryption_setup(pkgid);
468 ("Unable to Detach the loopback encryption setup for the application");
469 ret = APP2EXT_ERROR_DETACH_LOOPBACK_DEVICE;
472 /*Delete the loopback device from the SD card */
473 ret = _app2sd_delete_loopback_device(pkgid);
476 ("App2Sd Error : Unable to delete the loopback device from the SD Card\n");
477 ret = APP2EXT_ERROR_DELETE_LOOPBACK_DEVICE;
480 memset((void *)&buf_dir, '\0', FILENAME_MAX);
481 snprintf(buf_dir, FILENAME_MAX, "%s%s", APP_INSTALLATION_PATH, pkgid);
482 ret1 = _app2sd_delete_directory(buf_dir);
485 ("App2Sd Error : Unable to delete the directory %s\n",
488 /*remove encryption password from DB */
489 ret = _app2sd_initialize_db();
491 app2ext_print("\n app2sd db initialize failed");
492 ret = APP2EXT_ERROR_SQLITE_REGISTRY;
495 ret = _app2sd_remove_password_from_db(pkgid);
497 app2ext_print("cannot remove password from db \n");
498 ret = APP2EXT_ERROR_SQLITE_REGISTRY;
503 if (ret != APP2EXT_SUCCESS)
504 app2ext_print("App2Sd Error : app2sd has [%d]error, but return success for uninstallation\n", ret);
508 int app2sd_move_installed_app(const char *pkgid, GList* dir_list,
509 app2ext_move_type move_type)
512 int pkgmgrinfo_ret = 0;
514 /*Validate function arguments*/
515 if (pkgid == NULL || dir_list == NULL
516 || move_type < APP2EXT_MOVE_TO_EXT
517 || move_type > APP2EXT_MOVE_TO_PHONE) {
518 app2ext_print("App2Sd Error : Invalid function arguments\n");
519 ret = APP2EXT_ERROR_INVALID_ARGUMENTS;
523 /*If move is completed, then update installed storage to pkgmgr_parser db*/
524 pkgmgrinfo_pkginfo_h info_handle = NULL;
525 pkgmgrinfo_installed_storage storage = PMINFO_INTERNAL_STORAGE;
526 pkgmgrinfo_ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &info_handle);
527 if (pkgmgrinfo_ret < 0) {
528 app2ext_print("App2Sd Error : pkgmgrinfo_pkginfo_get_pkginfo[%s] fail.. \n", pkgid);
530 pkgmgrinfo_ret = pkgmgrinfo_pkginfo_get_installed_storage(info_handle, &storage);
531 if (pkgmgrinfo_ret < 0) {
532 app2ext_print("App2Sd Error : pkgmgrinfo_pkginfo_get_installed_storage[%s] fail.. \n", pkgid);
535 if ((move_type == APP2EXT_MOVE_TO_EXT && storage == PMINFO_EXTERNAL_STORAGE)
536 || (move_type == APP2EXT_MOVE_TO_PHONE && storage == PMINFO_INTERNAL_STORAGE)) {
537 ret = APP2EXT_ERROR_PKG_EXISTS;
538 app2ext_print("App2Sd Error : PKG_EXISTS in [%d]STORAGE\n", storage);
539 pkgmgrinfo_pkginfo_destroy_pkginfo(info_handle);
542 app2ext_print("App2Sd info : pkgid[%s] move to STORAGE[%d]\n", pkgid, storage);
544 pkgmgrinfo_pkginfo_destroy_pkginfo(info_handle);
546 ret = _app2sd_move_app(pkgid, move_type, dir_list);
548 app2ext_print("App2Sd Error : Unable to move application\n");
552 /*If move is completed, then update installed storage to pkgmgr_parser db*/
553 if (move_type == APP2EXT_MOVE_TO_EXT) {
554 pkgmgrinfo_ret = pkgmgrinfo_pkginfo_set_installed_storage(pkgid, INSTALL_EXTERNAL);
555 if (pkgmgrinfo_ret < 0) {
556 app2ext_print("App2Sd Error : fail to update installed location to db[%s, %s]\n", pkgid, INSTALL_EXTERNAL);
559 pkgmgrinfo_ret = pkgmgrinfo_pkginfo_set_installed_storage(pkgid, INSTALL_INTERNAL);
560 if (pkgmgrinfo_ret < 0) {
561 app2ext_print("App2Sd Error : fail to update installed location to db[%s, %s]\n", pkgid, INSTALL_INTERNAL);
566 // vconf_set_int(VCONFKEY_PKGMGR_STATUS, ret);
567 _app2sd_make_result_info_file((char*)pkgid, ret);
572 int app2sd_pre_app_upgrade(const char *pkgid, GList* dir_list,
575 int ret = APP2EXT_SUCCESS;
576 char app_path[FILENAME_MAX] = { 0, };
577 char *device_node = NULL;
578 unsigned long long curr_size = 0;
580 int reqd_disk_size = size + ceil(size*0.2);
582 /*Validate function arguments*/
583 if (pkgid == NULL || dir_list == NULL || size<=0) {
585 ("App2Sd Error : Invalid function arguments \n");
586 return APP2EXT_ERROR_INVALID_ARGUMENTS;
588 /*Check whether MMC is present or not */
589 ret = _app2sd_check_mmc_status();
591 app2ext_print("App2Sd Error : MMC not preset OR Not ready %d\n",
593 return APP2EXT_ERROR_MMC_STATUS;
595 /*check app entry is there in sd card or not. */
596 snprintf(app_path, FILENAME_MAX, "%s%s", APP2SD_PATH,
598 app2ext_print("App2Sd Log : Checking path %s\n", app_path);
599 fp = fopen(app_path, "r+");
602 ("App2SD Error: App Entry is not present in SD Card\n");
603 return APP2EXT_ERROR_INVALID_PACKAGE;
606 /*Get installed app size*/
607 curr_size = _app2sd_calculate_file_size(app_path);
608 curr_size = (curr_size)/(1024 * 1024);
612 ("App2SD Error: App Entry is not present in SD Card\n");
613 return APP2EXT_ERROR_LOOPBACK_DEVICE_UNAVAILABLE;
615 if ((int)curr_size < reqd_disk_size) {
616 ret = _app2sd_update_loopback_device_size(pkgid, reqd_disk_size, dir_list);
617 if(APP2EXT_SUCCESS !=ret) {
619 ("App2SD Error: _app2sd_update_loopback_device_size() failed\n");
624 /*Get the associated device node for SD card applicationer */
625 device_node = _app2sd_find_associated_device_node(pkgid);
626 if (NULL == device_node) {
627 /*Do loopback setup */
628 device_node = _app2sd_do_loopback_encryption_setup(pkgid);
629 if (device_node == NULL) {
631 ("App2Sd Error : loopback encryption setup failed\n");
632 return APP2EXT_ERROR_DO_LOSETUP;
636 _app2sd_mount_app_content(pkgid, device_node,
637 MOUNT_TYPE_RW, dir_list,
640 app2ext_print("App2Sd Error : Re-mount failed\n");
645 return APP2EXT_ERROR_MOUNT_PATH;
650 _app2sd_mount_app_content(pkgid, device_node,
651 MOUNT_TYPE_RW_REMOUNT, NULL,
654 app2ext_print("App2Sd Error : Re-mount failed\n");
659 return APP2EXT_ERROR_MOUNT_PATH;
671 int app2sd_post_app_upgrade(const char *pkgid,
672 app2ext_status install_status)
674 char *device_name = NULL;
675 int ret = APP2EXT_SUCCESS;
676 /*Validate the function parameter recieved */
677 if (pkgid == NULL || install_status < APP2EXT_STATUS_FAILED
678 || install_status > APP2EXT_STATUS_SUCCESS) {
679 app2ext_print("Invalid func parameters\n");
680 return APP2EXT_ERROR_INVALID_ARGUMENTS;
682 /*Check whether MMC is present or not */
683 ret = _app2sd_check_mmc_status();
685 app2ext_print("App2Sd Error : MMC not preset OR Not ready %d\n",
687 return APP2EXT_ERROR_MMC_STATUS;
690 /*Get the associated device node for SD card applicationer */
691 device_name = _app2sd_find_associated_device_node(pkgid);
692 if (NULL == device_name) {
693 return APP2EXT_ERROR_FIND_ASSOCIATED_DEVICE_NODE;
695 ret = _app2sd_unmount_app_content(pkgid);
701 app2ext_print("Unable to unmount the app content %d\n", ret);
702 return APP2EXT_ERROR_UNMOUNT;
704 ret = _app2sd_remove_loopback_encryption_setup(pkgid);
711 ("Unable to Detach the loopback encryption setup for the application");
712 return APP2EXT_ERROR_UNMOUNT;
723 * Reserved API for forced cleanup
726 int app2sd_force_cleanup(const char *pkgid){
727 char *device_name = NULL;
728 char buf_dir[FILENAME_MAX] = { 0, };
729 int ret = APP2EXT_SUCCESS;
732 /*Validate the function parameter recieved */
734 app2ext_print("invalid func parameters\n");
735 return APP2EXT_ERROR_INVALID_ARGUMENTS;
737 memset((void *)&buf_dir, '\0', FILENAME_MAX);
738 snprintf(buf_dir, FILENAME_MAX, "%s%s", APP2SD_PATH, pkgid);
739 fp = fopen(buf_dir, "r+");
741 app2ext_print("\"%s\" not installed on SD Card\n", pkgid);
742 return APP2EXT_ERROR_INVALID_PACKAGE;
745 /*Check whether MMC is present or not */
746 ret = _app2sd_check_mmc_status();
748 app2ext_print("App2Sd Error : MMC not preset OR Not ready %d\n",
750 return APP2EXT_ERROR_MMC_STATUS;
753 /*Get the associated device node for SD card applicationer */
754 device_name = _app2sd_find_associated_device_node(pkgid);
755 if (NULL != device_name) {
758 ret = _app2sd_unmount_app_content(pkgid);
760 app2ext_print("Unable to unmount the app content %d\n", ret);
761 return APP2EXT_ERROR_UNMOUNT;
763 ret = _app2sd_remove_loopback_encryption_setup(pkgid);
766 ("Unable to Detach the loopback encryption setup for the application");
767 return APP2EXT_ERROR_UNMOUNT;
771 memset((void *)&buf_dir, '\0', FILENAME_MAX);
772 snprintf(buf_dir, FILENAME_MAX, "%s%s", APP_INSTALLATION_PATH, pkgid);
773 ret = _app2sd_delete_directory(buf_dir);
776 ("App2Sd Error : Unable to delete the directory %s\n",
780 /*remove passwrd from DB*/
781 ret = _app2sd_initialize_db();
783 app2ext_print("\n app2sd db initialize failed");
784 return APP2EXT_ERROR_SQLITE_REGISTRY;
786 ret = _app2sd_remove_password_from_db(pkgid);
788 app2ext_print("cannot remove password from db \n");
789 return APP2EXT_ERROR_SQLITE_REGISTRY;
795 int app2sd_force_clean(const char *pkgid)
797 char buf_dir[FILENAME_MAX] = { 0, };
798 int ret = APP2EXT_SUCCESS;
800 /*Validate the function parameter recieved */
802 app2ext_print("Invalid func parameters\n");
803 return APP2EXT_ERROR_INVALID_ARGUMENTS;
805 app2ext_print("star force_clean [%s]", pkgid);
808 /*Unmount the loopback encrypted pseudo device from the application installation path */
809 ret = _app2sd_unmount_app_content(pkgid);
811 app2ext_print("Unable to unmount the app content %d\n", ret);
814 /*Detach the loopback encryption setup for the application */
815 ret = _app2sd_remove_all_loopback_encryption_setups(pkgid);
817 app2ext_print("Unable to Detach the loopback encryption setup for the application");
820 /*Delete the loopback device from the SD card */
821 ret = _app2sd_delete_loopback_device(pkgid);
823 app2ext_print("Unable to Detach the loopback encryption setup for the application");
827 memset((void *)&buf_dir, '\0', FILENAME_MAX);
828 snprintf(buf_dir, FILENAME_MAX, "%s%s", APP_INSTALLATION_PATH, pkgid);
830 _app2sd_delete_symlink(buf_dir);
832 /*remove passwrd from DB*/
833 ret = _app2sd_initialize_db();
835 app2ext_print("\n app2sd db initialize failed");
837 ret = _app2sd_remove_password_from_db(pkgid);
839 app2ext_print("cannot remove password from db \n");
842 app2ext_print("finish force_clean");
846 /* This is the plug-in load function. The plugin has to bind its functions to function pointers of handle
847 @param[in/out] st_interface Specifies the storage interface.
850 app2ext_on_load(app2ext_interface *st_interface)
853 st_interface->pre_install= app2sd_pre_app_install;
854 st_interface->post_install= app2sd_post_app_install;
855 st_interface->pre_uninstall= app2sd_pre_app_uninstall;
856 st_interface->post_uninstall= app2sd_post_app_uninstall;
857 st_interface->pre_upgrade= app2sd_pre_app_upgrade;
858 st_interface->post_upgrade= app2sd_post_app_upgrade;
859 st_interface->move= app2sd_move_installed_app;
860 st_interface->force_clean= app2sd_force_clean;
861 st_interface->enable= app2sd_on_demand_setup_init;
862 st_interface->disable= app2sd_on_demand_setup_exit;