Signed-off-by: wendel <yuwenze1@huawei.com>
Co-Authored-By: wendel
Change-Id: I4a746e832db9d4a2fa6ad639c8b0343a4d876a68
This commit is contained in:
wendel
2026-05-16 17:31:19 +08:00
parent d906bd7261
commit 7d5e246f3f
2 changed files with 6 additions and 0 deletions
@@ -180,6 +180,7 @@ private:
std::atomic<int32_t> interfaceCalledCount_ = 0;
ffrt::mutex sessionsMutex_;
std::unordered_map<std::string, std::shared_ptr<SessionRecord>> sessionRecords_;
ffrt::mutex observerMutex_;
std::unordered_map<std::string, sptr<AppExecFwk::IApplicationStateObserver>> bundleObservers_;
};
@@ -659,6 +659,10 @@ void CliToolManagerService::OnProcessDied(const std::string &bundleName, pid_t d
{
TAG_LOGI(AAFwkTag::CLI_TOOL, "OnProcessDied called: bundleName=%{public}s, diedPid=%{public}d",
bundleName.c_str(), diedPid);
{
std::lock_guard<ffrt::mutex> guard(observerMutex_);
bundleObservers_.erase(bundleName);
}
std::lock_guard<ffrt::mutex> guard(sessionsMutex_);
// Iterate through sessionRecords_ to find matching SessionRecord by callerPid
for (auto iter = sessionRecords_.begin(); iter != sessionRecords_.end();) {
@@ -692,6 +696,7 @@ void CliToolManagerService::RegisterAppStateObserver(const std::string &bundleNa
bundleName.c_str(), callerPid);
// Check if observer already exists for this bundle
std::lock_guard<ffrt::mutex> guard(observerMutex_);
if (bundleObservers_.find(bundleName) != bundleObservers_.end()) {
TAG_LOGI(AAFwkTag::CLI_TOOL, "Observer already registered for bundleName=%{public}s", bundleName.c_str());
return;