• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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_hievent.h"
17 
18 #include <securec.h>
19 
20 #include "dslm_bigdata.h"
21 
ReportHiEventInfoSync(const DslmDeviceInfo * info)22 void ReportHiEventInfoSync(const DslmDeviceInfo *info)
23 {
24     if (info == NULL) {
25         return;
26     }
27     if (!ReportSecurityInfoSyncEvent) {
28         return;
29     }
30     SecurityInfoSyncEvent event;
31     memset_s(&event, sizeof(SecurityInfoSyncEvent), 0, sizeof(SecurityInfoSyncEvent));
32 
33     if (info->lastResponseTime >= info->lastRequestTime) {
34         event.costTime = info->lastResponseTime - info->lastRequestTime;
35     }
36 
37     event.retCode = info->result;
38     event.secLevel = info->credInfo.credLevel;
39     event.localVersion = GetCurrentVersion();
40     event.targetVersion = info->version;
41     if (memcpy_s(event.targetModel, MODEL_MAX_LEN, info->credInfo.model, CRED_INFO_MODEL_LEN) != EOK) {
42         memset_s(event.targetModel, MODEL_MAX_LEN, 0, MODEL_MAX_LEN);
43     }
44 
45     event.credType = info->credInfo.credType;
46     ReportSecurityInfoSyncEvent(&event);
47 }
48 
ReportHiEventAppInvoke(const DslmDeviceInfo * info)49 void ReportHiEventAppInvoke(const DslmDeviceInfo *info)
50 {
51     if (info == NULL) {
52         return;
53     }
54 
55     if (!ReportAppInvokeEvent) {
56         return;
57     }
58     AppInvokeEvent event;
59     memset_s(&event, sizeof(AppInvokeEvent), 0, sizeof(AppInvokeEvent));
60     event.costTime = 0;
61     if (info->lastResponseTime >= info->lastRequestTime) {
62         event.costTime = info->lastResponseTime - info->lastRequestTime;
63     }
64     event.uid = 0;
65     event.retCode = info->result;
66     event.secLevel = info->credInfo.credLevel;
67     event.retMode = (info->result == ERR_NEED_COMPATIBLE) ? 1 : 0;
68 
69     if (memcpy_s(event.targetModel, MODEL_MAX_LEN, info->credInfo.model, CRED_INFO_MODEL_LEN) != EOK) {
70         memset_s(event.targetModel, MODEL_MAX_LEN, 0, MODEL_MAX_LEN);
71     }
72 
73     ReportAppInvokeEvent(&event);
74 }