change GetOsAccountType

Signed-off-by: dengxiaoyu <dengxiaoyu6@huawei.com>
This commit is contained in:
dengxiaoyu 2024-09-09 10:04:46 +08:00
parent 24350f6c38
commit 8dd6726bed
3 changed files with 4 additions and 9 deletions

View File

@ -31,7 +31,7 @@ public:
void OnReceiveEvent(const EventFwk::CommonEventData &eventData);
int32_t GetForegroundOsAccountLocalId();
ErrCode GetOsAccountType(int32_t &accountId);
void OnUserSwitched(int32_t &accountId);
};
} // namespace DistributedSchedule
} // namespace OHOS

View File

@ -98,24 +98,22 @@ int32_t CommonEventListener::GetForegroundOsAccountLocalId()
return INVALID_PARAMETERS_ERR;
}
HILOGD("GetForegroundOsAccountLocalId accountId is: %{public}d", accountId);
GetOsAccountType(accountId);
OnUserSwitched(accountId);
return accountId;
}
ErrCode CommonEventListener::GetOsAccountType(int32_t& accountId)
void CommonEventListener::OnUserSwitched(int32_t& accountId)
{
AccountSA::OsAccountType type;
ErrCode err = AccountSA::OsAccountManager::GetOsAccountType(accountId, type);
if (err != ERR_OK) {
HILOGE("GetOsAccountType passing param invalid or return error!, err : %{public}d", err);
return INVALID_PARAMETERS_ERR;
}
if (type == AccountSA::OsAccountType::PRIVATE) {
HILOGI("GetOsAccountType : OsAccountType is PRIVATE, type : %{public}d", type);
DataShareManager::GetInstance().UpdateSwitchStatus(SwitchStatusDependency::GetInstance()
.CONTINUE_SWITCH_STATUS_KEY, SwitchStatusDependency::GetInstance().CONTINUE_SWITCH_OFF);
}
return ERR_OK;
}
} // namespace DistributedSchedule
} // namespace OHOS

View File

@ -114,10 +114,7 @@ void DataShareManager::UnregisterObserver(const std::string &key)
Uri uri(AssembleUserSecureUri(userId, key));
dataShareHelper->UnregisterObserver(uri, observer);
dataShareHelper->Release();
if (observer != nullptr) {
HILOGI("UnregisterObserver delete observer");
delete observer;
}
std::lock_guard<std::mutex> lockGuard(observerMapMutex_);
settingObserverMap_.erase(key);
HILOGI("DataShareManager UnregisterObserver success with key is %{public}s", key.c_str());