• 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 
18 #include "message_option.h"
19 #include "string_ex.h"
20 
21 #include "mmi_log.h"
22 
23 namespace OHOS {
24 namespace MMI {
25 namespace {
26 constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, MMI_LOG_DOMAIN, "EventFilterProxy" };
27 } // namespace
28 
EventFilterProxy(const sptr<IRemoteObject> & impl)29 EventFilterProxy::EventFilterProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<IEventFilter>(impl)
30 {
31     MMI_HILOGI("EventFilterProxy()");
32 }
33 
~EventFilterProxy()34 EventFilterProxy::~EventFilterProxy()
35 {
36     MMI_HILOGI("~EventFilterProxy()");
37 }
38 
HandlePointerEvent(const std::shared_ptr<PointerEvent> event)39 bool EventFilterProxy::HandlePointerEvent(const std::shared_ptr<PointerEvent> event)
40 {
41     CALL_DEBUG_ENTER;
42     CHKPF(event);
43     MessageParcel data;
44     MessageParcel reply;
45     MessageOption option;
46     if (!data.WriteInterfaceToken(EventFilterProxy::GetDescriptor())) {
47         MMI_HILOGE("Failed to write descriptor");
48         return false;
49     }
50 
51     if (!event->WriteToParcel(data)) {
52         MMI_HILOGE("Failed to write event to req");
53         return false;
54     }
55 
56     sptr<IRemoteObject> remote = Remote();
57     CHKPF(remote);
58     const uint32_t code = static_cast<uint32_t>(OPERATOR_TYPE::HANDLE_POINTER_EVENT);
59     int32_t ret = remote->SendRequest(code, data, reply, option);
60     if (ret != NO_ERROR) {
61         MMI_HILOGE("Send request failed, ret:%{public}d", ret);
62         return false;
63     }
64 
65     bool result = false;
66     READBOOL(reply, result);
67     return result;
68 }
69 } // namespace MMI
70 } // namespace OHOS
71