1 /* 2 * Copyright (c) 2021-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 "sys_event_service_adapter.h" 17 18 #include "logger.h" 19 20 namespace OHOS { 21 namespace HiviewDFX { 22 DEFINE_LOG_TAG("HiView-SysEventServiceAdapter"); StartService(SysEventServiceBase * service,OHOS::HiviewDFX::NotifySysEvent notify)23void SysEventServiceAdapter::StartService(SysEventServiceBase* service, OHOS::HiviewDFX::NotifySysEvent notify) 24 { 25 if (service == nullptr) { 26 HIVIEW_LOGE("failed to start SysEventService."); 27 return; 28 } 29 OHOS::HiviewDFX::SysEventServiceOhos::StartService(service, notify); 30 } 31 OnSysEvent(std::shared_ptr<SysEvent> & event)32void SysEventServiceAdapter::OnSysEvent(std::shared_ptr<SysEvent> &event) 33 { 34 if (event == nullptr) { 35 HIVIEW_LOGE("sys event is nullptr."); 36 return; 37 } 38 auto service = OHOS::HiviewDFX::SysEventServiceOhos::GetInstance(); 39 if (service == nullptr) { 40 HIVIEW_LOGE("SysEventServiceOhos service is null."); 41 return; 42 } 43 service->OnSysEvent(event); 44 } 45 UpdateEventSeq(int64_t seq)46void SysEventServiceAdapter::UpdateEventSeq(int64_t seq) 47 { 48 auto service = OHOS::HiviewDFX::SysEventServiceOhos::GetInstance(); 49 if (service == nullptr) { 50 HIVIEW_LOGE("SysEventServiceOhos service is null."); 51 return; 52 } 53 service->UpdateEventSeq(seq); 54 } 55 BindGetTagFunc(const GetTagByDomainNameFunc & getTagFunc)56void SysEventServiceAdapter::BindGetTagFunc(const GetTagByDomainNameFunc& getTagFunc) 57 { 58 auto service = OHOS::HiviewDFX::SysEventServiceOhos::GetInstance(); 59 if (service == nullptr) { 60 HIVIEW_LOGE("SysEventServiceOhos service is null."); 61 return; 62 } 63 service->BindGetTagFunc(getTagFunc); 64 } 65 BindGetTypeFunc(const GetTypeByDomainNameFunc & getTypeFunc)66void SysEventServiceAdapter::BindGetTypeFunc(const GetTypeByDomainNameFunc& getTypeFunc) 67 { 68 auto service = OHOS::HiviewDFX::SysEventServiceOhos::GetInstance(); 69 if (service == nullptr) { 70 HIVIEW_LOGE("SysEventServiceOhos service is null."); 71 return; 72 } 73 service->BindGetTypeFunc(getTypeFunc); 74 } 75 } // namespace HiviewDFX 76 } // namespace OHOS