adapt sysevent new interface

Signed-off-by: jidong <jidong4@huawei.com>
Change-Id: I01773bd09361cb72086dc10cfa268d61ac2b5953
This commit is contained in:
jidong 2023-02-09 18:31:50 +08:00
parent ca4389f262
commit 56b44a14fd
2 changed files with 27 additions and 28 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -22,16 +22,15 @@ namespace OHOS {
namespace AccountSA {
namespace {
#ifdef HAS_HISYSEVENT_PART
using HiSysEventNameSpace = OHOS::HiviewDFX::HiSysEvent;
const std::string DOMAIN_STR = std::string(HiSysEventNameSpace::Domain::ACCOUNT);
using namespace OHOS::HiviewDFX;
#endif // HAS_HISYSEVENT_PART
}
void ReportServiceStartFail(int32_t errCode, const std::string& errMsg)
{
#ifdef HAS_HISYSEVENT_PART
int ret = HiSysEventNameSpace::Write(DOMAIN_STR, "SERVICE_START_FAILED",
HiSysEventNameSpace::EventType::FAULT,
int ret = HiSysEventWrite(HiSysEvent::Domain::ACCOUNT, "SERVICE_START_FAILED",
HiSysEvent::EventType::FAULT,
"ERROR_TYPE", errCode,
"ERROR_MSG", errMsg);
if (ret != 0) {
@ -45,8 +44,8 @@ void ReportServiceStartFail(int32_t errCode, const std::string& errMsg)
void ReportPermissionFail(int32_t callerUid, int32_t callerPid, const std::string& permName)
{
#ifdef HAS_HISYSEVENT_PART
int ret = HiSysEventNameSpace::Write(DOMAIN_STR, "PERMISSION_EXCEPTION",
HiSysEventNameSpace::EventType::SECURITY,
int ret = HiSysEventWrite(HiSysEvent::Domain::ACCOUNT, "PERMISSION_EXCEPTION",
HiSysEvent::EventType::SECURITY,
"CALLER_UID", callerUid,
"CALLER_PID", callerPid,
"PERMISSION_NAME", permName);
@ -65,8 +64,8 @@ void ReportOsAccountOperationFail(
int32_t id, const std::string& operationStr, int32_t errCode, const std::string& errMsg)
{
#ifdef HAS_HISYSEVENT_PART
int ret = HiSysEventNameSpace::Write(DOMAIN_STR, "OS_ACCOUNT_FAILED",
HiSysEventNameSpace::EventType::FAULT,
int ret = HiSysEventWrite(HiSysEvent::Domain::ACCOUNT, "OS_ACCOUNT_FAILED",
HiSysEvent::EventType::FAULT,
"ID", id,
"OPERATE_TYPE", operationStr,
"ERROR_TYPE", errCode,
@ -87,8 +86,8 @@ void ReportOhosAccountOperationFail(
int32_t userId, const std::string& operationStr, int32_t errCode, const std::string& errMsg)
{
#ifdef HAS_HISYSEVENT_PART
int ret = HiSysEventNameSpace::Write(DOMAIN_STR, "DISTRIBUTED_ACCOUNT_FAILED",
HiSysEventNameSpace::EventType::FAULT,
int ret = HiSysEventWrite(HiSysEvent::Domain::ACCOUNT, "DISTRIBUTED_ACCOUNT_FAILED",
HiSysEvent::EventType::FAULT,
"USER_ID", userId,
"OPERATE_TYPE", operationStr,
"ERROR_TYPE", errCode,
@ -109,8 +108,8 @@ void ReportAppAccountOperationFail(const std::string &name, const std::string &o
int32_t errCode, const std::string& errMsg)
{
#ifdef HAS_HISYSEVENT_PART
int ret = HiSysEventNameSpace::Write(DOMAIN_STR, "APP_ACCOUNT_FAILED",
HiSysEventNameSpace::EventType::FAULT,
int ret = HiSysEventWrite(HiSysEvent::Domain::ACCOUNT, "APP_ACCOUNT_FAILED",
HiSysEvent::EventType::FAULT,
"NAME", name,
"OWNER", owner,
"OPERATE_TYPE", operationStr,
@ -134,8 +133,8 @@ void ReportAppAccountOperationFail(const std::string &name, const std::string &o
void ReportOsAccountLifeCycle(int32_t id, const std::string& operationStr)
{
#ifdef HAS_HISYSEVENT_PART
int ret = HiSysEventNameSpace::Write(DOMAIN_STR, "OS_ACCOUNT_LIFE_CYCLE",
HiSysEventNameSpace::EventType::BEHAVIOR,
int ret = HiSysEventWrite(HiSysEvent::Domain::ACCOUNT, "OS_ACCOUNT_LIFE_CYCLE",
HiSysEvent::EventType::BEHAVIOR,
"ACCOUNT_ID", id,
"OPERATE_TYPE", operationStr);
if (ret != 0) {
@ -151,8 +150,8 @@ void ReportOsAccountLifeCycle(int32_t id, const std::string& operationStr)
void ReportOsAccountSwitch(int32_t currentId, int32_t oldId)
{
#ifdef HAS_HISYSEVENT_PART
int ret = HiSysEventNameSpace::Write(DOMAIN_STR, "OS_ACCOUNT_SWITCH",
HiSysEventNameSpace::EventType::BEHAVIOR,
int ret = HiSysEventWrite(HiSysEvent::Domain::ACCOUNT, "OS_ACCOUNT_SWITCH",
HiSysEvent::EventType::BEHAVIOR,
"CURRENT_ID", currentId,
"OLD_ID", oldId);
if (ret != 0) {
@ -168,8 +167,8 @@ void ReportOsAccountSwitch(int32_t currentId, int32_t oldId)
void ReportOhosAccountStateChange(int32_t userId, int32_t operateType, int32_t oldStat, int32_t newStat)
{
#ifdef HAS_HISYSEVENT_PART
int ret = HiSysEventNameSpace::Write(DOMAIN_STR, "DISTRIBUTED_ACCOUNT_CHANGE",
HiSysEventNameSpace::EventType::BEHAVIOR,
int ret = HiSysEventWrite(HiSysEvent::Domain::ACCOUNT, "DISTRIBUTED_ACCOUNT_CHANGE",
HiSysEvent::EventType::BEHAVIOR,
"USER_ID", userId,
"OPERATION_TYPE", operateType,
"OLD_STATE", oldStat,
@ -186,4 +185,4 @@ void ReportOhosAccountStateChange(int32_t userId, int32_t operateType, int32_t o
#endif // HAS_HISYSEVENT_PART
}
} // AccountSA
} // OHOS
} // OHOS

View File

@ -1,4 +1,4 @@
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
# Copyright (c) 2021-2023 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
@ -14,32 +14,32 @@
domain: ACCOUNT
PERMISSION_EXCEPTION:
__BASE: {type: SECURITY, level: CRITICAL, tag: security, desc: permission verification errors}
__BASE: {type: SECURITY, level: CRITICAL, desc: permission verification errors}
CALLER_UID: {type: INT32, desc: caller uid}
CALLER_PID: {type: INT32, desc: caller pid}
PERMISSION_NAME: {type: STRING, desc: permission name}
SERVICE_START_FAILED:
__BASE: {type: FAULT, level: CRITICAL, tag: usability, desc: service start errors}
__BASE: {type: FAULT, level: CRITICAL, desc: service start errors}
ERROR_TYPE: {type: INT32, desc: error code}
ERROR_MSG: {type: STRING, desc: error message}
OS_ACCOUNT_FAILED:
__BASE: {type: FAULT, level: CRITICAL, tag: usability, desc: osaccount operation errors}
__BASE: {type: FAULT, level: CRITICAL, desc: osaccount operation errors}
ID: {type: INT32, desc: the id of an os account}
OPERATE_TYPE: {type: STRING, desc: operation type on an os account}
ERROR_TYPE: {type: INT32, desc: error code}
ERROR_MSG: {type: STRING, desc: error message}
DISTRIBUTED_ACCOUNT_FAILED:
__BASE: {type: FAULT, level: MINOR, tag: usability, desc: kvstore related errors}
__BASE: {type: FAULT, level: MINOR, desc: kvstore related errors}
USER_ID: {type: INT32, desc: the user id bound to a distributed account}
OPERATE_TYPE: {type: STRING, desc: operation type on a distributed account}
ERROR_TYPE: {type: INT32, desc: error code}
ERROR_MSG: {type: STRING, desc: error message}
APP_ACCOUNT_FAILED:
__BASE: {type: SECURITY, level: CRITICAL, tag: security, desc: permission verification errors}
__BASE: {type: SECURITY, level: CRITICAL, desc: permission verification errors}
NAME: {type: STRING, desc: the name of an app account}
OWNER: {type: STRING, desc: the owner of an app account}
OPERATE_TYPE: {type: STRING, desc: operation type on an app account}
@ -47,12 +47,12 @@ APP_ACCOUNT_FAILED:
ERROR_MSG: {type: STRING, desc: error message}
OS_ACCOUNT_LIFE_CYCLE:
__BASE: {type: BEHAVIOR, level: MINOR, tag: usability, desc: osaccount create or delete event}
__BASE: {type: BEHAVIOR, level: MINOR, desc: osaccount create or delete event}
ID: {type: INT32, desc: the id of os account which is created or deleted}
OPERATE_TYPE: {type: STRING, desc: operation type on an os account create or delete}
OS_ACCOUNT_SWITCH:
__BASE: {type: BEHAVIOR, level: MINOR, tag: usability, desc: osaccount switch event}
__BASE: {type: BEHAVIOR, level: MINOR, desc: osaccount switch event}
CURRENT_ID: {type: INT32, desc: the id of os account after switch}
OLD_ID: {type: INT32, desc: the id of os account before switch}