bugfix related storing external_path
[platform/core/appfw/app2sd.git] / plugin / app2sd / src / app2sd_interface.c
index ecfc3a7..40e2cf8 100644 (file)
@@ -341,7 +341,7 @@ int app2sd_usr_post_app_install(const char *pkgid,
                 * to pkgmgr_parser db
                 */
                pkgmgr_ret = pkgmgrinfo_pkginfo_set_usr_installed_storage(pkgid,
-                       INSTALL_EXTERNAL, uid);
+                       INSTALL_EXTERNAL, loopback_device, uid);
                if (pkgmgr_ret < 0) {
                        _E("fail to update installed location " \
                                "to db[%s, %d] of uid(%d), pkgmgr ret(%d)",
@@ -488,7 +488,7 @@ static int _app2sd_application_handler(const pkgmgrinfo_appinfo_h handle, void *
                return APP2EXT_ERROR_KILLAPP_ERROR;
        }
 
-       ret = aul_terminate_pid_sync_for_uid(pid, uid);
+       ret = aul_terminate_pid_sync_without_restart_for_uid(pid, uid);
        if (ret != AUL_R_OK) {
                _E("failed to kill app");
                return APP2EXT_ERROR_KILLAPP_ERROR;
@@ -839,6 +839,7 @@ int app2sd_usr_pre_move_installed_app(const char *pkgid,
        int ret = 0;
        int pkgmgr_ret = 0;
        char *sdpath = NULL;
+       char *image_path = NULL;
        char mmc_path[FILENAME_MAX] = { 0, };
 
        /* validate function arguments */
@@ -865,7 +866,7 @@ int app2sd_usr_pre_move_installed_app(const char *pkgid,
                return ret;
        }
 
-       ret = _app2sd_usr_move_app(pkgid, move_type, dir_list, uid, mmc_path);
+       ret = _app2sd_usr_move_app(pkgid, move_type, dir_list, uid, mmc_path, &image_path);
        if (ret) {
                _D("unable to move application");
                return ret;
@@ -873,8 +874,12 @@ int app2sd_usr_pre_move_installed_app(const char *pkgid,
 
        /* if move is completed, then update installed storage to pkgmgr_parser db */
        if (move_type == APP2EXT_MOVE_TO_EXT) {
+               if (!image_path) {
+                       _E("image_path is NULL");
+                       return APP2EXT_ERROR_MEMORY_ALLOC_FAILED;
+               }
                pkgmgr_ret = pkgmgrinfo_pkginfo_set_usr_installed_storage(pkgid,
-                               INSTALL_EXTERNAL, uid);
+                               INSTALL_EXTERNAL, image_path, uid);
                if (pkgmgr_ret < 0) {
                        _E("failed to update installed location to db " \
                                "[%s, %s] of uid(%d), pkgmgr_ret(%d)",
@@ -883,7 +888,7 @@ int app2sd_usr_pre_move_installed_app(const char *pkgid,
                }
        } else {
                pkgmgr_ret = pkgmgrinfo_pkginfo_set_usr_installed_storage(pkgid,
-                               INSTALL_INTERNAL, uid);
+                               INSTALL_INTERNAL, image_path, uid);
                if (pkgmgr_ret < 0) {
                        _E("failed to update installed location to db " \
                                "[%s, %s] of uid(%d), pkgmgr_ret(%d)",
@@ -892,6 +897,9 @@ int app2sd_usr_pre_move_installed_app(const char *pkgid,
                }
        }
 
+       if (image_path)
+               free(image_path);
+
        sync();
        return APP2EXT_SUCCESS;
 }
@@ -1188,6 +1196,7 @@ int app2sd_usr_post_app_upgrade(const char *pkgid,
        char *device_name = NULL;
        char *encoded_id = NULL;
        int ret = APP2EXT_SUCCESS;
+       int pkgmgr_ret = 0;
 
        /* validate the function parameter recieved */
        if (pkgid == NULL || install_status < APP2EXT_STATUS_FAILED
@@ -1273,6 +1282,15 @@ int app2sd_usr_post_app_upgrade(const char *pkgid,
        }
 #endif
 
+       pkgmgr_ret = pkgmgrinfo_pkginfo_set_usr_installed_storage(pkgid,
+               INSTALL_EXTERNAL, loopback_device, uid);
+       if (pkgmgr_ret < 0) {
+               _E("fail to update installed location " \
+                       "to db[%s, %d] of uid(%d), pkgmgr ret(%d)",
+                       pkgid, INSTALL_EXTERNAL, uid, pkgmgr_ret);
+               return APP2EXT_ERROR_PKGMGR_ERROR;
+       }
+
        if (device_name) {
                free(device_name);
                device_name = NULL;