!11283 代码自检修改

Merge pull request !11283 from donglin/lock
This commit is contained in:
openharmony_ci 2024-10-30 07:33:01 +00:00 committed by Gitee
commit 1e6440c012
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 13 additions and 3 deletions

View File

@ -955,6 +955,7 @@ void ContextImpl::SubscribeToOverlayEvents(std::shared_ptr<Global::Resource::Res
const std::string &name, const std::string &hapModuleName, std::string &loadPath, const std::string &name, const std::string &hapModuleName, std::string &loadPath,
std::vector<AppExecFwk::OverlayModuleInfo> overlayModuleInfos) std::vector<AppExecFwk::OverlayModuleInfo> overlayModuleInfos)
{ {
std::lock_guard<std::mutex> lock(overlaySubscriberMutex_);
if (overlaySubscriber_ != nullptr) { if (overlaySubscriber_ != nullptr) {
return; return;
} }
@ -976,6 +977,7 @@ void ContextImpl::SubscribeToOverlayEvents(std::shared_ptr<Global::Resource::Res
void ContextImpl::UnsubscribeToOverlayEvents() void ContextImpl::UnsubscribeToOverlayEvents()
{ {
std::lock_guard<std::mutex> lock(overlaySubscriberMutex_);
if (overlaySubscriber_ != nullptr) { if (overlaySubscriber_ != nullptr) {
EventFwk::CommonEventManager::UnSubscribeCommonEvent(overlaySubscriber_); EventFwk::CommonEventManager::UnSubscribeCommonEvent(overlaySubscriber_);
overlaySubscriber_ = nullptr; overlaySubscriber_ = nullptr;

View File

@ -495,6 +495,7 @@ private:
// False: no need to get a new fms remote object. // False: no need to get a new fms remote object.
volatile bool resetFlag_ = false; volatile bool resetFlag_ = false;
std::mutex overlaySubscriberMutex_;
std::shared_ptr<AppExecFwk::OverlayEventSubscriber> overlaySubscriber_; std::shared_ptr<AppExecFwk::OverlayEventSubscriber> overlaySubscriber_;
}; };
} // namespace AbilityRuntime } // namespace AbilityRuntime

View File

@ -8120,6 +8120,10 @@ bool AppMgrServiceInner::IsProcessContainsOnlyUIAbility(const pid_t pid)
void AppMgrServiceInner::MakeIsolateSandBoxProcessName(const std::shared_ptr<AbilityInfo> &abilityInfo, void AppMgrServiceInner::MakeIsolateSandBoxProcessName(const std::shared_ptr<AbilityInfo> &abilityInfo,
const HapModuleInfo &hapModuleInfo, std::string &processName) const const HapModuleInfo &hapModuleInfo, std::string &processName) const
{ {
if (abilityInfo == nullptr) {
TAG_LOGE(AAFwkTag::APPMGR, "abilityInfo nullptr");
return;
}
auto type = abilityInfo->type; auto type = abilityInfo->type;
auto extensionType = abilityInfo->extensionAbilityType; auto extensionType = abilityInfo->extensionAbilityType;
if (type != AppExecFwk::AbilityType::EXTENSION || if (type != AppExecFwk::AbilityType::EXTENSION ||
@ -8127,9 +8131,12 @@ void AppMgrServiceInner::MakeIsolateSandBoxProcessName(const std::shared_ptr<Abi
extensionType == AppExecFwk::ExtensionAbilityType::SERVICE) { extensionType == AppExecFwk::ExtensionAbilityType::SERVICE) {
return; return;
} }
for (auto extensionInfo: hapModuleInfo.extensionInfos) { for (const auto& extensionInfo: hapModuleInfo.extensionInfos) {
if (extensionInfo.name == abilityInfo->name && extensionInfo.needCreateSandbox) { if (extensionInfo.name == abilityInfo->name) {
processName = (processName + ":" + abilityInfo->name); if (extensionInfo.needCreateSandbox) {
processName = (processName + ":" + abilityInfo->name);
}
return;
} }
} }
} }