12ee81decSopenharmony_ci/* 22ee81decSopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd. 32ee81decSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 42ee81decSopenharmony_ci * you may not use this file except in compliance with the License. 52ee81decSopenharmony_ci * You may obtain a copy of the License at 62ee81decSopenharmony_ci * 72ee81decSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 82ee81decSopenharmony_ci * 92ee81decSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 102ee81decSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 112ee81decSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 122ee81decSopenharmony_ci * See the License for the specific language governing permissions and 132ee81decSopenharmony_ci * limitations under the License. 142ee81decSopenharmony_ci */ 152ee81decSopenharmony_ci 162ee81decSopenharmony_ci#include "dslm_hievent.h" 172ee81decSopenharmony_ci 182ee81decSopenharmony_ci#include <stddef.h> 192ee81decSopenharmony_ci#include <stdint.h> 202ee81decSopenharmony_ci 212ee81decSopenharmony_ci#include "securec.h" 222ee81decSopenharmony_ci 232ee81decSopenharmony_ci#include "device_security_defines.h" 242ee81decSopenharmony_ci#include "dslm_core_defines.h" 252ee81decSopenharmony_ci#include "dslm_cred.h" 262ee81decSopenharmony_ci#include "dslm_bigdata.h" 272ee81decSopenharmony_ci 282ee81decSopenharmony_civoid ReportHiEventServiceStartFailed(const uint32_t errorType) 292ee81decSopenharmony_ci{ 302ee81decSopenharmony_ci ReportServiceStartFailedEvent(errorType); 312ee81decSopenharmony_ci} 322ee81decSopenharmony_ci 332ee81decSopenharmony_civoid ReportHiEventInitSelfFailed(const char *errorString) 342ee81decSopenharmony_ci{ 352ee81decSopenharmony_ci ReportInitSelfFailedEvent(errorString); 362ee81decSopenharmony_ci} 372ee81decSopenharmony_ci 382ee81decSopenharmony_civoid ReportHiEventInfoSync(const DslmDeviceInfo *info) 392ee81decSopenharmony_ci{ 402ee81decSopenharmony_ci if (info == NULL) { 412ee81decSopenharmony_ci return; 422ee81decSopenharmony_ci } 432ee81decSopenharmony_ci 442ee81decSopenharmony_ci SecurityInfoSyncEvent event; 452ee81decSopenharmony_ci (void)memset_s(&event, sizeof(SecurityInfoSyncEvent), 0, sizeof(SecurityInfoSyncEvent)); 462ee81decSopenharmony_ci 472ee81decSopenharmony_ci if (info->lastResponseTime >= info->lastRequestTime) { 482ee81decSopenharmony_ci event.costTime = (int32_t)(info->lastResponseTime - info->lastRequestTime); 492ee81decSopenharmony_ci } 502ee81decSopenharmony_ci 512ee81decSopenharmony_ci event.retCode = (int32_t)info->result; 522ee81decSopenharmony_ci event.secLevel = (int32_t)info->credInfo.credLevel; 532ee81decSopenharmony_ci event.localVersion = GetCurrentVersion(); 542ee81decSopenharmony_ci event.targetVersion = info->version; 552ee81decSopenharmony_ci if (memcpy_s(event.targetModel, MODEL_MAX_LEN, info->credInfo.model, CRED_INFO_MODEL_LEN) != EOK) { 562ee81decSopenharmony_ci (void)memset_s(event.targetModel, MODEL_MAX_LEN, 0, MODEL_MAX_LEN); 572ee81decSopenharmony_ci } 582ee81decSopenharmony_ci 592ee81decSopenharmony_ci event.credType = info->credInfo.credType; 602ee81decSopenharmony_ci ReportSecurityInfoSyncEvent(&event); 612ee81decSopenharmony_ci} 622ee81decSopenharmony_ci 632ee81decSopenharmony_civoid ReportHiEventAppInvoke(const DslmDeviceInfo *info) 642ee81decSopenharmony_ci{ 652ee81decSopenharmony_ci if (info == NULL) { 662ee81decSopenharmony_ci return; 672ee81decSopenharmony_ci } 682ee81decSopenharmony_ci 692ee81decSopenharmony_ci AppInvokeEvent event; 702ee81decSopenharmony_ci (void)memset_s(&event, sizeof(AppInvokeEvent), 0, sizeof(AppInvokeEvent)); 712ee81decSopenharmony_ci event.costTime = 0; 722ee81decSopenharmony_ci if (info->lastResponseTime >= info->lastRequestTime) { 732ee81decSopenharmony_ci event.costTime = (int32_t)(info->lastResponseTime - info->lastRequestTime); 742ee81decSopenharmony_ci } 752ee81decSopenharmony_ci event.uid = 0; 762ee81decSopenharmony_ci event.retCode = (int32_t)info->result; 772ee81decSopenharmony_ci event.secLevel = (int32_t)info->credInfo.credLevel; 782ee81decSopenharmony_ci event.retMode = (info->result == ERR_NEED_COMPATIBLE) ? 1 : 0; 792ee81decSopenharmony_ci 802ee81decSopenharmony_ci if (memcpy_s(event.targetModel, MODEL_MAX_LEN, info->credInfo.model, CRED_INFO_MODEL_LEN) != EOK) { 812ee81decSopenharmony_ci (void)memset_s(event.targetModel, MODEL_MAX_LEN, 0, MODEL_MAX_LEN); 822ee81decSopenharmony_ci } 832ee81decSopenharmony_ci 842ee81decSopenharmony_ci ReportAppInvokeEvent(&event); 852ee81decSopenharmony_ci}