1 /*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "bundle_resource_process.h"
17
18 #include "account_helper.h"
19 #include "bundle_mgr_service.h"
20 #include "bundle_resource_parser.h"
21
22 namespace OHOS {
23 namespace AppExecFwk {
24 namespace {
25 const std::string INNER_UNDER_LINE = "_";
26 }
27
GetBundleResourceInfo(const InnerBundleInfo & innerBundleInfo,const int32_t userId,ResourceInfo & resourceInfo)28 bool BundleResourceProcess::GetBundleResourceInfo(const InnerBundleInfo &innerBundleInfo,
29 const int32_t userId,
30 ResourceInfo &resourceInfo)
31 {
32 if (innerBundleInfo.GetBundleName().empty()) {
33 APP_LOGE("bundleName is empty");
34 return false;
35 }
36 if (innerBundleInfo.GetApplicationBundleType() == BundleType::SHARED) {
37 APP_LOGD("bundleName:%{public}s is shared", innerBundleInfo.GetBundleName().c_str());
38 return false;
39 }
40 resourceInfo = ConvertToBundleResourceInfo(innerBundleInfo);
41 // process overlay hap paths
42 GetOverlayModuleHapPaths(innerBundleInfo, resourceInfo.moduleName_, userId, resourceInfo.overlayHapPaths_);
43 return true;
44 }
45
GetAllResourceInfo(const int32_t userId,std::map<std::string,std::vector<ResourceInfo>> & resourceInfosMap)46 bool BundleResourceProcess::GetAllResourceInfo(
47 const int32_t userId,
48 std::map<std::string, std::vector<ResourceInfo>> &resourceInfosMap)
49 {
50 auto dataMgr = DelayedSingleton<BundleMgrService>::GetInstance()->GetDataMgr();
51 if (dataMgr == nullptr) {
52 APP_LOGE("dataMgr is nullptr");
53 return false;
54 }
55 if (!dataMgr->HasUserId(userId)) {
56 APP_LOGE("userId %{public}d not exist", userId);
57 return false;
58 }
59 std::vector<std::string> allBundleNames = dataMgr->GetAllBundleName();
60 if (allBundleNames.empty()) {
61 APP_LOGE("bundleInfos is empty");
62 return false;
63 }
64
65 for (const auto &bundleName : allBundleNames) {
66 InnerBundleInfo innerBundleInfo;
67 if (!dataMgr->FetchInnerBundleInfo(bundleName, innerBundleInfo)) {
68 APP_LOGE("bundleName %{public}s not exist", bundleName.c_str());
69 continue;
70 }
71 if (innerBundleInfo.GetApplicationBundleType() == BundleType::SHARED) {
72 APP_LOGD("bundleName:%{public}s is shared", bundleName.c_str());
73 continue;
74 }
75 std::vector<ResourceInfo> resourceInfos;
76 if (!InnerGetResourceInfo(innerBundleInfo, userId, resourceInfos) || resourceInfos.empty()) {
77 APP_LOGW("%{public}s resourceInfo empty", bundleName.c_str());
78 } else {
79 resourceInfosMap[bundleName] = resourceInfos;
80 }
81 }
82 return true;
83 }
84
GetResourceInfoByBundleName(const std::string & bundleName,const int32_t userId,std::vector<ResourceInfo> & resourceInfo)85 bool BundleResourceProcess::GetResourceInfoByBundleName(
86 const std::string &bundleName,
87 const int32_t userId,
88 std::vector<ResourceInfo> &resourceInfo)
89 {
90 APP_LOGD("start, bundleName:%{public}s", bundleName.c_str());
91 auto dataMgr = DelayedSingleton<BundleMgrService>::GetInstance()->GetDataMgr();
92 if (dataMgr == nullptr) {
93 APP_LOGE("dataMgr is nullptr");
94 return false;
95 }
96 if (!dataMgr->HasUserId(userId)) {
97 APP_LOGE("userId %{public}d not exist", userId);
98 return false;
99 }
100 InnerBundleInfo innerBundleInfo;
101 if (!dataMgr->FetchInnerBundleInfo(bundleName, innerBundleInfo)) {
102 APP_LOGE("bundleName %{public}s not exist", bundleName.c_str());
103 return false;
104 }
105
106 return InnerGetResourceInfo(innerBundleInfo, userId, resourceInfo);
107 }
108
GetLauncherResourceInfoByAbilityName(const std::string & bundleName,const std::string & moduleName,const std::string & abilityName,const int32_t userId,ResourceInfo & resourceInfo)109 bool BundleResourceProcess::GetLauncherResourceInfoByAbilityName(
110 const std::string &bundleName,
111 const std::string &moduleName,
112 const std::string &abilityName,
113 const int32_t userId,
114 ResourceInfo &resourceInfo)
115 {
116 APP_LOGD("start, bundleName:%{public}s, moduleName:%{public}s, abilityName:%{public}s",
117 bundleName.c_str(), moduleName.c_str(), abilityName.c_str());
118 auto dataMgr = DelayedSingleton<BundleMgrService>::GetInstance()->GetDataMgr();
119 if (dataMgr == nullptr) {
120 APP_LOGE("dataMgr is nullptr");
121 return false;
122 }
123 if (!dataMgr->HasUserId(userId)) {
124 APP_LOGE("userId %{public}d not exist", userId);
125 return false;
126 }
127 InnerBundleInfo innerBundleInfo;
128 if (!dataMgr->FetchInnerBundleInfo(bundleName, innerBundleInfo)) {
129 APP_LOGE("bundleName %{public}s not exist", bundleName.c_str());
130 return false;
131 }
132
133 std::vector<ResourceInfo> resourceInfos;
134 if (GetAbilityResourceInfos(innerBundleInfo, userId, resourceInfos)) {
135 for (const auto &info : resourceInfos) {
136 if ((info.moduleName_ == moduleName) && (info.abilityName_ == abilityName)) {
137 resourceInfo = info;
138 return true;
139 }
140 }
141 }
142 APP_LOGE("bundleName %{public}s, moduleName %{public}s, abilityName %{public}s not exist",
143 bundleName.c_str(), moduleName.c_str(), abilityName.c_str());
144 return false;
145 }
146
GetResourceInfoByColorModeChanged(const std::vector<std::string> & resourceNames,const int32_t userId,std::vector<ResourceInfo> & resourceInfos)147 bool BundleResourceProcess::GetResourceInfoByColorModeChanged(
148 const std::vector<std::string> &resourceNames,
149 const int32_t userId,
150 std::vector<ResourceInfo> &resourceInfos)
151 {
152 auto dataMgr = DelayedSingleton<BundleMgrService>::GetInstance()->GetDataMgr();
153 if (dataMgr == nullptr) {
154 APP_LOGE("dataMgr is nullptr");
155 return false;
156 }
157 const std::map<std::string, InnerBundleInfo> bundleInfos = dataMgr->GetAllInnerBundleInfos();
158 std::vector<std::string> bundleNames;
159 for (const auto &item : bundleInfos) {
160 bundleNames.emplace_back(item.first);
161 InnerBundleUserInfo innerBundleUserInfo;
162 if (item.second.GetInnerBundleUserInfo(userId, innerBundleUserInfo) &&
163 !innerBundleUserInfo.cloneInfos.empty()) {
164 // need process clone app resource
165 APP_LOGI("bundleName:%{public}s has clone info", item.first.c_str());
166 for (const auto &clone : innerBundleUserInfo.cloneInfos) {
167 bundleNames.emplace_back(std::to_string(clone.second.appIndex) + INNER_UNDER_LINE + item.first);
168 }
169 }
170 }
171 std::set<std::string> needAddResourceBundles;
172 for (const auto &bundleName : bundleNames) {
173 if (std::find(resourceNames.begin(), resourceNames.end(), bundleName) == resourceNames.end()) {
174 ResourceInfo info;
175 info.ParseKey(bundleName);
176 needAddResourceBundles.insert(info.bundleName_);
177 }
178 }
179 if (needAddResourceBundles.empty()) {
180 APP_LOGW("needAddResourceBundles is empty");
181 return true;
182 }
183
184 for (const auto &bundleName : needAddResourceBundles) {
185 if (!GetResourceInfoByBundleName(bundleName, userId, resourceInfos)) {
186 APP_LOGW("bundleName %{public}s GetResourceInfoByBundleName failed", bundleName.c_str());
187 }
188 }
189 return true;
190 }
191
ChangeDynamicIcon(std::vector<ResourceInfo> & resourceInfos,const ResourceInfo & resourceInfo)192 void BundleResourceProcess::ChangeDynamicIcon(
193 std::vector<ResourceInfo> &resourceInfos, const ResourceInfo &resourceInfo)
194 {
195 for (auto &info : resourceInfos) {
196 info.icon_ = resourceInfo.icon_;
197 info.foreground_ = resourceInfo.foreground_;
198 info.background_ = resourceInfo.background_;
199 info.iconNeedParse_ = false;
200 }
201 }
202
GetDynamicIcon(const InnerBundleInfo & innerBundleInfo,ResourceInfo & resourceInfo)203 bool BundleResourceProcess::GetDynamicIcon(
204 const InnerBundleInfo &innerBundleInfo, ResourceInfo &resourceInfo)
205 {
206 std::string curDynamicIconModule = innerBundleInfo.GetCurDynamicIconModule();
207 if (curDynamicIconModule.empty()) {
208 return false;
209 }
210
211 std::map<std::string, ExtendResourceInfo> extResourceInfos =
212 innerBundleInfo.GetExtendResourceInfos();
213 auto iter = extResourceInfos.find(curDynamicIconModule);
214 if (iter == extResourceInfos.end()) {
215 APP_LOGE("Module not exist %{public}s",
216 curDynamicIconModule.c_str());
217 return false;
218 }
219 auto &extendResourceInfo = iter->second;
220 BundleResourceParser parser;
221 if (parser.ParseIconResourceByPath(extendResourceInfo.filePath, extendResourceInfo.iconId, resourceInfo)) {
222 APP_LOGE("bundleName:%{public}s parse dynamicIcon failed, iconId:%{public}d",
223 innerBundleInfo.GetBundleName().c_str(), extendResourceInfo.iconId);
224 return false;
225 }
226 return true;
227 }
228
InnerGetResourceInfo(const InnerBundleInfo & innerBundleInfo,const int32_t userId,std::vector<ResourceInfo> & resourceInfos)229 bool BundleResourceProcess::InnerGetResourceInfo(
230 const InnerBundleInfo &innerBundleInfo,
231 const int32_t userId,
232 std::vector<ResourceInfo> &resourceInfos)
233 {
234 ResourceInfo dynamicResourceInfo;
235 bool hasDynamicIcon = GetDynamicIcon(innerBundleInfo, dynamicResourceInfo);
236 if (!OnGetResourceInfo(innerBundleInfo, userId, resourceInfos)) {
237 if (!hasDynamicIcon) {
238 APP_LOGW("bundleName: %{public}s get bundle resource failed",
239 innerBundleInfo.GetBundleName().c_str());
240 return false;
241 }
242
243 APP_LOGI("%{public}s no default icon, build new", innerBundleInfo.GetBundleName().c_str());
244 ResourceInfo defaultResourceInfo;
245 defaultResourceInfo.bundleName_ = innerBundleInfo.GetBundleName();
246 defaultResourceInfo.labelNeedParse_ = false;
247 defaultResourceInfo.iconNeedParse_ = false;
248 defaultResourceInfo.icon_ = dynamicResourceInfo.icon_;
249 defaultResourceInfo.foreground_ = dynamicResourceInfo.foreground_;
250 defaultResourceInfo.background_ = dynamicResourceInfo.background_;
251 resourceInfos.emplace_back(defaultResourceInfo);
252 }
253
254 if (hasDynamicIcon) {
255 APP_LOGI("bundle %{public}s has dynamicIcon", innerBundleInfo.GetBundleName().c_str());
256 ChangeDynamicIcon(resourceInfos, dynamicResourceInfo);
257 }
258 // for clone bundle
259 std::set<int32_t> appIndexes = innerBundleInfo.GetCloneBundleAppIndexes();
260 if (!appIndexes.empty()) {
261 APP_LOGI("bundleName:%{public}s contains clone bundle", innerBundleInfo.GetBundleName().c_str());
262 std::vector<int32_t> indexes(appIndexes.begin(), appIndexes.end());
263 for (auto &info : resourceInfos) {
264 info.appIndexes_ = indexes;
265 }
266 }
267 return true;
268 }
269
OnGetResourceInfo(const InnerBundleInfo & innerBundleInfo,const int32_t userId,std::vector<ResourceInfo> & resourceInfos)270 bool BundleResourceProcess::OnGetResourceInfo(
271 const InnerBundleInfo &innerBundleInfo,
272 const int32_t userId,
273 std::vector<ResourceInfo> &resourceInfos)
274 {
275 std::string bundleName = innerBundleInfo.GetBundleName();
276 APP_LOGD("start, bundleName:%{public}s", bundleName.c_str());
277 // get bundle
278 ResourceInfo bundleResourceInfo;
279 if (!GetBundleResourceInfo(innerBundleInfo, userId, bundleResourceInfo)) {
280 APP_LOGW("%{public}s get resource failed", bundleName.c_str());
281 return false;
282 }
283 resourceInfos.push_back(bundleResourceInfo);
284
285 // get ability
286 std::vector<ResourceInfo> abilityResourceInfos;
287 if (GetAbilityResourceInfos(innerBundleInfo, userId, abilityResourceInfos)) {
288 for (const auto &info : abilityResourceInfos) {
289 resourceInfos.push_back(info);
290 }
291 }
292 APP_LOGI("end, bundleName:%{public}s, resourceInfo.size:%{public}d", bundleName.c_str(),
293 static_cast<int32_t>(resourceInfos.size()));
294 return !resourceInfos.empty();
295 }
296
ConvertToLauncherAbilityResourceInfo(const AbilityInfo & info)297 ResourceInfo BundleResourceProcess::ConvertToLauncherAbilityResourceInfo(const AbilityInfo &info)
298 {
299 ResourceInfo resourceInfo;
300 resourceInfo.bundleName_ = info.bundleName;
301 resourceInfo.moduleName_ = info.moduleName;
302 resourceInfo.abilityName_ = info.name;
303 resourceInfo.labelId_ = info.labelId;
304 resourceInfo.iconId_ = info.iconId;
305 resourceInfo.hapPath_ = info.hapPath;
306 return resourceInfo;
307 }
308
ConvertToBundleResourceInfo(const InnerBundleInfo & innerBundleInfo)309 ResourceInfo BundleResourceProcess::ConvertToBundleResourceInfo(const InnerBundleInfo &innerBundleInfo)
310 {
311 ApplicationInfo appInfo = innerBundleInfo.GetBaseApplicationInfo();
312 innerBundleInfo.AdaptMainLauncherResourceInfo(appInfo);
313 ResourceInfo resourceInfo;
314 resourceInfo.bundleName_ = innerBundleInfo.GetBundleName();
315 resourceInfo.labelId_ = appInfo.labelResource.id;
316 resourceInfo.iconId_ = appInfo.iconResource.id;
317 const auto &moduleName = appInfo.labelResource.moduleName;
318 const auto &moduleInfos = innerBundleInfo.GetInnerModuleInfos();
319 for (const auto &iter : moduleInfos) {
320 if (iter.second.moduleName == moduleName) {
321 resourceInfo.hapPath_ = iter.second.hapPath;
322 break;
323 }
324 }
325 resourceInfo.moduleName_ = moduleName;
326 resourceInfo.abilityName_ = std::string();
327 return resourceInfo;
328 }
329
GetLauncherAbilityResourceInfos(const InnerBundleInfo & innerBundleInfo,const int32_t userId,std::vector<ResourceInfo> & resourceInfos)330 bool BundleResourceProcess::GetLauncherAbilityResourceInfos(
331 const InnerBundleInfo &innerBundleInfo,
332 const int32_t userId,
333 std::vector<ResourceInfo> &resourceInfos)
334 {
335 APP_LOGD("start get ability, bundleName:%{public}s", innerBundleInfo.GetBundleName().c_str());
336 if (!CheckIsNeedProcessAbilityResource(innerBundleInfo)) {
337 APP_LOGW("%{public}s no need add ability resource", innerBundleInfo.GetBundleName().c_str());
338 return false;
339 }
340
341 auto dataMgr = DelayedSingleton<BundleMgrService>::GetInstance()->GetDataMgr();
342 if (dataMgr == nullptr) {
343 APP_LOGE("dataMgr is nullptr");
344 return false;
345 }
346 OHOS::AAFwk::Want want;
347 want.SetAction(Want::ACTION_HOME);
348 want.AddEntity(Want::ENTITY_HOME);
349 std::vector<AbilityInfo> abilityInfos;
350 int64_t time = 0;
351 dataMgr->GetMatchLauncherAbilityInfos(want, innerBundleInfo, abilityInfos, time, userId);
352
353 if (abilityInfos.empty()) {
354 APP_LOGW("%{public}s no launcher ability Info", innerBundleInfo.GetBundleName().c_str());
355 return false;
356 }
357 for (const auto &info : abilityInfos) {
358 resourceInfos.push_back(ConvertToLauncherAbilityResourceInfo(info));
359 }
360 // process overlay hap paths
361 size_t size = resourceInfos.size();
362 for (size_t index = 0; index < size; ++index) {
363 if ((index > 0) && (resourceInfos[index].moduleName_ == resourceInfos[index - 1].moduleName_)) {
364 resourceInfos[index].overlayHapPaths_ = resourceInfos[index - 1].overlayHapPaths_;
365 continue;
366 }
367 GetOverlayModuleHapPaths(innerBundleInfo, resourceInfos[index].moduleName_,
368 userId, resourceInfos[index].overlayHapPaths_);
369 }
370
371 APP_LOGD("end get ability, size:%{public}zu, bundleName:%{public}s", resourceInfos.size(),
372 innerBundleInfo.GetBundleName().c_str());
373 return !resourceInfos.empty();
374 }
375
CheckIsNeedProcessAbilityResource(const InnerBundleInfo & innerBundleInfo)376 bool BundleResourceProcess::CheckIsNeedProcessAbilityResource(const InnerBundleInfo &innerBundleInfo)
377 {
378 if (innerBundleInfo.GetBundleName().empty()) {
379 APP_LOGE("bundleName is empty");
380 return false;
381 }
382 if (innerBundleInfo.GetApplicationBundleType() == BundleType::SHARED) {
383 APP_LOGD("bundleName:%{public}s is shared", innerBundleInfo.GetBundleName().c_str());
384 return false;
385 }
386 if (innerBundleInfo.GetBaseApplicationInfo().hideDesktopIcon) {
387 APP_LOGD("bundleName:%{public}s hide desktop icon", innerBundleInfo.GetBundleName().c_str());
388 return false;
389 }
390 if (innerBundleInfo.GetBaseBundleInfo().entryInstallationFree) {
391 APP_LOGD("bundleName:%{public}s is atomic service, hide desktop icon",
392 innerBundleInfo.GetBundleName().c_str());
393 return false;
394 }
395 return true;
396 }
397
GetOverlayModuleHapPaths(const InnerBundleInfo & innerBundleInfo,const std::string & moduleName,int32_t userId,std::vector<std::string> & overlayHapPaths)398 bool BundleResourceProcess::GetOverlayModuleHapPaths(
399 const InnerBundleInfo &innerBundleInfo,
400 const std::string &moduleName,
401 int32_t userId,
402 std::vector<std::string> &overlayHapPaths)
403 {
404 #ifdef BUNDLE_FRAMEWORK_OVERLAY_INSTALLATION
405 auto innerModuleInfo = innerBundleInfo.GetInnerModuleInfoByModuleName(moduleName);
406 if (innerModuleInfo == std::nullopt) {
407 APP_LOGE("moduleName %{public}s not exist", moduleName.c_str());
408 return false;
409 }
410 if (innerModuleInfo->overlayModuleInfo.empty()) {
411 APP_LOGD("moduleName:%{public}s has no overlay module", moduleName.c_str());
412 return false;
413 }
414 std::string bundleName = innerBundleInfo.GetBundleName();
415 APP_LOGI("bundleName %{public}s need add path", bundleName.c_str());
416 auto overlayModuleInfos = innerModuleInfo->overlayModuleInfo;
417 for (auto &info : overlayModuleInfos) {
418 if (info.bundleName == bundleName) {
419 innerBundleInfo.GetOverlayModuleState(info.moduleName, userId, info.state);
420 } else {
421 GetExternalOverlayHapState(info.bundleName, info.moduleName, userId, info.state);
422 }
423 }
424 // sort by priority
425 std::sort(overlayModuleInfos.begin(), overlayModuleInfos.end(),
426 [](const OverlayModuleInfo &lhs, const OverlayModuleInfo &rhs) -> bool {
427 return lhs.priority > rhs.priority;
428 });
429 for (const auto &info : overlayModuleInfos) {
430 if (info.state == OverlayState::OVERLAY_ENABLE) {
431 overlayHapPaths.emplace_back(info.hapPath);
432 }
433 }
434 if (overlayHapPaths.empty()) {
435 APP_LOGE("moduleName %{public}s overlay hap path empty", moduleName.c_str());
436 return false;
437 }
438 return true;
439 #endif
440 return true;
441 }
442
GetExternalOverlayHapState(const std::string & bundleName,const std::string & moduleName,const int32_t userId,int32_t & state)443 bool BundleResourceProcess::GetExternalOverlayHapState(const std::string &bundleName,
444 const std::string &moduleName, const int32_t userId, int32_t &state)
445 {
446 #ifdef BUNDLE_FRAMEWORK_OVERLAY_INSTALLATION
447 APP_LOGD("bundleName:%{public}s, moduleName:%{public}s get overlay state", bundleName.c_str(), moduleName.c_str());
448 auto dataMgr = DelayedSingleton<BundleMgrService>::GetInstance()->GetDataMgr();
449 if (dataMgr == nullptr) {
450 APP_LOGE("dataMgr is nullptr");
451 return false;
452 }
453 InnerBundleInfo bundleInfo;
454 if (!dataMgr->QueryOverlayInnerBundleInfo(bundleName, bundleInfo)) {
455 return false;
456 }
457 if (!bundleInfo.GetOverlayModuleState(moduleName, userId, state)) {
458 return false;
459 }
460 return true;
461 #endif
462 return true;
463 }
464
GetAbilityResourceInfos(const InnerBundleInfo & innerBundleInfo,const int32_t userId,std::vector<ResourceInfo> & resourceInfos)465 bool BundleResourceProcess::GetAbilityResourceInfos(
466 const InnerBundleInfo &innerBundleInfo,
467 const int32_t userId,
468 std::vector<ResourceInfo> &resourceInfos)
469 {
470 APP_LOGD("start get ability, bundleName:%{public}s", innerBundleInfo.GetBundleName().c_str());
471 if (innerBundleInfo.GetBundleName().empty()) {
472 APP_LOGE("bundleName is empty");
473 return false;
474 }
475 if (innerBundleInfo.GetApplicationBundleType() == BundleType::SHARED) {
476 APP_LOGW("bundleName:%{public}s is shared bundle, no ability", innerBundleInfo.GetBundleName().c_str());
477 return false;
478 }
479 std::map<std::string, AbilityInfo> abilityInfos = innerBundleInfo.GetInnerAbilityInfos();
480 for (const auto &item : abilityInfos) {
481 resourceInfos.emplace_back(ConvertToLauncherAbilityResourceInfo(item.second));
482 }
483 // process overlay hap paths
484 size_t size = resourceInfos.size();
485 for (size_t index = 0; index < size; ++index) {
486 if ((index > 0) && (resourceInfos[index].moduleName_ == resourceInfos[index - 1].moduleName_)) {
487 resourceInfos[index].overlayHapPaths_ = resourceInfos[index - 1].overlayHapPaths_;
488 continue;
489 }
490 GetOverlayModuleHapPaths(innerBundleInfo, resourceInfos[index].moduleName_,
491 userId, resourceInfos[index].overlayHapPaths_);
492 }
493
494 APP_LOGD("end get ability, size:%{public}zu, bundleName:%{public}s", resourceInfos.size(),
495 innerBundleInfo.GetBundleName().c_str());
496 return !resourceInfos.empty();
497 }
498
GetTargetBundleName(const std::string & bundleName,std::string & targetBundleName)499 void BundleResourceProcess::GetTargetBundleName(const std::string &bundleName,
500 std::string &targetBundleName)
501 {
502 targetBundleName = bundleName;
503 auto dataMgr = DelayedSingleton<BundleMgrService>::GetInstance()->GetDataMgr();
504 if (dataMgr == nullptr) {
505 APP_LOGE("dataMgr is nullptr");
506 return;
507 }
508 InnerBundleInfo bundleInfo;
509 if (!dataMgr->QueryOverlayInnerBundleInfo(bundleName, bundleInfo)) {
510 return;
511 }
512 if (bundleInfo.GetOverlayType() == OverlayType::OVERLAY_EXTERNAL_BUNDLE) {
513 targetBundleName = bundleInfo.GetTargetBundleName();
514 }
515 }
516 } // AppExecFwk
517 } // OHOS
518