Check if shared/data exist instead of api-version 55/85655/2 accepted/tizen/common/20160830.150123 accepted/tizen/ivi/20160830.061205 accepted/tizen/mobile/20160830.060927 accepted/tizen/tv/20160830.061032 accepted/tizen/wearable/20160830.061120 submit/tizen/20160830.010724
authorSemun Lee <sm79.lee@samsung.com>
Fri, 26 Aug 2016 09:05:20 +0000 (18:05 +0900)
committerSemun Lee <sm79.lee@samsung.com>
Mon, 29 Aug 2016 00:47:03 +0000 (17:47 -0700)
Since Tizen 3.0 shared/data directory is available for
applications that has appdir.shareddata privilege.
Otherwise, shared/data directory will not be created.
So, we could just check existence of shared/data in aul.

Change-Id: I3fc6b94e2b1ac1f478bb14ee60057892446d085d
Signed-off-by: Semun Lee <sm79.lee@samsung.com>
src/aul_path.c

index 2ed1a34..c76f5a3 100644 (file)
@@ -213,38 +213,6 @@ static const char *__get(char **path, const char *appid,
        return *path;
 }
 
-static int __compare_api_version(const char *appid, uid_t uid, int *result)
-{
-       int ret;
-       char pkgid[NAME_MAX];
-       pkgmgrinfo_pkginfo_h pkginfo;
-       char *api_version;
-
-       ret = __get_pkgid(pkgid, sizeof(pkgid), appid, uid);
-       if (ret != AUL_R_OK) {
-               _E("Failed to get package id");
-               return ret;
-       }
-
-       ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, uid, &pkginfo);
-       if (ret != PMINFO_R_OK) {
-               _E("Failed to get pakckage info");
-               return ret;
-       }
-
-       ret = pkgmgrinfo_pkginfo_get_api_version(pkginfo, &api_version);
-       if (ret != PMINFO_R_OK) {
-               _E("Failed to get api-version");
-               pkgmgrinfo_pkginfo_destroy_pkginfo(pkginfo);
-               return ret;
-       }
-
-       *result = strverscmp(api_version, "3.0");
-       pkgmgrinfo_pkginfo_destroy_pkginfo(pkginfo);
-
-       return ret;
-}
-
 API const char *aul_get_app_external_root_path(void)
 {
        static char *path;
@@ -289,15 +257,7 @@ API const char *aul_get_app_tep_resource_path(void)
 
 API int aul_get_app_shared_data_path(char **path)
 {
-       int res;
-
-       if (__compare_api_version(NULL, getuid(), &res) < 0)
-               return AUL_R_EREJECTED;
-
-       if (res >= 0)
-               return AUL_R_EREJECTED;
-
-       return __get_path(path, NULL, _SHARED_DATA_DIR, getuid());
+       return aul_get_app_shared_data_path_by_appid(NULL, path);
 }
 
 API const char *aul_get_app_shared_resource_path(void)
@@ -360,29 +320,22 @@ API const char *aul_get_app_external_specific_path(void)
 
 API int aul_get_app_shared_data_path_by_appid(const char *appid, char **path)
 {
-       int res;
-       int callee_pid;
-       int caller_pid = getpid();
-
-       if (appid == NULL || path == NULL)
-               return AUL_R_EINVAL;
+       int ret;
+       char *ret_path;
 
-       if (__compare_api_version(NULL, getuid(), &res) < 0)
-               return AUL_R_EREJECTED;
+       ret = __get_path(&ret_path, appid, _SHARED_DATA_DIR, getuid());
+       if (ret != AUL_R_OK)
+               return ret;
 
-       if (res >= 0)
+       ret = access(ret_path, F_OK);
+       if (ret == 0) {
+               *path = ret_path;
+       } else {
+               free(ret_path);
                return AUL_R_EREJECTED;
-
-       callee_pid = aul_app_get_pid(appid);
-       if (caller_pid != callee_pid) {
-               if (__compare_api_version(appid, getuid(), &res) < 0)
-                       return AUL_R_EREJECTED;
-
-               if (res >= 0)
-                       return AUL_R_EREJECTED;
        }
 
-       return __get_path(path, appid, _SHARED_DATA_DIR, getuid());
+       return AUL_R_OK;
 }
 
 API int aul_get_app_shared_resource_path_by_appid(const char *appid,