Refactor app2sd disable logic 98/119998/1 accepted/tizen/3.0/common/20170331.151857 accepted/tizen/3.0/ivi/20170331.044254 accepted/tizen/3.0/mobile/20170331.043959 accepted/tizen/3.0/tv/20170331.044145 accepted/tizen/3.0/wearable/20170331.044219 submit/tizen_3.0/20170329.045543
authorjongmyeongko <jongmyeong.ko@samsung.com>
Tue, 21 Mar 2017 05:23:36 +0000 (14:23 +0900)
committerjongmyeongko <jongmyeong.ko@samsung.com>
Tue, 21 Mar 2017 05:32:16 +0000 (14:32 +0900)
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 <jongmyeong.ko@samsung.com>
plugin/app2sd/server/app2sd_interface.c

index 500819e..ba52e5a 100644 (file)
@@ -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);