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