Deprecate shared directory related API 44/58044/6 accepted/tizen/mobile/20160202.114600 accepted/tizen/tv/20160202.114650 accepted/tizen/wearable/20160202.114729 submit/tizen/20160202.002216 submit/tizen/20160202.010556 submit/tizen/20160202.023804
authorHwankyu Jhun <h.jhun@samsung.com>
Wed, 27 Jan 2016 05:48:20 +0000 (14:48 +0900)
committerHwanKyu Jhun <h.jhun@samsung.com>
Mon, 1 Feb 2016 22:59:42 +0000 (14:59 -0800)
- Shared/data directory is only available applications
with api-version lower than 3.0 from Tizen 3.0.

Change-Id: I4fe84168f5921f033a31510cccfac84cb16ea6c3
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
include/aul.h
src/aul_path.c

index 9be56d8..ff19011 100644 (file)
@@ -1663,7 +1663,7 @@ const char *aul_get_app_tep_resource_path(void);
 /*
  * This API is only for Appfw internally.
  */
-const char *aul_get_app_shared_data_path(void);
+int aul_get_app_shared_data_path(char **path);
 
 /*
  * This API is only for Appfw internally.
index 400a0e7..0964635 100644 (file)
@@ -208,6 +208,38 @@ 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;
@@ -250,11 +282,17 @@ API const char *aul_get_app_tep_resource_path(void)
        return __get(&path, NULL, _TEP_RESOURCE_DIR, getuid(), __get_path_from_db);
 }
 
-API const char *aul_get_app_shared_data_path(void)
+API int aul_get_app_shared_data_path(char **path)
 {
-       static char *path;
+       int res;
 
-       return __get(&path, NULL, _SHARED_DATA_DIR, getuid(), __get_path);
+       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());
 }
 
 API const char *aul_get_app_shared_resource_path(void)
@@ -317,9 +355,28 @@ 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;
 
+       if (__compare_api_version(NULL, getuid(), &res) < 0)
+               return AUL_R_EREJECTED;
+
+       if (res >= 0)
+               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());
 }