From 8e73f088c325b39e1f10cfde3572bd3c18ad9596 Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Wed, 12 Oct 2016 19:47:42 +0900 Subject: [PATCH] Pass image path when change pkg db - Pass image path when change installed_location column at pkg db Change-Id: I8ec2b9abe2d967f2756025e9517a2873a19496d0 Signed-off-by: Junghyun Yeon --- plugin/app2sd/inc/app2sd_internals.h | 2 +- plugin/app2sd/src/app2sd_interface.c | 9 +++++---- plugin/app2sd/src/app2sd_internals.c | 8 +++++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/plugin/app2sd/inc/app2sd_internals.h b/plugin/app2sd/inc/app2sd_internals.h index ab70a9b..0d63709 100644 --- a/plugin/app2sd/inc/app2sd_internals.h +++ b/plugin/app2sd/inc/app2sd_internals.h @@ -83,7 +83,7 @@ int _app2sd_get_available_free_memory(char *mmc_path, int *free_mem); /* function to move the application from/to SD Card */ int _app2sd_usr_move_app(const char *pkgid, app2ext_move_type move_cmd, - GList *dir_list, uid_t uid, char *mmc_path); + GList *dir_list, uid_t uid, char *mmc_path, char **image_path); /* utility to delete symbolic link */ void _app2sd_delete_symlink(const char *dirname); diff --git a/plugin/app2sd/src/app2sd_interface.c b/plugin/app2sd/src/app2sd_interface.c index ff96a94..8bc6b29 100644 --- a/plugin/app2sd/src/app2sd_interface.c +++ b/plugin/app2sd/src/app2sd_interface.c @@ -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)", @@ -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; @@ -874,7 +875,7 @@ 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) { 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 +884,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)", diff --git a/plugin/app2sd/src/app2sd_internals.c b/plugin/app2sd/src/app2sd_internals.c index dfa8989..e3b712f 100644 --- a/plugin/app2sd/src/app2sd_internals.c +++ b/plugin/app2sd/src/app2sd_internals.c @@ -852,7 +852,7 @@ static int _app2sd_move_to_archive(const char *src_path, const char *arch_path) } static int _app2sd_move_app_to_external(const char *pkgid, GList *dir_list, - uid_t uid, char *mmc_path) + uid_t uid, char *mmc_path, char **image_path) { int ret = APP2EXT_SUCCESS; mode_t mode = DIR_PERMS; @@ -1088,6 +1088,7 @@ static int _app2sd_move_app_to_external(const char *pkgid, GList *dir_list, goto ERR; } + *image_path = strdup(loopback_device); return APP2EXT_SUCCESS; ERR: @@ -1096,6 +1097,7 @@ ERR: device_node = NULL; } + *image_path = NULL; return ret; } @@ -1369,14 +1371,14 @@ ERR: } int _app2sd_usr_move_app(const char *pkgid, app2ext_move_type move_type, - GList *dir_list, uid_t uid, char *mmc_path) + GList *dir_list, uid_t uid, char *mmc_path, char **image_path) { int ret = APP2EXT_SUCCESS; switch (move_type) { case APP2EXT_MOVE_TO_EXT: ret = _app2sd_move_app_to_external(pkgid, dir_list, - uid, mmc_path); + uid, mmc_path, image_path); if (ret) { _E("move app to external memory failed(%d)", ret); return ret; -- 2.7.4