已关闭
沙箱路径优化 #20368
dgm_2399562创建于 5 天前关闭于 4 天前
沙箱路径优化 #20368
已关闭
从已删除 :master合入到openharmony/ability_ability_runtimemaster
共 8 个文件变更+40-40
| @@ -66,8 +66,6 @@ constexpr char SANDBOX_ARK_PROFILE_PATH[] = "/data/storage/ark-profile/"; | |||
| 66 | constexpr char ARK_PROFILE_SUFFIX[] = ".ap"; | 66 | constexpr char ARK_PROFILE_SUFFIX[] = ".ap"; |
| 67 | constexpr char MERGE_ABC_PATH[] = "/ets/modules_static.abc"; | 67 | constexpr char MERGE_ABC_PATH[] = "/ets/modules_static.abc"; |
| 68 | constexpr char ABS_DATA_CODE_PATH[] = "/data/app/el1/bundle/public/"; | 68 | constexpr char ABS_DATA_CODE_PATH[] = "/data/app/el1/bundle/public/"; |
| 69 | -constexpr char BUNDLE[] = "bundle/"; | ||
| 70 | -constexpr char ABS_CODE_PATH[] = "/data/storage/el1/"; | ||
| 71 | 69 | ||
| 72 | 70 | ||
| 73 | using CreateVMETSRuntimeType = ani_status (*)(const ani_options *options, uint32_t version, ani_vm **result); | 71 | using CreateVMETSRuntimeType = ani_status (*)(const ani_options *options, uint32_t version, ani_vm **result); |
| @@ -1000,8 +998,9 @@ std::vector<std::string> ETSEnvironment::GetHspPathList() | |||
| 1000 | 998 | ||
| 1001 | for (const auto &pluginHspPath : staticPluginHspPathList_) { | 999 | for (const auto &pluginHspPath : staticPluginHspPathList_) { |
| 1002 | std::string targetPath = pluginHspPath; | 1000 | std::string targetPath = pluginHspPath; |
| 1003 | - std::regex patter(std::string(ABS_DATA_CODE_PATH) + bundleName_ + "/"); | 1001 | + std::regex patter((std::string(ABS_DATA_CODE_PATH))); |
| 1004 | - targetPath = std::regex_replace(targetPath, patter, std::string(ABS_CODE_PATH) + std::string(BUNDLE)); | 1002 | + targetPath = std::regex_replace(targetPath, patter, ""); |
| 1003 | + targetPath = std::string(BUNDLE_INSTALL_PATH) + targetPath.substr(targetPath.find("/") + 1); | ||
| 1005 | hspPathList.push_back(targetPath); | 1004 | hspPathList.push_back(targetPath); |
| 1006 | } | 1005 | } |
| 1007 | 1006 | ||
| @@ -60,7 +60,7 @@ std::mutex ContextImpl::getAllUIAbilitiesCallbackMutex_; | |||
| 60 | GetAllUIAbilitiesCallback ContextImpl::getAllUIAbilitiesCallback_ = nullptr; | 60 | GetAllUIAbilitiesCallback ContextImpl::getAllUIAbilitiesCallback_ = nullptr; |
| 61 | 61 | ||
| 62 | using namespace OHOS::AbilityBase::Constants; | 62 | using namespace OHOS::AbilityBase::Constants; |
| 63 | - | 63 | +using ExtractorUtil = AbilityBase::ExtractorUtil; |
| 64 | const std::string PATTERN_VERSION = std::string(FILE_SEPARATOR) + "v\\d+" + FILE_SEPARATOR; | 64 | const std::string PATTERN_VERSION = std::string(FILE_SEPARATOR) + "v\\d+" + FILE_SEPARATOR; |
| 65 | 65 | ||
| 66 | const size_t Context::CONTEXT_TYPE_ID(std::hash<const char*> {} ("Context")); | 66 | const size_t Context::CONTEXT_TYPE_ID(std::hash<const char*> {} ("Context")); |
| @@ -542,9 +542,7 @@ std::shared_ptr<Context> ContextImpl::WrapContext(const std::string &pluginBundl | |||
| 542 | continue; | 542 | continue; |
| 543 | } | 543 | } |
| 544 | if (inputContext->GetBundleName() == hostBundleName) { | 544 | if (inputContext->GetBundleName() == hostBundleName) { |
| 545 | - std::regex pattern( | 545 | + loadPath = ExtractorUtil::GetLoadFilePath(loadPath); |
| 546 | - std::string(ABS_CODE_PATH) + std::string(FILE_SEPARATOR) + inputContext->GetBundleName()); | ||
| 547 | - loadPath = std::regex_replace(loadPath, pattern, LOCAL_CODE_PATH); | ||
| 548 | bool newCreate = false; | 546 | bool newCreate = false; |
| 549 | std::shared_ptr<AbilityBase::Extractor> extractor = | 547 | std::shared_ptr<AbilityBase::Extractor> extractor = |
| 550 | AbilityBase::ExtractorUtil::GetExtractor(loadPath, newCreate, true); | 548 | AbilityBase::ExtractorUtil::GetExtractor(loadPath, newCreate, true); |
| @@ -991,8 +989,7 @@ void ContextImpl::InitResourceManager(const AppExecFwk::BundleInfo &bundleInfo, | |||
| 991 | TAG_LOGE(AAFwkTag::APPKIT, "empty loadPath"); | 989 | TAG_LOGE(AAFwkTag::APPKIT, "empty loadPath"); |
| 992 | break; | 990 | break; |
| 993 | } | 991 | } |
| 994 | - std::regex pattern(std::string(ABS_CODE_PATH) + std::string(FILE_SEPARATOR) + bundleInfo.name); | 992 | + loadPath = ExtractorUtil::GetLoadFilePath(loadPath); |
| 995 | - loadPath = std::regex_replace(loadPath, pattern, std::string(LOCAL_CODE_PATH)); | ||
| 996 | if (!resourceManager->AddResource(loadPath.c_str())) { | 993 | if (!resourceManager->AddResource(loadPath.c_str())) { |
| 997 | TAG_LOGE(AAFwkTag::APPKIT, "AddResource failed"); | 994 | TAG_LOGE(AAFwkTag::APPKIT, "AddResource failed"); |
| 998 | } | 995 | } |
| @@ -1046,8 +1043,6 @@ std::shared_ptr<Global::Resource::ResourceManager> ContextImpl::InitResourceMana | |||
| 1046 | } | 1043 | } |
| 1047 | if (!moduleName.empty() || !bundleInfo.applicationInfo.multiProjects) { | 1044 | if (!moduleName.empty() || !bundleInfo.applicationInfo.multiProjects) { |
| 1048 | TAG_LOGD(AAFwkTag::APPKIT, "hapModuleInfos count: %{public}zu", bundleInfo.hapModuleInfos.size()); | 1045 | TAG_LOGD(AAFwkTag::APPKIT, "hapModuleInfos count: %{public}zu", bundleInfo.hapModuleInfos.size()); |
| 1049 | - std::regex inner_pattern(std::string(ABS_CODE_PATH) + std::string(FILE_SEPARATOR) | ||
| 1050 | - + GetBundleNameWithContext(inputContext)); | ||
| 1051 | std::regex outer_pattern(ABS_CODE_PATH); | 1046 | std::regex outer_pattern(ABS_CODE_PATH); |
| 1052 | std::regex hsp_pattern(std::string(ABS_CODE_PATH) + FILE_SEPARATOR + bundleInfo.name + PATTERN_VERSION); | 1047 | std::regex hsp_pattern(std::string(ABS_CODE_PATH) + FILE_SEPARATOR + bundleInfo.name + PATTERN_VERSION); |
| 1053 | std::string hsp_sandbox = std::string(LOCAL_CODE_PATH) + FILE_SEPARATOR + bundleInfo.name + FILE_SEPARATOR; | 1048 | std::string hsp_sandbox = std::string(LOCAL_CODE_PATH) + FILE_SEPARATOR + bundleInfo.name + FILE_SEPARATOR; |
| @@ -1069,7 +1064,7 @@ std::shared_ptr<Global::Resource::ResourceManager> ContextImpl::InitResourceMana | |||
| 1069 | *deduplicate |= hapModuleInfo.deduplicateHar; | 1064 | *deduplicate |= hapModuleInfo.deduplicateHar; |
| 1070 | } | 1065 | } |
| 1071 | if (currentBundle) { | 1066 | if (currentBundle) { |
| 1072 | - loadPath = std::regex_replace(loadPath, inner_pattern, LOCAL_CODE_PATH); | 1067 | + loadPath = ExtractorUtil::GetLoadFilePath(loadPath); |
| 1073 | } else if (bundleInfo.applicationInfo.bundleType == AppExecFwk::BundleType::SHARED) { | 1068 | } else if (bundleInfo.applicationInfo.bundleType == AppExecFwk::BundleType::SHARED) { |
| 1074 | loadPath = std::regex_replace(loadPath, hsp_pattern, hsp_sandbox); | 1069 | loadPath = std::regex_replace(loadPath, hsp_pattern, hsp_sandbox); |
| 1075 | } else if (bundleInfo.applicationInfo.bundleType == AppExecFwk::BundleType::APP_SERVICE_FWK) { | 1070 | } else if (bundleInfo.applicationInfo.bundleType == AppExecFwk::BundleType::APP_SERVICE_FWK) { |
| @@ -1092,10 +1087,8 @@ std::shared_ptr<Global::Resource::ResourceManager> ContextImpl::InitResourceMana | |||
| 1092 | void ContextImpl::AddPatchResource(std::shared_ptr<Global::Resource::ResourceManager> &resourceManager, | 1087 | void ContextImpl::AddPatchResource(std::shared_ptr<Global::Resource::ResourceManager> &resourceManager, |
| 1093 | const std::string &loadPath, const std::string &hqfPath, bool isDebug, std::shared_ptr<Context> inputContext) | 1088 | const std::string &loadPath, const std::string &hqfPath, bool isDebug, std::shared_ptr<Context> inputContext) |
| 1094 | { | 1089 | { |
| 1095 | - std::regex pattern(std::string(ABS_CODE_PATH) + std::string(FILE_SEPARATOR) | ||
| 1096 | - + GetBundleNameWithContext(inputContext)); | ||
| 1097 | if (!hqfPath.empty() && isDebug) { | 1090 | if (!hqfPath.empty() && isDebug) { |
| 1098 | - std::string realHqfPath = std::regex_replace(hqfPath, pattern, LOCAL_CODE_PATH); | 1091 | + std::string realHqfPath = ExtractorUtil::GetLoadFilePath(hqfPath); |
| 1099 | TAG_LOGI(AAFwkTag::APPKIT, "AddPatchResource hapPath:%{public}s, patchPath:%{public}s", | 1092 | TAG_LOGI(AAFwkTag::APPKIT, "AddPatchResource hapPath:%{public}s, patchPath:%{public}s", |
| 1100 | loadPath.c_str(), realHqfPath.c_str()); | 1093 | loadPath.c_str(), realHqfPath.c_str()); |
| 1101 | if (!resourceManager->AddPatchResource(loadPath.c_str(), realHqfPath.c_str())) { | 1094 | if (!resourceManager->AddPatchResource(loadPath.c_str(), realHqfPath.c_str())) { |
| @@ -1128,8 +1121,7 @@ void ContextImpl::GetOverlayPath(std::shared_ptr<Global::Resource::ResourceManag | |||
| 1128 | TAG_LOGE(AAFwkTag::APPKIT, "hapPath: %{private}s", it.hapPath.c_str()); | 1121 | TAG_LOGE(AAFwkTag::APPKIT, "hapPath: %{private}s", it.hapPath.c_str()); |
| 1129 | } | 1122 | } |
| 1130 | if (isMatched) { | 1123 | if (isMatched) { |
| 1131 | - it.hapPath = std::regex_replace(it.hapPath, std::regex(std::string(ABS_CODE_PATH) + | 1124 | + it.hapPath = ExtractorUtil::GetLoadFilePath(it.hapPath); |
| 1132 | - std::string(FILE_SEPARATOR) + GetBundleNameWithContext(inputContext)), LOCAL_CODE_PATH); | ||
| 1133 | } else { | 1125 | } else { |
| 1134 | it.hapPath = std::regex_replace(it.hapPath, std::regex(ABS_CODE_PATH), LOCAL_BUNDLES); | 1126 | it.hapPath = std::regex_replace(it.hapPath, std::regex(ABS_CODE_PATH), LOCAL_BUNDLES); |
| 1135 | } | 1127 | } |
| @@ -1710,7 +1702,6 @@ void ContextImpl::OnOverlayChanged(const EventFwk::CommonEventData &data, | |||
| 1710 | 1702 | ||
| 1711 | void ContextImpl::ChangeToLocalPath(const std::string& bundleName, const std::string& sourceDir, std::string& localPath) | 1703 | void ContextImpl::ChangeToLocalPath(const std::string& bundleName, const std::string& sourceDir, std::string& localPath) |
| 1712 | { | 1704 | { |
| 1713 | - std::regex pattern(std::string(ABS_CODE_PATH) + std::string(FILE_SEPARATOR) + bundleName); | ||
| 1714 | if (sourceDir.empty()) { | 1705 | if (sourceDir.empty()) { |
| 1715 | return; | 1706 | return; |
| 1716 | } | 1707 | } |
| @@ -1722,7 +1713,7 @@ void ContextImpl::ChangeToLocalPath(const std::string& bundleName, const std::st | |||
| 1722 | localPath.c_str(), bundleName.c_str()); | 1713 | localPath.c_str(), bundleName.c_str()); |
| 1723 | } | 1714 | } |
| 1724 | if (isExist) { | 1715 | if (isExist) { |
| 1725 | - localPath = std::regex_replace(localPath, pattern, std::string(LOCAL_CODE_PATH)); | 1716 | + localPath = ExtractorUtil::GetLoadFilePath(localPath); |
| 1726 | } else { | 1717 | } else { |
| 1727 | localPath = std::regex_replace(localPath, std::regex(ABS_CODE_PATH), LOCAL_BUNDLES); | 1718 | localPath = std::regex_replace(localPath, std::regex(ABS_CODE_PATH), LOCAL_BUNDLES); |
| 1728 | } | 1719 | } |
| @@ -29,12 +29,13 @@ | |||
| 29 | 29 | ||
| 30 | 30 | ||
| 31 | 31 | ||
| 32 | + | ||
| 32 | 33 | ||
| 33 | 34 | ||
| 34 | namespace OHOS { | 35 | namespace OHOS { |
| 35 | namespace AppExecFwk { | 36 | namespace AppExecFwk { |
| 36 | using namespace OHOS::AbilityBase::Constants; | 37 | using namespace OHOS::AbilityBase::Constants; |
| 37 | - | 38 | +using ExtractorUtil = AbilityBase::ExtractorUtil; |
| 38 | const std::string ContextDeal::CONTEXT_DEAL_FILE_SEPARATOR("/"); | 39 | const std::string ContextDeal::CONTEXT_DEAL_FILE_SEPARATOR("/"); |
| 39 | const std::string ContextDeal::CONTEXT_DEAL_Files("files"); | 40 | const std::string ContextDeal::CONTEXT_DEAL_Files("files"); |
| 40 | const int64_t ContextDeal::CONTEXT_CREATE_BY_SYSTEM_APP(0x00000001); | 41 | const int64_t ContextDeal::CONTEXT_CREATE_BY_SYSTEM_APP(0x00000001); |
| @@ -200,8 +201,7 @@ std::string ContextDeal::GetBundleResourcePath() | |||
| 200 | if (isCreateBySystemApp_) { | 201 | if (isCreateBySystemApp_) { |
| 201 | dir = std::regex_replace(abilityInfo_->resourcePath, std::regex(ABS_CODE_PATH), LOCAL_BUNDLES); | 202 | dir = std::regex_replace(abilityInfo_->resourcePath, std::regex(ABS_CODE_PATH), LOCAL_BUNDLES); |
| 202 | } else { | 203 | } else { |
| 203 | - std::regex pattern(std::string(ABS_CODE_PATH) + std::string(FILE_SEPARATOR) + abilityInfo_->bundleName); | 204 | + dir = ExtractorUtil::GetLoadFilePath(abilityInfo_->resourcePath); |
| 204 | - dir = std::regex_replace(abilityInfo_->resourcePath, pattern, LOCAL_CODE_PATH); | ||
| 205 | } | 205 | } |
| 206 | return dir; | 206 | return dir; |
| 207 | } | 207 | } |
| @@ -112,6 +112,7 @@ | |||
| 112 | 112 | ||
| 113 | 113 | ||
| 114 | 114 | ||
| 115 | + | ||
| 115 | 116 | ||
| 116 | 117 | ||
| 117 | 118 | ||
| @@ -149,7 +150,7 @@ constexpr char FORM_RENDER_LIB_PATH[] = "/system/lib64/libformrender.z.so"; | |||
| 149 | 150 | ||
| 150 | constexpr char FORM_RENDER_LIB_PATH[] = "/system/lib64/libformrender.z.so"; | 151 | constexpr char FORM_RENDER_LIB_PATH[] = "/system/lib64/libformrender.z.so"; |
| 151 | 152 | ||
| 152 | - | 153 | +using ExtractorUtil = AbilityBase::ExtractorUtil; |
| 153 | constexpr int32_t DELIVERY_TIME = 200; | 154 | constexpr int32_t DELIVERY_TIME = 200; |
| 154 | constexpr int32_t DISTRIBUTE_TIME = 100; | 155 | constexpr int32_t DISTRIBUTE_TIME = 100; |
| 155 | constexpr int32_t START_HIGH_SENSITIVE = 1; | 156 | constexpr int32_t START_HIGH_SENSITIVE = 1; |
| @@ -1327,8 +1328,7 @@ std::vector<std::string> MainThread::GetOverlayPaths(const std::string &bundleNa | |||
| 1327 | std::vector<std::string> overlayPaths; | 1328 | std::vector<std::string> overlayPaths; |
| 1328 | for (auto &it : overlayModuleInfos_) { | 1329 | for (auto &it : overlayModuleInfos_) { |
| 1329 | if (std::regex_search(it.hapPath, std::regex(bundleName))) { | 1330 | if (std::regex_search(it.hapPath, std::regex(bundleName))) { |
| 1330 | - it.hapPath = std::regex_replace(it.hapPath, std::regex(std::string(ABS_CODE_PATH) + | 1331 | + it.hapPath = ExtractorUtil::GetLoadFilePath(it.hapPath); |
| 1331 | - std::string(FILE_SEPARATOR) + bundleName), std::string(LOCAL_CODE_PATH)); | ||
| 1332 | } else { | 1332 | } else { |
| 1333 | it.hapPath = std::regex_replace(it.hapPath, std::regex(ABS_CODE_PATH), LOCAL_BUNDLES); | 1333 | it.hapPath = std::regex_replace(it.hapPath, std::regex(ABS_CODE_PATH), LOCAL_BUNDLES); |
| 1334 | } | 1334 | } |
| @@ -2109,7 +2109,7 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con | |||
| 2109 | std::string loadPath = | 2109 | std::string loadPath = |
| 2110 | entryHapModuleInfo.hapPath.empty() ? entryHapModuleInfo.resourcePath : entryHapModuleInfo.hapPath; | 2110 | entryHapModuleInfo.hapPath.empty() ? entryHapModuleInfo.resourcePath : entryHapModuleInfo.hapPath; |
| 2111 | std::regex inner_pattern(std::string(ABS_CODE_PATH) + std::string(FILE_SEPARATOR) + bundleInfo.name); | 2111 | std::regex inner_pattern(std::string(ABS_CODE_PATH) + std::string(FILE_SEPARATOR) + bundleInfo.name); |
| 2112 | - loadPath = std::regex_replace(loadPath, inner_pattern, LOCAL_CODE_PATH); | 2112 | + loadPath = ExtractorUtil::GetLoadFilePath(loadPath); |
| 2113 | application_->SetEntryLoadPath(loadPath); | 2113 | application_->SetEntryLoadPath(loadPath); |
| 2114 | auto res = GetOverlayModuleInfos(bundleInfo.name, moduleName, overlayModuleInfos_); | 2114 | auto res = GetOverlayModuleInfos(bundleInfo.name, moduleName, overlayModuleInfos_); |
| 2115 | std::vector<std::string> overlayPaths; | 2115 | std::vector<std::string> overlayPaths; |
| @@ -2548,8 +2548,7 @@ void MainThread::ChangeToLocalPath(const std::string &bundleName, | |||
| 2548 | if (item.empty()) { | 2548 | if (item.empty()) { |
| 2549 | continue; | 2549 | continue; |
| 2550 | } | 2550 | } |
| 2551 | - localPath.emplace_back( | 2551 | + localPath.emplace_back(ExtractorUtil::GetLoadFilePath(item)); |
| 2552 | - std::regex_replace(item, pattern, std::string(LOCAL_CODE_PATH) + std::string(FILE_SEPARATOR))); | ||
| 2553 | } | 2552 | } |
| 2554 | } | 2553 | } |
| 2555 | 2554 | ||
| @@ -2568,7 +2567,7 @@ void MainThread::ChangeToLocalPath(const std::string &bundleName, | |||
| 2568 | localPath.c_str(), bundleName.c_str()); | 2567 | localPath.c_str(), bundleName.c_str()); |
| 2569 | } | 2568 | } |
| 2570 | if (isExist) { | 2569 | if (isExist) { |
| 2571 | - localPath = std::regex_replace(localPath, pattern, std::string(LOCAL_CODE_PATH)); | 2570 | + localPath = ExtractorUtil::GetLoadFilePath(localPath); |
| 2572 | } else { | 2571 | } else { |
| 2573 | localPath = std::regex_replace(localPath, std::regex(ABS_CODE_PATH), LOCAL_BUNDLES); | 2572 | localPath = std::regex_replace(localPath, std::regex(ABS_CODE_PATH), LOCAL_BUNDLES); |
| 2574 | } | 2573 | } |
| @@ -134,9 +134,7 @@ std::string HybridJsModuleReader::GetPluginHspPath(const std::string& inputPath) | |||
| 134 | && sharedBundleName == pluginBundleInfo.pluginBundleName) { | 134 | && sharedBundleName == pluginBundleInfo.pluginBundleName) { |
| 135 | presetAppHapPath = pluginModuleInfo.hapPath; | 135 | presetAppHapPath = pluginModuleInfo.hapPath; |
| 136 | TAG_LOGD(AAFwkTag::JSRUNTIME, "presetAppHapPath %{public}s", presetAppHapPath.c_str()); | 136 | TAG_LOGD(AAFwkTag::JSRUNTIME, "presetAppHapPath %{public}s", presetAppHapPath.c_str()); |
| 137 | - std::regex pattern(std::string(ABS_DATA_CODE_PATH) + bundleName_ + "/"); | 137 | + presetAppHapPath = ExtractorUtil::GetLoadFilePath(presetAppHapPath); |
| 138 | - presetAppHapPath = std::regex_replace( | ||
| 139 | - presetAppHapPath, pattern, std::string(ABS_CODE_PATH) + std::string(BUNDLE)); | ||
| 140 | TAG_LOGD(AAFwkTag::JSRUNTIME, "presetAppHapPath %{public}s", presetAppHapPath.c_str()); | 138 | TAG_LOGD(AAFwkTag::JSRUNTIME, "presetAppHapPath %{public}s", presetAppHapPath.c_str()); |
| 141 | return presetAppHapPath; | 139 | return presetAppHapPath; |
| 142 | } | 140 | } |
| @@ -12,7 +12,7 @@ | |||
| 12 | * See the License for the specific language governing permissions and | 12 | * See the License for the specific language governing permissions and |
| 13 | * limitations under the License. | 13 | * limitations under the License. |
| 14 | */ | 14 | */ |
| 15 | - | 15 | + |
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | 18 | ||
| @@ -125,9 +125,7 @@ std::string JsModuleReader::GetPluginHspPath(const std::string& inputPath) const | |||
| 125 | && sharedBundleName == pluginBundleInfo.pluginBundleName) { | 125 | && sharedBundleName == pluginBundleInfo.pluginBundleName) { |
| 126 | presetAppHapPath = pluginModuleInfo.hapPath; | 126 | presetAppHapPath = pluginModuleInfo.hapPath; |
| 127 | TAG_LOGD(AAFwkTag::JSRUNTIME, "presetAppHapPath %{public}s", presetAppHapPath.c_str()); | 127 | TAG_LOGD(AAFwkTag::JSRUNTIME, "presetAppHapPath %{public}s", presetAppHapPath.c_str()); |
| 128 | - std::regex pattern(std::string(ABS_DATA_CODE_PATH) + bundleName_ + "/"); | 128 | + presetAppHapPath = ExtractorUtil::GetLoadFilePath(presetAppHapPath); |
| 129 | - presetAppHapPath = std::regex_replace( | ||
| 130 | - presetAppHapPath, pattern, std::string(ABS_CODE_PATH) + std::string(BUNDLE)); | ||
| 131 | TAG_LOGD(AAFwkTag::JSRUNTIME, "presetAppHapPath %{public}s", presetAppHapPath.c_str()); | 129 | TAG_LOGD(AAFwkTag::JSRUNTIME, "presetAppHapPath %{public}s", presetAppHapPath.c_str()); |
| 132 | return presetAppHapPath; | 130 | return presetAppHapPath; |
| 133 | } | 131 | } |
| @@ -302,4 +300,4 @@ void JsModuleReader::GetHapPathList(const std::string &bundleName, std::vector<s | |||
| 302 | } | 300 | } |
| 303 | } | 301 | } |
| 304 | } // namespace AbilityRuntime | 302 | } // namespace AbilityRuntime |
| 305 | -} // namespace OHOS | 303 | +} // namespace OHOS |
| @@ -2514,6 +2514,7 @@ private: | |||
| 2514 | const std::shared_ptr<AppRunningRecord> &appRecord, const UIExtensionProcessBindInfo &bindInfo); | 2514 | const std::shared_ptr<AppRunningRecord> &appRecord, const UIExtensionProcessBindInfo &bindInfo); |
| 2515 | void UnBindUIExtensionProcess( | 2515 | void UnBindUIExtensionProcess( |
| 2516 | const std::shared_ptr<AppRunningRecord> &appRecord, const UIExtensionProcessBindInfo &bindInfo); | 2516 | const std::shared_ptr<AppRunningRecord> &appRecord, const UIExtensionProcessBindInfo &bindInfo); |
| 2517 | + std::string GetStoragePath(const std::string& hapPath); | ||
| 2517 | bool WrapBindInfo(std::shared_ptr<AAFwk::Want> &want, std::shared_ptr<AppRunningRecord> &appRecord, | 2518 | bool WrapBindInfo(std::shared_ptr<AAFwk::Want> &want, std::shared_ptr<AppRunningRecord> &appRecord, |
| 2518 | UIExtensionProcessBindInfo &bindInfo); | 2519 | UIExtensionProcessBindInfo &bindInfo); |
| 2519 | void ReportEventToRSS(const AppExecFwk::AbilityInfo &abilityInfo, | 2520 | void ReportEventToRSS(const AppExecFwk::AbilityInfo &abilityInfo, |
| @@ -2262,8 +2262,8 @@ void AppMgrServiceInner::LoadAbility(std::shared_ptr<AbilityInfo> abilityInfo, s | |||
| 2262 | appInfo->bundleName = hostBundleName; | 2262 | appInfo->bundleName = hostBundleName; |
| 2263 | std::regex pattern( | 2263 | std::regex pattern( |
| 2264 | std::string(ABS_CODE_PATH) + std::string(FILE_SEPARATOR) + hostBundleName); | 2264 | std::string(ABS_CODE_PATH) + std::string(FILE_SEPARATOR) + hostBundleName); |
| 2265 | - abilityInfo->hapPath = std::regex_replace(abilityInfo->hapPath, pattern, LOCAL_CODE_PATH); | 2265 | + abilityInfo->hapPath = GetStoragePath(abilityInfo->hapPath); |
| 2266 | - abilityInfo->resourcePath = std::regex_replace(abilityInfo->resourcePath, pattern, LOCAL_CODE_PATH); | 2266 | + abilityInfo->resourcePath = GetStoragePath(abilityInfo->resourcePath); |
| 2267 | GetBundleAndHapInfo(*abilityInfo, appInfo, bundleInfo, hapModuleInfo, appIndex); | 2267 | GetBundleAndHapInfo(*abilityInfo, appInfo, bundleInfo, hapModuleInfo, appIndex); |
| 2268 | appInfo = std::make_shared<ApplicationInfo>(bundleInfo.applicationInfo); | 2268 | appInfo = std::make_shared<ApplicationInfo>(bundleInfo.applicationInfo); |
| 2269 | auto pluginRet = DelayedSingleton<BundleMgrHelper>::GetInstance()->GetPluginHapModuleInfo( | 2269 | auto pluginRet = DelayedSingleton<BundleMgrHelper>::GetInstance()->GetPluginHapModuleInfo( |
| @@ -13409,6 +13409,20 @@ void AppMgrServiceInner::CheckRenderAttachTimeout(std::shared_ptr<RenderRecord> | |||
| 13409 | ProcessStartFailedReason::ATTACH_TIMEOUT, elapsedMs); | 13409 | ProcessStartFailedReason::ATTACH_TIMEOUT, elapsedMs); |
| 13410 | } | 13410 | } |
| 13411 | 13411 | ||
| 13412 | +std::string AppMgrServiceInner::GetStoragePath(const std::string& hapPath) { | ||
| 13413 | + if (hapPath.empty()) { | ||
| 13414 | + return hapPath; | ||
| 13415 | + } | ||
| 13416 | + std::regex hapPattern(std::string(ABS_CODE_PATH) + std::string(FILE_SEPARATOR)); | ||
| 13417 | + std::string loadPath = std::regex_replace(hapPath, hapPattern, ""); | ||
| 13418 | + auto pos = loadPath.find(std::string(FILE_SEPARATOR)); | ||
| 13419 | + if (pos == std::string::npos) { | ||
| 13420 | + return std::string(LOCAL_CODE_PATH) + std::string(FILE_SEPARATOR) + loadPath; | ||
| 13421 | + } | ||
| 13422 | + loadPath = std::string(LOCAL_CODE_PATH) + std::string(FILE_SEPARATOR) + loadPath.substr(pos + 1); | ||
| 13423 | + return loadPath; | ||
| 13424 | +} | ||
| 13425 | + | ||
| 13412 | void AppMgrServiceInner::HandleForegroundAbilityDied( | 13426 | void AppMgrServiceInner::HandleForegroundAbilityDied( |
| 13413 | const std::vector<sptr<IRemoteObject>>& abilityTokens,ApplicationState state) | 13427 | const std::vector<sptr<IRemoteObject>>& abilityTokens,ApplicationState state) |
| 13414 | { | 13428 | { |