• 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_parcel.h"
17 #include "define_multimodal.h"
18 
19 namespace OHOS {
20 namespace MMI {
21 namespace {
22     constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, MMI_LOG_DOMAIN, "PointerEventParcel" };
23 }
Marshalling(Parcel & out) const24 bool PointerEventParcel::Marshalling(Parcel& out) const
25 {
26     if (data_ == nullptr) {
27         data_ = PointerEvent::Create();
28     }
29     CHKPF(data_);
30     if (!data_->WriteToParcel(out)) {
31         data_ = nullptr;
32         return false;
33     }
34     return true;
35 }
36 
Unmarshalling(Parcel & in)37 PointerEventParcel *PointerEventParcel::Unmarshalling(Parcel& in)
38 {
39     auto* request = new (std::nothrow) PointerEventParcel();
40     if (request == nullptr) {
41         return nullptr;
42     }
43 
44     if (request->data_ == nullptr) {
45         request->data_ = PointerEvent::Create();
46     }
47 
48     if (request->data_ == nullptr) {
49         return nullptr;
50     }
51 
52     if (!request->data_->ReadFromParcel(in)) {
53         request->data_ = nullptr;
54         delete request;
55         request = nullptr;
56         return nullptr;
57     }
58     return request;
59 }
60 } // namespace MMI
61 } // namespace OHOS
62