12dc7c57fSopenharmony_ci/* 22dc7c57fSopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd. 32dc7c57fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 42dc7c57fSopenharmony_ci * you may not use this file except in compliance with the License. 52dc7c57fSopenharmony_ci * You may obtain a copy of the License at 62dc7c57fSopenharmony_ci * 72dc7c57fSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 82dc7c57fSopenharmony_ci * 92dc7c57fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 102dc7c57fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 112dc7c57fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 122dc7c57fSopenharmony_ci * See the License for the specific language governing permissions and 132dc7c57fSopenharmony_ci * limitations under the License. 142dc7c57fSopenharmony_ci */ 152dc7c57fSopenharmony_ci 162dc7c57fSopenharmony_ci#ifndef FOUNDATION_EVENT_CESFWK_SERVICES_INCLUDE_EVENT_REPORT_H 172dc7c57fSopenharmony_ci#define FOUNDATION_EVENT_CESFWK_SERVICES_INCLUDE_EVENT_REPORT_H 182dc7c57fSopenharmony_ci 192dc7c57fSopenharmony_ci#include <unordered_map> 202dc7c57fSopenharmony_ci#include <string> 212dc7c57fSopenharmony_ci 222dc7c57fSopenharmony_ci#ifdef HAS_HISYSEVENT_PART 232dc7c57fSopenharmony_ci#include "hisysevent.h" 242dc7c57fSopenharmony_ci#endif 252dc7c57fSopenharmony_ci 262dc7c57fSopenharmony_cinamespace OHOS { 272dc7c57fSopenharmony_cinamespace EventFwk { 282dc7c57fSopenharmony_cinamespace { 292dc7c57fSopenharmony_ci// event name 302dc7c57fSopenharmony_ciconstexpr char ORDERED_EVENT_PROC_TIMEOUT[] = "ORDERED_EVENT_PROC_TIMEOUT"; 312dc7c57fSopenharmony_ciconstexpr char STATIC_EVENT_PROC_ERROR[] = "STATIC_EVENT_PROC_ERROR"; 322dc7c57fSopenharmony_ciconstexpr char SUBSCRIBER_EXCEED_MAXIMUM[] = "SUBSCRIBER_EXCEED_MAXIMUM"; 332dc7c57fSopenharmony_ciconstexpr char PUBLISH_ERROR[] = "PUBLISH_ERROR"; 342dc7c57fSopenharmony_ciconstexpr char SUBSCRIBE[] = "SUBSCRIBE"; 352dc7c57fSopenharmony_ciconstexpr char UNSUBSCRIBE[] = "UNSUBSCRIBE"; 362dc7c57fSopenharmony_ciconstexpr char PUBLISH[] = "PUBLISH"; 372dc7c57fSopenharmony_ciconstexpr char STATIC_SUBSCRIBER_START[] = "STATIC_SUBSCRIBER_START"; 382dc7c57fSopenharmony_ciconstexpr char STATIC_SUBSCRIBER_RUNTIME[] = "STATIC_SUBSCRIBER_RUNTIME"; 392dc7c57fSopenharmony_ci} // namespace 402dc7c57fSopenharmony_ci 412dc7c57fSopenharmony_cistruct EventInfo { 422dc7c57fSopenharmony_ci int32_t userId; 432dc7c57fSopenharmony_ci int32_t pid; 442dc7c57fSopenharmony_ci int32_t uid; 452dc7c57fSopenharmony_ci int32_t resultCode; 462dc7c57fSopenharmony_ci uint32_t subscriberNum; 472dc7c57fSopenharmony_ci std::string publisherName; 482dc7c57fSopenharmony_ci std::string subscriberName; 492dc7c57fSopenharmony_ci std::string eventName; 502dc7c57fSopenharmony_ci 512dc7c57fSopenharmony_ci EventInfo() : userId(-1), pid(0), uid(0), resultCode(0), subscriberNum(0) {} 522dc7c57fSopenharmony_ci}; 532dc7c57fSopenharmony_ci 542dc7c57fSopenharmony_ciclass EventReport { 552dc7c57fSopenharmony_cipublic: 562dc7c57fSopenharmony_ci /** 572dc7c57fSopenharmony_ci * @brief send hisysevent 582dc7c57fSopenharmony_ci * 592dc7c57fSopenharmony_ci * @param eventName event name, corresponding to the document 'hisysevent.yaml' 602dc7c57fSopenharmony_ci * @param eventInfo event info 612dc7c57fSopenharmony_ci */ 622dc7c57fSopenharmony_ci static void SendHiSysEvent(const std::string &eventName, const EventInfo &eventInfo); 632dc7c57fSopenharmony_ci 642dc7c57fSopenharmony_ciprivate: 652dc7c57fSopenharmony_ci#ifdef HAS_HISYSEVENT_PART 662dc7c57fSopenharmony_ci // fault event 672dc7c57fSopenharmony_ci static void InnerSendOrderedEventProcTimeoutEvent(const EventInfo &eventInfo); 682dc7c57fSopenharmony_ci static void InnerSendStaticEventProcErrorEvent(const EventInfo &eventInfo); 692dc7c57fSopenharmony_ci static void InnerSendSubscriberExceedMaximumEvent(const EventInfo &eventInfo); 702dc7c57fSopenharmony_ci static void InnerSendPublishErrorEvent(const EventInfo &eventInfo); 712dc7c57fSopenharmony_ci 722dc7c57fSopenharmony_ci // statistic event 732dc7c57fSopenharmony_ci static void InnerSendSubscribeEvent(const EventInfo &eventInfo); 742dc7c57fSopenharmony_ci static void InnerSendUnSubscribeEvent(const EventInfo &eventInfo); 752dc7c57fSopenharmony_ci static void InnerSendPublishEvent(const EventInfo &eventInfo); 762dc7c57fSopenharmony_ci static void InnerSendStaticSubStartEvent(const EventInfo &eventInfo); 772dc7c57fSopenharmony_ci static void InnerSendStaticSubRunEvent(const EventInfo &eventInfo); 782dc7c57fSopenharmony_ci 792dc7c57fSopenharmony_ci template<typename... Types> 802dc7c57fSopenharmony_ci static void InnerEventWrite(const std::string &eventName, 812dc7c57fSopenharmony_ci HiviewDFX::HiSysEvent::EventType type, Types... keyValues); 822dc7c57fSopenharmony_ci 832dc7c57fSopenharmony_ci static std::unordered_map<std::string, void (*)(const EventInfo &eventInfo)> cesSysEventFuncMap_; 842dc7c57fSopenharmony_ci#endif 852dc7c57fSopenharmony_ci}; 862dc7c57fSopenharmony_ci} // namespace EventFwk 872dc7c57fSopenharmony_ci} // namespace OHOS 882dc7c57fSopenharmony_ci#endif // FOUNDATION_EVENT_CESFWK_SERVICES_INCLUDE_EVENT_REPORT_H