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
34 int app2sd_pre_app_install(const char *pkgid, GList* dir_list,
39 char *device_node = NULL;
42 int reqd_disk_size = size + ceil(size*0.2);
45 app2ext_print("MMC_PATH = (%s)\n", MMC_PATH);
46 app2ext_print("APP2SD_PATH = (%s)\n", APP2SD_PATH);
47 app2ext_print("APP_INSTALLATION_PATH = (%s)\n", APP_INSTALLATION_PATH);
48 app2ext_print("APP_INSTALLATION_USER_PATH = (%s)\n", APP_INSTALLATION_USER_PATH);
50 /* Validate the function parameter recieved */
51 if (pkgid == NULL || dir_list == NULL || size <= 0) {
52 app2ext_print("App2Sd Error : Invalid function arguments\n");
53 return APP2EXT_ERROR_INVALID_ARGUMENTS;
55 /* Check whether MMC is present or not */
56 ret = _app2sd_check_mmc_status();
58 app2ext_print("App2Sd Error : MMC not preset OR Not ready %d\n",
60 return APP2EXT_ERROR_MMC_STATUS;
62 /* Find available free memory in the MMC card */
63 ret = _app2sd_get_available_free_memory(MMC_PATH,
66 app2ext_print("App2Sd Error : Unable to get available free memory in MMC %d\n", ret);
67 return APP2EXT_ERROR_MMC_STATUS;
69 app2ext_print("Size details for application installation:size=%dMB, reqd_disk_size=%dMB, free_mmc_size=%dMB\n",
70 size, reqd_disk_size, free_mmc_mem);
71 /* If avaialalbe free memory in MMC is less than required size + 5MB , return error */
72 if ((reqd_disk_size + PKG_BUF_SIZE + MEM_BUF_SIZE) > free_mmc_mem) {
73 app2ext_print("Insufficient memory in MMC for application installation %d\n", ret);
74 return APP2EXT_ERROR_MMC_INSUFFICIENT_MEMORY;
76 /* Create a loopback device */
77 ret = _app2sd_create_loopback_device(pkgid, (reqd_disk_size+PKG_BUF_SIZE));
79 app2ext_print("App2Sd Error : Package already present\n");
80 char buf_dir[FILENAME_MAX] = { 0, };
81 memset((void *)&buf_dir, '\0', FILENAME_MAX);
82 snprintf(buf_dir, FILENAME_MAX, "%s%s", APP_INSTALLATION_PATH, pkgid);
83 ret = _app2sd_delete_directory(buf_dir);
86 ("App2Sd Error : Unable to delete the directory %s\n",
90 /* Perform Loopback encryption setup */
91 device_node = _app2sd_do_loopback_encryption_setup(pkgid);
93 app2ext_print("App2Sd Error : Loopback encryption setup failed\n");
94 _app2sd_delete_loopback_device(pkgid);
95 return APP2EXT_ERROR_DO_LOSETUP;
97 /* Check whether loopback device is associated with device node or not */
98 devi = _app2sd_find_associated_device_node(pkgid);
100 app2ext_print("App2Sd Error : finding associated device node failed\n");
101 ret = APP2EXT_ERROR_DO_LOSETUP;
105 /* Format the loopback file system */
106 ret = _app2sd_create_file_system(device_node);
108 app2ext_print("App2Sd Error : creating FS failed failed\n");
109 ret = APP2EXT_ERROR_CREATE_FS;
113 /* Mount the loopback encrypted pseudo device on application installation path as with Read Write permission */
114 ret =_app2sd_mount_app_content(pkgid, device_node, MOUNT_TYPE_RW,
115 dir_list, APP2SD_PRE_INSTALL);
117 app2ext_print("App2Sd Error : mounting dev path to app install path failed\n");
118 ret = APP2EXT_ERROR_MOUNT_PATH;
123 ret = APP2EXT_SUCCESS;
129 result = _app2sd_detach_loop_device(device_node);
134 _app2sd_delete_loopback_device(pkgid);
148 int app2sd_post_app_install(const char *pkgid,
149 app2ext_status install_status)
151 char *device_name = NULL;
152 char buf_dir[FILENAME_MAX] = { 0, };
153 int ret = APP2EXT_SUCCESS;
154 /*Validate the function parameter recieved */
155 if (pkgid == NULL || install_status < APP2EXT_STATUS_FAILED
156 || install_status > APP2EXT_STATUS_SUCCESS) {
157 app2ext_print("Invalid func parameters\n");
158 return APP2EXT_ERROR_INVALID_ARGUMENTS;
161 /*Check whether MMC is present or not */
162 ret = _app2sd_check_mmc_status();
164 app2ext_print("App2Sd Error : MMC not preset OR Not ready %d\n",
166 return APP2EXT_ERROR_MMC_STATUS;
169 /*Get the associated device node for SD card applicationer */
170 device_name = _app2sd_find_associated_device_node(pkgid);
171 if (NULL == device_name) {
172 return APP2EXT_ERROR_FIND_ASSOCIATED_DEVICE_NODE;
174 ret = _app2sd_unmount_app_content(pkgid);
180 app2ext_print("Unable to unmount the app content %d\n", ret);
181 return APP2EXT_ERROR_UNMOUNT;
183 ret = _app2sd_remove_loopback_encryption_setup(pkgid);
190 ("Unable to Detach the loopback encryption setup for the application");
191 return APP2EXT_ERROR_UNMOUNT;
198 /*Take appropriate action based on installation
199 status of application package */
200 if (install_status == APP2EXT_STATUS_FAILED) {
201 /*Delete the loopback device from the SD card */
202 ret = _app2sd_delete_loopback_device(pkgid);
205 ("App2Sd Error : Unable to delete the loopback device from the SD Card\n");
206 return APP2EXT_ERROR_DELETE_LOOPBACK_DEVICE;
208 ret = _app2sd_remove_password_from_db(pkgid);
212 ("App2Sd Error : Unable to delete the password\n");
215 snprintf(buf_dir, FILENAME_MAX, "%s%s", APP_INSTALLATION_PATH, pkgid);
217 ret = _app2sd_delete_directory(buf_dir);
221 ("App2Sd Error : Unable to delete the directory %s\n",
226 /*If the status is success, then update installed storage to pkgmgr_parser db*/
228 rt = pkgmgrinfo_pkginfo_set_installed_storage(pkgid, INSTALL_EXTERNAL);
230 app2ext_print("fail to update installed location to db[%s, %d]\n", pkgid, INSTALL_EXTERNAL);
236 int app2sd_on_demand_setup_init(const char *pkgid)
238 int ret = APP2EXT_SUCCESS;
239 char app_path[FILENAME_MAX] = { 0, };
240 char *device_node = NULL;
244 /*Validate the function parameter recieved */
247 ("App2Sd Error : Invalid function arguments to app launch setup\n");
248 return APP2EXT_ERROR_INVALID_ARGUMENTS;
251 /*Check whether MMC is present or not */
252 ret = _app2sd_check_mmc_status();
254 app2ext_print("App2Sd Error : MMC not preset OR Not ready %d\n",
256 return APP2EXT_ERROR_MMC_STATUS;
259 /*check app entry is there in sd card or not. */
260 snprintf(app_path, FILENAME_MAX, "%s%s", APP2SD_PATH,
262 fp = fopen(app_path, "r+");
265 ("App2SD Error: App Entry is not present in SD Card\n");
266 return APP2EXT_ERROR_INVALID_PACKAGE;
269 result = (char *)_app2sd_find_associated_device(app_path);
270 /*process the string */
271 if ((result!=NULL) && strstr(result, "/dev") != NULL) {
272 app2ext_print("App2SD Error! Already associated\n");
275 return APP2EXT_ERROR_ALREADY_MOUNTED;
278 /*Do loopback setup */
279 device_node = _app2sd_do_loopback_encryption_setup(pkgid);
280 if (device_node == NULL) {
282 ("App2Sd Error : loopback encryption setup failed\n");
283 return APP2EXT_ERROR_DO_LOSETUP;
288 _app2sd_mount_app_content(pkgid, device_node, MOUNT_TYPE_RD,
289 NULL, APP2SD_APP_LAUNCH);
291 app2ext_print("App2Sd Error : Re-mount failed\n");
296 return APP2EXT_ERROR_MOUNT_PATH;
305 int app2sd_on_demand_setup_exit(const char *pkgid)
307 int ret = APP2EXT_SUCCESS;
308 char app_path[FILENAME_MAX] = { 0, };
311 /*Validate the function parameter recieved */
314 ("App2Sd Error : Invalid function arguments to app launch setup\n");
315 return APP2EXT_ERROR_INVALID_ARGUMENTS;
318 /*Check whether MMC is present or not */
319 ret = _app2sd_check_mmc_status();
321 app2ext_print("App2Sd Error : MMC not preset OR Not ready %d\n",
323 return APP2EXT_ERROR_MMC_STATUS;
325 /*check app entry is there in sd card or not. */
326 snprintf(app_path, FILENAME_MAX, "%s%s", APP2SD_PATH,
328 fp = fopen(app_path, "r+");
331 ("App2SD Error: App Entry is not present in SD Card\n");
332 return APP2EXT_ERROR_INVALID_PACKAGE;
335 ret = _app2sd_unmount_app_content(pkgid);
338 ("App2SD Error: Unable to unmount the SD application\n");
339 return APP2EXT_ERROR_UNMOUNT;
341 ret = _app2sd_remove_loopback_encryption_setup(pkgid);
343 app2ext_print("App2SD Error: Unable to remove loopback setup\n");
344 return APP2EXT_ERROR_DELETE_LOOPBACK_DEVICE;
349 int app2sd_pre_app_uninstall(const char *pkgid)
351 int ret = APP2EXT_SUCCESS;
352 char app_path[FILENAME_MAX] = { 0, };
353 char *device_node = NULL;
356 /*Validate the function parameter recieved */
359 ("App2Sd Error : Invalid function arguments to app launch setup\n");
360 ret = APP2EXT_ERROR_INVALID_ARGUMENTS;
363 /*Check whether MMC is present or not */
364 ret = _app2sd_check_mmc_status();
366 app2ext_print("App2Sd Error : MMC not preset OR Not ready %d\n",
368 ret = APP2EXT_ERROR_MMC_STATUS;
371 /*check app entry is there in sd card or not. */
372 snprintf(app_path, FILENAME_MAX, "%s%s", APP2SD_PATH, pkgid);
373 fp = fopen(app_path, "r+");
376 ("App2SD Error: App Entry is not present in SD Card\n");
377 ret = APP2EXT_ERROR_INVALID_PACKAGE;
382 /*Get the associated device node for SD card applicationer */
383 device_node = _app2sd_find_associated_device_node(pkgid);
384 if (NULL == device_node) {
385 /*Do loopback setup */
386 device_node = _app2sd_do_loopback_encryption_setup(pkgid);
388 if (device_node == NULL) {
390 ("App2Sd Error : loopback encryption setup failed\n");
391 ret = APP2EXT_ERROR_DO_LOSETUP;
396 _app2sd_mount_app_content(pkgid, device_node,
398 APP2SD_PRE_UNINSTALL);
401 app2ext_print("App2Sd Error : RW-mount failed\n");
406 ret = APP2EXT_ERROR_MOUNT_PATH;
412 _app2sd_mount_app_content(pkgid, device_node,
413 MOUNT_TYPE_RW_REMOUNT, NULL,
414 APP2SD_PRE_UNINSTALL);
417 app2ext_print("App2Sd Error : Re-mount failed\n");
422 ret = APP2EXT_ERROR_MOUNT_PATH;
432 if (ret != APP2EXT_SUCCESS)
433 app2ext_print("App2Sd Error : app2sd has [%d]error, but return success for uninstallation\n", ret);
438 * app2sd_post_app_uninstall_setup
439 * Uninstall Application and free all the allocated resources
440 * Called after dpkg remove, It deallocates dev node and loopback
442 int app2sd_post_app_uninstall(const char *pkgid)
444 char buf_dir[FILENAME_MAX] = { 0, };
445 int ret = APP2EXT_SUCCESS;
446 int ret1 = APP2EXT_SUCCESS;
447 /*Validate the function parameter recieved */
450 ("App2Sd Error : Invalid function arguments to Post Uninstall\n");
451 ret = APP2EXT_ERROR_INVALID_ARGUMENTS;
454 /*Check whether MMC is present or not */
455 ret = _app2sd_check_mmc_status();
457 app2ext_print("App2Sd Error : MMC not preset OR Not ready %d\n",
459 ret = APP2EXT_ERROR_MMC_STATUS;
462 /*Unmount the loopback encrypted pseudo device from the application installation path */
463 ret = _app2sd_unmount_app_content(pkgid);
465 app2ext_print("Unable to unmount the app content %d\n", ret);
466 ret = APP2EXT_ERROR_UNMOUNT;
469 /*Detach the loopback encryption setup for the application */
470 ret = _app2sd_remove_loopback_encryption_setup(pkgid);
473 ("Unable to Detach the loopback encryption setup for the application");
474 ret = APP2EXT_ERROR_DETACH_LOOPBACK_DEVICE;
477 /*Delete the loopback device from the SD card */
478 ret = _app2sd_delete_loopback_device(pkgid);
481 ("App2Sd Error : Unable to delete the loopback device from the SD Card\n");
482 ret = APP2EXT_ERROR_DELETE_LOOPBACK_DEVICE;
485 memset((void *)&buf_dir, '\0', FILENAME_MAX);
486 snprintf(buf_dir, FILENAME_MAX, "%s%s", APP_INSTALLATION_PATH, pkgid);
487 ret1 = _app2sd_delete_directory(buf_dir);
490 ("App2Sd Error : Unable to delete the directory %s\n",
493 /*remove encryption password from DB */
494 ret = _app2sd_initialize_db();
496 app2ext_print("\n app2sd db initialize failed");
497 ret = APP2EXT_ERROR_SQLITE_REGISTRY;
500 ret = _app2sd_remove_password_from_db(pkgid);
502 app2ext_print("cannot remove password from db \n");
503 ret = APP2EXT_ERROR_SQLITE_REGISTRY;
508 if (ret != APP2EXT_SUCCESS)
509 app2ext_print("App2Sd Error : app2sd has [%d]error, but return success for uninstallation\n", ret);
513 int app2sd_move_installed_app(const char *pkgid, GList* dir_list,
514 app2ext_move_type move_type)
517 int pkgmgrinfo_ret = 0;
519 /*Validate function arguments*/
520 if (pkgid == NULL || dir_list == NULL
521 || move_type < APP2EXT_MOVE_TO_EXT
522 || move_type > APP2EXT_MOVE_TO_PHONE) {
523 app2ext_print("App2Sd Error : Invalid function arguments\n");
524 ret = APP2EXT_ERROR_INVALID_ARGUMENTS;
528 /*If move is completed, then update installed storage to pkgmgr_parser db*/
529 pkgmgrinfo_pkginfo_h info_handle = NULL;
530 pkgmgrinfo_installed_storage storage = PMINFO_INTERNAL_STORAGE;
531 pkgmgrinfo_ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &info_handle);
532 if (pkgmgrinfo_ret < 0) {
533 app2ext_print("App2Sd Error : pkgmgrinfo_pkginfo_get_pkginfo[%s] fail.. \n", pkgid);
535 pkgmgrinfo_ret = pkgmgrinfo_pkginfo_get_installed_storage(info_handle, &storage);
536 if (pkgmgrinfo_ret < 0) {
537 app2ext_print("App2Sd Error : pkgmgrinfo_pkginfo_get_installed_storage[%s] fail.. \n", pkgid);
540 if ((move_type == APP2EXT_MOVE_TO_EXT && storage == PMINFO_EXTERNAL_STORAGE)
541 || (move_type == APP2EXT_MOVE_TO_PHONE && storage == PMINFO_INTERNAL_STORAGE)) {
542 ret = APP2EXT_ERROR_PKG_EXISTS;
543 app2ext_print("App2Sd Error : PKG_EXISTS in [%d]STORAGE\n", storage);
544 pkgmgrinfo_pkginfo_destroy_pkginfo(info_handle);
547 app2ext_print("App2Sd info : pkgid[%s] move to STORAGE[%d]\n", pkgid, storage);
549 pkgmgrinfo_pkginfo_destroy_pkginfo(info_handle);
551 ret = _app2sd_move_app(pkgid, move_type, dir_list);
553 app2ext_print("App2Sd Error : Unable to move application\n");
557 /* If move is completed, then update installed storage to pkgmgr_parser db */
558 if (move_type == APP2EXT_MOVE_TO_EXT) {
559 pkgmgrinfo_ret = pkgmgrinfo_pkginfo_set_installed_storage(pkgid, INSTALL_EXTERNAL);
560 if (pkgmgrinfo_ret < 0) {
561 app2ext_print("App2Sd Error : fail to update installed location to db[%s, %s]\n", pkgid, INSTALL_EXTERNAL);
564 pkgmgrinfo_ret = pkgmgrinfo_pkginfo_set_installed_storage(pkgid, INSTALL_INTERNAL);
565 if (pkgmgrinfo_ret < 0) {
566 app2ext_print("App2Sd Error : fail to update installed location to db[%s, %s]\n", pkgid, INSTALL_INTERNAL);
571 _app2sd_make_result_info_file((char*)pkgid, ret);
576 int app2sd_pre_app_upgrade(const char *pkgid, GList* dir_list,
579 int ret = APP2EXT_SUCCESS;
580 char app_path[FILENAME_MAX] = { 0, };
581 char *device_node = NULL;
582 unsigned long long curr_size = 0;
584 int reqd_disk_size = size + ceil(size*0.2);
586 /*Validate function arguments*/
587 if (pkgid == NULL || dir_list == NULL || size<=0) {
589 ("App2Sd Error : Invalid function arguments \n");
590 return APP2EXT_ERROR_INVALID_ARGUMENTS;
592 /*Check whether MMC is present or not */
593 ret = _app2sd_check_mmc_status();
595 app2ext_print("App2Sd Error : MMC not preset OR Not ready %d\n",
597 return APP2EXT_ERROR_MMC_STATUS;
599 /*check app entry is there in sd card or not. */
600 snprintf(app_path, FILENAME_MAX, "%s%s", APP2SD_PATH,
602 app2ext_print("App2Sd Log : Checking path %s\n", app_path);
603 fp = fopen(app_path, "r+");
606 ("App2SD Error: App Entry is not present in SD Card\n");
607 return APP2EXT_ERROR_INVALID_PACKAGE;
610 /*Get installed app size*/
611 curr_size = _app2sd_calculate_file_size(app_path);
612 curr_size = (curr_size)/(1024 * 1024);
616 ("App2SD Error: App Entry is not present in SD Card\n");
617 return APP2EXT_ERROR_LOOPBACK_DEVICE_UNAVAILABLE;
619 if ((int)curr_size < reqd_disk_size) {
620 ret = _app2sd_update_loopback_device_size(pkgid, reqd_disk_size, dir_list);
621 if(APP2EXT_SUCCESS !=ret) {
623 ("App2SD Error: _app2sd_update_loopback_device_size() failed\n");
628 /*Get the associated device node for SD card applicationer */
629 device_node = _app2sd_find_associated_device_node(pkgid);
630 if (NULL == device_node) {
631 /*Do loopback setup */
632 device_node = _app2sd_do_loopback_encryption_setup(pkgid);
633 if (device_node == NULL) {
635 ("App2Sd Error : loopback encryption setup failed\n");
636 return APP2EXT_ERROR_DO_LOSETUP;
640 _app2sd_mount_app_content(pkgid, device_node,
641 MOUNT_TYPE_RW, dir_list,
644 app2ext_print("App2Sd Error : Re-mount failed\n");
649 return APP2EXT_ERROR_MOUNT_PATH;
654 _app2sd_mount_app_content(pkgid, device_node,
655 MOUNT_TYPE_RW_REMOUNT, NULL,
658 app2ext_print("App2Sd Error : Re-mount failed\n");
663 return APP2EXT_ERROR_MOUNT_PATH;
675 int app2sd_post_app_upgrade(const char *pkgid,
676 app2ext_status install_status)
678 char *device_name = NULL;
679 int ret = APP2EXT_SUCCESS;
680 /*Validate the function parameter recieved */
681 if (pkgid == NULL || install_status < APP2EXT_STATUS_FAILED
682 || install_status > APP2EXT_STATUS_SUCCESS) {
683 app2ext_print("Invalid func parameters\n");
684 return APP2EXT_ERROR_INVALID_ARGUMENTS;
686 /*Check whether MMC is present or not */
687 ret = _app2sd_check_mmc_status();
689 app2ext_print("App2Sd Error : MMC not preset OR Not ready %d\n",
691 return APP2EXT_ERROR_MMC_STATUS;
694 /*Get the associated device node for SD card applicationer */
695 device_name = _app2sd_find_associated_device_node(pkgid);
696 if (NULL == device_name) {
697 return APP2EXT_ERROR_FIND_ASSOCIATED_DEVICE_NODE;
699 ret = _app2sd_unmount_app_content(pkgid);
705 app2ext_print("Unable to unmount the app content %d\n", ret);
706 return APP2EXT_ERROR_UNMOUNT;
708 ret = _app2sd_remove_loopback_encryption_setup(pkgid);
715 ("Unable to Detach the loopback encryption setup for the application");
716 return APP2EXT_ERROR_UNMOUNT;
727 * Reserved API for forced cleanup
730 int app2sd_force_cleanup(const char *pkgid){
731 char *device_name = NULL;
732 char buf_dir[FILENAME_MAX] = { 0, };
733 int ret = APP2EXT_SUCCESS;
736 /*Validate the function parameter recieved */
738 app2ext_print("invalid func parameters\n");
739 return APP2EXT_ERROR_INVALID_ARGUMENTS;
741 memset((void *)&buf_dir, '\0', FILENAME_MAX);
742 snprintf(buf_dir, FILENAME_MAX, "%s%s", APP2SD_PATH, pkgid);
743 fp = fopen(buf_dir, "r+");
745 app2ext_print("\"%s\" not installed on SD Card\n", pkgid);
746 return APP2EXT_ERROR_INVALID_PACKAGE;
749 /*Check whether MMC is present or not */
750 ret = _app2sd_check_mmc_status();
752 app2ext_print("App2Sd Error : MMC not preset OR Not ready %d\n",
754 return APP2EXT_ERROR_MMC_STATUS;
757 /*Get the associated device node for SD card applicationer */
758 device_name = _app2sd_find_associated_device_node(pkgid);
759 if (NULL != device_name) {
762 ret = _app2sd_unmount_app_content(pkgid);
764 app2ext_print("Unable to unmount the app content %d\n", ret);
765 return APP2EXT_ERROR_UNMOUNT;
767 ret = _app2sd_remove_loopback_encryption_setup(pkgid);
770 ("Unable to Detach the loopback encryption setup for the application");
771 return APP2EXT_ERROR_UNMOUNT;
775 memset((void *)&buf_dir, '\0', FILENAME_MAX);
776 snprintf(buf_dir, FILENAME_MAX, "%s%s", APP_INSTALLATION_PATH, pkgid);
777 ret = _app2sd_delete_directory(buf_dir);
780 ("App2Sd Error : Unable to delete the directory %s\n",
784 /*remove passwrd from DB*/
785 ret = _app2sd_initialize_db();
787 app2ext_print("\n app2sd db initialize failed");
788 return APP2EXT_ERROR_SQLITE_REGISTRY;
790 ret = _app2sd_remove_password_from_db(pkgid);
792 app2ext_print("cannot remove password from db \n");
793 return APP2EXT_ERROR_SQLITE_REGISTRY;
799 int app2sd_force_clean(const char *pkgid)
801 char buf_dir[FILENAME_MAX] = { 0, };
802 int ret = APP2EXT_SUCCESS;
804 /*Validate the function parameter recieved */
806 app2ext_print("Invalid func parameters\n");
807 return APP2EXT_ERROR_INVALID_ARGUMENTS;
809 app2ext_print("star force_clean [%s]", pkgid);
812 /*Unmount the loopback encrypted pseudo device from the application installation path */
813 ret = _app2sd_unmount_app_content(pkgid);
815 app2ext_print("Unable to unmount the app content %d\n", ret);
818 /*Detach the loopback encryption setup for the application */
819 ret = _app2sd_remove_all_loopback_encryption_setups(pkgid);
821 app2ext_print("Unable to Detach the loopback encryption setup for the application");
824 /*Delete the loopback device from the SD card */
825 ret = _app2sd_delete_loopback_device(pkgid);
827 app2ext_print("Unable to Detach the loopback encryption setup for the application");
831 memset((void *)&buf_dir, '\0', FILENAME_MAX);
832 snprintf(buf_dir, FILENAME_MAX, "%s%s", APP_INSTALLATION_PATH, pkgid);
834 _app2sd_delete_symlink(buf_dir);
836 /*remove passwrd from DB*/
837 ret = _app2sd_initialize_db();
839 app2ext_print("\n app2sd db initialize failed");
841 ret = _app2sd_remove_password_from_db(pkgid);
843 app2ext_print("cannot remove password from db \n");
846 app2ext_print("finish force_clean");
850 /* This is the plug-in load function. The plugin has to bind its functions to function pointers of handle
851 @param[in/out] st_interface Specifies the storage interface.
854 app2ext_on_load(app2ext_interface *st_interface)
857 st_interface->pre_install= app2sd_pre_app_install;
858 st_interface->post_install= app2sd_post_app_install;
859 st_interface->pre_uninstall= app2sd_pre_app_uninstall;
860 st_interface->post_uninstall= app2sd_post_app_uninstall;
861 st_interface->pre_upgrade= app2sd_pre_app_upgrade;
862 st_interface->post_upgrade= app2sd_post_app_upgrade;
863 st_interface->move= app2sd_move_installed_app;
864 st_interface->force_clean= app2sd_force_clean;
865 st_interface->enable= app2sd_on_demand_setup_init;
866 st_interface->disable= app2sd_on_demand_setup_exit;