• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 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 "accessibility_caption_parcel.h"
17 #include "hilog_wrapper.h"
18 #include "parcel_util.h"
19 
20 namespace OHOS {
21 namespace Accessibility {
CaptionPropertyParcel(const CaptionProperty & property)22 CaptionPropertyParcel::CaptionPropertyParcel(const CaptionProperty &property)
23     : CaptionProperty(property)
24 {
25 }
26 
27 // LCOV_EXCL_START
ReadFromParcel(Parcel & parcel)28 bool CaptionPropertyParcel::ReadFromParcel(Parcel& parcel)
29 {
30     READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, fontFamily_);
31     READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, fontScale_);
32     READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, fontColor_);
33     READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, fontEdgeType_);
34     READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, backgroundColor_);
35     READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, windowColor_);
36 
37     return true;
38 }
39 // LCOV_EXCL_STOP
40 
Marshalling(Parcel & parcel) const41 bool CaptionPropertyParcel::Marshalling(Parcel& parcel) const
42 {
43     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, fontFamily_);
44     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, fontScale_);
45     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, fontColor_);
46     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, fontEdgeType_);
47     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, backgroundColor_);
48     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, windowColor_);
49 
50     return true;
51 }
52 
53 // LCOV_EXCL_START
Unmarshalling(Parcel & parcel)54 sptr<CaptionPropertyParcel> CaptionPropertyParcel::Unmarshalling(Parcel& parcel)
55 {
56     sptr<CaptionPropertyParcel> captionProperty = new(std::nothrow) CaptionPropertyParcel();
57     if (captionProperty == nullptr) {
58         HILOG_ERROR("Failed to create captionProperty.");
59         return nullptr;
60     }
61     if (!captionProperty->ReadFromParcel(parcel)) {
62         HILOG_ERROR("read from parcel failed");
63         return nullptr;
64     }
65     return captionProperty;
66 }
67 // LCOV_EXCL_STOP
68 } // namespace Accessibility
69 } // namespace OHOS