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