1 /* 2 * Copyright (c) 2021-2025 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 "event_loop.h" 19 #include "hiview_logger.h" 20 #include "sys_event_service_ohos.h" 21 22 namespace OHOS { 23 namespace HiviewDFX { 24 DEFINE_LOG_TAG("HiView-SysEventServiceAdapter"); StartService(SysEventServiceBase * service)25void SysEventServiceAdapter::StartService(SysEventServiceBase* service) 26 { 27 if (service == nullptr) { 28 HIVIEW_LOGE("failed to start SysEventService."); 29 return; 30 } 31 OHOS::HiviewDFX::SysEventServiceOhos::StartService(service); 32 } 33 OnSysEvent(std::shared_ptr<SysEvent> & event)34void SysEventServiceAdapter::OnSysEvent(std::shared_ptr<SysEvent> &event) 35 { 36 if (event == nullptr) { 37 HIVIEW_LOGE("sys event is nullptr."); 38 return; 39 } 40 auto service = OHOS::HiviewDFX::SysEventServiceOhos::GetInstance(); 41 if (service == nullptr) { 42 HIVIEW_LOGE("SysEventServiceOhos service is null."); 43 return; 44 } 45 service->OnSysEvent(event); 46 } 47 SetWorkLoop(std::shared_ptr<EventLoop> looper)48void SysEventServiceAdapter::SetWorkLoop(std::shared_ptr<EventLoop> looper) 49 { 50 auto service = OHOS::HiviewDFX::SysEventServiceOhos::GetInstance(); 51 if (service == nullptr) { 52 HIVIEW_LOGE("SetWorkLoop SysEventServiceOhos service is null."); 53 return; 54 } 55 service->SetWorkLoop(looper); 56 } 57 } // namespace HiviewDFX 58 } // namespace OHOS