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 "dev_auth_hievent.h"
17
18 #include <stddef.h>
19 #include <stdint.h>
20 #include "securec.h"
21 #include "hc_types.h"
22
23 #include "hisysevent_adapter.h"
24 #include "device_auth_defines.h"
25 #include "device_auth.h"
26
ReportHiEventCoreFuncInvoke(int32_t eventId,int32_t osAccountId,CJson * params,int32_t result)27 void ReportHiEventCoreFuncInvoke(int32_t eventId, int32_t osAccountId, CJson *params, int32_t result)
28 {
29 if (params == NULL) {
30 return;
31 }
32
33 InvokeEvent event;
34 (void)memset_s(&event, sizeof(InvokeEvent), 0, sizeof(InvokeEvent));
35
36 int32_t groupType = PEER_TO_PEER_GROUP;
37 if (GetIntFromJson(params, FIELD_GROUP_TYPE, &groupType) != HC_SUCCESS) {
38 return;
39 }
40
41 event.eventId = eventId;
42 event.type = groupType;
43 event.batchNumber = 0;
44 event.result = result;
45 event.osAccountId = osAccountId;
46
47 const char *appId = GetStringFromJson(params, FIELD_APP_ID);
48 if (appId == NULL) {
49 return;
50 }
51 if (memcpy_s(event.appId, EVENT_APPID_LEN, appId, HcStrlen(appId)) != EOK) {
52 (void)memset_s(event.appId, EVENT_APPID_LEN, 0, EVENT_APPID_LEN);
53 }
54
55 ReportCoreFuncInvokeEvent(&event);
56 }