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 "bigdata.h" 17 18#include "hisysevent.h" 19 20namespace OHOS::Security::SecurityGuard { 21namespace { 22 constexpr const char* CALLER_PID = "CALLER_PID"; 23 constexpr const char* CALL_TIME = "CALL_TIME"; 24 constexpr const char* EVENT_SIZE = "EVENT_SIZE"; 25 constexpr const char* EVENT_INFO = "EVENT_INFO"; 26 constexpr const char* RISK_STATUS = "RISK_STATUS"; 27 constexpr const char* EVENT_ID = "EVENT_ID"; 28 constexpr const char* SUB_RET = "SUB_RET"; 29 constexpr const char* UNSUB_RET = "UNSUB_RET"; 30 constexpr const char* CONFIG_PATH = "CONFIG_PATH"; 31 constexpr const char* RET = "RET"; 32} 33 34void BigData::ReportObatinDataEvent(const ObatinDataEvent &event) 35{ 36 HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::SECURITY_GUARD, "OBTAIN_DATA", 37 OHOS::HiviewDFX::HiSysEvent::EventType::STATISTIC, CALLER_PID, event.pid, 38 CALL_TIME, event.time, EVENT_SIZE, event.size); 39} 40 41void BigData::ReportClassifyEvent(const ClassifyEvent &event) 42{ 43 HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::SECURITY_GUARD, "RISK_ANALYSIS", 44 OHOS::HiviewDFX::HiSysEvent::EventType::STATISTIC, CALLER_PID, event.pid, 45 CALL_TIME, event.time, EVENT_INFO, event.eventInfo, RISK_STATUS, event.status); 46} 47 48void BigData::ReportSgSubscribeEvent(const SgSubscribeEvent &event) 49{ 50 HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::SECURITY_GUARD, "SG_EVENT_SUBSCRIBE", 51 OHOS::HiviewDFX::HiSysEvent::EventType::STATISTIC, CALLER_PID, event.pid, 52 CALL_TIME, event.time, EVENT_ID, event.eventId, SUB_RET, event.ret); 53} 54 55void BigData::ReportSgUnsubscribeEvent(const SgUnsubscribeEvent &event) 56{ 57 HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::SECURITY_GUARD, "SG_EVENT_UNSUBSCRIBE", 58 OHOS::HiviewDFX::HiSysEvent::EventType::STATISTIC, CALLER_PID, event.pid, 59 CALL_TIME, event.time, UNSUB_RET, event.ret); 60} 61 62void BigData::ReportConfigUpdateEvent(const ConfigUpdateEvent &event) 63{ 64 HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::SECURITY_GUARD, "SG_UPDATE_CONFIG", 65 OHOS::HiviewDFX::HiSysEvent::EventType::STATISTIC, CONFIG_PATH, event.path, 66 CALL_TIME, event.time, RET, event.ret); 67} 68}