mirror of
https://gitee.com/openharmony/account_os_account
synced 2024-11-23 10:10:11 +00:00
commit
eddf13069d
@ -26,6 +26,7 @@ namespace AccountSA {
|
||||
class AccountEventProvider {
|
||||
public:
|
||||
static bool EventPublish(const std::string& event, int32_t userId, const DomainAccountEventData *report);
|
||||
static bool EventPublishAsUser(const std::string& event, int32_t userId);
|
||||
};
|
||||
} // namespace AccountSA
|
||||
} // namespace OHOS
|
||||
|
@ -26,6 +26,7 @@
|
||||
#endif // HAS_CES_PART
|
||||
#include "account_hisysevent_adapter.h"
|
||||
#include "hitrace_adapter.h"
|
||||
#include "common_event_constant.h"
|
||||
|
||||
#ifdef HAS_CES_PART
|
||||
using namespace OHOS::EventFwk;
|
||||
@ -60,6 +61,7 @@ bool AccountEventProvider::EventPublish(const std::string& event, int32_t userId
|
||||
if (!CommonEventManager::PublishCommonEvent(data)) {
|
||||
ACCOUNT_LOGE("PublishCommonEvent failed! event %{public}s. userId is %{public}d", event.c_str(), userId);
|
||||
ReportOhosAccountOperationFail(userId, EVENT_PUBLISH, false, "PublishCommonEvent failed");
|
||||
FinishTraceAdapter();
|
||||
return false;
|
||||
} else {
|
||||
ACCOUNT_LOGI("PublishCommonEvent succeed! event %{public}s.", event.c_str());
|
||||
@ -70,5 +72,39 @@ bool AccountEventProvider::EventPublish(const std::string& event, int32_t userId
|
||||
#endif // HAS_CES_PART
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AccountEventProvider::EventPublishAsUser(const std::string& event, int32_t userId)
|
||||
{
|
||||
if (userId == UNDEFINED_USER) {
|
||||
ACCOUNT_LOGE("EventPublishAsUser failed, userId is UNDEFINED_USER");
|
||||
return EventPublish(event, userId, nullptr);
|
||||
}
|
||||
#ifdef HAS_CES_PART
|
||||
Want want;
|
||||
want.SetAction(event);
|
||||
CommonEventData data;
|
||||
if (event == EventFwk::CommonEventSupport::COMMON_EVENT_USER_INFO_UPDATED) {
|
||||
data.SetCode(userId);
|
||||
} else {
|
||||
want.SetParam("userId", userId);
|
||||
}
|
||||
|
||||
data.SetWant(want);
|
||||
StartTraceAdapter("Ohos account event publish.");
|
||||
/* publish */
|
||||
if (!CommonEventManager::PublishCommonEventAsUser(data, userId)) {
|
||||
ACCOUNT_LOGE("PublishCommonEventAsUser failed! event %{public}s. userId is %{public}d", event.c_str(), userId);
|
||||
ReportOhosAccountOperationFail(userId, EVENT_PUBLISH, false, "PublishCommonEventAsUser failed");
|
||||
FinishTraceAdapter();
|
||||
return false;
|
||||
} else {
|
||||
ACCOUNT_LOGI("PublishCommonEventAsUser succeed! event %{public}s.", event.c_str());
|
||||
}
|
||||
FinishTraceAdapter();
|
||||
#else // HAS_CES_PART
|
||||
ACCOUNT_LOGI("No common event part, do not publish anything! event %{public}s.", event.c_str());
|
||||
#endif // HAS_CES_PART
|
||||
return true;
|
||||
}
|
||||
} // namespace AccountSA
|
||||
} // namespace OHOS
|
@ -366,12 +366,13 @@ ErrCode OhosAccountManager::LoginOhosAccount(const int32_t userId, const OhosAcc
|
||||
|
||||
#ifdef HAS_CES_PART
|
||||
if (!isPubLoginEvent) {
|
||||
AccountEventProvider::EventPublish(CommonEventSupport::COMMON_EVENT_USER_INFO_UPDATED, userId, nullptr);
|
||||
AccountEventProvider::EventPublishAsUser(CommonEventSupport::COMMON_EVENT_USER_INFO_UPDATED, userId);
|
||||
(void)CreateCommonEventSubscribe();
|
||||
return ERR_OK;
|
||||
}
|
||||
AccountEventProvider::EventPublish(CommonEventSupport::COMMON_EVENT_HWID_LOGIN, userId, nullptr);
|
||||
AccountEventProvider::EventPublish(CommonEventSupport::COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGIN, userId, nullptr);
|
||||
AccountEventProvider::EventPublishAsUser(CommonEventSupport::COMMON_EVENT_HWID_LOGIN, userId);
|
||||
AccountEventProvider::EventPublishAsUser(
|
||||
CommonEventSupport::COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGIN, userId);
|
||||
#else // HAS_CES_PART
|
||||
ACCOUNT_LOGI("No common event part, publish nothing!");
|
||||
#endif // HAS_CES_PART
|
||||
@ -414,9 +415,10 @@ ErrCode OhosAccountManager::LogoutOhosAccount(
|
||||
subscribeManager_.Publish(userId, DISTRIBUTED_ACCOUNT_SUBSCRIBE_TYPE::LOGOUT);
|
||||
|
||||
#ifdef HAS_CES_PART
|
||||
AccountEventProvider::EventPublish(EventFwk::CommonEventSupport::COMMON_EVENT_HWID_LOGOUT, userId, nullptr);
|
||||
AccountEventProvider::EventPublish(
|
||||
EventFwk::CommonEventSupport::COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOUT, userId, nullptr);
|
||||
AccountEventProvider::EventPublishAsUser(
|
||||
EventFwk::CommonEventSupport::COMMON_EVENT_HWID_LOGOUT, userId);
|
||||
AccountEventProvider::EventPublishAsUser(
|
||||
EventFwk::CommonEventSupport::COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOUT, userId);
|
||||
#else // HAS_CES_PART
|
||||
ACCOUNT_LOGI("No common event part! Publish nothing!");
|
||||
#endif // HAS_CES_PART
|
||||
@ -457,9 +459,10 @@ ErrCode OhosAccountManager::LogoffOhosAccount(
|
||||
subscribeManager_.Publish(userId, DISTRIBUTED_ACCOUNT_SUBSCRIBE_TYPE::LOGOFF);
|
||||
|
||||
#ifdef HAS_CES_PART
|
||||
AccountEventProvider::EventPublish(EventFwk::CommonEventSupport::COMMON_EVENT_HWID_LOGOFF, userId, nullptr);
|
||||
AccountEventProvider::EventPublish(
|
||||
EventFwk::CommonEventSupport::COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOFF, userId, nullptr);
|
||||
AccountEventProvider::EventPublishAsUser(
|
||||
EventFwk::CommonEventSupport::COMMON_EVENT_HWID_LOGOFF, userId);
|
||||
AccountEventProvider::EventPublishAsUser(
|
||||
EventFwk::CommonEventSupport::COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOFF, userId);
|
||||
#else // HAS_CES_PART
|
||||
ACCOUNT_LOGI("No common event part, publish nothing for logoff!");
|
||||
#endif // HAS_CES_PART
|
||||
@ -501,10 +504,10 @@ ErrCode OhosAccountManager::HandleOhosAccountTokenInvalidEvent(
|
||||
subscribeManager_.Publish(userId, DISTRIBUTED_ACCOUNT_SUBSCRIBE_TYPE::TOKEN_INVALID);
|
||||
|
||||
#ifdef HAS_CES_PART
|
||||
AccountEventProvider::EventPublish(EventFwk::CommonEventSupport::COMMON_EVENT_HWID_TOKEN_INVALID,
|
||||
userId, nullptr);
|
||||
AccountEventProvider::EventPublish(
|
||||
EventFwk::CommonEventSupport::COMMON_EVENT_DISTRIBUTED_ACCOUNT_TOKEN_INVALID, userId, nullptr);
|
||||
AccountEventProvider::EventPublishAsUser(
|
||||
EventFwk::CommonEventSupport::COMMON_EVENT_HWID_TOKEN_INVALID, userId);
|
||||
AccountEventProvider::EventPublishAsUser(
|
||||
EventFwk::CommonEventSupport::COMMON_EVENT_DISTRIBUTED_ACCOUNT_TOKEN_INVALID, userId);
|
||||
#else // HAS_CES_PART
|
||||
ACCOUNT_LOGI("No common event part, publish nothing for token invalid event.");
|
||||
#endif // HAS_CES_PART
|
||||
@ -615,10 +618,10 @@ void OhosAccountManager::OnPackageRemoved(const std::int32_t callingUid)
|
||||
(void)GetAccountInfoByUserId(info.GetLocalId(), accountInfo);
|
||||
if (accountInfo.ohosAccountInfo_.callingUid_ == callingUid) {
|
||||
(void)ClearOhosAccount(accountInfo);
|
||||
AccountEventProvider::EventPublish(
|
||||
EventFwk::CommonEventSupport::COMMON_EVENT_HWID_LOGOUT, info.GetLocalId(), nullptr);
|
||||
AccountEventProvider::EventPublish(
|
||||
EventFwk::CommonEventSupport::COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOUT, info.GetLocalId(), nullptr);
|
||||
AccountEventProvider::EventPublishAsUser(
|
||||
EventFwk::CommonEventSupport::COMMON_EVENT_HWID_LOGOUT, info.GetLocalId());
|
||||
AccountEventProvider::EventPublishAsUser(
|
||||
EventFwk::CommonEventSupport::COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOUT, info.GetLocalId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -595,8 +595,8 @@ ErrCode IInnerOsAccountManager::UpdateOsAccountWithFullInfo(OsAccountInfo &newIn
|
||||
if (errCode != ERR_OK) {
|
||||
ReportOsAccountOperationFail(localId, Constants::OPERATION_UPDATE, errCode, "UpdateOsAccount failed!");
|
||||
} else {
|
||||
OsAccountInterface::PublishCommonEvent(oldInfo,
|
||||
OHOS::EventFwk::CommonEventSupport::COMMON_EVENT_USER_INFO_UPDATED, Constants::OPERATION_UPDATE);
|
||||
AccountEventProvider::EventPublishAsUser(
|
||||
EventFwk::CommonEventSupport::COMMON_EVENT_USER_INFO_UPDATED, oldInfo.GetLocalId());
|
||||
}
|
||||
RemoveLocalIdToOperating(localId);
|
||||
return errCode;
|
||||
@ -775,9 +775,10 @@ ErrCode IInnerOsAccountManager::RemoveOsAccountOperate(const int id, OsAccountIn
|
||||
(void)OhosAccountManager::GetInstance().GetAccountInfoByUserId(id, ohosInfo);
|
||||
if (ohosInfo.ohosAccountInfo_.name_ != DEFAULT_OHOS_ACCOUNT_NAME) {
|
||||
#ifdef HAS_CES_PART
|
||||
AccountEventProvider::EventPublish(EventFwk::CommonEventSupport::COMMON_EVENT_HWID_LOGOUT, id, nullptr);
|
||||
AccountEventProvider::EventPublish(
|
||||
EventFwk::CommonEventSupport::COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOUT, id, nullptr);
|
||||
AccountEventProvider::EventPublishAsUser(
|
||||
EventFwk::CommonEventSupport::COMMON_EVENT_HWID_LOGOUT, id);
|
||||
AccountEventProvider::EventPublishAsUser(
|
||||
EventFwk::CommonEventSupport::COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOUT, id);
|
||||
#else // HAS_CES_PART
|
||||
ACCOUNT_LOGI("No common event part! Publish nothing!");
|
||||
#endif // HAS_CES_PART
|
||||
@ -1475,8 +1476,8 @@ ErrCode IInnerOsAccountManager::SetOsAccountName(const int id, const std::string
|
||||
return ERR_OSACCOUNT_SERVICE_INNER_UPDATE_ACCOUNT_ERROR;
|
||||
}
|
||||
osAccountControl_->UpdateAccountIndex(osAccountInfo, false);
|
||||
OsAccountInterface::PublishCommonEvent(
|
||||
osAccountInfo, OHOS::EventFwk::CommonEventSupport::COMMON_EVENT_USER_INFO_UPDATED, Constants::OPERATION_UPDATE);
|
||||
AccountEventProvider::EventPublishAsUser(
|
||||
EventFwk::CommonEventSupport::COMMON_EVENT_USER_INFO_UPDATED, osAccountInfo.GetLocalId());
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
@ -1550,8 +1551,8 @@ ErrCode IInnerOsAccountManager::SetOsAccountProfilePhoto(const int id, const std
|
||||
ACCOUNT_LOGE("Update osaccount info faile code=%{public}d, id=%{public}d", errCode, osAccountInfo.GetLocalId());
|
||||
return ERR_OSACCOUNT_SERVICE_INNER_UPDATE_ACCOUNT_ERROR;
|
||||
}
|
||||
OsAccountInterface::PublishCommonEvent(
|
||||
osAccountInfo, OHOS::EventFwk::CommonEventSupport::COMMON_EVENT_USER_INFO_UPDATED, Constants::OPERATION_UPDATE);
|
||||
AccountEventProvider::EventPublishAsUser(
|
||||
EventFwk::CommonEventSupport::COMMON_EVENT_USER_INFO_UPDATED, osAccountInfo.GetLocalId());
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
@ -2188,8 +2189,8 @@ ErrCode IInnerOsAccountManager::UpdateAccountInfoByDomainAccountInfo(
|
||||
}
|
||||
RemoveLocalIdToOperating(userId);
|
||||
#ifdef HAS_CES_PART
|
||||
AccountEventProvider::EventPublish(EventFwk::CommonEventSupport::COMMON_EVENT_USER_INFO_UPDATED,
|
||||
userId, nullptr);
|
||||
AccountEventProvider::EventPublishAsUser(
|
||||
EventFwk::CommonEventSupport::COMMON_EVENT_USER_INFO_UPDATED, userId);
|
||||
#endif // HAS_CES_PART
|
||||
return ERR_OK;
|
||||
}
|
||||
|
@ -98,8 +98,8 @@ void BindDomainAccountCallback::OnResult(int32_t errCode, Parcel &parcel)
|
||||
errCode = osAccountControl_->UpdateOsAccount(osAccountInfo_);
|
||||
if ((osAccountInfo_.GetLocalId() == Constants::START_USER_ID) && (errCode == ERR_OK)) {
|
||||
#ifdef HAS_CES_PART
|
||||
AccountEventProvider::EventPublish(
|
||||
EventFwk::CommonEventSupport::COMMON_EVENT_USER_INFO_UPDATED, Constants::START_USER_ID, nullptr);
|
||||
AccountEventProvider::EventPublishAsUser(
|
||||
EventFwk::CommonEventSupport::COMMON_EVENT_USER_INFO_UPDATED, Constants::START_USER_ID);
|
||||
#else // HAS_CES_PART
|
||||
ACCOUNT_LOGI("No common event part! Publish nothing!");
|
||||
#endif // HAS_CES_PART
|
||||
|
Loading…
Reference in New Issue
Block a user