• 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 "event_filter_proxy.h"
17 #include "event_filter_parcel.h"
18 #include "message_option.h"
19 #include "mmi_log.h"
20 #include "string_ex.h"
21 
22 namespace OHOS {
23 namespace MMI {
24 namespace {
25 constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, MMI_LOG_DOMAIN, "EventFilterProxy" };
26 } // namespace
27 
28 // 获取其他设备注册的SA的Proxy
EventFilterProxy(const sptr<IRemoteObject> & impl)29 EventFilterProxy::EventFilterProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<IEventFilter>(impl)
30 {
31     MMI_LOGI("EventFilterProxy()");
32 }
33 
~EventFilterProxy()34 EventFilterProxy::~EventFilterProxy()
35 {
36     MMI_LOGI("~EventFilterProxy()");
37 }
38 
HandlePointerEvent(const std::shared_ptr<PointerEvent> event)39 bool EventFilterProxy::HandlePointerEvent(const std::shared_ptr<PointerEvent> event)
40 {
41     MMI_LOGD("enter");
42     MessageParcel data;
43     MessageParcel reply;
44     MessageOption option;
45     CHKPF(event);
46     if (!data.WriteInterfaceToken(EventFilterProxy::GetDescriptor())) {
47         MMI_LOGE("Failed to write descriptor");
48         return false;
49     }
50 
51     if (!event->WriteToParcel(data)) {
52         MMI_LOGE("Failed to write event to req");
53         return false;
54     }
55 
56     const uint32_t code = static_cast<uint32_t>(OPERATOR_TYPE::HANDLE_POINTER_EVENT);
57     int32_t requestResult = Remote()->SendRequest(code, data, reply, option);
58     if (requestResult != NO_ERROR) {
59         MMI_LOGE("send request fail, result:%{public}d", requestResult);
60         return false;
61     }
62 
63     MMI_LOGD("have recieve message from server");
64 
65     bool result = false;
66     if (!reply.ReadBool(result)) {
67         MMI_LOGE("reply ReadBool fail");
68         return false;
69     }
70 
71     MMI_LOGD("leave");
72     return result;
73 }
74 } // namespace MMI
75 } // namespace OHOS
76