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 "hisysevent_listener_proxy.h"
17 
18 #include "string_ex.h"
19 
20 namespace OHOS {
21 namespace HiviewDFX {
Handle(const std::u16string & domain,const std::u16string & eventName,uint32_t eventType,const std::u16string & eventDetail)22 void HiSysEventListenerProxy::Handle(const std::u16string& domain, const std::u16string& eventName,
23     uint32_t eventType, const std::u16string& eventDetail)
24 {
25     auto eventListener = GetEventListener();
26     if (eventListener != nullptr) {
27         eventListener->OnEvent(Str16ToStr8(domain), Str16ToStr8(eventName),
28             eventType, Str16ToStr8(eventDetail));
29     }
30 }
31 
GetCallbackDeathRecipient() const32 sptr<CallbackDeathRecipient> HiSysEventListenerProxy::GetCallbackDeathRecipient() const
33 {
34     return callbackDeathRecipient;
35 }
36 
GetEventListener() const37 std::shared_ptr<HiSysEventBaseListener> HiSysEventListenerProxy::GetEventListener() const
38 {
39     if (callbackDeathRecipient != nullptr) {
40         return callbackDeathRecipient->GetEventListener();
41     }
42     return nullptr;
43 }
44 
OnRemoteDied(const wptr<IRemoteObject> & object)45 void CallbackDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &object)
46 {
47     auto eventListener = GetEventListener();
48     if (eventListener != nullptr) {
49         eventListener->OnServiceDied();
50     }
51 }
52 
GetEventListener() const53 std::shared_ptr<HiSysEventBaseListener> CallbackDeathRecipient::GetEventListener() const
54 {
55     return eventListener;
56 }
57 } // namespace HiviewDFX
58 } // namespace OHOS
59