From f68116d8a9e2e6a052dee5ca0f35de4c74ba4dac Mon Sep 17 00:00:00 2001 From: jongmyeongko Date: Tue, 21 Mar 2017 14:23:36 +0900 Subject: [PATCH] Refactor app2sd disable logic remove unncessary file checking. this change prevent cyclic call between deviced and app2sd-server when the sdcard removed. deviced -> disalbe all -> mmc check -> deviced Change-Id: I91c778107fda15c865fb5ad6c7a43534f48a5957 Signed-off-by: jongmyeongko --- plugin/app2sd/server/app2sd_interface.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/plugin/app2sd/server/app2sd_interface.c b/plugin/app2sd/server/app2sd_interface.c index 500819e..ba52e5a 100644 --- a/plugin/app2sd/server/app2sd_interface.c +++ b/plugin/app2sd/server/app2sd_interface.c @@ -548,13 +548,13 @@ static int _app2sd_kill_running_app(const char *pkgid, uid_t uid) int app2sd_usr_on_demand_setup_exit(const char *pkgid, uid_t uid) { int ret = APP2EXT_SUCCESS; - char mmc_path[FILENAME_MAX] = { 0, }; char application_path[FILENAME_MAX] = { 0, }; char loopback_device[FILENAME_MAX] = { 0, }; +#if !defined(TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION) + char mmc_path[FILENAME_MAX] = { 0, }; char *sdpath = NULL; char *encoded_id = NULL; - FILE *fp = NULL; - int mmc_present = 1; +#endif /* validate the function parameter recieved */ if (pkgid == NULL) { @@ -564,12 +564,22 @@ int app2sd_usr_on_demand_setup_exit(const char *pkgid, uid_t uid) _app2sd_kill_running_app(pkgid, uid); +#ifdef TIZEN_FEATURE_APP2SD_DMCRYPT_ENCRYPTION + if (_is_global(uid)) { + snprintf(application_path, FILENAME_MAX - 1, "%s/%s", + tzplatform_getenv(TZ_SYS_RW_APP), pkgid); + } else { + tzplatform_set_user(uid); + snprintf(application_path, FILENAME_MAX - 1, "%s/%s", + tzplatform_getenv(TZ_USER_APP), pkgid); + tzplatform_reset_user(); + } +#else /* check whether MMC is present or not */ ret = _app2sd_check_mmc_status(&sdpath); - if (ret) { + if (ret) _W("MMC not present OR Not ready (%d)", ret); - mmc_present = 0; - } + snprintf(mmc_path, FILENAME_MAX - 1, "%s", sdpath); free(sdpath); @@ -577,7 +587,6 @@ int app2sd_usr_on_demand_setup_exit(const char *pkgid, uid_t uid) if (encoded_id == NULL) return APP2EXT_ERROR_MEMORY_ALLOC_FAILED; - /* check app entry is there in sd card or not. */ if (_is_global(uid)) { snprintf(application_path, FILENAME_MAX - 1, "%s/%s", tzplatform_getenv(TZ_SYS_RW_APP), pkgid); @@ -592,15 +601,7 @@ int app2sd_usr_on_demand_setup_exit(const char *pkgid, uid_t uid) tzplatform_reset_user(); } free(encoded_id); - - if (mmc_present) { - fp = fopen(loopback_device, "r+"); - if (fp == NULL) { - _E("app entry is not present in SD Card"); - return APP2EXT_ERROR_INVALID_PACKAGE; - } - fclose(fp); - } +#endif ret = __app2sd_finalize_device_setup(pkgid, loopback_device, application_path, uid); -- 2.7.4