diff --git a/appdata-sandbox-app.json b/appdata-sandbox-app.json index 05ae5c5b948a8442504702c8aa333b76ef39cb86..42ae0674aa2e9be196f78c7b1adde0d55e1e978a 100755 --- a/appdata-sandbox-app.json +++ b/appdata-sandbox-app.json @@ -72,7 +72,7 @@ "src-path" : "/vendor/etc/hiai", "sandbox-path" : "/vendor/etc/hiai" }, { - "src-path" : "/data/local/shader_cache/cloud/common", + "src-path" : "/data/app/el1/public/shader_cache/cloud/common", "sandbox-path" : "/data/storage/shader_cache/common" }, { "src-path" : "/data/service/el0/public/for-all-app", @@ -142,10 +142,10 @@ "src-path" : "/data/app/el1//aot_compiler/ark_profile/", "sandbox-path" : "/data/storage/ark-profile" }, { - "src-path" : "/data/local/shader_cache/local/", + "src-path" : "/data/app/el1//shader_cache/", "sandbox-path" : "/data/storage/shader_cache/local" }, { - "src-path" : "/data/local/shader_cache/cloud/", + "src-path" : "/data/app/el1/public/shader_cache/cloud/", "sandbox-path" : "/data/storage/shader_cache/cloud" }, { "src-path" : "/data/service/el1/public/themes//a/app", @@ -258,8 +258,11 @@ }, { "name": "ohos.permission.ACCESS_SHADER_CACHE_DIR", "mount-paths": [{ - "src-path": "/data/local/shader_cache", - "sandbox-path": "/data/storage/shader_caches" + "src-path": "/data/service/el1/public/shader_cache/local", + "sandbox-path": "/data/storage/shader_caches/local" + }, { + "src-path": "/data/app/el1/public/shader_cache/cloud", + "sandbox-path": "/data/storage/shader_caches/cloud" }] }, { "name": "ohos.permission.ACCESS_HIVIEWX", diff --git a/appdata-sandbox.json b/appdata-sandbox.json index ce3425734850459d261cf22a856174c09aac04c8..d1cddf4d7ffe02d87d26ddfa0a4d7adc6daee18a 100755 --- a/appdata-sandbox.json +++ b/appdata-sandbox.json @@ -164,17 +164,17 @@ "sandbox-flags" : [ "bind", "rec" ], "check-action-status": "false" }, { - "src-path" : "/data/local/shader_cache/local/", + "src-path" : "/data/app/el1//shader_cache/", "sandbox-path" : "/data/storage/shader_cache/local", "sandbox-flags" : [ "bind", "rec" ], "check-action-status": "false" }, { - "src-path" : "/data/local/shader_cache/cloud/", + "src-path" : "/data/app/el1/public/shader_cache/cloud/", "sandbox-path" : "/data/storage/shader_cache/cloud", "sandbox-flags" : [ "bind", "rec" ], "check-action-status": "false" }, { - "src-path" : "/data/local/shader_cache/cloud/common", + "src-path" : "/data/app/el1/public/shader_cache/cloud/common", "sandbox-path" : "/data/storage/shader_cache/common", "sandbox-flags" : [ "bind", "rec" ], "check-action-status": "false" @@ -629,17 +629,17 @@ "sandbox-flags" : [ "bind", "rec" ], "check-action-status": "false" }, { - "src-path" : "/data/local/shader_cache/local/", + "src-path" : "/data/app/el1//shader_cache/", "sandbox-path" : "/data/storage/shader_cache/local", "sandbox-flags" : [ "bind", "rec" ], "check-action-status": "false" }, { - "src-path" : "/data/local/shader_cache/cloud/", + "src-path" : "/data/app/el1/public/shader_cache/cloud/", "sandbox-path" : "/data/storage/shader_cache/cloud", "sandbox-flags" : [ "bind", "rec" ], "check-action-status": "false" }, { - "src-path" : "/data/local/shader_cache/cloud/common", + "src-path" : "/data/app/el1/public/shader_cache/cloud/common", "sandbox-path" : "/data/storage/shader_cache/common", "sandbox-flags" : [ "bind", "rec" ], "check-action-status": "false" @@ -831,8 +831,12 @@ "ohos.permission.ACCESS_SHADER_CACHE_DIR":[{ "sandbox-switch": "ON", "mount-paths": [{ - "src-path": "/data/local/shader_cache", - "sandbox-path": "/data/storage/shader_caches", + "src-path": "/data/service/el1/public/shader_cache/local", + "sandbox-path": "/data/storage/shader_caches/local", + "sandbox-flags": [ "bind", "rec" ] + }, { + "src-path": "/data/app/el1/public/shader_cache/cloud", + "sandbox-path": "/data/storage/shader_caches/cloud", "sandbox-flags": [ "bind", "rec" ] } ] diff --git a/interfaces/innerkits/include/appspawn.h b/interfaces/innerkits/include/appspawn.h index bd2f16d15d06d8b785a0a5c617fb257c4e03cb48..f04bcf1a1e1fe0a47a8685c62d485c7bc393602f 100644 --- a/interfaces/innerkits/include/appspawn.h +++ b/interfaces/innerkits/include/appspawn.h @@ -295,6 +295,7 @@ int AppSpawnClientAddPermission(AppSpawnClientHandle handle, AppSpawnReqMsgHandl #define MSG_EXT_NAME_JIT_PERMISSIONS "Permissions" #define MSG_EXT_NAME_USERID "uid" #define MSG_EXT_NAME_EXTENSION_TYPE "ExtensionType" +#define MSG_EXT_NAME_PARENT_UID "ParentUid" int AppSpawnReqMsgAddExtInfo(AppSpawnReqMsgHandle reqHandle, const char *name, const uint8_t *value, uint32_t valueLen); diff --git a/modules/sandbox/sandbox_utils.cpp b/modules/sandbox/sandbox_utils.cpp index 605eceb950de80fa6ae161e7bdda0c076b98b437..d681aa6ca8e7a7129fa131453cfa0fc6a197816e 100644 --- a/modules/sandbox/sandbox_utils.cpp +++ b/modules/sandbox/sandbox_utils.cpp @@ -551,6 +551,25 @@ static std::string ReplaceVariablePackageName(const AppSpawningCtx *appProperty, return tmpSandboxPath; } +static std::string ReplaceUserId(const AppSpawningCtx *appProperty, const std::string &path, + const AppSpawnMsgDacInfo *dacInfo) +{ + std::string tmpSandboxPath = path; + char *processType = (char *)(GetAppSpawnMsgExtInfo(appProperty->message, MSG_EXT_NAME_PROCESS_TYPE, NULL)); + if (processType == nullptr) { + tmpSandboxPath = replace_all(tmpSandboxPath, g_userId, std::to_string(dacInfo->uid / UID_BASE)); + } else if (strcmp(processType, "gpu") == 0) { + int32_t uid = 0; + const char *userId = + (const char *)(GetAppSpawnMsgExtInfo(appProperty->message, MSG_EXT_NAME_PARENT_UID, NULL)); + if (userId != nullptr) { + uid = atoi(userId); + } + tmpSandboxPath = replace_all(tmpSandboxPath, g_userId, std::to_string(uid / UID_BASE)); + } + return tmpSandboxPath; +} + string SandboxUtils::ConvertToRealPath(const AppSpawningCtx *appProperty, std::string path) { AppSpawnMsgBundleInfo *info = @@ -572,7 +591,7 @@ string SandboxUtils::ConvertToRealPath(const AppSpawningCtx *appProperty, std::s } if (path.find(g_userId) != std::string::npos) { - path = replace_all(path, g_userId, std::to_string(dacInfo->uid / UID_BASE)); + path = ReplaceUserId(appProperty, path, dacInfo); } if (path.find(g_variablePackageName) != std::string::npos) {