return strdup(icon);
do {
- snprintf(icon_with_path, sizeof(icon_with_path), "%s%s",
- getIconPath(uid, true), icon);
- if (access(icon_with_path, F_OK) == 0)
- break;
+ if (uid == GLOBAL_USER || uid == OWNER_ROOT) {
+ snprintf(icon_with_path, sizeof(icon_with_path),
+ "%s%s", getIconPath(uid, true), icon);
+ if (access(icon_with_path, F_OK) == 0)
+ break;
- snprintf(icon_with_path, sizeof(icon_with_path), "%s%s",
- getIconPath(uid, false), icon);
- if (access(icon_with_path, F_OK) == 0)
- break;
+ snprintf(icon_with_path, sizeof(icon_with_path),
+ "%s%s", getIconPath(uid, false), icon);
+ if (access(icon_with_path, F_OK) == 0)
+ break;
- /* for backward compatibility (.../default/small/...)
- * this should be removed
- */
- snprintf(icon_with_path, sizeof(icon_with_path),
+ /* for backward compatibility (.../default/small/...)
+ * this should be removed
+ */
+ snprintf(icon_with_path, sizeof(icon_with_path),
"%sdefault/small/%s",
getIconPath(uid, true), icon);
- if (access(icon_with_path, F_OK) == 0)
- break;
+ if (access(icon_with_path, F_OK) == 0)
+ break;
- snprintf(icon_with_path, sizeof(icon_with_path),
+ snprintf(icon_with_path, sizeof(icon_with_path),
"%sdefault/small/%s",
getIconPath(uid, false), icon);
- if (access(icon_with_path, F_OK) == 0)
- break;
+ if (access(icon_with_path, F_OK) == 0)
+ break;
- /* If doesn't exist in case of Global app,
- * try to get icon directly into app's directory
- */
- if (uid == GLOBAL_USER || uid == OWNER_ROOT) {
+ /* If doesn't exist in case of Global app,
+ * try to get icon directly into app's directory
+ */
app_path = tzplatform_getenv(TZ_SYS_RO_APP);
snprintf(icon_with_path, sizeof(icon_with_path),
gid_t gid = ROOT_UID;
if (uid != GLOBAL_USER && uid != ROOT_UID) {
- tzplatform_set_user(uid);
- path = tzplatform_mkpath(TZ_USER_ICONS, "/");
- gid = _get_gid(tzplatform_getenv(TZ_SYS_USER_GROUP));
- tzplatform_reset_user();
- } else {
- if (readonly)
- path = tzplatform_mkpath(TZ_SYS_RO_ICONS, "/");
- else
- path = tzplatform_mkpath(TZ_SYS_RW_ICONS, "/");
+ _LOGD("not supported target user");
+ return NULL;
}
+ if (readonly)
+ path = tzplatform_mkpath(TZ_SYS_RO_ICONS, "/");
+ else
+ path = tzplatform_mkpath(TZ_SYS_RW_ICONS, "/");
+
/* just allow certain users to create the icon directory if needed. */
if (uid_caller == ROOT_UID || uid_caller == uid)
_mkdir_for_user(path, uid, gid);