1 /*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "dslm_bigdata.h"
17 #include "hisysevent.h"
18
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 namespace {
23 constexpr char STR_EVENT_START_FAILED[] = "SERVICE_START_FAILED";
24 constexpr char STR_EVENT_INIT_SELF_LEVEL_FAULT[] = "INIT_SELF_LEVEL_FAULT";
25 constexpr char STR_EVENT_CALL_INTERFACE[] = "CALL_INTERFACE";
26 constexpr char STR_EVENT_QUERY_INFO[] = "QUERY_INFO";
27 constexpr char STR_ERROR_TYPE[] = "ERROR_TYPE";
28 constexpr char STR_ERROR_STR[] = "ERROR_STR";
29 constexpr char STR_USER_ID[] = "USER_ID";
30 constexpr char STR_COST_TIME[] = "COST_TIME";
31 constexpr char STR_RET_CODE[] = "RET_CODE";
32 constexpr char STR_SEC_LEVEL[] = "SEC_LEVEL";
33 constexpr char STR_RET_MODE[] = "RET_MODE";
34 constexpr char STR_LOCAL_MODEL[] = "LOCAL_MODEL";
35 constexpr char STR_TARGET_MODEL[] = "TARGET_MODEL";
36 constexpr char STR_PKG_NAME[] = "PKG_NAME";
37 constexpr char STR_LOCAL_VERSION[] = "LOCAL_VERSION";
38 constexpr char STR_TARGET_VERSION[] = "TARGET_VERSION";
39 constexpr char STR_CRED_TYPE[] = "CRED_TYPE";
40 } // namespace
ReportServiceStartFailedEvent(const uint32_t errorType)41 void ReportServiceStartFailedEvent(const uint32_t errorType)
42 {
43 HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::DSLM, STR_EVENT_START_FAILED,
44 OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, STR_ERROR_TYPE, errorType);
45 }
46
ReportInitSelfFailedEvent(const char * errorString)47 void ReportInitSelfFailedEvent(const char *errorString)
48 {
49 HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::DSLM, STR_EVENT_INIT_SELF_LEVEL_FAULT,
50 OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, STR_ERROR_STR, errorString);
51 }
52
ReportAppInvokeEvent(const AppInvokeEvent * event)53 void ReportAppInvokeEvent(const AppInvokeEvent *event)
54 {
55 if (event == nullptr) {
56 return;
57 }
58
59 HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::DSLM, STR_EVENT_CALL_INTERFACE,
60 OHOS::HiviewDFX::HiSysEvent::EventType::STATISTIC, STR_USER_ID, event->uid, STR_COST_TIME, event->costTime,
61 STR_RET_CODE, event->retCode, STR_SEC_LEVEL, event->secLevel, STR_RET_MODE, event->retMode, STR_LOCAL_MODEL,
62 event->localModel, STR_TARGET_MODEL, event->targetModel, STR_PKG_NAME, event->pkgName);
63 }
64
ReportSecurityInfoSyncEvent(const SecurityInfoSyncEvent * event)65 void ReportSecurityInfoSyncEvent(const SecurityInfoSyncEvent *event)
66 {
67 if (event == nullptr) {
68 return;
69 }
70
71 HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::DSLM, STR_EVENT_QUERY_INFO,
72 OHOS::HiviewDFX::HiSysEvent::EventType::STATISTIC, STR_LOCAL_MODEL, event->localModel, STR_TARGET_MODEL,
73 event->targetModel, STR_LOCAL_VERSION, event->localVersion, STR_TARGET_VERSION, event->targetVersion,
74 STR_CRED_TYPE, event->credType, STR_RET_CODE, event->retCode, STR_COST_TIME, event->costTime, STR_SEC_LEVEL,
75 event->secLevel);
76 }
77
78 #ifdef __cplusplus
79 }
80 #endif
81