mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-24 12:43:16 -04:00
修复user0通知场景
Signed-off-by: wlh2624 <1968860844@qq.com> Change-Id: I5f823b9abfbb2ea42b6eaca45343077cec23e7ed
This commit is contained in:
@@ -36,6 +36,8 @@ public:
|
||||
private:
|
||||
void UpdateMultiUserConfiguration(const Configuration& config);
|
||||
void UpdateMultiUserConfigurationForGlobal(const Configuration& globalConfig);
|
||||
void SetOrUpdateConfigByUserId(const int32_t userId, const Configuration& config,
|
||||
std::vector<std::string>& changeKeyV);
|
||||
|
||||
std::map<int32_t, Configuration> multiUserConfiguration_;
|
||||
std::mutex multiUserConfigurationMutex_;
|
||||
|
||||
@@ -61,12 +61,36 @@ std::shared_ptr<AppExecFwk::Configuration> MultiUserConfigurationMgr::GetConfigu
|
||||
}
|
||||
}
|
||||
|
||||
void MultiUserConfigurationMgr::SetOrUpdateConfigByUserId(
|
||||
const int32_t userId, const Configuration& config, std::vector<std::string>& changeKeyV)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(multiUserConfigurationMutex_);
|
||||
auto it = multiUserConfiguration_.find(userId);
|
||||
if (it != multiUserConfiguration_.end()) {
|
||||
it->second.CompareDifferent(changeKeyV, config);
|
||||
if (!changeKeyV.empty()) {
|
||||
it->second.Merge(changeKeyV, config);
|
||||
}
|
||||
} else {
|
||||
if (globalConfiguration_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "globalConfiguration_ null");
|
||||
return;
|
||||
}
|
||||
Configuration userConfig = *globalConfiguration_;
|
||||
userConfig.CompareDifferent(changeKeyV, config);
|
||||
if (!changeKeyV.empty()) {
|
||||
userConfig.Merge(changeKeyV, config);
|
||||
}
|
||||
multiUserConfiguration_[userId] = userConfig;
|
||||
}
|
||||
}
|
||||
|
||||
void MultiUserConfigurationMgr::HandleConfiguration(
|
||||
const int32_t userId, const Configuration& config, std::vector<std::string>& changeKeyV, bool &isNotifyUser0)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(multiUserConfigurationMutex_);
|
||||
isNotifyUser0 = false;
|
||||
if (userId == -1) {
|
||||
std::lock_guard<std::mutex> guard(multiUserConfigurationMutex_);
|
||||
if (globalConfiguration_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "globalConfiguration_ null");
|
||||
return;
|
||||
@@ -81,29 +105,11 @@ void MultiUserConfigurationMgr::HandleConfiguration(
|
||||
}
|
||||
UpdateMultiUserConfiguration(config);
|
||||
} else {
|
||||
auto it = multiUserConfiguration_.find(userId);
|
||||
if (it != multiUserConfiguration_.end()) {
|
||||
it->second.CompareDifferent(changeKeyV, config);
|
||||
if (changeKeyV.size() != 0) {
|
||||
it->second.Merge(changeKeyV, config);
|
||||
}
|
||||
} else {
|
||||
if (globalConfiguration_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "globalConfiguration_ null");
|
||||
return;
|
||||
}
|
||||
Configuration userConfig = *globalConfiguration_;
|
||||
userConfig.CompareDifferent(changeKeyV, config);
|
||||
if (changeKeyV.size() != 0) {
|
||||
userConfig.Merge(changeKeyV, config);
|
||||
}
|
||||
multiUserConfiguration_[userId] = userConfig;
|
||||
}
|
||||
SetOrUpdateConfigByUserId(userId, config, changeKeyV);
|
||||
if (userId != USER0 && userId == MultiUserConfigurationMgr::GetForegroundOsAccountLocalId()) {
|
||||
std::vector<std::string> diff;
|
||||
multiUserConfiguration_[USER0].CompareDifferent(diff, multiUserConfiguration_[userId]);
|
||||
if (diff.size() != 0) {
|
||||
multiUserConfiguration_[USER0].Merge(diff, multiUserConfiguration_[userId]);
|
||||
SetOrUpdateConfigByUserId(USER0, config, diff);
|
||||
if (!diff.empty()) {
|
||||
isNotifyUser0 = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user